annotate previous-work/more_control_helpers/lib/mkdir @ 9:a0c0ccd22ca5

progress on setuid wrapper script.
author Robert McIntyre <rlm@mit.edu>
date Wed, 09 Jan 2013 04:53:59 +0000
parents d6bef198ae71
children
rev   line source
rlm@1 1 #!/bin/bash
rlm@1 2 # Copyright (c) 2000 Matthias S. Benkmann <article AT winterdrache DOT de>
rlm@1 3 # You may do everything with this code except misrepresent its origin.
rlm@1 4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
rlm@1 5
rlm@1 6 watchdir=/usr/share/locale
rlm@1 7
rlm@1 8 DAISY_CHAIN=""
rlm@1 9
rlm@1 10 for p in $(type -ap mkdir) ; do
rlm@1 11 if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi
rlm@1 12 done
rlm@1 13
rlm@1 14 if [ ! -n "$DAISY_CHAIN" ]; then
rlm@1 15 echo Cannot find real ${0##*/} command
rlm@1 16 exit 1
rlm@1 17 fi
rlm@1 18
rlm@1 19 if [ $UID == 0 ]; then
rlm@1 20 exec $DAISY_CHAIN "$@"
rlm@1 21 fi
rlm@1 22
rlm@1 23 cmdline="$@"
rlm@1 24
rlm@1 25 dirs=""
rlm@1 26 for((i=$#; $i>0;))
rlm@1 27 do
rlm@1 28 a="$1"
rlm@1 29 shift 1; i=$(($i-1))
rlm@1 30 case "$a" in
rlm@1 31 $watchdir/*) dirs="$dirs ""`expr $a : "$watchdir/\(.*\)"`"
rlm@1 32 set -- "$@" "$a"
rlm@1 33 ;;
rlm@1 34 *) set -- "$@" "$a" ;;
rlm@1 35 esac
rlm@1 36 done
rlm@1 37
rlm@1 38 $DAISY_CHAIN "$@" || exit $?
rlm@1 39
rlm@1 40 test z"$dirs" != z &&
rlm@1 41 echo 1>&2 '***' mkdir "$cmdline"
rlm@1 42 for dir in $dirs ; do
rlm@1 43 cumuldir=""
rlm@1 44 for d in `echo $dirs | sed 's#/# #g' -` ; do
rlm@1 45 cumuldir=$cumuldir$d/
rlm@1 46 chgrp install $watchdir/$cumuldir
rlm@1 47 test -k $watchdir/$cumuldir || chmod g+w,o+t $watchdir/$cumuldir
rlm@1 48 done
rlm@1 49 done
rlm@1 50 exit 0