2018-09-07 16:47:54 +02:00
sed -i -e 's#^\(passwd:.*\) files#\1 files db altfile#g;s#^\(shadow:.*\) files#\1 files altfiles db#g;s#^\(group:.*\) files#\1 files altfiles db#g' \
" $sysroot " /etc/nsswitch.conf
2018-08-28 09:25:03 +02:00
mkdir -p " $sysroot " /usr/db
sed -i -e 's#/var/db#/usr/db#g' " $sysroot " /lib64/libnss_db-2*.so " $sysroot " /var/db/Makefile
chroot " $sysroot " bash -c 'useradd -G wheel admin'
egrep -e '^(adm|wheel):.*' " $sysroot " /etc/group > " $sysroot " /etc/group.admin
egrep -e '^(adm|wheel):.*' " $sysroot " /etc/gshadow > " $sysroot " /etc/gshadow.admin
sed -i -e '/^wheel:.*/d;/^adm:.*/d' " $sysroot " /etc/group " $sysroot " /etc/gshadow
sed -i -e '/^admin:.*/d' " $sysroot " /etc/passwd " $sysroot " /etc/shadow " $sysroot " /etc/group " $sysroot " /etc/gshadow
2018-09-07 16:47:54 +02:00
chroot " $sysroot " bash -c 'make -C /var/db /usr/db/passwd.db /usr/db/shadow.db /usr/db/gshadow.db /usr/db/group.db && mv /etc/{passwd,shadow,group,gshadow} /lib && >/etc/passwd && > /etc/shadow && >/etc/group && >/etc/gshadow'
2018-08-28 09:25:03 +02:00
mv " $sysroot " /etc/group.admin " $sysroot " /etc/group
mv " $sysroot " /etc/gshadow.admin " $sysroot " /etc/gshadow
chroot " $sysroot " bash -c 'useradd admin; usermod -a -G wheel admin; echo -n admin | passwd --stdin admin'
2018-09-05 15:52:23 +02:00
chroot " $sysroot " bash -c 'passwd -e admin'
2018-08-28 09:25:03 +02:00
mkdir -p " $sysroot " /usr/share/factory/var
mv " $sysroot " /etc/passwd " $sysroot " /etc/sub{ u,g} id " $sysroot " /etc/shadow " $sysroot " /etc/group " $sysroot " /etc/gshadow " $sysroot " /usr/share/factory/var
sed -i -e 's!^# directory = /etc!directory = /var!g' " $sysroot " /etc/libuser.conf
for i in passwd shadow group gshadow .pwd.lock subuid subgid; do
2018-09-06 15:56:53 +02:00
ln -sfnr " $sysroot " /var/" $i " " $sysroot " /etc/" $i "
2018-08-28 09:25:03 +02:00
done
sed -i -e 's#/etc/passwd#/var/passwd#g;s#/etc/npasswd#/var/npasswd#g' " $sysroot " /usr/lib64/security/pam_unix.so
sed -i -e 's#/etc/shadow#/var/shadow#g;s#/etc/nshadow#/var/nshadow#g' " $sysroot " /usr/lib64/security/pam_unix.so
sed -i -e 's#/etc/.pwdXXXXXX#/var/.pwdXXXXXX#g' " $sysroot " /usr/lib64/security/pam_unix.so
sed -i -e 's#/etc/passwd#/var/passwd#g;s#/etc/shadow#/var/shadow#g;s#/etc/gshadow#/var/gshadow#g;s#/etc/group#/var/group#g;s#/etc/subuid#/var/subuid#g;s#/etc/subgid#/var/subgid#g' " $sysroot " /usr/sbin/user{ add,mod,del} " $sysroot " /usr/sbin/group{ add,mod,del}
sed -i -e 's#/etc/.pwd.lock#/var/.pwd.lock#g' \
2018-09-05 12:30:55 +02:00
" $sysroot " /lib*/libc.so.* \
2018-08-28 09:25:03 +02:00
" $sysroot " /usr/lib*/librpmostree-1.so.1 \
" $sysroot " /usr/lib/systemd/libsystemd-shared*.so
mkdir -p " $sysroot " /usr/share/factory/home
cp -avxr " $sysroot " /etc/skel " $sysroot " /usr/share/factory/home/admin
chown -R +1000.+1000 " $sysroot " /usr/share/factory/home/admin
cat > " $sysroot " /usr/lib/tmpfiles.d/home.conf <<EOF
C /data/home/admin - - - - -
C /data/var/passwd - - - - -
C /data/var/shadow - - - - -
C /data/var/group - - - - -
C /data/var/gshadow - - - - -
C /data/var/subuid - - - - -
C /data/var/subgid - - - - -
C /data/var/etc - - - - -
EOF