From d57e7c27520a864627723fa79ffbf949a47e3639 Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Sat, 31 Dec 2011 15:46:11 +0000 Subject: [PATCH] =?UTF-8?q?Pouvoir=20specifier=20le=20compte=20=C3=A0=20tr?= =?UTF-8?q?aiter=20lors=20d'un=20fixperm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * -l login du compte concerné (/var/alternc/html/l/login) * -l uid (gid unix associé au compte concerné) Le comportement initial est conservé * si pas d'arguments alors on fixe les droits de l'ensemble de /var/alternc/html Si on fournit un autre parametre on annule le traitement avec message d'erreur --- src/fixperms.sh | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/fixperms.sh b/src/fixperms.sh index d5da2a05..7021c22f 100755 --- a/src/fixperms.sh +++ b/src/fixperms.sh @@ -29,6 +29,37 @@ # ---------------------------------------------------------------------- # +#Default Query : fixperms for all account +query="SELECT uid,login FROM membres" + +#Two optionals argument +# -l string : a specific login to fix +# -u interger : a specifi uid to fix +while getopts "l:u:" optname + do + case "$optname" in + "l") + query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'" + ;; + "u") + query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'" + ;; + "?") + echo "Unknown option $OPTARG - stop processing" + exit + ;; + ":") + echo "No argument value for option $OPTARG - stop processing" + exit + ;; + *) + # Should not occur + echo "Unknown error while processing options" + exit + ;; + esac + done + CONFIG_FILE="/etc/alternc/local.sh" PATH=/sbin:/bin:/usr/sbin:/usr/bin @@ -55,7 +86,7 @@ doone() { fi INITIALE=`echo $LOGIN |cut -c1` REP="$ALTERNC_LOC/html/$INITIALE/$LOGIN" - + # Set the file readable only for the AlternC User chown -R $GID:$GID "$REP" chmod 2770 -R "$REP" @@ -64,11 +95,10 @@ doone() { # Set the defaults acl on all the files setfacl -b -k -m d:g:alterncpanel:rw- -m d:u:$GID:rw- -m d:g:$GID:rw- \ -m g:alterncpanel:rw- -m u:$GID:rw- -m g:$GID:rw- \ - -R "$REP" + -R "$REP" read GID LOGIN done } -mysql --defaults-file=/etc/alternc/my.cnf -B -e "select uid,login from membres" |grep -v ^uid|doone - +mysql --defaults-file=/etc/alternc/my.cnf -B -e "$query" |grep -v ^uid|doone