If you have a directory, say /test that looks like this:

drwxrwx---    2 stork  stork          17 May 27 23:57 test

You can do a SGID with 'chmod g+s test/' to force the group on new files
and directories to be whatever the group of the directory is, in this
example it would be stork.  So after that command it should look like
this:

drwxrws---    2 stork  stork          17 May 27 23:57 test

Then as root, I could create a file in /test:

touch /test/testfile

And then create a directory:

mkdir /test/testdir

A 'ls -l /test/' would show:

ls -l /test/

total 0
drwxr-sr-x    2 root     stork           6 May 28 00:11 testdir
-rw-r--r--    1 root     stork           0 May 28 00:01 testfile

The file is owned by the user root, however the group is set to stork
instead of what it would have been otherwise.  The same is also true for
the directory, however the new sub-directory also has the SGID bit set on
it too, so files and directories created under it would also have the same
effect.  If you also want to force permissions you can take a look at the
'umask' man page.

As far as I have been able to find out, there is no way to force the user
in a similar manner (Someone please share this knowledge if there is a way
:), however Samba does have that kind of functionality.  Not sure about
NFS, haven't played with it enough too say.

For Samba, you can use "force user = <user>" and "force group = <group>"
under each share section to force which user/group is used to access the
share after authentication occurs.  You may also want to check the man
page for smb.conf and look at the following options, they may offer some
more functionality that could prove useful:

force create mode
force directory mode
force directory security mode
force security mode

Sorry I couldn't fully answer your question, I hope this helps though.

Cheers,

--
Trevor Lauder
Web: http://www.thelauders.net
E-Mail: [EMAIL PROTECTED]
Resume: http://www.thelauders.net/resume.html
Gentoo Powered

"Any intelligent fool can make things bigger and more complex... It takes
a touch of genius -- and a lot of courage to move in the opposite
direction."  -- Albert Einstein

Johnny Stork said:
> I am trying to re-configure much of my network and cant recall, or now
> find, how to force a directory to use a specific user.group when new files
> or sub-directories are created, even when logged in as root or another
> user. For instance, if I have the following
>
> /home/stork   (currently chown -R stork.stork)
> /home/german (currently chown -R german.german)
>
> I would like to ensure that no matter who I am logged in as (root, stork,
> german), that all new files and directories get created with the same
> user.group as set above. Obviously only root having access to both, but
> when files or directories are created in either, the new object is created
> with the user.group set above.
>
> Also, since these home locations are also exported via NFS and shared via
> Samba, I want the same behavior whether I am connecting from a Windows or
> Linux machine.
>
>
>
> <hr>
> <b><font color=blue size=4>Open Enterprise Solutions</font>
> <font color=red>Linux & Open Source Solutions for Business</font></b>
>
> Johnny Stork, B.A.
> Calgary, AB
>
> <a href="http://www.openenterprise.ca";>
> www.openenterprise.ca</a>
>
>

Reply via email to