LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A question about default groups & permissions for uploaded files (https://www.linuxquestions.org/questions/linux-newbie-8/a-question-about-default-groups-and-permissions-for-uploaded-files-4175479406/)

DrinkinHomeBrew 10-03-2013 12:22 AM

A question about default groups & permissions for uploaded files
 
I've never quite got this, so maybe someone can help out.

I installed a new drive for storing ISOs & VMs. Got it mounted at /kvm and created the directories /kvm/iso & /kvm/vm. This is as root, so the directory looks something like this:

drwxr-xr-x 5 root root 4096 Oct 2 23:21 ./
drwxr-xr-x 24 root root 4096 Oct 2 22:48 ../
drwxr-xr-x 2 root root 4096 Oct 2 23:21 iso/
drwxr-xr-x 2 root root 4096 Oct 2 23:21 vm/

I want to copy files using scp, and authenticating as a non-root account (drunk) that's in the libvirtd group. Because I'm lazy, I want that copied file to automatically have its group and permissions set for libvirtd so KVM can use it without having to run a chgrp/chmod on the file directly.

So I change the group of iso: sudo chgrp libvirtd iso
And change the permissions on the directory: sudo chmod 770 iso
And I can copy up a file: scp ubuntu-12.04.3-server-amd64.iso drunk@remote:/kvm/iso

I can see the file up at its destination

drwxrwx--- 2 root libvirtd 4.0K Oct 2 23:29 ./
drwxr-xr-x 5 root root 4.0K Oct 2 23:21 ../
-rwx------ 1 drunk drunk 665M Oct 2 23:31 ubuntu-12.04.3-server-amd64.iso*

So, my question is

1) How can I get that directory configured so new files automatically belong to the libvirtd group?

2) And that the group permissions are set to rwx?

Is this possible?

Thanks!

frieza 10-03-2013 12:24 AM

if you log into the system as user "drunk" via scp than anything uploaded will automatically belong to user "drunk" ;)

DrinkinHomeBrew 10-03-2013 12:27 AM

Quote:

Originally Posted by frieza (Post 5039029)
if you log into the system as user "drunk" via scp than anything uploaded will automatically belong to user "drunk" ;)

Right, and I would understand and expect that the owner will always be the user who uploaded it. I was hoping I could set it so that the group defaults to a specified group (e.g. libvirtd or web-data).

If I'm forced to make the extra step of changing the group & permissions, that's fine. I was just hoping there was a way around having to do that all the time.

frieza 10-03-2013 12:31 AM

Quote:

Originally Posted by DrinkinHomeBrew (Post 5039031)
Right, and I would understand and expect that the owner will always be the user who uploaded it. I was hoping I could set it so that the group defaults to a specified group (e.g. libvirtd or web-data).

If I'm forced to make the extra step of changing the group & permissions, that's fine. I was just hoping there was a way around having to do that all the time.

the one way i can think of is have a cron job do it hourly, not sure if that's quick enough for you though.

chrism01 10-03-2013 02:18 AM

Code:

chmod g+s dirname
??

DrinkinHomeBrew 10-03-2013 04:15 AM

Quote:

Originally Posted by chrism01 (Post 5039076)
Code:

chmod g+s dirname
??

Yup. That's what I was looking for. That solved the first item.

After about 3-4 hours of playing around with umask and acls, I think I finally got default permissions to work as I wanted. It probably took 2 hours longer than it should have because I was copying files from cygwin, and that seemed to be the root cause of why it wasn't setting any of the group/other permissions. On a lark, I tried using scp from linux to copy a file over, and I got the permissions I wanted.

chrism01 10-03-2013 06:19 PM

Thought that would be it :)
I'd stick to using scp or pscp from putty toolset if you've got a win client or even Filezilla; a nice gui using sftp :)
If you use Filezilla, do tell it port 22 or it'll use ftp instead :)


All times are GMT -5. The time now is 02:34 PM.