HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Set SUID so files owned by owner of directory ?

 
SOLVED
Go to solution
Sammy_2
Super Advisor

How to Set SUID so files owned by owner of directory ?

I have user (samu11) put files in
/home/cognos directory. The files are owned by samu11. How do I make so any files put in /home/cognos are always owned by cognos user.

Thanks
good judgement comes from experience and experience comes from bad judgement.
6 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: How to Set SUID so files owned by owner of directory ?

Hi Sammy:

The best you can do is set the 'setgid' bit on the "/home/cognos" directory. Then, when any user who has permission to write into that directory does so, the files added will have a _group_ ownership of the "/home/cognos" directory.

Regards!

...JRF...

Sammy_2
Super Advisor

Re: How to Set SUID so files owned by owner of directory ?

Thanks, JRF. The SGID worked.
but SUID on a directory does not.
But is it possible to change the owner of the file in a directory to have the same owner as the directory itself.
We got different users put out file in a directory but just want one owner of all files in there.
good judgement comes from experience and experience comes from bad judgement.
Patrick Wallek
Honored Contributor

Re: How to Set SUID so files owned by owner of directory ?

The only thing I can think of is to have a cron job run periodically that changes the ownership of the files in that directory.
Pete Randall
Outstanding Contributor

Re: How to Set SUID so files owned by owner of directory ?

The only thing I can think of is to write a script that will be run by cron at whatever interval you deem necessary. Said script would look at the ownership of the directory, then chown -R the directory, thus ensuring that all files are owned by the directory owner.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: How to Set SUID so files owned by owner of directory ?

Hi (again) Sammy:

> The SGID worked. but SUID on a directory does not.

That's correct. The idea of a 'setuid' bit is that when set for an executable, the executable runs with an effective UID of the executable file's owner. The 'passwd' command is one classic example. That command runs with an effective UID of 'root'.

This said, of course, if a SETUID executable were to create a file, then the owner of the file would be that of the effective UID.

You do NOT want to travel this road except in very, very special cases. As Patrick and Pete said, setup a 'cron'task to 'chown' what you need.

Regards!

...JRF...
Sammy_2
Super Advisor

Re: How to Set SUID so files owned by owner of directory ?

Thanks Pat and Pete. I will use cron.
And of course , kudos to JRF for explaining the SUID concept.
good judgement comes from experience and experience comes from bad judgement.