Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rclone mount with UUID and GUID #25

Open
jeroenvdheuvel opened this issue Nov 29, 2018 · 1 comment
Open

Rclone mount with UUID and GUID #25

jeroenvdheuvel opened this issue Nov 29, 2018 · 1 comment

Comments

@jeroenvdheuvel
Copy link

jeroenvdheuvel commented Nov 29, 2018

This is actually not an issue but a finding that might be nice to write in the documentation.

I managed to use rclone-mount with a specific user id and group id via docker. It's a bit of a hack but it works.

docker run \
    ... default options like environment variables and volume mounts
    -e MountCommands="--cache-dir /rclone-cache ... a lot more mount commands" \
    -v /etc/passwd:/etc/passwd:ro \
    -v /home/somebody/rclone-cache:/rclone-cache \
    -u $(id -u):$(id -g) \
     mumiehub/rclone-mount

The user id and group id are set via the Docker --user/-u argument. I used $(id -u) and $(id -g) in order to get the user id and group id of the logged in user. Any other id can also be provided. This user most likely doesn't exist inside the container. That means that this user only has an id and not a name. Rclone/fuse need a username in order to function properly:

static const char *get_user_name(void)
{
	struct passwd *pw = getpwuid(getuid());
	if (pw != NULL && pw->pw_name != NULL)
		return pw->pw_name;
	else {
		fprintf(stderr, "%s: could not determine username\n", progname);
		return NULL;
	}
}

By mounting the local /etc/passwd file into the container (as read only) the user name becomes available.

The second problem is that Rclone is no longer able to write cache to the default cache directory. Because it has insufficient permissions. By explicitly setting the --cache-dir /rclone-cache via the environment variable MountCommands the directory can be changed. Now it's possible to create a mount for the cache directory to make it possible to write here as the specified user.

This covers the TODO: launch with specific USER_ID.

@Rodeoclash
Copy link

This is great, I would add that you need to update /etc/fuse.conf with user_allow_other in the container (I mounted my host fuse.conf read only) to enable running as another user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants