How to get the correct group id on files created via an SMB/CIFS shared folder ? {SOLVED}

  • OMV 5.5.20-1


    I have created a new user account (picted) via the OMV web app and added the user to the system group 'www-data'. OMV automatically adds the new users to group 'Users' and via SSH the new user appears as:


    root@CMHomeNAS1:~# id picted

    uid=1004(picted) gid=100(users) groups=100(users),33(www-data)


    I have created a shared folder (scans) with Owner as 'www-data' (read, write, execute) and group as 'www-data' (read, write, execute). I then made the shared folder available via NFS and CIFS/SMB


    I have connected my Windows 10 machine to the SMB/CIFS share, logged into the share as user 'picted' and created some new files in this folder via Windows Explorer which get the following settings back on the OMV filesystem:


    root@CMHomeNAS1:/srv/dev-disk-by-label-BigDisk/scans/PHOTO_1#ls -lrt

    -rw-rwxr--+ 1 picted users 372425 Nov 27 11:48 PD_0002.jpg

    -rw-rwxr--+ 1 picted users 299290 Nov 27 11:51 PD_0001.jpg


    The files are created with the correct user ('picted') but with the Group id as 'users' not the 'www-data' group id I need for compatibility with other users/apps which need to access these files via the user 'www-data' (which is also a member of the group 'www-data') and which cannot be changed.


    How can I get the files created via the Windows Explorer SMB/CIFS connection to have the correct group id (ie 'www-data') and not as group 'users' ?


    Many thanks


    Chris

    • Offizieller Beitrag

    If the folder "/srv/dev-disk-by-label-BigDisk/scans/" is created from the GUI of OMV as shared folders, then the SGID permission should be set.

    Try to change the group of that folder recursively to www-data and see if it works.


    Otherwise you might have to add force group www-data to the extra options of the smb share.

  • Thanks. The group of the folder "/srv/dev-disk-by-label-BigDisk/scans/" is already set to 'www-data'. I added the suggested 'force group www-data' to the extra options of the smb share and unfortunately this does not seem to have any effect.


    Any other suggestions


    Chris

  • Could you please post the results of ls -la /srv/dev-disk-by-label-BigDisk/scans so we can see the groups and permissions of the directories underneath.


    To forcefully change goup and set the SGID bit you could use sudo chgrp -R www-data /srv/dev-disk-by-label-BigDisk/scans and sudo chmod -R g+s /srv/dev-disk-by-label-BigDisk/scans


    but do this only if the other options fail.

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • As requested:


    ls -la /srv/dev-disk-by-label-BigDisk/scans

    total 392

    drwxrwxr-x+ 37 www-data www-data 4096 Nov 16 15:19 .

    drwxr-xr-x 15 root root 4096 Jun 24 2020 ..

    drwxrwxr-x+ 4 www-data www-data 4096 May 1 2020 .dtrash

    drwxrwxr-x+ 13 www-data www-data 4096 Apr 10 2021 Family-Albums

    drwxrwxr-x+ 2 www-data www-data 4096 Oct 8 2020 MF_Slides

    drwxrwxr-x+ 2 www-data www-data 12288 Nov 28 09:53 PHOTO_1

    drwxrwxr-x+ 2 www-data www-data 12288 May 7 2018 PHOTO_10

    drwxrwxr-x+ 2 www-data www-data 4096 Jun 2 2017 PHOTO_11

    drwxrwxr-x+ 2 www-data www-data 4096 Dec 26 2018 PHOTO_12

    drwxrwxr-x+ 2 www-data www-data 4096 Dec 26 2018 PHOTO_13

    drwxrwxr-x+ 2 www-data www-data 12288 Dec 26 2018 PHOTO_14

    drwxrwxr-x+ 2 www-data www-data 4096 Dec 26 2018 PHOTO_15

    drwxrwxr-x+ 2 www-data www-data 12288 Dec 26 2018 PHOTO_16

    drwxrwxr-x+ 2 www-data www-data 4096 Jan 21 2018 PHOTO_17

    drwxrwxr-x+ 2 www-data www-data 16384 May 7 2018 PHOTO_18

    drwxrwxr-x+ 2 www-data www-data 4096 Jan 21 2018 PHOTO_19

    drwxrwxr-x+ 2 www-data www-data 4096 Mar 3 2021 PHOTO_2

    drwxrwxr-x+ 2 www-data www-data 12288 Jan 21 2018 PHOTO_20

    drwxrwxr-x+ 2 www-data www-data 12288 Feb 5 2018 PHOTO_21

    drwxrwxr-x+ 2 www-data www-data 4096 Feb 5 2018 PHOTO_22

    drwxrwxr-x+ 2 www-data www-data 12288 Dec 26 2018 PHOTO_23

    drwxrwxr-x+ 2 www-data www-data 4096 Feb 5 2018 PHOTO_24

    drwxrwxr-x+ 2 www-data www-data 4096 May 12 2018 PHOTO_25

    drwxrwxr-x+ 2 www-data www-data 12288 Nov 19 2018 PHOTO_26

    drwxrwxr-x+ 2 www-data www-data 4096 Nov 24 2018 PHOTO_27

    drwxrwxr-x+ 2 www-data www-data 4096 Dec 1 2018 PHOTO_28

    drwxrwxr-x+ 2 www-data www-data 4096 Nov 23 17:08 PHOTO_29

    drwxrwxr-x+ 2 www-data www-data 12288 Mar 4 2021 PHOTO_3

    drwxrwxr-x+ 2 www-data www-data 4096 Jan 20 2019 PHOTO_30

    drwxrwxr-x+ 2 www-data www-data 4096 Nov 21 09:43 PHOTO_31

    drwxrwxr-x+ 2 www-data www-data 4096 Mar 15 2018 PHOTO_4

    drwxrwxr-x+ 2 www-data www-data 4096 Mar 15 2018 PHOTO_5

    drwxrwxr-x+ 2 www-data www-data 12288 Mar 15 2018 PHOTO_6

    drwxrwxr-x+ 2 www-data www-data 4096 Mar 15 2018 PHOTO_7

    drwxrwxr-x+ 2 www-data www-data 4096 Mar 15 2018 PHOTO_8

    drwxrwxr-x+ 2 www-data www-data 12288 May 7 2018 PHOTO_9

    drwxrwxr-x+ 2 www-data www-data 4096 Jul 22 2018 Wedding


    and, yes the folder /srv/dev-disk-by-label-BigDisk/scans/PHOTO_1 has the SGID for all folders is set to www-data but this folder only contains picture files.


    As you might now realise this folder set is used for my photo album application (ZenPhoto)


    I have also noticed that if I login via SSH as root and create a new user as in:


    # useradd -G www-data test1

    # groups test1

    test1 : test1 www-data


    The new user, test1, is added with group as 'www-data'. If I then 'import this user into OMV via the web app and then add the group 'users' (because it seems some things in OVM don't work as expected - set password for example - if the group 'users' is not added) then the 'users' group is promoted to be the primary group, as in:


    # groups test1

    test1 : users www-data test1


    If I were then to modify the user again from the command line as in:


    # usermod -a -G www-data test1


    Would this have the desired effect of promoting 'www-data' to be the primary group for user 'test1' AND more importantly would it upset OMV ?


    Thanks


    Chris

  • OK, let' get things a bit sorted:


    All of the directories above

    • are owned by user www-data and group www-data
    • are readable / writable / executable by the user www-data and all usess in the group www-data
    • are readable and executable by everyone else
    • and have additional ACLs which override these rules

    executable for directories means one can cd into it.


    The SGID bit is not set to any of the folders. SGID bit is the same a executable for group, but additionally every new directory / file inside this directory gets the group of the directory, not the (primary) group of the user creating it.


    Read more about Linux file permissions here


    Users in Linux do have a primary group (can be found in /etc/password) and additional groups (in /etc/group).


    OMV creates all users with the primary group users and adds additional groups.


    When you created the user on the cli, you gave it the primary group www-data, not users. OMV will not work especially well with this combination.


    Go and change the primary group of the ueser to users and add additional groups.


    Btw. user and group www-data are not meant for wht you are doing with it, but for a webserver with limited privileges.

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • Zoki


    Thanks for the link and information about setting up the SGID correctly. The 'scans' folder has existed for quite a long time (possibly from pre-OMV days when votdev was working on FreeNAS). It may also have been created from the CLI hence the missing attributes. I have created a new folder via OMV5 and the SGID attribute is set as expected on the new folder. I have been able to copy over all the scanned photos from the old to the new folder. I am now working my way through my other folders to check and change where necessary. Having the SGID attribute set gives me exactly what I was after from my first post.


    Many thanks


    Chris

  • ceejayemm

    Hat das Label gelöst hinzugefügt.
  • ceejayemm

    Hat den Titel des Themas von „How to get the correct group id on files created via an SMB/CIFS shared folder ?“ zu „How to get the correct group id on files created via an SMB/CIFS shared folder ? {SOLVED}“ geändert.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!