File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 43
43
# whether or not we requested tailscale ssh support at setup time, which is
44
44
# redundant, but we at least avoid doing it when dropbear-initramfs is present
45
45
# as it will prevent that from working.
46
- if [ ! -e " /etc/dropbear/initramfs" ]; then
47
- # create home
48
- home=$( mktemp -d " $DESTDIR /root-XXXXXX" )
49
- chmod 0700 " $home "
50
- mkdir -m0700 " $home /.ssh"
51
-
52
- # Create user/group required for login
53
- for x in passwd group; do echo " $x : files" ; done > " $DESTDIR /etc/nsswitch.conf"
54
- echo " root:x:0:0:root:/root:/bin/sh" > " $DESTDIR /etc/passwd"
55
- echo " root:!:19808:0:99999:7:::" > " $DESTDIR /etc/shadow"
56
- echo " root:x:0:" > " $DESTDIR /etc/group"
46
+ if home=$( grep -s ' ^root:' " $DESTDIR /etc/passwd" | cut -d: -f6) && [ -n " $home " ]; then
47
+ # Ensure /etc/passwd points at password stored in /etc/shadow
48
+ sed -Ei -e ' s/^root:[^:]+/root:x/' " $DESTDIR /etc/passwd"
49
+ else
50
+ # create home
51
+ home=$( mktemp -d " $DESTDIR /root-XXXXXX" )
52
+ chmod 0700 " $home "
53
+ mkdir -m0700 " $home /.ssh"
54
+ home=${home# " $DESTDIR " }
57
55
fi
58
56
57
+ # Create user/group required for login
58
+ for x in passwd group; do echo " $x : files" ; done > " $DESTDIR /etc/nsswitch.conf"
59
+ echo " root:x:0:0:root:$home :/bin/sh" > " $DESTDIR /etc/passwd"
60
+ echo " root:!:19808:0:99999:7:::" > " $DESTDIR /etc/shadow"
61
+ echo " root:x:0:" > " $DESTDIR /etc/group"
62
+
59
63
exit 0
You can’t perform that action at this time.
0 commit comments