Parcourir la source

installer.sh.in: check for empty USERLOGIN

Append a line to sudoers only, if the USERLOGIN is actually non-empty.
Otherwise only enable sudo for the members of group 'wheel'.

Closes #138

Closes: #143 [via git-merge-pr]
Jürgen Buchmüller il y a 7 ans
Parent
commit
c2086d3ec7
1 fichiers modifiés avec 7 ajouts et 5 suppressions
  1. 7 5
      installer.sh.in

+ 7 - 5
installer.sh.in

@@ -1284,15 +1284,17 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
     fi
 
     if [ -f $TARGETDIR/etc/sudoers ]; then
-        if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" ]; then
-            # enable sudo for primary user USERLOGIN
-            echo "# Enable sudo for login '$(get_option USERLOGIN)'" >> $TARGETDIR/etc/sudoers
-            echo "$(get_option USERLOGIN) ALL=(ALL) ALL" >> $TARGETDIR/etc/sudoers
+        USERLOGIN="$(get_option USERLOGIN)"
+        if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then
+            # enable sudo for primary user USERLOGIN who is not member of wheel
+            echo "# Enable sudo for login '$USERLOGIN'" >> $TARGETDIR/etc/sudoers
+            echo "$USERLOGIN ALL=(ALL) ALL" >> $TARGETDIR/etc/sudoers
         else
-            # enable sudoers entry for members of group wheel for primary user
+            # enable the sudoers entry for members of group wheel
             sed -i $TARGETDIR/etc/sudoers \
                 -e "s;#.*%wheel ALL=(ALL) ALL;%wheel ALL=(ALL) ALL;"
         fi
+        unset USERLOGIN
     fi
 
     # enable text console for grub if chosen