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

wsdd: init at 0.6.2 #104520

Merged
merged 3 commits into from Nov 23, 2020
Merged

wsdd: init at 0.6.2 #104520

merged 3 commits into from Nov 23, 2020

Conversation

Izorkin
Copy link
Contributor

@Izorkin Izorkin commented Nov 21, 2020

Motivation for this change

Add wsdd package. This package implements a Web Service Discovery host daemon. This enables (Samba) hosts, like your local NAS device, to be found by Web Service Discovery Clients like Windows.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

pkgs/servers/wsdd/default.nix Outdated Show resolved Hide resolved
pkgs/servers/wsdd/default.nix Outdated Show resolved Hide resolved
@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

cc @flokli @aanderse @Mic92

@flokli
Copy link
Contributor

flokli commented Nov 22, 2020 via email

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

With DynamicUser = true; worked, updated.

@flokli
Copy link
Contributor

flokli commented Nov 22, 2020

How does this relate so samba's wins?

Can this trivially be included in nixos/tests/samba.nix, and is there a client implementation, so this can be tested?

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

Used this information - https://linux-blog.anracom.com/2020/05/24/samba-4-shares-wsdd-and-windows-10-how-to-list-linux-samba-servers-in-the-win-10-explorer/
I running wsl on my home server - samba server is displayed in in the Explorer. With runnig wins server - in the Explorer not displayed.

@flokli
Copy link
Contributor

flokli commented Nov 22, 2020

Look at https://www.mankier.com/1/wsdd#Options-Client/Discovery_Mode_Options - we should enable wssd server on the samba server, and check with wssd's discovery mode on the client VM that the server can be seen.

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

Example configuration:

  services.samba-wsdd = {
    enable = true;
    interface = "eno1";
    workgroup = "WORKGROUP";
    hostname = "FILESERVER";
    extraOptions = [ "--verbose" "--ipv4only" ];
  };

  services.samba = {
    enable = true;
    enableNmbd = true;
    enableWinbindd = false;
    nsswins = false;
    package = pkgs.samba4Minimal;
    securityType = "user";
    extraConfig = ''
      workgroup = WORKGROUP
      netbios name = FILESERVER
...

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 22, 2020

@flokli
Copy link
Contributor

flokli commented Nov 22, 2020

Sorry, not sure I understand.

Please extend nixos/tests/samba.nix with a wssd configuration, so there's a working example in nixpkgs, that can be tested in an automated fashion.

Above example does not work, and pkgs.samba4Minimal doesn't even exist in nixpkgs, nor is there any described way on how to verify this, without booting a Windows machine and checking there.

I tried extending the test, by adding a second server with wsdd running, and using wsdd --discovery on the client, hoping I could see the server, but it didn't work, even when disabling the firewall.

Maybe you can pick up from here, here's my diff:

diff --git a/nixos/tests/samba.nix b/nixos/tests/samba.nix
index 142269752b3..6aa43bc7a3f 100644
--- a/nixos/tests/samba.nix
+++ b/nixos/tests/samba.nix
@@ -5,34 +5,52 @@ import ./make-test-python.nix ({ pkgs, ... }:
 
   meta.maintainers = [ pkgs.lib.maintainers.eelco ];
 
-  nodes =
-    { client =
-        { pkgs, ... }:
-        { fileSystems = pkgs.lib.mkVMOverride
-            { "/public" = {
-                fsType = "cifs";
-                device = "//server/public";
-                options = [ "guest" ];
-              };
-            };
+  nodes = {
+    client = { pkgs, ... }: {
+      fileSystems = pkgs.lib.mkVMOverride {
+        "/public" = {
+          fsType = "cifs";
+          device = "//server/public";
+          options = [ "guest" ];
         };
+      };
+      networking.firewall.allowedTCPPorts = [ 5357 ];
+      networking.firewall.allowedUDPPorts = [ 3702 ];
+      networking.firewall.enable = false;
+    };
 
-      server =
-        { ... }:
-        { services.samba.enable = true;
-          services.samba.shares.public =
-            { path = "/public";
-              "read only" = true;
-              browseable = "yes";
-              "guest ok" = "yes";
-              comment = "Public samba share.";
-            };
-          networking.firewall.allowedTCPPorts = [ 139 445 ];
-          networking.firewall.allowedUDPPorts = [ 137 138 ];
-        };
+    server = { ... }: {
+      services.samba.enable = true;
+      services.samba.shares.public = {
+        path = "/public";
+        "read only" = true;
+        browseable = "yes";
+        "guest ok" = "yes";
+        comment = "Public samba share.";
+      };
+      networking.firewall.allowedTCPPorts = [ 139 445 ];
+      networking.firewall.allowedUDPPorts = [ 137 138 ];
     };
 
-  # client# [    4.542997] mount[777]: sh: systemd-ask-password: command not found
+    server_wsdd = { ... }: {
+      services.samba = {
+        enable = true;
+        enableNmbd = true;
+        enableWinbindd = false;
+        nsswins = false;
+      };
+      services.samba-wsdd = {
+        enable = true;
+        interface = "eth0";
+        workgroup = "WORKGROUP";
+        hostname = "SERVER-WSDD";
+        extraOptions = [ "--verbose" ];
+      };
+      networking.firewall.allowedTCPPorts = [ 139 445 5357 ];
+      networking.firewall.allowedUDPPorts = [ 137 138 3702 ];
+      networking.firewall.enable = false;
+    };
+  };
 
   testScript =
     ''
@@ -43,5 +61,16 @@ import ./make-test-python.nix ({ pkgs, ... }:
       client.start()
       client.wait_for_unit("remote-fs.target")
       client.succeed("[[ $(cat /public/foo) = bar ]]")
+
+      server_wsdd.start()
+      server_wsdd.wait_for_unit("samba-wsdd")
+
+      client.succeed(
+          "systemd-run -u wsdd-discovery -- ${pkgs.wsdd}/bin/wsdd --verbose --discovery --preserve-case -l /run/wsdd.sock >&2"
+      )
+
+      client.wait_until_succeeds(
+          "echo list | ${pkgs.libressl.nc}/bin/nc -U /run/wsdd.sock | grep -i SERVER-WSDD"
+      )
     '';
 })

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 23, 2020

Working if runnig in test VM
wsdd --interface eth0 --verbose --discovery

2020-11-23 10:12:38,157:wsdd INFO(pid 2046): using pre-defined UUID fd3a88ed-...-...
2020-11-23 10:12:38,157:wsdd WARNING(pid 2046): Discovery enabled but no listen option provided. Falling back to port 5359
2020-11-23 10:12:38,159:wsdd INFO(pid 2046): joined multicast group ('239.255.255.250', 3702) on 192. ... .221%eth0
2020-11-23 10:12:40,248:wsdd INFO(pid 2046): joined multicast group ('ff02::c', 3702, 22364, 2) on fe80::...:d2d5%eth0
2020-11-23 10:12:43,254:wsdd INFO(pid 2046): 192. ... .221:44651(eth0) - - "ProbeMatches urn:uuid:45e06928-...-... UDP" - -
2020-11-23 10:12:43,255:wsdd INFO(pid 2046): 192. ... .221:44651(eth0) - - "ResolveMatches urn:uuid:47aae12f-...-... UDP" - -
2020-11-23 10:12:43,261:wsdd INFO(pid 2046): discovered TECH in Workgroup:WORKGROUP on 192. ... .221%eth0

With nixos/tests i can't do the test.

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 23, 2020

Updatet PR and added test WSD Discovery.

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 23, 2020

@GrahamcOfBorg test samba

nixos/tests/samba.nix Outdated Show resolved Hide resolved
nixos/tests/samba.nix Outdated Show resolved Hide resolved
nixos/tests/samba.nix Outdated Show resolved Hide resolved
nixos/tests/samba.nix Outdated Show resolved Hide resolved
pkgs/servers/wsdd/default.nix Outdated Show resolved Hide resolved
@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 23, 2020

@flokli updated PR.

@Izorkin
Copy link
Contributor Author

Izorkin commented Nov 23, 2020

@GrahamcOfBorg test samba-wsdd

Copy link
Member

@Mic92 Mic92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested, but LGTM.

@flokli flokli merged commit bbf3c94 into NixOS:master Nov 23, 2020
@Izorkin Izorkin deleted the wsdd branch November 24, 2020 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants