Static ID mapping not functional in NFS

Bug #1812280 reported by kosheo
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
libnfsidmap (Ubuntu)
Fix Released
Undecided
Andreas Hasenack

Bug Description

Static NFS UID/GID translation doesn't work, even when using with sec=krb5.

The share is exported with:

/nfs 192.168.0.0/24(rw,sync,crossmnt,no_subtree_check,root_squash,fsid=0,sec=krb5)

Mapping configuration in /etc/idmapd.conf:

...
[Translation]
Method = static

[Static]
<email address hidden> = sam
<email address hidden> = bob
...

Logs from rpc.idmapd:

...
rpc.idmapd[3591]: libnfsidmap: processing 'Method' list
libnfsidmap: loaded plugin /lib/x86_64-linux-gnu/libnfsidmap/static.so for method static
rpc.idmapd[3592]: Expiration time is 600 seconds.
rpc.idmapd[3592]: Opened /proc/net/rpc/nfs4.nametoid/channel
rpc.idmapd[3592]: Opened /proc/net/rpc/nfs4.idtoname/channel
...
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=user
rpc.idmapd[3592]: nfs4_uid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (user) id "1000" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=group
rpc.idmapd[3592]: nfs4_gid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (group) id "1000" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=group
rpc.idmapd[3592]: nfs4_gid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (group) id "1003" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=user
rpc.idmapd[3592]: nfs4_uid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (user) id "0" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=group
rpc.idmapd[3592]: nfs4_gid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (group) id "0" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=user
rpc.idmapd[3592]: nfs4_uid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (user) id "1002" -> name ""
rpc.idmapd[3592]: nfsdcb: authbuf=gss/krb5 authtype=group
rpc.idmapd[3592]: nfs4_gid_to_name: final return value is 0
rpc.idmapd[3592]: Server : (group) id "1002" -> name ""
...

As you can see, even though static.so plugin was loaded, ID translation was not performed.

Looking at this issue with GDB shows that static translation plugin is skipped in these two lines in libnfsidmap.c:

...
if (plgns[i]->trans->funcname == NULL)
    continue;
...

The reason that funcname is null is that pointers to name_to_uid, name_to_gid, uid_to_name, gid_to_name are explicitly initialized to NULL in the Ubuntu's version of libnfsidmap/static.c:

...
struct trans_func static_trans = {
        .name = "static",
        .init = NULL,
        .name_to_uid = NULL,
        .name_to_gid = NULL,
        .uid_to_name = NULL,
        .gid_to_name = NULL,
        .princ_to_ids = static_gss_princ_to_ids,
        .gss_princ_to_grouplist = static_gss_princ_to_grouplist,
};
...

Please note, that in original sources of NFS these callbacks are correctly initialized like so:

...
struct trans_func static_trans = {
 .name = "static",
 .init = static_init,
 .name_to_uid = static_name_to_uid,
 .name_to_gid = static_name_to_gid,
 .uid_to_name = static_uid_to_name,
 .gid_to_name = static_gid_to_name,
 .princ_to_ids = static_gss_princ_to_ids,
 .gss_princ_to_grouplist = static_gss_princ_to_grouplist,
};
...

I am not sure why in Ubuntu's package the NFS static ID translation was disabled, but if it was done deliberately it should've been documented (maybe here https://help.ubuntu.com/community/NFSv4Howto ?).

Side note: nsswitch translation works correctly.

Ubuntu Server 18.04.1 LTS
libnfsidmap2:amd64 0.25-5.1

kosheo (kosheo)
affects: snapd (Ubuntu) → libnfsidmap (Ubuntu)
Changed in libnfsidmap (Ubuntu):
assignee: nobody → Andreas Hasenack (ahasenack)
status: New → Triaged
tags: added: server-todo
Changed in libnfsidmap (Ubuntu):
milestone: none → ubuntu-22.04-feature-freeze
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I'm attempting to update nfs-utils for ubuntu jammy 22.04[1], and libnfsidmap is bundled with nfs-utils now. As far as I can see, [Static] is working, but I still have some experiments to run with it. Since you seem a user of this mapping, if you could help test the new nfs-utils package that would be great!

1. https://bugs.launchpad.net/bugs/1878601

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I confirmed the brokeness of this feature in the current packaging, and also that it is fixed in the new one I'm working on, from the ppa linked in the bug above.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fixed in the latest nfs-utils which now produces this

Changed in libnfsidmap (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.