Operating System - HP-UX
1752762 Members
5009 Online
108789 Solutions
New Discussion юеВ

Re: Setuid on a directory

 
Luis Toro
Regular Advisor

Setuid on a directory

What does setting the setuid bit on a directory do (chmod o+s /dir) ? On an HPUX 11.11 system we'd like all files created within a certain directory to have a specific ownership for user and group. Seems that by turning on the setgid bit, the group affiliation of a new file takes on the group of the directory, but the owner remains the same as the creating owner even though the setuid bit is turned on. Am I missing something?
Thanks
9 REPLIES 9
spex
Honored Contributor

Re: Setuid on a directory

Hi Luis,

You've discovered that setgid on a directory will cause subdirectories to inherit their parent's group. However, there is no analogue for suid (I think you meant 'chmod u+s /dir'?).

Note that this is different from setting the sticky bit for a directory, which prevents users from deleting files other than their own.

PCS
James R. Ferguson
Acclaimed Contributor

Re: Setuid on a directory

Hi:

No, you aren't missing anything. This is the expected behavior.

Setting the 'setgid' bit on a directory causes all files in the directory to be created with their group ID equal to that of the parenet directory. This applies for new directories, too. These new subdirectories will also have their setgid bit set on (at least on some Unixes).

Setting the 'setuid' bit on a directory has no effect on the ownership of files created in the directory.

Regards!

...JRF...
Luis Toro
Regular Advisor

Re: Setuid on a directory

:-(
I need to control the user ownership of files dumped onto a directory. Cronning a chmod would not be an acceptable solution either.
A. Clay Stephenson
Acclaimed Contributor

Re: Setuid on a directory

Then prepare to be disappointed. It makes perfect sense to me that the owner of a file would actually be the user that creates the files. Bear in mind that this user is allowed to chown the files to another user.
If it ain't broke, I can fix that.
florin_10
Frequent Advisor

Re: Setuid on a directory

The creator of a file is the owner. Scripting might be the answer to your problem!
Luis Toro
Regular Advisor

Re: Setuid on a directory

I guess I should have elaborated a bit...
developers place files in a staging directory. The QA group copies the files from this directory to a location the developers do not have access to. We are using Samba for QA to move the files from one directory to the other. The QA folks are mapped to a single "QA" unix userid, but what we were seeing in Samba is that the file ownerships were being retained even though we were using the "force user" parameter in Samba. We thought we could get around this with the setuid bit on the directory. What we've since discovered is that the "force user" works across Samba folders, but not within a single folder. The staging and QA areas were subdirectories within a samba share. We changed the samba config such that each subdirectory is now its own share, and now when you copy files across, the ownerships are changed accordingly.
Luis Toro
Regular Advisor

Re: Setuid on a directory

See last reply for solution.
Thanks
A. Clay Stephenson
Acclaimed Contributor

Re: Setuid on a directory

It would have really helped had you mentioned Samba/CIFS. When you specifically mentioned setuid, silly us, we thought this was a UNIX question.
If it ain't broke, I can fix that.
Luis Toro
Regular Advisor

Re: Setuid on a directory

It was a unix question to get around what I perceived to be a samba issue. As far as I'm concerned, my inquiry was answered, and I moved onto the next "layer" to see if I could find a workaround. I only put in the samba details for the benefit of others who might come across a similar requirement.