LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-22-2010, 09:40 AM   #1
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Rep: Reputation: 48
permissions for 'chown'


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?
 
Old 02-22-2010, 09:43 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
What is the error you're getting when you attempt to execute the command?
 
Old 02-22-2010, 09:57 AM   #3
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by rweaver View Post
What is the error you're getting when you attempt to execute the command?
Code:
$ chown userx myfile
chown: changing ownership of 'myfile': Operation not permitted
$
 
Old 02-22-2010, 10:01 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,906

Rep: Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026
It has nothing to do with who can run the chown executable. Only root can change the owner of a file. You can't even give away your own files.
 
1 members found this post helpful.
Old 02-22-2010, 10:10 AM   #5
eaglek1
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Rep: Reputation: 2
This makes sense.

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.

Regards,
 
Old 02-23-2010, 03:33 AM   #6
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 48
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?
 
Old 02-23-2010, 04:22 AM   #7
eaglek1
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Rep: Reputation: 2
Hi,

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.

Regards,
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
really screwy permissions error involving chmod, chgrp, chown Ryzol Linux - Software 1 03-26-2008 11:36 PM
chmod chown permissions not working operation not allowed UMG:Chicken_Soüp Slackware 1 11-06-2007 12:15 AM
Cannot chown or change permissions Fear Fedora 3 10-26-2005 07:07 PM
permissions messed up chown command used tsayles21 Debian 3 03-30-2004 08:38 PM
Graphically setup user permissions (frontend to chmod and chown) sfonvill Linux - Security 2 08-27-2003 03:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration