You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
296 lines
7.4 KiB
296 lines
7.4 KiB
#!/bin/sh -eu
|
|
|
|
ERRCNT=""
|
|
|
|
# Known good post-debootstrap values
|
|
passwd_bootstrap="e6075a0d2a38e214ae5e9a5545f7eda3"
|
|
shadow_bootstrap="7fa48d7fb0e3a1ede9c98ff7b1b33622"
|
|
group_bootstrap="5fd842058cd526ddaf51c2a61870c12a"
|
|
gshadow_bootstrap="3145b72315c7306edb13bf546bb350b9"
|
|
|
|
# Current post-debootstrap values
|
|
passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1)
|
|
shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1)
|
|
group_hash=$(set -- $(md5sum /etc/group) && echo $1)
|
|
gshadow_hash=$(set -- $(md5sum /etc/gshadow) && echo $1)
|
|
|
|
# /etc/passwd
|
|
if [ "$passwd_bootstrap" = "$passwd_hash" ]; then
|
|
cat > /etc/passwd <<EOF
|
|
root:x:0:0:root:/root:/bin/bash
|
|
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
|
|
bin:x:2:2:bin:/bin:/usr/sbin/nologin
|
|
sys:x:3:3:sys:/dev:/usr/sbin/nologin
|
|
sync:x:4:65534:sync:/bin:/bin/sync
|
|
games:x:5:60:games:/usr/games:/usr/sbin/nologin
|
|
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
|
|
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
|
|
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
|
|
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
|
|
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
|
|
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
|
|
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
|
|
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
|
|
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
|
|
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
|
|
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
|
|
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
|
|
systemd-timesync:x:100:104:systemd Time Synchronization,,,:/run/systemd:/bin/false
|
|
systemd-network:x:101:105:systemd Network Management,,,:/run/systemd/netif:/bin/false
|
|
systemd-resolve:x:102:106:systemd Resolver,,,:/run/systemd/resolve:/bin/false
|
|
systemd-bus-proxy:x:103:107:systemd Bus Proxy,,,:/run/systemd:/bin/false
|
|
syslog:x:104:110::/home/syslog:/bin/false
|
|
usermetrics:x:105:111:User Metrics:/var/lib/usermetrics:/bin/false
|
|
messagebus:x:106:112::/var/run/dbus:/bin/false
|
|
uuidd:x:107:113::/run/uuidd:/bin/false
|
|
snappypkg:x:108:114::/nonexistent:/bin/false
|
|
avahi:x:109:115:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
|
|
dnsmasq:x:110:65534:dnsmasq,,,:/var/lib/misc:/bin/false
|
|
pulse:x:111:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false
|
|
whoopsie:x:112:118::/nonexistent:/bin/false
|
|
sshd:x:113:65534::/var/run/sshd:/usr/sbin/nologin
|
|
rtkit:x:114:123:RealtimeKit,,,:/proc:/bin/false
|
|
usbmux:x:115:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false
|
|
colord:x:116:124:colord colour management daemon,,,:/var/lib/colord:/bin/false
|
|
lightdm:x:117:126:Light Display Manager:/var/lib/lightdm:/bin/false
|
|
EOF
|
|
else
|
|
echo "/etc/passwd post-debootstrap hash doesn't match record" >&2
|
|
echo "The output below might help to resolve the issue" >&2
|
|
cat /etc/passwd
|
|
echo "passwd md5sum: $passwd_hash" >&2
|
|
ERRCNT=1
|
|
fi
|
|
|
|
# /etc/shadow
|
|
if [ "$shadow_bootstrap" = "$shadow_hash" ]; then
|
|
cat > /etc/shadow <<EOF
|
|
root:*:16591:0:99999:7:::
|
|
daemon:*:16591:0:99999:7:::
|
|
bin:*:16591:0:99999:7:::
|
|
sys:*:16591:0:99999:7:::
|
|
sync:*:16591:0:99999:7:::
|
|
games:*:16591:0:99999:7:::
|
|
man:*:16591:0:99999:7:::
|
|
lp:*:16591:0:99999:7:::
|
|
mail:*:16591:0:99999:7:::
|
|
news:*:16591:0:99999:7:::
|
|
uucp:*:16591:0:99999:7:::
|
|
proxy:*:16591:0:99999:7:::
|
|
www-data:*:16591:0:99999:7:::
|
|
backup:*:16591:0:99999:7:::
|
|
list:*:16591:0:99999:7:::
|
|
irc:*:16591:0:99999:7:::
|
|
gnats:*:16591:0:99999:7:::
|
|
nobody:*:16591:0:99999:7:::
|
|
systemd-timesync:*:16591:0:99999:7:::
|
|
systemd-network:*:16591:0:99999:7:::
|
|
systemd-resolve:*:16591:0:99999:7:::
|
|
systemd-bus-proxy:*:16591:0:99999:7:::
|
|
syslog:*:16591:0:99999:7:::
|
|
usermetrics:*:16594:0:99999:7:::
|
|
messagebus:*:16594:0:99999:7:::
|
|
uuidd:*:16594:0:99999:7:::
|
|
snappypkg:*:16594:0:99999:7:::
|
|
avahi:*:16594:0:99999:7:::
|
|
dnsmasq:*:16594:0:99999:7:::
|
|
pulse:*:16594:0:99999:7:::
|
|
whoopsie:*:16594:0:99999:7:::
|
|
sshd:*:16594:0:99999:7:::
|
|
rtkit:*:16594:0:99999:7:::
|
|
usbmux:*:16594:0:99999:7:::
|
|
colord:*:16594:0:99999:7:::
|
|
lightdm:*:16594:0:99999:7:::
|
|
EOF
|
|
else
|
|
echo "/etc/shadow post-debootstrap hash doesn't match record" >&2
|
|
echo "The output below might help to resolve the issue" >&2
|
|
cat /etc/shadow
|
|
echo "shadow md5sum: $shadow_hash" >&2
|
|
ERRCNT=1
|
|
fi
|
|
|
|
# /etc/group
|
|
if [ "$group_bootstrap" = "$group_hash" ]; then
|
|
cat > /etc/group <<EOF
|
|
root:x:0:
|
|
daemon:x:1:
|
|
bin:x:2:
|
|
sys:x:3:
|
|
adm:x:4:syslog,ubuntu
|
|
tty:x:5:
|
|
disk:x:6:
|
|
lp:x:7:
|
|
mail:x:8:
|
|
news:x:9:
|
|
uucp:x:10:
|
|
man:x:12:
|
|
proxy:x:13:
|
|
kmem:x:15:
|
|
dialout:x:20:ubuntu
|
|
fax:x:21:
|
|
voice:x:22:
|
|
cdrom:x:24:ubuntu
|
|
floppy:x:25:
|
|
tape:x:26:
|
|
sudo:x:27:ubuntu
|
|
audio:x:29:pulse,ubuntu
|
|
dip:x:30:ubuntu
|
|
www-data:x:33:
|
|
backup:x:34:
|
|
operator:x:37:
|
|
list:x:38:
|
|
irc:x:39:
|
|
src:x:40:
|
|
gnats:x:41:
|
|
shadow:x:42:
|
|
utmp:x:43:
|
|
video:x:44:ubuntu
|
|
sasl:x:45:
|
|
plugdev:x:46:ubuntu
|
|
staff:x:50:
|
|
games:x:60:
|
|
users:x:100:
|
|
nogroup:x:65534:
|
|
input:x:101:
|
|
systemd-journal:x:102:
|
|
systemd-timesync:x:104:
|
|
systemd-network:x:105:
|
|
systemd-resolve:x:106:
|
|
systemd-bus-proxy:x:107:
|
|
netdev:x:108:
|
|
crontab:x:109:
|
|
syslog:x:110:
|
|
usermetrics:x:111:
|
|
messagebus:x:112:
|
|
uuidd:x:113:
|
|
snappypkg:x:114:
|
|
avahi:x:115:
|
|
pulse:x:116:
|
|
pulse-access:x:117:
|
|
whoopsie:x:118:
|
|
bluetooth:x:119:
|
|
mlocate:x:120:
|
|
ssh:x:121:
|
|
scanner:x:122:
|
|
rtkit:x:123:
|
|
colord:x:124:
|
|
autopilot:x:125:
|
|
lightdm:x:126:
|
|
nopasswdlogin:x:127:
|
|
EOF
|
|
else
|
|
echo "/etc/group post-debootstrap hash doesn't match record" >&2
|
|
echo "The output below might help to resolve the issue" >&2
|
|
cat /etc/group
|
|
echo "group md5sum: $group_hash" >&2
|
|
ERRCNT=1
|
|
fi
|
|
|
|
# /etc/gshadow
|
|
if [ "$gshadow_bootstrap" = "$gshadow_hash" ]; then
|
|
cat > /etc/gshadow <<EOF
|
|
root:*::
|
|
daemon:*::
|
|
bin:*::
|
|
sys:*::
|
|
adm:*::syslog,ubuntu
|
|
tty:*::
|
|
disk:*::
|
|
lp:*::
|
|
mail:*::
|
|
news:*::
|
|
uucp:*::
|
|
man:*::
|
|
proxy:*::
|
|
kmem:*::
|
|
dialout:*::ubuntu
|
|
fax:*::
|
|
voice:*::
|
|
cdrom:*::ubuntu
|
|
floppy:*::
|
|
tape:*::
|
|
sudo:*::ubuntu
|
|
audio:*::pulse,ubuntu
|
|
dip:*::ubuntu
|
|
www-data:*::
|
|
backup:*::
|
|
operator:*::
|
|
list:*::
|
|
irc:*::
|
|
src:*::
|
|
gnats:*::
|
|
shadow:*::
|
|
utmp:*::
|
|
video:*::ubuntu
|
|
sasl:*::
|
|
plugdev:*::ubuntu
|
|
staff:*::
|
|
games:*::
|
|
users:*::
|
|
nogroup:*::
|
|
input:!::
|
|
systemd-journal:!::
|
|
systemd-timesync:!::
|
|
systemd-network:!::
|
|
systemd-resolve:!::
|
|
systemd-bus-proxy:!::
|
|
netdev:!::
|
|
crontab:!::
|
|
syslog:!::
|
|
usermetrics:!::
|
|
messagebus:!::
|
|
uuidd:!::
|
|
snappypkg:!::
|
|
avahi:!::
|
|
pulse:!::
|
|
pulse-access:!::
|
|
whoopsie:!::
|
|
bluetooth:!::
|
|
mlocate:!::
|
|
ssh:!::
|
|
scanner:!::
|
|
rtkit:!::
|
|
colord:!::
|
|
autopilot:!::
|
|
lightdm:!::
|
|
nopasswdlogin:!::
|
|
EOF
|
|
else
|
|
echo "/etc/gshadow post-debootstrap hash doesn't match record" >&2
|
|
echo "The output below might help to resolve the issue" >&2
|
|
cat /etc/gshadow
|
|
echo "gshadow md5sum: $gshadow_hash" >&2
|
|
ERRCNT=1
|
|
fi
|
|
|
|
if [ -n "$ERRCNT" ]; then
|
|
echo "There were changes to the password database," >&2
|
|
echo "please adjust the values in the livecd-rootfs source in the file:" >&2
|
|
echo "live-build/ubuntu-desktop-next/hooks/00-uid-gid-fix.chroot_early" >&2
|
|
echo >&2
|
|
echo "Please check also if a maintainer script of the package" >&2
|
|
echo "that added these entries perhaps created a home directory and," >&2
|
|
echo "if needed, add code for creation of it to the above hook" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Create some missing directories
|
|
mkdir -p /var/lib/lightdm
|
|
chown lightdm:lightdm /var/lib/lightdm
|
|
chmod 750 /var/lib/lightdm
|
|
|
|
mkdir -p /var/lib/usermetrics
|
|
chown usermetrics:usermetrics /var/lib/usermetrics
|
|
chmod 750 /var/lib/usermetrics
|
|
|
|
echo "adjusting ownership of /var/log" >&2
|
|
chown root:syslog /var/log
|
|
ls -ln /var | grep log >&2
|
|
|
|
# Record the current state for later comparison
|
|
for file in /etc/passwd /etc/shadow /etc/group /etc/gshadow; do
|
|
rm -f ${file}-
|
|
cp ${file} ${file}.orig
|
|
done
|