Hi all, I’ll cut to the point: is anyone out there running a NAS with multiple users, and each user has their own media folders and files that belong to them, with share access to those files (samba), and separately is also running an instance of Immich (as its own user) that in some way has access to these files and folders, AND is able to upload new files, while maintaining the NAS user ownership/permissions on those files?

In my current setup, each user’s media files have permissions user:media 740 (so the “media” group has read access). The Immich user is in the media group. I then have the NAS files mapped as read-only, and added in Immich as external storage per user. This means I’m currently not uploading anything. (If I do, they get stored separately in Immich, not merged with the rest of the media files).

I could instead make the dir writable by the media group, map each NAS user’s media directories directly as their Immich upload location (and fix up the Immich file naming/organization so that it matches), but I would still have the problem that it would create new files as the Immich user on the NAS, not the specific user.

Is there a clever permissions solution here I’m missing, or is it a lost cause to try and have both coherent per-user permissions on the NAS/samba share, AND use Immich? I don’t really want a script that runs and chmods everything to user:media periodically. Feels hacky, and then Immich isn’t able to change/delete any files, but that might be the only solution…

  • pairwise@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    8 hours ago

    You can configure samba to handle the permissions, but immich will need to connect to the user’s share using their password (no ideal)

    In smb.conf for each user’s share

    [user_media]
       path = /path/to/user/media
       valid users = username, immich
       force user = username  # This makes all files.  appear as owned by the user
       force group = media
       create mask = 0660
       directory mask = 0770
    

    Alternatively you can use setguid with your media group:

    chmod g+s /path/to/media/dirs
    chown -R :media /path/to/media/dirs
    chmod 2770 /path/to/media/dirs. (2 = SetGID, 770 = rwx for user and group)
    
    • Any new file created by Immich will automatically belong to the media group
    • The SetGID bit ensures files inherit the parent directory’s group
    • All users (including Immich) can read/write files as long as they’re in the media group
    • Individual users still “own” their files (UID stays as the original user when they upload via Samba)