From 7f26c0abefaf1bc5ae75075600c70e2e2c2b95ce Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Wed, 11 Jun 2014 03:04:17 +0200 Subject: [PATCH] =?utf8?q?[populate=5Fforwards]=20Un=20peu=20plus=20g?= =?utf8?q?=C3=A9n=C3=A9rique=20et=20{cwd,sudo}-proof?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- populate_forward.sh | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/populate_forward.sh b/populate_forward.sh index 276a5f3..b492c9c 100755 --- a/populate_forward.sh +++ b/populate_forward.sh @@ -2,15 +2,26 @@ # Remplir le fichier forward -find /home -mindepth 1 -maxdepth 1 -type d | sort | \ -while read -r dossier; -do - if test -f ${dossier}/.forward; - then - echo -n "${dossier/\/home\//} : "; - cat ${dossier}/.forward - fi -done > forwards +USER=legallic -chown legallic:users forwards -chmod 600 forwards +FILE=/home/${USER}/forwards + +if [ $EUID -eq 0 ] +then + touch ${FILE} + chown ${USER}:users ${FILE} + chmod 600 ${FILE} + + find /home -mindepth 1 -maxdepth 1 -type d | sort | \ + while read -r dossier; + do + if test -f ${dossier}/.forward; + then + echo -n "${dossier/\/home\//} : "; + cat ${dossier}/.forward + fi + done > ${FILE} + +else + echo "À exécuter en root !" +fi -- 2.39.2