Operating System - HP-UX
1834465 Members
3163 Online
110067 Solutions
New Discussion

Re: Directory permissions

 
SOLVED
Go to solution
David_246
Trusted Contributor

Directory permissions

Hi,

I have a question about two complete different users that need to have read/write access in the same directory.
Both users should be able to add files in that dir, but the new files should always have the same ownership :

drwxrwx--- ftpuser applgroup 1024 /ftp/in

Each file that is created should get above UID and GROUPID OWNER. By setting an s bit on the group does not make any difference. By setting permission as :
drwxrws---
will create files still under it's own USERid. Does anyone know a method how to always set the permission to the above standard ??


Regs David
@yourservice
5 REPLIES 5
Leif Halvarsson_2
Honored Contributor

Re: Directory permissions

Hi,

I don't think there is any direct way to do this. When created files is always owned by the creator.
Some suggestions:

- Pre-create the files as empty files with correct owner.
- If possible, have the application to change owner.
- Running a cron job every 10 minute (for ex.) which find and changes the files with wrong owner.
Francisco J. Soler
Honored Contributor

Re: Directory permissions

Hi David, i think this is the correct behaviour.

You must add the two users to a common group, this can be a secondary group, then with the s bit set on in the directory, the two users can share the files in that directory.

The new files created will have user and group permissions and there will be no problems to share.

Frank.
Linux?. Yes, of course.
Bernhard Mueller
Honored Contributor
Solution

Re: Directory permissions

David as a 4th alternative to Leifs suggestions:
change inittab to respawn this "daemon" script in run level 3

###############################################
#!/bin/sh
cd /your_ftp_dir
while true
do
ll | grep -v total | while read line
do
if [ `echo $line | awk '{print $3}'` != ftpuser ] || [ `echo $line | awk '{print $4}'` != applgroup ] || [ `echo $line | awk '{print $1}'` != '-rwxrwx---' ]
then
chown ftpuser *
chgrp applgroup *
chmod 750 *
fi
done
done

###############################################

Regards,
Bernhard
David_246
Trusted Contributor

Re: Directory permissions

Hi All,

Thanks for all your help !
Bernhard; It doesn't solve my issue as prefer not to use that many extra entries (I need multiple of these users). Still your time in this deffinitly earnes a 8 points !!
Thanks for your help

Regs David
@yourservice
john korterman
Honored Contributor

Re: Directory permissions

Hi David,

something really alternative....
Make use of ftpaccess: you can define that files delivered into a certain users' home directory via ftp should be owned by a certain user, belong to a certain group and have certain predefined permissions.
(man ftpaccess, search for the keyword upload to see the examples.)
One tricky thing is that the file destination dir must be an ftp users' home directory: in the script below the file david ends in the home dir of the xxxxxx user.
Another tricky thing is of course to make use of this facility without the user being aware of making an ftp session.
I have just tried this primitive script, ftpjk, which tries to hide the ftp session for the user:

#!/usr/bin/sh
# cd to where the file is
cd /tmp/jxk
YOUR_MACHINE=$(uname -n)
USERNAME=xxxxxx
PASSWORD=yyy1234
(
echo "
open $YOUR_MACHINE
user $USERNAME $PASSWORD
put $1
close
"
) | ftp -i -n

# end of script.

the source file used to put into the xxxxxx users home directory:
ls -l /tmp/jxk/david
-rw-r--r-- 1 jxk users 0 Sep 5 14:38 /tmp/jxk/david

the filename used as parameter for the above script:
# ./ftpjk david

and when david appeared in the xxxxxx users' home dir, it had these permissions:
-rw-rw-rw- 1 root dba 0 Sep 5 14:39 david

because of the upload config in /etc/ftpd/ftpaccess.
Perhaps you can elaborate on it yourself.

regards,
John K.


it would be nice if you always got a second chance