#!/bin/bash # Copyright (c) 2004 Matthias S. Benkmann
# You may do everything with this code except misrepresent its origin. # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND! DAISY_CHAIN="" for p in $(type -ap chmod) ; do if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p break fi done if [ ! -n "$DAISY_CHAIN" ]; then echo Cannot find real ${0##*/} command exit 1 fi if [ $UID == 0 ]; then exec $DAISY_CHAIN "$@" fi report=0 doit=1 reportmsg="*** chmod $@" case "$1" in g+s|u+s) report=1; doit=0 ;; 4755) shift 1 ; set -- 755 "$@" ; report=1; doit=1 ;; 4555) shift 1 ; set -- 555 "$@" ; report=1; doit=1 ;; *) ;; esac if [ "$report" = 1 ]; then echo 1>&2 "$reportmsg" fi if [ "$doit" = 1 ]; then exec $DAISY_CHAIN "$@" fi exit 0