Advertisement
nighthoodie

nok

Apr 23rd, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.77 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # determine if file is locked
  4. #############################
  5.  
  6. # Notes:
  7. #
  8. # on snow leopard
  9. # show flags with
  10. # ls -lO
  11. #
  12. #
  13. #   lock:  chflags uchg <file>
  14. #               uchange, uimmutable
  15. #               set the user immutable flag (owner or super-user only)
  16. #
  17. #          chflags nodump <file>
  18. #               set the nodump flag (owner or super-user only)
  19. #
  20. #          chflags uappnd <file>
  21. #               uappend
  22. #               set the user append-only flag (owner or super-user only)
  23. #
  24. #          chflags sappnd <file>
  25. #               sappend
  26. #               set the system append-only flag (super-user only)
  27. #
  28. #          chflags schg <file>
  29. #               schange, simmutable
  30. #               set the system immutable flag (super-user only)
  31. #               ***************************************************************
  32. #               ** As discussed in chflags(2), the sappnd and schg flags     **
  33. #               ** may only be unset when the system is in single-user mode. **
  34. #               ***************************************************************
  35. #
  36. # unlock:  Putting the letters ``no'' before or removing the letters ``no''
  37. #          from a keyword causes the flag to be cleared.
  38. #
  39. #          chflags nouchg <file>
  40. #               clear the user immutable flag (owner or super-user only)
  41. #
  42. #          chflags dump <file>
  43. #               clear the nodump flag (owner or super-user only)
  44. #
  45. #          chflags nouappnd <file>
  46. #               nouappend
  47. #               set the user append-only flag (owner or super-user only)
  48. #
  49. #          chflags nosappnd
  50. #               nosappend
  51. #               clear the system append-only flag (super-user only)
  52. #
  53. #          chflags noschg <file>
  54. #               noschange, nosimmutable
  55. #               set the system immutable flag (super-user only)
  56. #               ***************************************************************
  57. #               ** As discussed in chflags(2), the sappnd and schg flags     **
  58. #               ** may only be unset when the system is in single-user mode. **
  59. #               ***************************************************************
  60. #
  61. #
  62.  
  63. ls="/bin/ls"
  64. #chflags="/usr/bin/chflags"
  65. cut="/usr/bin/cut"
  66.  
  67.  
  68. while [ "$1" != "" ]
  69. do
  70.         latch=`ls -lO "$1" |cut -c30-34`
  71.         door=`echo $latch`
  72.         if [ "$door" != "nodu" ]
  73.         then
  74.                 if [ "$door" != "schg" ]
  75.                 then
  76.                         if [ "$door" != "uchg" ]
  77.                         then
  78.                                 echo "    not locked: $1"
  79.                         else
  80.                                 echo "        locked: $1"
  81.                         fi
  82.                 else
  83.                         echo " system locked: $1"
  84.                 fi
  85.         else
  86.                 echo "flagged nodump: $1"
  87.         fi
  88.         shift
  89. done
  90. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement