mobile logo

Amusing a Sysadmin

posted on April 17, 2013 / IN 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..

By admin

2 Comments

Please use the form to leave a comment

    • Name
      Posted on April 30, 20137:58 pm Reply

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

      • nwilkens
        Posted on April 30, 20139:35 pm Reply

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

Page 1 of 1

Leave a comment.