Hello,
I am running successfully FreeBSD jails with full userland-stack and enjail'ed ZFS datasets. The technology works great:
- /etc/rc and /etc/rc.shutdown initialize mutli-user environment
- root user has full control over enjail'ed datasets in the jail: create, mount, destroy, allow, etc.
The problem is to allow non-privileged users in the jail to manage child datasets via ZFS privileges (zfs allow and friends).
I allowed a user/group to create/mount/destroy datasets in a jail, but an attempt to actually create a dataset fails at mounting with Insufficient Privileges.
Workflow
Allow test user ztest:ztest inside the jail to manage child datasets:
Now, create a child-dataset as ztest:ztest user:
Howerver, running the command as root in the jail works:
Host Setup
I am running successfully FreeBSD jails with full userland-stack and enjail'ed ZFS datasets. The technology works great:
- /etc/rc and /etc/rc.shutdown initialize mutli-user environment
- root user has full control over enjail'ed datasets in the jail: create, mount, destroy, allow, etc.
The problem is to allow non-privileged users in the jail to manage child datasets via ZFS privileges (zfs allow and friends).
I allowed a user/group to create/mount/destroy datasets in a jail, but an attempt to actually create a dataset fails at mounting with Insufficient Privileges.
Workflow
Allow test user ztest:ztest inside the jail to manage child datasets:
Code:
jail:mercury # zfs list | tail -1
zroot/net.skhal/dev/mercury/zroot 88K 14.6G 88K /
jail:mercury # zfs allow zroot/net.skhal/dev/mercury/zroot
---- Permissions on zroot/net.skhal/dev/mercury/zroot ----------------
Permission sets:
@zjail canmount,create,destroy,mount,mountpoint
Local+Descendent permissions:
group ztest @zjail
Now, create a child-dataset as ztest:ztest user:
Code:
jail:ztest@mercury % id -Gn
ztest
jail:ztest@mercury % zfs create -o mountpoint=/tmp/ztest zroot/net.skhal/dev/mercury/zroot/ztest
cannot mount 'zroot/net.skhal/dev/mercury/zroot/ztest': Insufficient privileges
filesystem successfully created, but not mounted
Howerver, running the command as root in the jail works:
Code:
jail:mercury # zfs create -o mountpoint=/tmp/rtest zroot/net.skhal/dev/mercury/zroot/rtest
jail:mercury # zfs mount
zroot/net.skhal/dev/mercury/ROOT/default /
zroot/net.skhal/dev/mercury/zroot/rtest /tmp/rtest
Host Setup
Code:
% uname -a
FreeBSD freebsd.skhal.net 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
% grep '\(allow\|enforce\)' /etc/jail.conf
allow.mount;
allow.mount.zfs;
allow.noset_hostname;
allow.raw_sockets;
enforce_statfs = 1;
% { grep -m 1 '^[[:alnum:]]'; cat; } < /etc/sysctl.conf
vfs.usermount=1
security.jail.allow_raw_sockets=1
security.jail.mount_allowed=1
security.jail.enforce_statfs=1