Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # determine if file is locked
- #############################
- # Notes:
- #
- # on snow leopard
- # show flags with
- # ls -lO
- #
- #
- # lock: chflags uchg <file>
- # uchange, uimmutable
- # set the user immutable flag (owner or super-user only)
- #
- # chflags nodump <file>
- # set the nodump flag (owner or super-user only)
- #
- # chflags uappnd <file>
- # uappend
- # set the user append-only flag (owner or super-user only)
- #
- # chflags sappnd <file>
- # sappend
- # set the system append-only flag (super-user only)
- #
- # chflags schg <file>
- # schange, simmutable
- # set the system immutable flag (super-user only)
- # ***************************************************************
- # ** As discussed in chflags(2), the sappnd and schg flags **
- # ** may only be unset when the system is in single-user mode. **
- # ***************************************************************
- #
- # unlock: Putting the letters ``no'' before or removing the letters ``no''
- # from a keyword causes the flag to be cleared.
- #
- # chflags nouchg <file>
- # clear the user immutable flag (owner or super-user only)
- #
- # chflags dump <file>
- # clear the nodump flag (owner or super-user only)
- #
- # chflags nouappnd <file>
- # nouappend
- # set the user append-only flag (owner or super-user only)
- #
- # chflags nosappnd
- # nosappend
- # clear the system append-only flag (super-user only)
- #
- # chflags noschg <file>
- # noschange, nosimmutable
- # set the system immutable flag (super-user only)
- # ***************************************************************
- # ** As discussed in chflags(2), the sappnd and schg flags **
- # ** may only be unset when the system is in single-user mode. **
- # ***************************************************************
- #
- #
- ls="/bin/ls"
- #chflags="/usr/bin/chflags"
- cut="/usr/bin/cut"
- while [ "$1" != "" ]
- do
- latch=`ls -lO "$1" |cut -c30-34`
- door=`echo $latch`
- if [ "$door" != "nodu" ]
- then
- if [ "$door" != "schg" ]
- then
- if [ "$door" != "uchg" ]
- then
- echo " not locked: $1"
- else
- echo " locked: $1"
- fi
- else
- echo " system locked: $1"
- fi
- else
- echo "flagged nodump: $1"
- fi
- shift
- done
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement