From e16e51702b9df803d172e7bdb4cbb4976778eee2 Mon Sep 17 00:00:00 2001 From: jnetod <49963580+jnetod@users.noreply.github.com> Date: Sun, 5 Jul 2020 18:09:46 -0300 Subject: [PATCH 1/3] zfs: patch client path used in smb share fix zfs smb share integration before: # zfs share tank/smb_share cannot share tank/smb_share: smb add share failed now works as intended. --- pkgs/os-specific/linux/zfs/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index e41ae3bece24..75f5dcd0e312 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -6,7 +6,7 @@ # Userspace dependencies , zlib, libuuid, python3, attr, openssl , libtirpc -, nfs-utils +, nfs-utils, samba , gawk, gnugrep, gnused, systemd , smartmontools, enableMail ? false , sysstat, pkg-config @@ -55,6 +55,7 @@ let # And if it's enabled by default, only change that if we explicitly disable python to remove python from the closure nfs-utils.override (old: { enablePython = old.enablePython or true && enablePython; }) }/bin/exportfs" + substituteInPlace ./lib/libshare/smb.h --replace "/usr/bin/net" "${samba}/bin/net" substituteInPlace ./config/user-systemd.m4 --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d" substituteInPlace ./config/zfs-build.m4 --replace "\$sysconfdir/init.d" "$out/etc/init.d" \ --replace "/etc/default" "$out/etc/default" From 86b1feefbdd51d57b5ca5be0050d992126dee411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 11 Jun 2021 08:24:56 +0200 Subject: [PATCH 2/3] nixos/zfs: add tests for samba --- nixos/tests/zfs.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nixos/tests/zfs.nix b/nixos/tests/zfs.nix index ba5eb7cd528e..5a6138c68d47 100644 --- a/nixos/tests/zfs.nix +++ b/nixos/tests/zfs.nix @@ -18,13 +18,29 @@ let maintainers = [ adisbladis ]; }; - machine = { pkgs, lib, ... }: { + machine = { pkgs, lib, ... }: + let + usersharePath = "/var/lib/samba/usershares"; + in { virtualisation.emptyDiskImages = [ 4096 ]; networking.hostId = "deadbeef"; boot.kernelPackages = kernelPackage; boot.supportedFilesystems = [ "zfs" ]; boot.zfs.enableUnstable = enableUnstable; + services.samba = { + enable = true; + extraConfig = '' + registry shares = yes + usershare path = ${usersharePath} + usershare allow guests = yes + usershare max shares = 100 + usershare owner only = no + ''; + }; + systemd.services.samba-smbd.serviceConfig.ExecStartPre = + "${pkgs.coreutils}/bin/mkdir -m +t -p ${usersharePath}"; + environment.systemPackages = [ pkgs.parted ]; # Setup regular fileSystems machinery to ensure forceImportAll can be @@ -60,6 +76,8 @@ let "zfs create -o mountpoint=legacy rpool/root", "mount -t zfs rpool/root /tmp/mnt", "udevadm settle", + "zfs set sharesmb=on rpool/root", + "smbclient -NL localhost", "umount /tmp/mnt", "zpool destroy rpool", "udevadm settle", From a4cb90bdbd57eabb7ff93d179e687873ac3fafcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 18 Jun 2021 22:19:16 +0200 Subject: [PATCH 3/3] Update nixos/tests/zfs.nix Co-authored-by: jnetod <49963580+jnetod@users.noreply.github.com> --- nixos/tests/zfs.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/tests/zfs.nix b/nixos/tests/zfs.nix index 5a6138c68d47..d25090403e5f 100644 --- a/nixos/tests/zfs.nix +++ b/nixos/tests/zfs.nix @@ -74,10 +74,15 @@ let "udevadm settle", "zpool create rpool /dev/vdb1", "zfs create -o mountpoint=legacy rpool/root", + # shared datasets cannot have legacy mountpoint + "zfs create rpool/shared_smb", "mount -t zfs rpool/root /tmp/mnt", "udevadm settle", - "zfs set sharesmb=on rpool/root", - "smbclient -NL localhost", + # wait for samba services + "systemctl is-system-running --wait", + "zfs set sharesmb=on rpool/shared_smb", + "zfs share rpool/shared_smb", + "smbclient -gNL localhost | grep rpool_shared_smb", "umount /tmp/mnt", "zpool destroy rpool", "udevadm settle",