nfs4_disable_idmapping 参数到底有什么作用?

ovk*_*ovk 2 ubuntu nfs nfs4

我一直在 NFSv4 中尝试用户/组 ID 映射(翻译)。我想要实现的是基于名称的 ID 转换,它独立于服务器和客户端上的实际 UID/GID。

许多指南和文章提到,要使 ID 映射正常工作,您必须在客户端模块和服务器模块中将nfs4_disable_idmapping参数设置为0(又名 N) 。但是,我没有找到任何有关此参数的具体用途的信息或文档。nfsnfsd

作为实验,我配置了 NFSv4 服务器和客户端(使用sec=krb5),并故意将这些参数保留为其默认值(禁用映射)。我可以验证服务器上是否禁用了映射:

$ cat /sys/module/nfsd/parameters/nfs4_disable_idmapping 
Y
Run Code Online (Sandbox Code Playgroud)

并在客户端上:

$ cat /sys/module/nfs/parameters/nfs4_disable_idmapping 
Y
Run Code Online (Sandbox Code Playgroud)

我在服务器上创建了用户bob(uid=1002)and ,在客户端上创建了用户and 。正如您所看到的,UID 不匹配,但是用户仍然映射正确。用户在服务器上创建的文件被视为由服务器拥有,反之亦然。sam(uid=1001)bob(uid=1003)sam(uid=1004)bobbob

此外,如果我查看客户端上的日志:

nfsidmap[1874]: key: 0x322c739a type: uid value: bob@home.lan timeout 600                                            
nfsidmap[1874]: nfs4_name_to_uid: calling nsswitch->name_to_uid                                                      
nfsidmap[1874]: nss_getpwnam: name 'bob@home.lan' domain 'home.lan': resulting localname 'bob'                       
nfsidmap[1874]: nfs4_name_to_uid: nsswitch->name_to_uid returned 0                                                   
nfsidmap[1874]: nfs4_name_to_uid: final return value is 0       
Run Code Online (Sandbox Code Playgroud)

并在服务器上:

rpc.idmapd[1717]: nfsdcb: authbuf=gss/krb5p authtype=user                                                                                                                   
rpc.idmapd[1717]: nfs4_uid_to_name: calling nsswitch->uid_to_name                                                                                                           
rpc.idmapd[1717]: nfs4_uid_to_name: nsswitch->uid_to_name returned 0                                                                                                        
rpc.idmapd[1717]: nfs4_uid_to_name: final return value is 0                                                                                                                 
rpc.idmapd[1717]: Server : (user) id "1002" -> name "bob@home.lan"  
Run Code Online (Sandbox Code Playgroud)

他们都表明 ID 映射确实是“按名称”而不是“按 id”工作。

nfs4_disable_idmapping所以我的问题是:如果参数似乎对 ID 映射没有任何明显的影响,那么参数是什么?

kof*_*ann 5

你遇到了一个糟糕的测试用例。根据内核文档, 选项仅在使用nfs4_disable_idmapping时才有意义。sec=sys