[Solved] /etc/passwd changes with resets

Any questions about the Command Line Interface can be placed here!
Forum rules
Please note the disclaimer before modifying your Synology Product.
35mal3
I'm New!
I'm New!
Posts: 5
Joined: Sat Jun 17, 2017 9:55 pm

[Solved] /etc/passwd changes with resets

Postby 35mal3 » Sat Jun 17, 2017 10:11 pm

Hi there,

first post. I use a DS216+II and try to configure it as a backup solution for several linux clients.
Client side I use Duplicity, created a pretty isolated backup user on the NAS and log in with a
private key via SSH. So far so good.

The problem: When I restart my NAS, "/etc/passwd" changes the login shell for my backup user
from "/bin/sh" to "/sbin/nologin" automatically. So my cron jobs on my linux clients won't work anymore
because I can't login via SSH to my backup-user.

What I read is: I could change the user to a UID lower than 1024 to make it a system user. But how
do I do that without "usermod" installed? Is there a solution to change UIDs on DSM 6.1 (i think)?
Or, even better, to keep "/etc/passwd" from being overwritten by restarts? Thanks!
Last edited by 35mal3 on Wed Jul 05, 2017 8:07 am, edited 1 time in total.
35mal3
I'm New!
I'm New!
Posts: 5
Joined: Sat Jun 17, 2017 9:55 pm

Re: /etc/passwd changes with resets

Postby 35mal3 » Wed Jun 21, 2017 8:26 am

So to answer my own question, I wrote a startup script "99passwd.sh" and put it in "/usr/local/etc/rc.d/".
It basically replaces the standard entry ("/sbin/nologin") for my backup user "archive" in "/etc/passwd"
with the slightly changed entry "/bin/sh".

For the script to run, user has to do a:
"chmod u+x /usr/local/etc/rc.d/99passwd.sh"

Code: Select all

#!/bin/bash
# Keep /bin/sh as login shell
# for a normal user with a UID bigger than 1024

# Synology Default Entry
PWUSER="archive\:x\:1030\:100\:Archivar\:\/var\/services\/homes\/archive\:\/sbin\/nologin"

# Changed Entry
CHUSER="archive\:x\:1030\:100\:Archivar\:\/var\/services\/homes\/archive\:\/bin\/sh"

# Check if "/sbin/nologin" is set ands if so...
NOLOGIN=$(grep "${PWUSER}" /etc/passwd)

case $1 in
start)

    if [ "${NOLOGIN}" ]; then
        # ...backup /etc/passwd...
        cp /etc/passwd /etc/passwd_BACKUP
        # ...replace line with changed entry
        sed -i 's/'"${PWUSER}"'/'"${CHUSER}"'/' /etc/passwd
    fi

;;

*)
    echo "Do nothing"
;;
esac
raydenz
I'm New!
I'm New!
Posts: 1
Joined: Sat Aug 12, 2017 3:35 pm

Re: [Solved] /etc/passwd changes with resets

Postby raydenz » Sat Aug 12, 2017 3:41 pm

Hello,

Someone have a better solution?
I think your solution works but it is dirty.. :roll:

regards

RAY

Return to “Command Line Interface”

Who is online

Users browsing this forum: No registered users and 2 guests