From f2fa090a1aaf77fbdccbcac64a63d42b846ad65c Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Thu, 23 Aug 2012 06:58:44 -0500 Subject: [PATCH] j/seeds/debian: robustify sudoers editing and password hash insertion --- seeds/debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seeds/debian.sh b/seeds/debian.sh index aaf2713..4b235f7 100644 --- a/seeds/debian.sh +++ b/seeds/debian.sh @@ -54,7 +54,7 @@ EOF chmod 755 "${jroot}/etc/rcJ.d/S00localegen" echo "Adding user" -sed -i '/%sudo/s/^# *//' "${jroot}/etc/sudoers" +printf '$a\n%%sudo ALL=(ALL) NOPASSWD: ALL' | ed "${jroot}/etc/sudoers" user="${ORIG_USER}" uid="$(id -u "${ORIG_USER}")" [ "${user}" -a "${uid}" ] || { echo "Cannot add nonexistent user"; false; } @@ -62,5 +62,5 @@ chroot "${jroot}" /usr/sbin/useradd -m -o -u "${uid}" -G root,sudo "${user}" echo "Propagating password hash" [ -f /etc/shadow ] && { hash="$(grep "^${user}:" /etc/shadow | cut -d: -f2)" - [ "${hash}" ] && sed -i "s?^${user}:[^:]*:?${user}:${hash}:?" ${jroot}/etc/shadow + [ "${hash}" ] && sed -i "s?^${user}:[^:]*:?${user}:${hash}:?" "${jroot}/etc/shadow" } -- 2.42.0