summaryrefslogtreecommitdiff
path: root/precise-armhf-ubuntu-desktop/customization/hooks/03-check_sudoers_for_admin.chroot
blob: 5c8242965513f23643cb6909b8ddc6975e7377a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh 

# check to make sure sudoers file has ref for admin
ADMINEXISTS="$(awk '$1 == "%admin" { print $1 }' /etc/sudoers)"
if [ -z "$ADMINEXISTS" ]; then
  # append admin entry to sudoers
  echo "# Members of the admin group may gain root privileges" >> /etc/sudoers
  echo "%admin  ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
fi

# make sure that NOPASSWD is set for %admin
# expecially in the case that we didn't add it to /etc/sudoers
# just blow the %admin line away and force it to be NOPASSWD
sed -i -e '
/\%admin/ c \
%admin  ALL = (ALL) NOPASSWD: ALL
' /etc/sudoers