Stéphane Graber 9caf7cafdd * Add two new hooks for Ubuntu Touch to setup sensible /etc/passwd,
/etc/shadow, /etc/group and /etc/gshadow PRIOR to package installation
  to guarantee user/group ordering on the image and then to check for any
  unexpected change to those files. (LP: #1332538)
  Any change to either the initial set of users and groups or to the
  post-package-install set will now be fatal to the image and will require
  a manual update of the hardcoded user/group list contained in this new
  chroot_early hook.
* Bump dependency on live-build accordingly.
* Update the setup_user hook to also take care of gshadow.
2014-09-24 10:58:50 +01:00

45 lines
1.5 KiB
Bash
Executable File

#!/bin/sh -x
USER=phablet
UGID=32011
echo "I: creating default user $USER"
adduser --gecos $USER --disabled-login $USER --uid $UGID
echo "I: set user $USER password to blank"
passwd -d $USER
adduser --gecos system --no-create-home --disabled-login --disabled-password system --uid 1000
adduser --gecos radio --no-create-home --disabled-login --disabled-password radio --uid 1001
# Enable libnss-extrusers
sed -i 's/^group:.*compat/\0 extrausers/' /etc/nsswitch.conf
sed -i 's/^passwd:.*compat/\0 extrausers/' /etc/nsswitch.conf
sed -i 's/^shadow:.*compat/\0 extrausers/' /etc/nsswitch.conf
# Move user from /etc to extrausers location
grep "^$USER" /etc/group >> /var/lib/extrausers/group
grep "^$USER" /etc/passwd >> /var/lib/extrausers/passwd
grep "^$USER" /etc/shadow >> /var/lib/extrausers/shadow
grep "^$USER" /etc/gshadow >> /var/lib/extrausers/gshadow
chmod 0644 /var/lib/extrausers/group
chmod 0644 /var/lib/extrausers/passwd
chmod 0640 /var/lib/extrausers/shadow
chmod 0640 /var/lib/extrausers/gshadow
chown root:shadow /var/lib/extrausers/shadow
chown root:shadow /var/lib/extrausers/gshadow
sed -i "/^$USER/d" /etc/group
sed -i "/^$USER/d" /etc/passwd
sed -i "/^$USER/d" /etc/shadow
sed -i "/^$USER/d" /etc/gshadow
# Prevent the system user from being presented in the greeter by bumping MIN_UID
sed -i 's/^\(UID_MIN\s\+\).*/\11002/g' /etc/login.defs
mkdir -p /home/$USER/Music
mkdir -p /home/$USER/Pictures
mkdir -p /home/$USER/Videos
mkdir -p /home/$USER/Downloads
mkdir -p /home/$USER/Documents
chown -R $UGID:$UGID /home/$USER