From 2910ae281a07441f55215ca74ec38f1d499420f2 Mon Sep 17 00:00:00 2001 From: Marco Amadori Date: Tue, 2 Sep 2008 10:42:11 +0200 Subject: [PATCH] Fix default user handling. * Handle the case in which an user is present but the default user could not be created (e.g. when configuring another user at build time in the chroot). If the default user could not be created or assigned, disable autologins (which previously just fails leaving without console login capabilities), and propagate that information to the scripts thinking that a default user will always be available. Note for live-helper documentation: The latter case could leave the system accessible only if root password is set in other ways or via ssh rsa/dsa passwordless accesses. --- scripts/live-bottom/10adduser | 22 ++++++++++++++++++++++ scripts/live-bottom/15autologin | 6 +++--- scripts/live-bottom/22gnome_panel_data | 2 +- scripts/live-bottom/30accessibility | 6 ++++++ scripts/live-bottom/32disable_hibernation | 2 +- scripts/live-bottom/44pk_allow | 9 +++++++++ 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser index 7498476..4c0fe80 100755 --- a/scripts/live-bottom/10adduser +++ b/scripts/live-bottom/10adduser @@ -58,6 +58,28 @@ set passwd/username set passwd/user-uid EOF +if ! grep "${USERNAME}" /root/etc/passwd +then + echo "The default user (${USERNAME}) is not present," + first_user=$(grep '^[^:]*:[^:]*:[12]\?[0-9][0-9][0-9][0-9]:' /root/etc/passwd | head -1 | cut -f1 -d ':') + if [ -n "${first_user}" ]; + then + echo "setting default user to: ${first_user}." + USERNAME="${first_user}" + really_export USERNAME + else + echo "no other valid users found, disabling autologin." + NOAUTOLOGIN="Yes" + NOXAUTOLOGIN="Yes" + USERNAME="" + really_export NOAUTOLOGIN + really_export NOXAUTOLOGIN + really_export USERNAME + log_end_msg + exit 0 + fi +fi + if [ -z "${NOSUDO}" ] then if ! grep -q "${USERNAME}" /root/etc/sudoers diff --git a/scripts/live-bottom/15autologin b/scripts/live-bottom/15autologin index bb9902e..28a3141 100755 --- a/scripts/live-bottom/15autologin +++ b/scripts/live-bottom/15autologin @@ -20,13 +20,13 @@ esac # live-initramfs header -if [ -n "${NOXAUTOLOGIN}" ] +. /scripts/live-functions + +if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ] then exit 0 fi -. /scripts/live-functions - log_begin_msg "Setting up automatic login" # live-initramfs script diff --git a/scripts/live-bottom/22gnome_panel_data b/scripts/live-bottom/22gnome_panel_data index 9767e45..bd0be26 100755 --- a/scripts/live-bottom/22gnome_panel_data +++ b/scripts/live-bottom/22gnome_panel_data @@ -41,7 +41,7 @@ fi panel_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-panel-data 2>/dev/null) || panel_version="" -if [ -n "${panel_version}" ] +if [ -n "${panel_version}" ] && [ -n "${USERNAME}" ] then chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true fi diff --git a/scripts/live-bottom/30accessibility b/scripts/live-bottom/30accessibility index 7753154..a169342 100755 --- a/scripts/live-bottom/30accessibility +++ b/scripts/live-bottom/30accessibility @@ -27,6 +27,12 @@ fi . /scripts/live-functions +if [ -z "${USERNAME}" ] +then + echo "No default user for accessibility options." + exit 0 +fi + log_begin_msg "Configuring accessibility options" # live-initramfs script diff --git a/scripts/live-bottom/32disable_hibernation b/scripts/live-bottom/32disable_hibernation index 8c9eb9a..f4960e6 100755 --- a/scripts/live-bottom/32disable_hibernation +++ b/scripts/live-bottom/32disable_hibernation @@ -33,7 +33,7 @@ log_begin_msg "Configuring power management" gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version="" -if [ -n "${gpm_version}" ] +if [ -n "${gpm_version}" ] && [ -n "${USERNAME}" ] then #live-reconfigure /root gnome-power-manager # Gnome < 2.20 diff --git a/scripts/live-bottom/44pk_allow b/scripts/live-bottom/44pk_allow index 7fd026e..fec6401 100755 --- a/scripts/live-bottom/44pk_allow +++ b/scripts/live-bottom/44pk_allow @@ -40,10 +40,19 @@ cat << EOF > /root/etc/PolicyKit/PolicyKit.conf +EOF + +if [ -n "${USERNAME}" ] +then + cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf +EOF +fi + +cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf EOF -- 2.1.4