From 62aa56f051bfd33679842f751d368c9e5d337a45 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 28 May 2012 12:49:43 +0200 Subject: [PATCH] make_chroot_jail: suppport sudo configuration via /etc/sudoers.d --- usr_sbin/make_chroot_jail | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/usr_sbin/make_chroot_jail b/usr_sbin/make_chroot_jail index d14d112..083c2d2 100755 --- a/usr_sbin/make_chroot_jail +++ b/usr_sbin/make_chroot_jail @@ -278,10 +278,17 @@ echo # skip the creation of the new account if [ "$1" != "update" ]; then -# Modifiy /etc/sudoers to enable chroot-ing for users +# Modify sudo config to enable chroot-ing for users, # must be removed by hand if account is deleted -echo "Modifying /etc/sudoers" -echo "$CHROOT_USERNAME ALL=NOPASSWD: `which chroot`, /bin/su - $CHROOT_USERNAME" >> /etc/sudoers +SUDOERS="$CHROOT_USERNAME ALL=NOPASSWD: $(which chroot), /bin/su - $CHROOT_USERNAME" +if [ -d /etc/sudoers.d ]; then + echo "Installing sudoers configuration file /etc/sudoers.d/jail-$CHROOT_USERNAME" + echo "$SUDOERS" > "/etc/sudoers.d/jail-$CHROOT_USERNAME" + chmod 0440 "/etc/sudoers.d/jail-$CHROOT_USERNAME" +else + echo "Modifying /etc/sudoers" + echo "$SUDOERS" >> /etc/sudoers +fi # Define HomeDir for simple referencing HOMEDIR="$JAILPATH/home/$CHROOT_USERNAME" -- 2.1.4