Advertisement
Guest User

var4.sh

a guest
Oct 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. #!/usr/bin/ksh
  2.  
  3. if ! [[ -d $1 ]]; then
  4.     echo No such directory "'$1'"
  5.     exit 1
  6. fi
  7.  
  8. . ./lib.sh
  9.  
  10. dir_perms $1 && dir_owners $1 || {
  11.     echo Cannot get metainfo of "'$1'" >2
  12.     exit 1
  13. }
  14.  
  15. if [[ wperm_g -eq 0 ]]; then
  16.     set -A allowed $(getent group "$dir_gid" | cut -d: -f4 | tr ',' ' ')
  17. fi
  18. usr_by_id $dir_uid || {
  19.         echo Cannot resolve user by uid $dir_uid >2
  20.         exit 1
  21. }
  22. if [[ wperm_u -eq 0 ]]; then
  23.     if [[ -z $(echo ${allowed[@]} | sed -n "/$my_usr/p") ]]; then
  24.         set -A allowed $my_usr ${allowed[@]}
  25.     fi
  26. else
  27.     set -A allowed $(echo ${allowed[@]} | sed "s/\(.*\)$my_usr\(.*\)/\1\2/")
  28. fi
  29. if [[ wperm_o -eq 0 ]]; then
  30.     set -A others $(getent passwd | cut -d: -f1)
  31.     echo ${#others[@]} ${#allowed[@]}
  32.     for human in ${allowed[@]}; do
  33.         set -A others $(echo ${others[@]} | sed "s/\(.*\)$human\(.*\)/\1\2/")
  34.     done
  35.     set -A allowed ${others[@]} ${allowed[@]}
  36. fi
  37. echo ${allowed[@]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement