17 Apr 2013

Amusing a Sysadmin 

By - amusings 2 Comments

As most geek discussions go.. we like to push the envelope — to see what is possible!

As we discussed using chattr to protect a file from being overwritten, it occurred to me that we might perform a weak form of “Inception” on chattr!

So I ran:


# chmod 000 chattr & chattr +i chattr
# chmod +x chattr
chmod: changing permissions of `chattr': Operation not permitted
# chattr -l
-bash: /usr/bin/chattr: Permission denied
# chattr -i chattr
-bash: /usr/bin/chattr: Permission denied
# chmod +x chattr
chmod: changing permissions of `chattr': Operation not permitted

And one solution

To restore functionality to chattr …

# cp /usr/bin/chattr /usr/bin/chattr2
# chmod 755 /usr/bin/chattr2
# chattr2 -i /usr/bin/chattr
# chmod 755 /usr/bin/chattr
# ls -la /usr/bin/chattr ; lsattr /usr/bin/chattr
-rwxr-xr-x 1 root root 9664 2010-08-17 01:29 /usr/bin/chattr
-----------------e- /usr/bin/chattr

Notice the immutable bit is not present on the copy of chattr -> chattr2.

Back to work..

2 Responses to “Amusing a Sysadmin”

  1. Name says:

    Or you could’ve just done chmod 755 /usr/bin/chattr …

  2. nwilkens says:

    Except you can’t! Because /usr/bin/chattr is immutable at this point still! Try it and let me know what happens ;)

Leave a Reply