X-Git-Url: http://cgit.sxemacs.org/?p=pkgusr;a=blobdiff_plain;f=usr%2Flib%2Fpkgusr%2Fchmod;fp=usr%2Flib%2Fpkgusr%2Fchmod;h=e1aa49e1c65c8b10aea4c70185fb0586bb4f2857;hp=555ca3f1bd6fc820eba4a1813cfdd3dc381df2cf;hb=89087453d412f26224203bc3549d86c4729af683;hpb=f42935ec1d3286f3644fc39a4f437a19e966e3bb diff --git a/usr/lib/pkgusr/chmod b/usr/lib/pkgusr/chmod index 555ca3f..e1aa49e 100755 --- a/usr/lib/pkgusr/chmod +++ b/usr/lib/pkgusr/chmod @@ -24,16 +24,13 @@ fi if [ $UID == 0 ]; then echo 1>&2 '***' $(dirname $0) should not be in root\'s \$PATH - echo 1>&2 '***' call "$DAISY_CHAIN $@" directly. + echo 1>&2 '***' call '"'$DAISY_CHAIN $@'"' directly. exit 1 fi # Save the original cmdline as we're gonna mess with it cmdline="$@" -reportmsg="*** chmod $cmdline" -report=0 - # Remove any options so $1 becomes the perm arg, however save the # options for later opts="" @@ -46,11 +43,12 @@ done # $1 should now be the perm arg # Octal or symbolic? -if [ $1 -ge 0 2>/dev/null ]; then +printf '%d' $1 &>/dev/null +if [ $? -eq 0 ]; then perm=$1 else touch /tmp/hack-o-matic-4500 - chmod $1 /tmp/hack-o-matic-4500 + $DAISY_CHAIN $1 /tmp/hack-o-matic-4500 perm=$(stat --printf "%a" /tmp/hack-o-matic-4500) rm -f /tmp/hack-o-matic-4500 fi @@ -59,13 +57,13 @@ fi if [ $perm -gt 999 ]; then # Chop off the 1st digit (the set{uid,gid,sticky} bit) perm=${perm/?/} - echo 1>&2 "$reportmsg" + echo 1>&2 '***' chmod ${cmdline} fi # kill off $1 and replace it with our maybe sanitised $perm shift 1; set -- $perm "$@" -exec $DAISY_CHAIN "$opts $@" || exit $? +exec $DAISY_CHAIN ${opts} $@ || exit $? exit 0 # Local variables: