Skip to content

Commit f3b5938

Browse files
committed
Fix password handling.
1 parent caa25e3 commit f3b5938

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

svc/init.d/00-setpass.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/mnt/secure/su /bin/sh
2-
export TZ=
3-
nopw="password=(keep unchanged)"
4-
if [ ! -e /mnt/secure/etc/passwd ] || [ -n "$(find -L /mnt/ext1/rootpassword.txt -prune -newer /mnt/secure/etc/passwd)" ]; then
5-
if [ ! -e /mnt/ext1/rootpassword.txt ] || [ "$(cat /mnt/ext1/rootpassword.txt)" == "$nopw" ]; then
6-
echo "password=$RANDOM" > /mnt/ext1/rootpassword.txt
7-
fi
8-
. /mnt/ext1/rootpassword.txt
9-
echo -n $password > /mnt/secure/etc/passwd
2+
if [ -e /mnt/ext1/rootpassword.txt ]; then
3+
password="$(cut -c 10- < /mnt/ext1/rootpassword.txt)"
4+
if [ "$password" == "(keep unchanged)" ]; then
5+
if [ -e /mnt/secure/etc/passwd ]; then
6+
exit 0
7+
fi
8+
password=$RANDOM
9+
echo "password=$password" > /mnt/ext1/rootpassword.txt
10+
fi
11+
echo -n "$password" > /mnt/secure/etc/passwd
1012
fi
13+
1114
suff=":[U ]:LCT-00000001:"
1215
pw="$(cat /mnt/secure/etc/passwd)"
1316
(echo "root:0:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:"$(ntlmhash "$pw")"$suff"; echo "reader:100:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:"$(ntlmhash "")"$suff") > /mnt/secure/etc/samba/smbpasswd

0 commit comments

Comments
 (0)