[Nix-dev] NetBIOS/WINS name lookup in NixOS
Bjørn Forsman
bjorn.forsman at gmail.com
Mon Sep 2 20:30:25 CEST 2013
Hi everyone,
In Ubuntu I can install libnss-winbind + winbind and append "wins" to
the "hosts:" section in /etc/nsswitch.conf to have NetBIOS/WINS name
lookup (Windows machine names). But when I try to do "the same" for
NixOS, it doesn't work:
$ ping windows-pc
ping: unknown host windows-pc
I've already made the samba package install libnss_winbind.so and
libnss_wins.so (in git master), but I don't think they are picked up.
nscd seems to load several libnss*.so libraries, but not
libnss_{winbind,wins}.so:
$ sudo pmap $(pidof nscd) | grep libnss
00007fb5859c7000 12K r-x--
/nix/store/n9yvgrp6i1fh3jzpbw1cyfvdil0n9j1r-systemd-203/lib/libnss_myhostname.so.2
00007fb5859ca000 2044K -----
/nix/store/n9yvgrp6i1fh3jzpbw1cyfvdil0n9j1r-systemd-203/lib/libnss_myhostname.so.2
00007fb585bc9000 4K r----
/nix/store/n9yvgrp6i1fh3jzpbw1cyfvdil0n9j1r-systemd-203/lib/libnss_myhostname.so.2
00007fb585bca000 4K rw---
/nix/store/n9yvgrp6i1fh3jzpbw1cyfvdil0n9j1r-systemd-203/lib/libnss_myhostname.so.2
00007fb585bcb000 8K r-x--
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns.so.2
00007fb585bcd000 2048K -----
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns.so.2
00007fb585dcd000 4K rw---
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns.so.2
00007fb585fe5000 20K r-x--
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_dns-2.17.so
00007fb585fea000 2044K -----
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_dns-2.17.so
00007fb5861e9000 4K r----
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_dns-2.17.so
00007fb5861ea000 4K rw---
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_dns-2.17.so
00007fb5861eb000 8K r-x--
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns_minimal.so.2
00007fb5861ed000 2048K -----
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns_minimal.so.2
00007fb5863ed000 4K rw---
/nix/store/67dm2724h0cl8gj2pklf009nir0p28l4-nss-mdns-0.10/lib/libnss_mdns_minimal.so.2
00007fb5863ee000 48K r-x--
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_files-2.17.so
00007fb5863fa000 2044K -----
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_files-2.17.so
00007fb5865f9000 4K r----
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_files-2.17.so
00007fb5865fa000 4K rw---
/nix/store/zm4bhsm8lprkzvrjgqr0klfkvr21als4-glibc-2.17/lib/libnss_files-2.17.so
I tried increasing the loglevel of nscd but it didn't give me anything
more to work with.
Below is the patch I'm using. You can also see it online:
https://github.com/bjornfor/nixos/commit/6922607a8022432b054bc6e765f9d84ffc31fb19
Is "system.nssModules = optional cfg.nsswins samba;" not being picked up?
diff --git a/modules/config/nsswitch.nix b/modules/config/nsswitch.nix
index 7e989c1..7e29e42 100644
--- a/modules/config/nsswitch.nix
+++ b/modules/config/nsswitch.nix
@@ -28,6 +28,7 @@ let
};
inherit (config.services.avahi) nssmdns;
+ inherit (config.services.samba) nsswins;
in
@@ -43,7 +44,7 @@ in
passwd: files ldap
group: files ldap
shadow: files ldap
- hosts: files ${optionalString nssmdns "mdns_minimal
[NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} myhostname
+ hosts: files ${optionalString nssmdns "mdns_minimal
[NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"}
${optionalString nsswins "wins"} myhostname
networks: files dns
ethers: files
services: files
diff --git a/modules/services/network-filesystems/samba.nix
b/modules/services/network-filesystems/samba.nix
index 518142b..779f919 100644
--- a/modules/services/network-filesystems/samba.nix
+++ b/modules/services/network-filesystems/samba.nix
@@ -170,6 +170,15 @@ in
example = "share";
};
+ nsswins = mkOption {
+ default = true; # FIXME: just for debug
+ description = ''
+ Whether to enable the WINS NSS (Name Service Switch)
plug-in.
+ Enabling it allows applications to resolve NetBIOS names
(a.k.a.
+ Windows machine names) by transparently querying the
winbindd daemon.
+ '';
+ };
+
};
};
@@ -196,6 +205,8 @@ in
users.extraGroups.smbguest.gid = config.ids.uids.smbguest;
+ system.nssModules = optional cfg.nsswins samba;
+
systemd = {
targets.samba = {
description = "Samba server";
Best regards,
Bjørn Forsman
More information about the nix-dev
mailing list