Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Local network sharing config issue

  1. #1
    Join Date
    Sep 2013
    Beans
    29

    Local network sharing config issue

    Hi All,

    I have a few directories on a Ubuntu machine that I would like to share with both Windows and Ubuntu PCs. I am building this for a friend and adding new shares needs to be simple. I have managed to share the directories by using the "Local network share" option in "files" with both "allow others to create and delete files" and "guest access" enabled. I am able to see it in Windows and create files but it seems that files created from my test windows machine defaults to a file permissions of 744 and owned by nobody:nobody.

    Anyone know how to configure this to default to r/w everyone instead? If it is from a Windows machine then I guess x is not particularly relevant but for the Ubuntu machines then the file permissions would need to be determined by the client end user.

    I thought this would be in /etc/samba/smb.conf but everything I found only suggests I have to do this individually for each shared directory. This gives me 2 issues
    1. The shared folders are not in the smb.conf file so couldn't do it there
    2. Editing smb.conf isn't user friendly for the person I am building this for so was hoping there is a global config for setting the file permissions for new files?

    If these shares are samba shares, how come they don't appear in smb.conf? Where is the config stored?

    Thanks in advance for your help

    Lee.

  2. #2
    Join Date
    Dec 2009
    Beans
    6,539

    Re: Local network sharing config issue

    Local Network Share creates Samba Usershares. They are not defined in smb.conf. They are defined in /var/lib/samba/usershares. You can see how all of these shares are defined with this command:
    Code:
    net usershare info --long
    They are generally not edited like you would in Samba Classic Shares - the ones in smb.conf.

    One way around the nobody:nobody issue is to edit /etc/samba/smb.conf ( Usershares are still controlled on a macro level in smb.conf ) and right below the workgroup = WORKGROUP line add this one:
    Code:
    force user = XXXXX
    Then restart smbd.

    Where XXXXX is the Linux user name on the server. When the guest user accesses the share his identity - at least for the samba shares - will be converted from nobody to XXXXX.

  3. #3
    Join Date
    Sep 2013
    Beans
    29

    Re: Local network sharing config issue

    Thanks very much @Morbius1. Is that the only way around the file permission aspect of my issue i.e. force all to come in as a certain user so that all files are owned by that user (say sambauser) and therefore 744 is makes them r/w for all samba users? I think this would work for my situation except that the user logged on to the server would not be able to edit the files?

  4. #4
    Join Date
    Dec 2009
    Beans
    6,539

    Re: Local network sharing config issue

    I think this would work for my situation except that the user logged on to the server would not be able to edit the files?
    Let's say I log into my Ubuntu server - locally - as user = morbius. I create a usershare of my Public folder. I edit smb.conf and set the following directive:
    Code:
     force user = morbius
    When the Windows, Mac, other Linux guest users connects to my share they will become morbius. Any new file he adds will save with owner = morbius. The local logged in user and all of the networked users will be as morbius.

    They are not connecting as mobius. They are connecting as a guest. They are being converted internally to morbius. Even if you set up a share that requires credentials to access and say ... user=agnes connects to the share. Agness will become morbius internally to samba.

    There are far more complex ways to achieve the same relative result but it violates your original use case:
    I am building this for a friend and adding new shares needs to be simple.
    With the force user in place in the [global] section of smb,conf all new samba shared created from the file manager will operate in the same way without adjusting smb.conf or adjusting Linux permissions on the folder being shared.

  5. #5
    Join Date
    Sep 2013
    Beans
    29

    Re: Local network sharing config issue

    Thanks very much for your reply. Sorry I should have said, I have multiple users on the server so was hoping to get the files r/w for all of them.

  6. #6
    Join Date
    Dec 2009
    Beans
    6,539

    Re: Local network sharing config issue

    Okey Doke,

    Let's say I have a folder at /mnt/Shared

    [1] Change the group of the folder to say ... plugdev ( group already exists ):
    Code:
    sudo chown :plugdev /mnt/Shared
    [2] Set the group inheritance for all files and folders:
    Code:
    sudo chmod 2775 /mnt/Shared
    [3] Create a Classic samba share definition in smb.conf for that folder - not a usershare:
    Code:
    [Shared]
    path = /mnt/Shared
    browseable = yes
    guest ok = yes
    force group = plugdev
    writeable = yes
    create mask = 0664
    force directory mode = 2775
    [4] Restart smbd

    [5] All local users will need to be members of the plugdev group

    EDIT: I should have stated that the default umask for your system needs to be 0002 for this to work.

    Your only alternative to this is to place all shared folders on an NTFS partition so that the permissions can be predefined and immutable or use something like bindfs to make a Linux filesystem act like an NTFS partition in that regard.
    Last edited by Morbius1; February 10th, 2021 at 02:31 PM.

  7. #7
    Join Date
    Sep 2013
    Beans
    29

    Re: Local network sharing config issue

    Ah... I don't suppose "create mask" and "force directory mode" can be used as global for all shares - e.g. if I put them immediately under the workgroup=WORKGROUP line? If so, what would they need to be to make them r/w for all users? The trouble with the above is that they would need to add a section like your "Shared" example themselves if they want to share a different directory?

    thanks

    Lee.

  8. #8
    Join Date
    Dec 2009
    Beans
    6,539

    Re: Local network sharing config issue

    That depends entirely on the full extent of your use case.

    The process described in panel #6 will make it so every user on the network and every local user on the server has write and edit access on every new file added to the shared folder.

    You can set create mask / force directory mode to 0666 / 0777 globally I suppose and every file added to the share across the network will be able to be edited by all users everywhere. However if userA adds a file locally to the shared folder it will save with owner = userA:userA and permissions of 664. UserB on the server itself will have read access to the file but cannot edit that file.

  9. #9
    Join Date
    Sep 2013
    Beans
    29

    Re: Local network sharing config issue

    Thanks Morbius1. I have now implemented your suggestion in box #6 but put the group and perm/ mask in the global section instead hoping that then if they add another share in files it will work ok. You mentioned that the default umask needs to be 0002. Where do I set this? The only issue I have now is if someone locally on the server creates a file it defaults to the users group rather than my new samba group (perms 664). Is this because I haven't set the default umask?

    Thanks again you have been really helpful

  10. #10
    Join Date
    Dec 2009
    Beans
    6,539

    Re: Local network sharing config issue

    I have now implemented your suggestion in box #6 but put the group and perm/ mask in the global section instead hoping that then if they add another share in files it will work ok
    Nope. For every usershare you create in Files you will also need to do this:
    Code:
    sudo chown :plugdev /folder-being-shared
    sudo chmod 2775 /folder-being-shared
    The only issue I have now is if someone locally on the server creates a file it defaults to the users group rather than my new samba group (perms 664). Is this because I haven't set the default umask?
    Nope. It's what I said:
    However if userA adds a file locally to the shared folder it will save with owner = userA:userA and permissions of 664. UserB on the server itself will have read access to the file but cannot edit that file.
    Your umask is already set correctly or else the saved file would not be 664. That is why you need to do the chown / chmod on every folder shared. Then the saved file will still save as 664 but the group would be - in my example - plugdev. Just remember that all users will have to be added to that group.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •