-if [ -f /root/etc/sudoers ]; then
- if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then
- grep -q '^%admin' /root/etc/sudoers && sed -i -e '/^%admin/s/ALL$/NOPASSWD: ALL/' /root/etc/sudoers || echo '%admin ALL=(ALL) NOPASSWD: ALL' >> /root/etc/sudoers
-
- # XXX - awful hack to stop xscreensaver locking the screen (#7150)
- echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment
+if ! grep -qs "${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