aboutsummaryrefslogtreecommitdiff
path: root/scripts/LINARO/03-check_sudoers_for_admin.chroot
blob: b9073f250589d9920a663625c54064ceb8b54a24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
set -e

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

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