| version 1.1, 2002/06/11 19:22:27 |
version 1.2, 2002/06/11 22:26:59 |
|
|
| exit 1; |
exit 1; |
| } |
} |
| |
|
| yes() |
# function to check, if action is permitted or NOT {{{ |
| |
check() |
| { |
{ |
| echo "yes"; |
#echo "check_deny $*" |
| exit 0; |
|
| } |
CONFIG="$1"; shift |
| |
USER="$1" ; shift |
| no() |
ACTION="$1"; shift |
| { |
PARAM="$*" ; shift |
| echo "no"; |
|
| exit 0; |
awk " |
| } |
BEGIN { |
| |
user=\"$USER\"; |
| # function to check, if action is permitted |
action=\"$ACTION\"; |
| check_allow() |
param=\"$PARAM\"; |
| { |
result=\"no\"; |
| echo "check_allow $*" |
hard_result=\"\"; |
| } |
} |
| |
# comments, ORDER:, empty lines ... |
| # function to check, if action is NOT permitted |
/^[#;]/ { next; } |
| check_deny() |
/^ORDER:/ { next; } |
| { |
/^$/ { next; } |
| echo "check_deny $*" |
# check it there are at least 3 fields on the line |
| } |
// { |
| |
if (NF < 3) { |
| |
printf \"Error in config file at line %d\n\", NR; |
| |
exit; |
| |
} |
| |
} |
| |
# ignore line 'deny ALL ALL' |
| |
/^$first_order/ { # /^deny/ for 'ORDER: deny allow' |
| |
if (\$2 == \"ALL\" && \$3 == \"ALL\") |
| |
next; |
| |
if (\$2 == user && \$3 == action) { |
| |
#print > \"/dev/stderr\" ; |
| |
result=\"no\"; |
| |
exit; |
| |
} |
| |
if (\$2 == \"ALL\" && \$3 == action ) { |
| |
#printf \"hard_result %s\n\", \$0 > \"/dev/stderr\" ; |
| |
hard_result=\"no\"; |
| |
next; |
| |
} |
| |
} |
| |
/^$second_order/ { # /^allow/ for 'ORDER: deny allow' |
| |
if (\$2 == user && \$3 == action) { |
| |
#print > \"/dev/stderr\" ; |
| |
result=\"yes\"; |
| |
exit; |
| |
} |
| |
# if line 'deny ALL action' is not found hard_result=\"\" |
| |
if (\$2 == user && (\$3 == action || \$3 == \"ALL\") && hard_result != \"no\") { |
| |
#printf \"hard_result=%s\n\", hard_result > \"/dev/stderr\" ; |
| |
result=\"yes\"; |
| |
} |
| |
} |
| |
END { printf \"%s\n\", result; } |
| |
" $CONFIG |
| |
} # }}} |
| |
|
| if [ "$#" -lt 3 ]; then |
if [ "$#" -lt 3 ]; then |
| usage; |
usage; |
| Line 62 if [ "x$first_order" = "x" -o "x$second_ |
|
| Line 98 if [ "x$first_order" = "x" -o "x$second_ |
|
| fi |
fi |
| |
|
| if [ "x$first_order" = "xallow" ]; then |
if [ "x$first_order" = "xallow" ]; then |
| check_allow $CONFIG $USER $ACTION $PARAM |
check $CONFIG $USER $ACTION $PARAM |
| else |
else |
| if [ "x$first_order" = "xdeny" ]; then |
if [ "x$first_order" = "xdeny" ]; then |
| check_deny $CONFIG $USER $ACTION $PARAM |
check $CONFIG $USER $ACTION $PARAM |
| else |
else |
| echo "Bad order $first_order!" |
echo "Bad order $first_order!" |
| exit -1; |
exit -1; |
| fi |
fi |
| fi |
fi |
| |
|
| |
# vim:set ts=4: |
| |
# vim600:fdm=marker fdl=0 fdc=3 vb t_vb=: |