Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Inspite of having 755 permissions on the chown command, it seems the command can be executed by the root only. I was under the impression that the 'x' permission for 'others' can give executable rights to the normal user too, which does not seem to be the case here.
Just curious to know, if not the file perms itself, what controls the execution of the command?
If you think a bit you would see that if a user could change the owner of a file it will create some security issues.
Think of someone writing a rootkit, virus or some malware and then put it on a public area. So far so good, but what will happen if it changed the owner to, lets say the worst case, the root user. If for some reason a Sys Admin ran that file, well... i think you can figure it out .
I think thats why the chown or chgrp only allow the root user to change the owner and group of a file.
Thanks for the replies...
I asked this because, i am writing a script to audit a system, and want to make sure that no one but root has rights to run the chown command. While checking this, i thought it would be good idea to check if the default behavior has been changed, and a non-privileged user has been given the rights to run it. Is there _one place_ i can check this? or is it absolutely impossible to change the behavior?
After a more careful reading of some previous postings and manuals, i see that you might be able to change that behaviour, but for that you need to change some POSIX settings. You need to disable the _POSIX_CHOWN_RESTRICTED, and for that you only need to add the following to /etc/system:
set rstchown = 0
For some distributions that file doesn't exist, but you can find it on /etc/sysctl.conf or /etc/sysctl.d/10*something
You can also check if this flag was been changed by issuing the command
sysctl -a | grep chown
and if you don't get any results or the result is something like
fs.*.chown = 1
that means everything is how it should
but if you get something like
fs.*.chown = 0
this means the behavior has been changed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.