Amusing a Sysadmin
Mar 25, 2022

Amusing a Sysadmin

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 chattrchmod: 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 chattrchmod: changing permissions of `chattr': Operation not permittedAnd one solutionTo 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/chattrNotice the immutable bit is not present on the copy of chattr -> chattr2.Back to work..

Related posts

Browse more
We haven't published any posts