You are not logged in.

#1 2022-03-02 00:55:21

markov
Member
Registered: 2020-04-04
Posts: 3

How to allow users to mount ZFS datasets?

I have separate ZFS dataset for each user home dir, I would like to allow users to use zfs create snapshot etc, on their home directories. There is zfs allow command for this, but each user must have ability to mount. Right now when user run zfs create
command this message is printed

filesystem successfully created, but it may only be mounted by root

I could allow users to mount through sudo but this is to much privileges, It would be perfect to somehow limit ability to mount only to zfs datasets and only within home directory.

Offline

#2 2022-03-03 10:11:44

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: How to allow users to mount ZFS datasets?

You can limit sudo to only running specific commands... Perhaps something like:

myuser ALL=(root) /usr/bin/zfs mount *

Of course, this doesn't restrict mounting only to /home since the mountpoint is a property of the dataset. I don't see a way to limit that.

Offline

#3 2022-03-03 14:14:44

markov
Member
Registered: 2020-04-04
Posts: 3

Re: How to allow users to mount ZFS datasets?

Thanks @fukawi2

I can limit mount command to users home dir by:

myuser ALL=(root) /usr/bin/zfs mount path/to/user_dataset/*

It solves problem partially, although user now can mount own datasets. Any other programs still can't utilize this feature of ZFS on user level privileges, Eg. I was preparing to use podman to create and run containers without root. But command

zfs create some_ds

still returns error because user can't mount (zfs does not try to use sudo for mount)

Offline

#4 2022-03-04 00:43:27

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: How to allow users to mount ZFS datasets?

Your other option would be to setuid on the zfs binary, but that would allow any user to do anything with ZFS. I guess you could change the permissions to remove o= perms, and only allow user/group to execute (with setuid) for a specific group.... But that's getting pretty messy.

Offline

Board footer

Powered by FluxBB