Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 23, 2026

Diff for scripts/shell/access/access.sh between version 1.1 and 1.2

version 1.1, 2002/06/11 19:22:27 version 1.2, 2002/06/11 22:26:59
Line 14  usage()
Line 14  usage()
         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=:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top