Skip to contentSkip to conversation

libnfsidmap: add support for multiple domains

RFC PATCH In review Scott Mayhew 2 participants 5 messages Dec 7, 2016 – Dec 15, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 libnfsidmap: add support for multiple domains

Quick disclaimer -- this is different than the multi-domain support described in RFC 8000. In the description below I'm really using 'multi-domain' to mean 'multiple AD/IdM domains', rather than multiple NFSv4 domains.

NFSv4 id mapping on Linux does not work well in multi-domain environments. RFCs 3530, 5661, and 7530 all describe the fattr4_owner and fattr4_owner_group strings in the form "user@dns_domain".

The Linux libnfsidmap nssswitch plugin currently treats that domain as an arbitrary string. As long as the domain part of the incoming string matches the Domain parameter of the idmapd.conf, the plugin strips off the domain and does a getpwnam() with what's left over.

When a Linux machine is joined to an environment involving multiple AD or IdM domains, it is usually necessary for usernames to be qualified with the domain, either in a user principal format (e.g. "[email protected]") or a down-level logon name format (e.g. "AD\smayhew").

When an environment with just Linux NFS clients and servers, the machines will all use this format the libnfsimap plugin will automatically format the username in one of these two forms, because libnfsidmap is just using the name that is returned from getpwuid()... so in the above example, if the NFSv4 domain in idmapd.conf is configured as "example.com", the full fattr4_owner might appear as "[email protected]@example.com" if the machines are using SSSD, and "AD\[email protected]" if they're using Winbind.

Non-Linux NFS servers do not do that.

DATA ONTAP maps a uid to a short username and then appends the NFSv4 id mapping domain to that. The nsswitch plugin is unable to map those, because once it strips off the domain it will be unable to resolve the short username. It's possible to configure the Linux clients that are using SSSD to be able to use the short usernames by turning off the subdomains_provider and explicitly adding stanzas for each trusted domain in the sssd.conf. This works as long as each username & uid is unique across all the trusted domains. For example if you have subdomains "na", "emea", and "apac", then it will not work (or rather it will be unpredictable) if each of those domains has an "smayhew" user... but otherwise it will work. But there's no corresponding solution for Linux clients that are using Winbind... and and solution does not work for other NFS servers.

The NFS v4.1 server in Microsoft Windows does not appear to allow the NFSv4 domain to be configured at all. It just sends the names in UPN format, so it's essentially treating the AD domain as the NFSv4 domain. The Windows NFS v4.1 server is therefore capable of working with multiple domains. Since the current libnfsidmap nsswitch plugin only allows a single domain to be configured, it's only able to map users from that single domain.

EMC Isilon servers are also capable of using multiple domains by unchecking the "Enable NFSv4 Replace Domain" box on the NFS Zone Settings in the web UI or via 'isi nfs settings zone modify --nfsv4-replace-domain no' on the command line. This causes the Isilon to send AD/IdM domain instead of the NFSv4 domain value in the fattr4_owner and fattr4_owner_group strings. Again, since the current libnfsidmap plugin only allows a single domain to be configured, it's only able to users from a single domain.

This patch adds a new plugin called 'multidom' (I'm not attached to the name and open to suggestions. Maybe something like 'nostripdomain' would be better).

What it does is adds another parameter 'Domain-List' to the idmap.conf. That parameter takes (unsurprisingly) a list of domains, in much the same way the Local-Realms parameter works. The value specified in the Domain parameter does not have to be in the Domain-List. When the Domains list is populated, the plugin does a few things:
1. For name-to-id mapping, it compares the domain in the attribute to the list of domains. If it's not in the list, it gets mapped to the uid for nobody.
2. If the domain in the attribute is in the list of domains, then that attibute is passed as-is to getpwnam() (or getgrnam() if its a group). IOW the domain is NOT stripped off.
3. For id-to-name mapping, after the getpwuid() (or getgrgid()) call, the domain in the result is compared to the Domains list... if it's not in the list, the the id is mapped to the nobody string... even if the name was otherwise resolved successfully.

With the plugin enabled I'm able to map users from multiple AD/IdM domains.

ot@rhel6client ~]# cat /etc/idmapd.conf
[General]
Domain = smayhew.local

[Multi-Domain]
Domain-List = smayhew.local,ad.smayhew.local,lab.smayhew.local

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = multidom,nsswitch

[root@rhel6client ~]# ls -l /mnt/t
total 10

-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 [email protected]        domain [email protected]     29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 [email protected]          domain [email protected]     29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 [email protected]     domain [email protected] 29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 [email protected]     domain [email protected]  29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 [email protected] domain [email protected] 29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 [email protected]    domain [email protected]  29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 [email protected]      domain [email protected] 29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 [email protected]  domain [email protected] 29 Sep 26 15:23 written-by-zoidberg

This also works on systems using Winbind instead of SSSD. The idmap.conf is the same, with the exception of an additional parameter 'Reformat-Group-For-Winbind-Query = true' in the '[Multi-Domain]' stanza.

[root@rhel6wbnfs ~]# ls -l /mnt/t
total 10
-rw-rw-r--. 1 LAB\amy LAB\domain users 29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 SMAYHEW\barney SMAYHEW\domain users 29 Sep 26 15:22 written-by-barney

-rw-rw-r--. 1 AD\bart        AD\domain users      29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 LAB\bender     LAB\domain users     29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 SMAYHEW\betty  SMAYHEW\domain users 29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 SMAYHEW\fred   SMAYHEW\domain users 29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 LAB\fry        LAB\domain users     29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 LAB\hermes     LAB\domain users     29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 AD\homer       AD\domain users      29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 LAB\kif        LAB\domain users     29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 LAB\leela      LAB\domain users     29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 AD\lisa        AD\domain users      29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 AD\maggie      AD\domain users      29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 AD\marge       AD\domain users      29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 LAB\professor  LAB\domain users     29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 AD\smayhew     AD\domain users      29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 SMAYHEW\wilma  SMAYHEW\domain users 29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 LAB\zapp       LAB\domain users     29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 LAB\zoidberg   LAB\domain users     29 Sep 26 15:23 written-by-zoidberg

-Scott

Scott Mayhew (1):
libnfsidmap: add support for multiple domains

 Makefile.am   |   5 +-
 idmapd.conf   |  26 +++-
 idmapd.conf.5 |  40 ++++++-
 multidom.c    | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 multidom.c
Signature · 1 line
2.7.4
#1 lore raw

RFC PATCH 1/1 libnfsidmap: add support for multiple domains

---
 Makefile.am   |   5 +-
 idmapd.conf   |  26 +++-
 idmapd.conf.5 |  40 ++++++-
 multidom.c    | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 multidom.c
Makefile.am +4 -1
index 85f19c8..62a1d1e 100644
@@ -11,7 +11,7 @@ else
 GUMS_MAPPING_LIB =
 endif
 lib_LTLIBRARIES = libnfsidmap.la
-pkglib_LTLIBRARIES = nsswitch.la static.la $(UMICH_LDAP_LIB) $(GUMS_MAPPING_LIB)
+pkglib_LTLIBRARIES = nsswitch.la static.la multidom.la $(UMICH_LDAP_LIB) $(GUMS_MAPPING_LIB)
 
 # Library versioning notes from:
 #  http://sources.redhat.com/autobook/autobook/autobook_91.html
@@ -35,6 +35,9 @@ nsswitch_la_LDFLAGS = -module -avoid-version
 static_la_SOURCES = static.c
 static_la_LDFLAGS = -module -avoid-version
 
+multidom_la_SOURCES = multidom.c
+multidom_la_LDFLAGS = -module -avoid-version
+
 umich_ldap_la_SOURCES = umich_ldap.c
 umich_ldap_la_LDFLAGS = -module -avoid-version
 umich_ldap_la_LIBADD = -lldap
idmapd.conf +24 -2
index ebf9754..0517d40 100644
@@ -24,8 +24,8 @@
 
 # Translation Method is an comma-separated, ordered list of
 # translation methods that can be used.  Distributed methods
-# include "nsswitch", "umich_ldap", and "static".  Each method
-# is a dynamically loadable plugin library.
+# include "nsswitch", "multidom", "umich_ldap", and "static".  Each
+# method is a dynamically loadable plugin library.
 # New methods may be defined and inserted in the list.
 # The default is "nsswitch".
 #Method = nsswitch
@@ -36,6 +36,28 @@
 # If this option is omitted, the same methods as those
 # specified in "Method" are used.
 #GSS-Methods = <alternate method list for translating GSS names>
+
+#-------------------------------------------------------------------#
+# The following are used only for the "multidom" Translation Method.
+#-------------------------------------------------------------------#
+[Multi-Domain]
+# The "multidom" plugin does not strip the domain off the name before
+# passing it to the password/group lookup function.  Instead it
+# compares the domain to this list.  If the domain does not match a
+# domain in the list, then the name is mapped to the Nobody-User or
+# Nobody-Group.  If the domain does match a domain in the list, then
+# the name is passed to the password/group lookup function as-is.
+#Domain-List = americas.example.com,emea.example.com,apac,example.com
+
+# Winbind has a "quirk" whereby doing a group lookup in UPN format
+# (e.g. [email protected]) will cause the group to be
+# displayed prefixed with the full domain in uppercase
+# (e.g. AMERICAS.EXAMPLE.COM\staff) instead of in the familiar netbios
+# name format (e.g. AMERICAS\staff).  Setting this option to true
+# causes the name to be reformatted before passing it to the group
+# lookup function in order to work around this "quirk".
+# The default is "false".
+#Reformat-Group-For-Winbind-Query = false
  
 #-------------------------------------------------------------------#
 # The following are used only for the "static" Translation Method.
idmapd.conf.5 +38 -2
index de1bfa9..74cc683 100644
@@ -102,8 +102,8 @@ A comma-separated, ordered list of mapping methods (plug-ins)
 to use when mapping between NFSv4 names and local IDs.  Each
 specified method is tried in order until a mapping is found,
 or there are no more methods to try.  The methods included in
-the default distribution include "nsswitch", "umich_ldap", and
-"static".
+the default distribution include "nsswitch", "multidom",
+"umich_ldap", and "static".
 (Default: nsswitch)
 .TP
 .B GSS-Methods
@@ -113,6 +113,42 @@ to use when mapping between GSS Authenticated names and local IDs.
 .B Method)
 .\"
 .\" -------------------------------------------------------------------
+.\" The [Multi-Domain] section
+.\" -------------------------------------------------------------------
+.\"
+.SS "[Multi-Domain] section variables"
+.nf
+
+.fi
+If the "multidom" translation method is specified, the following
+variables within the [Multi-Domain] section are used.
+.TP
+.B Domain-List
+A comma-separated list of domains in which to attempt to map users
+and groups.  In multi-domain environments, some NFS servers will send
+append the owner and group_owner attributes with the identity
+management domain in lieu of a true NFSv4 domain.  To accomodate
+lookups in those environments, the "multidom" plugin does not strip
+the domain off the name before passing it to the password/group lookup
+function.  Instead it compares the domain to this list.  If the domain
+does not match a domain in the list, then the name is mapped to the
+Nobody-User or Nobody-Group.  If the domain does match a domain in the
+list, then the name is passed to the password/group lookup function as-is.
+
+.fi
+.TP
+.B Reformat-Group-For-Winbind-Query
+Winbind has a "quirk" whereby doing a group lookup in UPN format
+(e.g. [email protected]) will cause the group to be
+displayed prefixed with the full domain in uppercase
+(e.g. AMERICAS.EXAMPLE.COM\\staff) instead of in the familiar netbios
+name format (e.g. AMERICAS\\staff).  Setting this option to true
+causes the name to be reformatted before passing it to the group
+lookup function in order to work around this "quirk".
+(Default: false)
+
+.\"
+.\" -------------------------------------------------------------------
 .\" The [Static] section
 .\" -------------------------------------------------------------------
 .\"
multidom.c new file +379 -0

379 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw
In reply to Scott Mayhew
Quoted 66 lines · Scott Mayhew

Quick disclaimer -- this is different than the multi-domain support described in RFC 8000. In the description below I'm really using 'multi-domain' to mean 'multiple AD/IdM domains', rather than multiple NFSv4 domains.

NFSv4 id mapping on Linux does not work well in multi-domain environments. RFCs 3530, 5661, and 7530 all describe the fattr4_owner and fattr4_owner_group strings in the form "user@dns_domain".

The Linux libnfsidmap nssswitch plugin currently treats that domain as an arbitrary string. As long as the domain part of the incoming string matches the Domain parameter of the idmapd.conf, the plugin strips off the domain and does a getpwnam() with what's left over.

When a Linux machine is joined to an environment involving multiple AD or IdM domains, it is usually necessary for usernames to be qualified with the domain, either in a user principal format (e.g. "[email protected]") or a down-level logon name format (e.g. "AD\smayhew").

When an environment with just Linux NFS clients and servers, the machines will all use this format the libnfsimap plugin will automatically format the username in one of these two forms, because libnfsidmap is just using the name that is returned from getpwuid()... so in the above example, if the NFSv4 domain in idmapd.conf is configured as "example.com", the full fattr4_owner might appear as "[email protected]@example.com" if the machines are using SSSD, and "AD\[email protected]" if they're using Winbind.

Non-Linux NFS servers do not do that.

DATA ONTAP maps a uid to a short username and then appends the NFSv4 id mapping domain to that. The nsswitch plugin is unable to map those, because once it strips off the domain it will be unable to resolve the short username. It's possible to configure the Linux clients that are using SSSD to be able to use the short usernames by turning off the subdomains_provider and explicitly adding stanzas for each trusted domain in the sssd.conf. This works as long as each username & uid is unique across all the trusted domains. For example if you have subdomains "na", "emea", and "apac", then it will not work (or rather it will be unpredictable) if each of those domains has an "smayhew" user... but otherwise it will work. But there's no corresponding solution for Linux clients that are using Winbind... and and solution does not work for other NFS servers.

The NFS v4.1 server in Microsoft Windows does not appear to allow the NFSv4 domain to be configured at all. It just sends the names in UPN format, so it's essentially treating the AD domain as the NFSv4 domain. The Windows NFS v4.1 server is therefore capable of working with multiple domains. Since the current libnfsidmap nsswitch plugin only allows a single domain to be configured, it's only able to map users from that single domain.

EMC Isilon servers are also capable of using multiple domains by unchecking the "Enable NFSv4 Replace Domain" box on the NFS Zone Settings in the web UI or via 'isi nfs settings zone modify --nfsv4-replace-domain no' on the command line. This causes the Isilon to send AD/IdM domain instead of the NFSv4 domain value in the fattr4_owner and fattr4_owner_group strings. Again, since the current libnfsidmap plugin only allows a single domain to be configured, it's only able to users from a single domain.

This patch adds a new plugin called 'multidom' (I'm not attached to the name and open to suggestions. Maybe something like 'nostripdomain' would be better).

Quoted 15 lines

What it does is adds another parameter 'Domain-List' to the idmap.conf. That parameter takes (unsurprisingly) a list of domains, in much the same way the Local-Realms parameter works. The value specified in the Domain parameter does not have to be in the Domain-List. When the Domains list is populated, the plugin does a few things:
1. For name-to-id mapping, it compares the domain in the attribute to the list of domains. If it's not in the list, it gets mapped to the uid for nobody.
2. If the domain in the attribute is in the list of domains, then that attibute is passed as-is to getpwnam() (or getgrnam() if its a group). IOW the domain is NOT stripped off.
3. For id-to-name mapping, after the getpwuid() (or getgrgid()) call, the domain in the result is compared to the Domains list... if it's not in the list, the the id is mapped to the nobody string... even if the name was otherwise resolved successfully.

Dumb questions:

- Do we even need the list, or can we leave that decision to whatever's really mapping the names? If the admin already set up things to map @some-weird-domain then why do we need them to whitelist that domain again here?
- should something like this method be the default? Or is there a way we can auto-detect this kind of setup?

In general idmapper configuration has been a bit of an annoyance and anything we can do to help more admins ignore it is good.

Anyway, seems like a major improvement, thanks for doing this.

--b.

Quoted 87 lines

With the plugin enabled I'm able to map users from multiple AD/IdM domains.

ot@rhel6client ~]# cat /etc/idmapd.conf
[General]
Domain = smayhew.local

[Multi-Domain]
Domain-List = smayhew.local,ad.smayhew.local,lab.smayhew.local

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = multidom,nsswitch

[root@rhel6client ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -19
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 [email protected]        domain [email protected]     29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 [email protected]          domain [email protected]     29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 [email protected]     domain [email protected] 29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 [email protected]     domain [email protected]  29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 [email protected] domain [email protected] 29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 [email protected]    domain [email protected]  29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 [email protected]      domain [email protected] 29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 [email protected]  domain [email protected] 29 Sep 26 15:23 written-by-zoidberg

This also works on systems using Winbind instead of SSSD. The idmap.conf is the same, with the exception of an additional parameter 'Reformat-Group-For-Winbind-Query = true' in the '[Multi-Domain]' stanza.

[root@rhel6wbnfs ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -20
-rw-rw-r--. 1 LAB\amy        LAB\domain users     29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 SMAYHEW\barney SMAYHEW\domain users 29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 AD\bart        AD\domain users      29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 LAB\bender     LAB\domain users     29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 SMAYHEW\betty  SMAYHEW\domain users 29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 SMAYHEW\fred   SMAYHEW\domain users 29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 LAB\fry        LAB\domain users     29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 LAB\hermes     LAB\domain users     29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 AD\homer       AD\domain users      29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 LAB\kif        LAB\domain users     29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 LAB\leela      LAB\domain users     29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 AD\lisa        AD\domain users      29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 AD\maggie      AD\domain users      29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 AD\marge       AD\domain users      29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 LAB\professor  LAB\domain users     29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 AD\smayhew     AD\domain users      29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 SMAYHEW\wilma  SMAYHEW\domain users 29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 LAB\zapp       LAB\domain users     29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 LAB\zoidberg   LAB\domain users     29 Sep 26 15:23 written-by-zoidberg
 
-Scott

Scott Mayhew (1):
libnfsidmap: add support for multiple domains

 Makefile.am   |   5 +-
 idmapd.conf   |  26 +++-
 idmapd.conf.5 |  40 ++++++-
 multidom.c    | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 multidom.c
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 83 lines · J. Bruce Fields
Quoted 66 lines · Scott Mayhew

Quick disclaimer -- this is different than the multi-domain support described in RFC 8000. In the description below I'm really using 'multi-domain' to mean 'multiple AD/IdM domains', rather than multiple NFSv4 domains.

NFSv4 id mapping on Linux does not work well in multi-domain environments. RFCs 3530, 5661, and 7530 all describe the fattr4_owner and fattr4_owner_group strings in the form "user@dns_domain".

The Linux libnfsidmap nssswitch plugin currently treats that domain as an arbitrary string. As long as the domain part of the incoming string matches the Domain parameter of the idmapd.conf, the plugin strips off the domain and does a getpwnam() with what's left over.

When a Linux machine is joined to an environment involving multiple AD or IdM domains, it is usually necessary for usernames to be qualified with the domain, either in a user principal format (e.g. "[email protected]") or a down-level logon name format (e.g. "AD\smayhew").

When an environment with just Linux NFS clients and servers, the machines will all use this format the libnfsimap plugin will automatically format the username in one of these two forms, because libnfsidmap is just using the name that is returned from getpwuid()... so in the above example, if the NFSv4 domain in idmapd.conf is configured as "example.com", the full fattr4_owner might appear as "[email protected]@example.com" if the machines are using SSSD, and "AD\[email protected]" if they're using Winbind.

Non-Linux NFS servers do not do that.

DATA ONTAP maps a uid to a short username and then appends the NFSv4 id mapping domain to that. The nsswitch plugin is unable to map those, because once it strips off the domain it will be unable to resolve the short username. It's possible to configure the Linux clients that are using SSSD to be able to use the short usernames by turning off the subdomains_provider and explicitly adding stanzas for each trusted domain in the sssd.conf. This works as long as each username & uid is unique across all the trusted domains. For example if you have subdomains "na", "emea", and "apac", then it will not work (or rather it will be unpredictable) if each of those domains has an "smayhew" user... but otherwise it will work. But there's no corresponding solution for Linux clients that are using Winbind... and and solution does not work for other NFS servers.

The NFS v4.1 server in Microsoft Windows does not appear to allow the NFSv4 domain to be configured at all. It just sends the names in UPN format, so it's essentially treating the AD domain as the NFSv4 domain. The Windows NFS v4.1 server is therefore capable of working with multiple domains. Since the current libnfsidmap nsswitch plugin only allows a single domain to be configured, it's only able to map users from that single domain.

EMC Isilon servers are also capable of using multiple domains by unchecking the "Enable NFSv4 Replace Domain" box on the NFS Zone Settings in the web UI or via 'isi nfs settings zone modify --nfsv4-replace-domain no' on the command line. This causes the Isilon to send AD/IdM domain instead of the NFSv4 domain value in the fattr4_owner and fattr4_owner_group strings. Again, since the current libnfsidmap plugin only allows a single domain to be configured, it's only able to users from a single domain.

This patch adds a new plugin called 'multidom' (I'm not attached to the name and open to suggestions. Maybe something like 'nostripdomain' would be better).

Quoted 15 lines

What it does is adds another parameter 'Domain-List' to the idmap.conf. That parameter takes (unsurprisingly) a list of domains, in much the same way the Local-Realms parameter works. The value specified in the Domain parameter does not have to be in the Domain-List. When the Domains list is populated, the plugin does a few things:
1. For name-to-id mapping, it compares the domain in the attribute to the list of domains. If it's not in the list, it gets mapped to the uid for nobody.
2. If the domain in the attribute is in the list of domains, then that attibute is passed as-is to getpwnam() (or getgrnam() if its a group). IOW the domain is NOT stripped off.
3. For id-to-name mapping, after the getpwuid() (or getgrgid()) call, the domain in the result is compared to the Domains list... if it's not in the list, the the id is mapped to the nobody string... even if the name was otherwise resolved successfully.

Quoted 6 lines

Dumb questions:

- Do we even need the list, or can we leave that decision to whatever's really mapping the names? If the admin already set up things to map @some-weird-domain then why do we need them to whitelist that domain again here?

We definitely don't need the domain list. The reason I added the whitelist was because without it, it pretty much felt like it was completely tossing the NFSv4 domain aside. With the whitelist, it at least feels like the admin has the ability to say 'we want to map domains W, X, and Y, but not Z'. I'd be perfectly happy to toss that out. Then it would behave pretty much like the plugin shipped with SSSD (but without having to talk to SSSD).

Quoted 2 lines

- should something like this method be the default? Or is there a way we can auto-detect this kind of setup?

I'd rather leave it as a separate plugin that can be inserted ahead of the nsswitch plugin, that way the whole thing can be yanked out in the future if desired. Also I can't really think of a way to auto-detect whether it should be used or not.

-Scott

Quoted 95 lines

In general idmapper configuration has been a bit of an annoyance and anything we can do to help more admins ignore it is good.

Anyway, seems like a major improvement, thanks for doing this.

--b.

Quoted 87 lines

With the plugin enabled I'm able to map users from multiple AD/IdM domains.

ot@rhel6client ~]# cat /etc/idmapd.conf
[General]
Domain = smayhew.local

[Multi-Domain]
Domain-List = smayhew.local,ad.smayhew.local,lab.smayhew.local

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = multidom,nsswitch

[root@rhel6client ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -19
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 [email protected]        domain [email protected]     29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 [email protected]          domain [email protected]     29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 [email protected]     domain [email protected] 29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 [email protected]     domain [email protected]  29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 [email protected] domain [email protected] 29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 [email protected]    domain [email protected]  29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 [email protected]      domain [email protected] 29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 [email protected]  domain [email protected] 29 Sep 26 15:23 written-by-zoidberg

This also works on systems using Winbind instead of SSSD. The idmap.conf is the same, with the exception of an additional parameter 'Reformat-Group-For-Winbind-Query = true' in the '[Multi-Domain]' stanza.

[root@rhel6wbnfs ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -20
-rw-rw-r--. 1 LAB\amy        LAB\domain users     29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 SMAYHEW\barney SMAYHEW\domain users 29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 AD\bart        AD\domain users      29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 LAB\bender     LAB\domain users     29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 SMAYHEW\betty  SMAYHEW\domain users 29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 SMAYHEW\fred   SMAYHEW\domain users 29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 LAB\fry        LAB\domain users     29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 LAB\hermes     LAB\domain users     29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 AD\homer       AD\domain users      29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 LAB\kif        LAB\domain users     29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 LAB\leela      LAB\domain users     29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 AD\lisa        AD\domain users      29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 AD\maggie      AD\domain users      29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 AD\marge       AD\domain users      29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 LAB\professor  LAB\domain users     29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 AD\smayhew     AD\domain users      29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 SMAYHEW\wilma  SMAYHEW\domain users 29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 LAB\zapp       LAB\domain users     29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 LAB\zoidberg   LAB\domain users     29 Sep 26 15:23 written-by-zoidberg
 
-Scott

Scott Mayhew (1):
libnfsidmap: add support for multiple domains

 Makefile.am   |   5 +-
 idmapd.conf   |  26 +++-
 idmapd.conf.5 |  40 ++++++-
 multidom.c    | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 multidom.c
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 92 lines · Scott Mayhew
Quoted 83 lines · J. Bruce Fields
Quoted 66 lines · Scott Mayhew

Quick disclaimer -- this is different than the multi-domain support described in RFC 8000. In the description below I'm really using 'multi-domain' to mean 'multiple AD/IdM domains', rather than multiple NFSv4 domains.

NFSv4 id mapping on Linux does not work well in multi-domain environments. RFCs 3530, 5661, and 7530 all describe the fattr4_owner and fattr4_owner_group strings in the form "user@dns_domain".

The Linux libnfsidmap nssswitch plugin currently treats that domain as an arbitrary string. As long as the domain part of the incoming string matches the Domain parameter of the idmapd.conf, the plugin strips off the domain and does a getpwnam() with what's left over.

When a Linux machine is joined to an environment involving multiple AD or IdM domains, it is usually necessary for usernames to be qualified with the domain, either in a user principal format (e.g. "[email protected]") or a down-level logon name format (e.g. "AD\smayhew").

When an environment with just Linux NFS clients and servers, the machines will all use this format the libnfsimap plugin will automatically format the username in one of these two forms, because libnfsidmap is just using the name that is returned from getpwuid()... so in the above example, if the NFSv4 domain in idmapd.conf is configured as "example.com", the full fattr4_owner might appear as "[email protected]@example.com" if the machines are using SSSD, and "AD\[email protected]" if they're using Winbind.

Non-Linux NFS servers do not do that.

DATA ONTAP maps a uid to a short username and then appends the NFSv4 id mapping domain to that. The nsswitch plugin is unable to map those, because once it strips off the domain it will be unable to resolve the short username. It's possible to configure the Linux clients that are using SSSD to be able to use the short usernames by turning off the subdomains_provider and explicitly adding stanzas for each trusted domain in the sssd.conf. This works as long as each username & uid is unique across all the trusted domains. For example if you have subdomains "na", "emea", and "apac", then it will not work (or rather it will be unpredictable) if each of those domains has an "smayhew" user... but otherwise it will work. But there's no corresponding solution for Linux clients that are using Winbind... and and solution does not work for other NFS servers.

The NFS v4.1 server in Microsoft Windows does not appear to allow the NFSv4 domain to be configured at all. It just sends the names in UPN format, so it's essentially treating the AD domain as the NFSv4 domain. The Windows NFS v4.1 server is therefore capable of working with multiple domains. Since the current libnfsidmap nsswitch plugin only allows a single domain to be configured, it's only able to map users from that single domain.

EMC Isilon servers are also capable of using multiple domains by unchecking the "Enable NFSv4 Replace Domain" box on the NFS Zone Settings in the web UI or via 'isi nfs settings zone modify --nfsv4-replace-domain no' on the command line. This causes the Isilon to send AD/IdM domain instead of the NFSv4 domain value in the fattr4_owner and fattr4_owner_group strings. Again, since the current libnfsidmap plugin only allows a single domain to be configured, it's only able to users from a single domain.

This patch adds a new plugin called 'multidom' (I'm not attached to the name and open to suggestions. Maybe something like 'nostripdomain' would be better).

Quoted 15 lines

What it does is adds another parameter 'Domain-List' to the idmap.conf. That parameter takes (unsurprisingly) a list of domains, in much the same way the Local-Realms parameter works. The value specified in the Domain parameter does not have to be in the Domain-List. When the Domains list is populated, the plugin does a few things:
1. For name-to-id mapping, it compares the domain in the attribute to the list of domains. If it's not in the list, it gets mapped to the uid for nobody.
2. If the domain in the attribute is in the list of domains, then that attibute is passed as-is to getpwnam() (or getgrnam() if its a group). IOW the domain is NOT stripped off.
3. For id-to-name mapping, after the getpwuid() (or getgrgid()) call, the domain in the result is compared to the Domains list... if it's not in the list, the the id is mapped to the nobody string... even if the name was otherwise resolved successfully.

Quoted 6 lines

Dumb questions:

- Do we even need the list, or can we leave that decision to whatever's really mapping the names? If the admin already set up things to map @some-weird-domain then why do we need them to whitelist that domain again here?

Quoted 7 lines

We definitely don't need the domain list. The reason I added the whitelist was because without it, it pretty much felt like it was completely tossing the NFSv4 domain aside. With the whitelist, it at least feels like the admin has the ability to say 'we want to map domains W, X, and Y, but not Z'. I'd be perfectly happy to toss that out. Then it would behave pretty much like the plugin shipped with SSSD (but without having to talk to SSSD).

OK by me, unless you see some security risk.

Another alternative would be to allow a whitelist, but not require one by default.

--b.

Quoted 106 lines
Quoted 3 lines

- should something like this method be the default? Or is there a way we can auto-detect this kind of setup?

I'd rather leave it as a separate plugin that can be inserted ahead of the nsswitch plugin, that way the whole thing can be yanked out in the future if desired. Also I can't really think of a way to auto-detect whether it should be used or not.

-Scott

Quoted 95 lines

In general idmapper configuration has been a bit of an annoyance and anything we can do to help more admins ignore it is good.

Anyway, seems like a major improvement, thanks for doing this.

--b.

Quoted 87 lines

With the plugin enabled I'm able to map users from multiple AD/IdM domains.

ot@rhel6client ~]# cat /etc/idmapd.conf
[General]
Domain = smayhew.local

[Multi-Domain]
Domain-List = smayhew.local,ad.smayhew.local,lab.smayhew.local

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = multidom,nsswitch

[root@rhel6client ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -19
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 [email protected]        domain [email protected]     29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 [email protected]          domain [email protected]     29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 [email protected]    domain [email protected] 29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 [email protected]       domain [email protected] 29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 [email protected]     domain [email protected] 29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 [email protected]       domain [email protected]  29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 [email protected]     domain [email protected]  29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 [email protected]      domain [email protected]  29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 [email protected] domain [email protected] 29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 [email protected]    domain [email protected]  29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 [email protected]         domain [email protected]     29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 [email protected]      domain [email protected] 29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 [email protected]  domain [email protected] 29 Sep 26 15:23 written-by-zoidberg

This also works on systems using Winbind instead of SSSD. The idmap.conf is the same, with the exception of an additional parameter 'Reformat-Group-For-Winbind-Query = true' in the '[Multi-Domain]' stanza.

[root@rhel6wbnfs ~]# ls -l /mnt/t
total 10

(quoted diff) +0 -20
-rw-rw-r--. 1 LAB\amy        LAB\domain users     29 Sep 26 15:22 written-by-amy
-rw-r--r--. 1 SMAYHEW\barney SMAYHEW\domain users 29 Sep 26 15:22 written-by-barney
-rw-rw-r--. 1 AD\bart        AD\domain users      29 Sep 26 15:22 written-by-bart
-rw-rw-r--. 1 LAB\bender     LAB\domain users     29 Sep 26 15:22 written-by-bender
-rw-r--r--. 1 SMAYHEW\betty  SMAYHEW\domain users 29 Sep 26 15:22 written-by-betty
-rw-r--r--. 1 SMAYHEW\fred   SMAYHEW\domain users 29 Sep 26 15:22 written-by-fred
-rw-rw-r--. 1 LAB\fry        LAB\domain users     29 Sep 26 15:23 written-by-fry
-rw-rw-r--. 1 LAB\hermes     LAB\domain users     29 Sep 26 15:22 written-by-hermes
-rw-rw-r--. 1 AD\homer       AD\domain users      29 Sep 26 15:22 written-by-homer
-rw-rw-r--. 1 LAB\kif        LAB\domain users     29 Sep 26 15:23 written-by-kif
-rw-rw-r--. 1 LAB\leela      LAB\domain users     29 Sep 26 15:23 written-by-leela
-rw-rw-r--. 1 AD\lisa        AD\domain users      29 Sep 26 15:22 written-by-lisa
-rw-rw-r--. 1 AD\maggie      AD\domain users      29 Sep 26 15:22 written-by-maggie
-rw-rw-r--. 1 AD\marge       AD\domain users      29 Sep 26 15:22 written-by-marge
-rw-rw-r--. 1 LAB\professor  LAB\domain users     29 Sep 26 15:23 written-by-professor
-rw-rw-r--. 1 AD\smayhew     AD\domain users      29 Sep 26 15:22 written-by-smayhew
-rw-r--r--. 1 SMAYHEW\wilma  SMAYHEW\domain users 29 Sep 26 15:22 written-by-wilma
-rw-rw-r--. 1 LAB\zapp       LAB\domain users     29 Sep 26 15:23 written-by-zapp
-rw-rw-r--. 1 LAB\zoidberg   LAB\domain users     29 Sep 26 15:23 written-by-zoidberg
 
-Scott

Scott Mayhew (1):
libnfsidmap: add support for multiple domains

 Makefile.am   |   5 +-
 idmapd.conf   |  26 +++-
 idmapd.conf.5 |  40 ++++++-
 multidom.c    | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 multidom.c
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html