Default user:group permissions while creating files and directories

Hi,

I am working on setup a environment where only a specific user can upload the builds on htdocs of apache.
Now i want that a specific user can copy the builds on htdocs folder.

I created a group "deploy" and assign user1 and user2 to this group.
On Apache side i mentioned User=deploy and group=deploy in httpd.conf.

So the challenge is that i want if user1 or user2 login and they copied the builds on htdocs, default user and group will be deploy:deploy

Please help me on this.

Thanks,
Sunny

If you set the group-sticky bit on a folder, files created in the folder will belong to the group of the folder.

I don't think you can do the same with the username, since you need elevated permissions to change the owner of a file...

Hello,

I created a user who should have rights to work under /opt/lampp/htdocs directory. This directory is having below rights.

drwxr-xr-x 184 deploy deploy 12288 Dec 3 17:42 htdocs

i created a user deploy which belongs to deploy group
uid=502(deploy) gid=502(deploy) groups=502(deploy) context=root:system_r:hotplug_t:SystemLow-SystemHigh

but now when user deploy going to create any directory/files under /opt/lampp/htdocs, is giving the below error

Sorry, user deploy is not allowed to execute '/bin/mkdir 1' as root on localhost

Please let me know how to fix this.

Thanks,
Sunny

What, exactly, does he do to try and create the directory? That message is very weird. It's not the usual error mkdir would give you for that. That it's saying he's trying to do so as root is doubly odd!

You need to make the directory group-writable, of couse -- chmod g+w -- but that hardly matters if he's not actually doing so as himself but as root!