DumbDrop icon indicating copy to clipboard operation
DumbDrop copied to clipboard

Feature Request: Allow Setting PUID/GUID for File Ownership

Open vin-im opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe. Files saved by DumbDrop have root ownership, which can cause permission issues for users trying to access the files.

Describe the solution you'd like Users would like the ability to set PUID/GUID in the Docker configuration to control the file ownership. The Docker configuration should include environment variables for setting user and group IDs. Additionally, an entry point script should ensure the ownership of the files is set correctly I think?

Additional context This feature will enhance the usability of DumbDrop, especially for users running the application in a Docker environment. It will help prevent permission issues and make file management more straightforward.

References

vin-im avatar Mar 14 '25 01:03 vin-im

This feature will be great. I encountered issues with puid/pgid as well.

explicitworkload avatar Jun 30 '25 17:06 explicitworkload

This and umask

shinji257 avatar Mar 23 '26 16:03 shinji257

Please, no.

The PUID/PGID convention and chowning bind mounts is a hack that came about before Docker could be run rootless and before the prevalence/adoption of other container engines that could. Consequently, container images that opt for this and similar strategies actually end up making it a headache to run rootless containers, since now it's trying to chown things that it may not even be able to, among other fun things that vary from image to image.

This approach is an anti-pattern these days and makes things convenient for those running rootful containers at the detriment of those running rootless. Many projects' containers carry this baggage out of habit, inertia, or backwards compatibility reasons; newer projects like this one don't need to start. Instead, more people should use rootless containers and learn about user namespacing.

With the exception of some LXCs, every service in my home lab is running via rootless Podman, and I've had to work around shenanigans like this (PUID/PGID, hard-coded unprivileged user, etc.) for nearly every one of them.

Alternative: Rootless

Rootless containers by default map your (or whatever user is running Docker/Podman/etc) UID to root in the container namespace, but the effective access to files bind-mounted from the host is still your UID. The Docker documentation linked in the issue description actually talks about UID/GID namespacing, which is the more modern approach. In fact, PUID and PGID are not mentioned there at all.

Run the container rootless as the user you wish to own the files and let the container engine handle mapping that user to be "root" inside the container (to reiterate, it's not actually root from the host's perspective) and you get the best of both worlds:

  • No permission issues in-container since it's running as "root" (uid-mapped)
  • Files written to bind mounts are owned by the user running the container
  • No clusterfuck of environment variables and chown that will never cover everyone's use cases

It should be the responsibility of the user running the container (and thus the one bind-mounting) to make sure that they have access to the directory that they're mounting; this problem solves itself, as it turns out. The README alludes to this as well.


If you absolutely must run your container as (actual) root, then just make your own entrypoint.sh:

  • Set up your unprivileged user (chown/chmod/etc.) and anything else you need/want
  • Bind mount it into the container as well
  • Tell the container to use it via --entrypoint (cmdline) or entrypoint: (compose)

ZeroKnight avatar Apr 05 '26 21:04 ZeroKnight

While I agree with you I need it for running this container on unraid. Docker there runs as root but unless the containers are using PUID and GUID the files get owned as root and can't be deleted via smb when a samba user logs in.

Alternatively can we maybe just support UMASK instead?

shinji257 avatar Apr 05 '26 22:04 shinji257

While I agree with you I need it for running this container on unraid. Docker there runs as root but unless the containers are using PUID and GUID the files get owned as root and can't be deleted via smb when a samba user logs in.

Alternatively can we maybe just support UMASK instead?

I don't use unraid personally, but couldn't you just add a --user=xxx:yyy argument in the extra options for the container? This image is well-built and shouldn't need root at runtime, so that should work.

Just make sure the directory that you're mounting has the correct permissions for the user you use with the --user option. You shouldn't need to set a umask in that case (I'm assuming you're using it to set group/other permissions as a workaround).

ZeroKnight avatar Apr 05 '26 22:04 ZeroKnight

That sort of works. It does change users but I think something inside the container needs to be read as root and can't be anymore because of the user change. Here is a log for reference. (repost because I forgot to remove my site url from the log)

Node.js v22.21.1
npm notice
npm notice New major version of npm available! 10.9.4 -> 11.12.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.12.1
npm notice To update run: npm install -g [email protected]
npm notice

> [email protected] start
> node src/server.js

Loaded ENV: {
  PORT: 3000,
  UPLOAD_DIR: '/app/uploads',
  LOCAL_UPLOAD_DIR: undefined,
  NODE_ENV: 'production',
  BASE_URL: '[removed]',
  ALLOWED_ORIGINS: '*'
}
ℹ INFO: CONFIGURATION: Upload directory set from UPLOAD_DIR: /app/uploads
ℹ INFO: CONFIGURATION: Final upload directory path: /app/uploads
ℹ INFO: CONFIGURATION: CLIENT_MAX_RETRIES: 5 (default)
ℹ INFO: CONFIGURATION: UPLOAD_PIN: null
Upload directory configured as: /app/uploads
[INFO] 2026-04-12T05:25:07.393Z - Proxy trust disabled (secure default mode)
ALLOWED ORIGINS: *
[WARN] 2026-04-12T05:25:07.403Z - BASE_URL did not end with a trailing slash. Automatically appending "/".
[INFO] 2026-04-12T05:25:07.403Z - Notifications disabled - No Configuration
[SUCCESS] 2026-04-12T05:25:07.405Z - Directory is writable: /app/uploads
[INFO] 2026-04-12T05:25:07.407Z - Metadata directory exists: /app/uploads/.metadata
[SUCCESS] 2026-04-12T05:25:07.409Z - Metadata directory is writable: /app/uploads/.metadata
[INFO] 2026-04-12T05:25:07.409Z - Maximum file size set to: 1048576MB
[INFO] 2026-04-12T05:25:07.409Z - Auto upload is disabled
[ERROR] 2026-04-12T05:25:07.412Z - Failed to start server:
[ERROR] 2026-04-12T05:25:07.412Z - Server failed to start:
[INFO] 2026-04-12T05:25:07.418Z - Server running at [removed]
[INFO] 2026-04-12T05:25:07.418Z - Server listening on 0.0.0.0:3000
[INFO] 2026-04-12T05:25:07.418Z - Upload directory: /app/uploads
node:fs:2425
    return binding.writeFileUtf8(
                   ^

Error: EACCES: permission denied, open '/usr/src/app/public/asset-manifest.json'
    at Object.writeFileSync (node:fs:2425:20)
    at generateAssetManifest (/usr/src/app/src/scripts/pwa-manifest-generator.js:25:6)
    at generatePWAManifest (/usr/src/app/src/scripts/pwa-manifest-generator.js:30:3)
    at startServer (/usr/src/app/src/server.js:46:5) {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/src/app/public/asset-manifest.json'
}```

shinji257 avatar Apr 12 '26 05:04 shinji257

So I thought I'd use setfacl instead to set folder perms but I guess docker doesn't really respect that at all or something. (running setfacl -Rdm m::rwx uploads) Folder extended perms:

root@Pithos:/mnt/user/dumbdrop# getfacl uploads
# file: uploads
# owner: root
# group: root
user::rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:group::r-x
default:mask::rwx
default:other::r-x

This ends up being effecting 775 on the folder and makes it so that all users can read, write, and execute in the uploads folder. I can tighten it up later but this is a test. This is the result when I upload a file though.

root@Pithos:/mnt/user/dumbdrop/uploads# ls -l
total 1291
-rw-r--r--+ 1 root root 1192853 Apr 12 01:46 eXo.Collection.2026_04_11_RomVault.zip
root@Pithos:/mnt/user/dumbdrop/uploads# getfacl eXo.Collection.2026_04_11_RomVault.zip 
# file: eXo.Collection.2026_04_11_RomVault.zip
# owner: root
# group: root
user::rw-
group::r-x                      #effective:r--
mask::r--
other::r--

Somehow my extended mask didn't make it through and group wise it is effective read only.

shinji257 avatar Apr 12 '26 05:04 shinji257