大网数据广告活动
服务器运维问答

NFSv4 mapping UID and GID on Debian Stretch

· 52CE 我爱测

I use the following setup: NFS Server (Ubuntu 16.04 LTS) nfs-common 1:1.2.8-6ubuntu1.2 nfs-kernel-server 1:1.2.8-6ubuntu1.2 user: test (uid=1300) NFS Client nfs-common 1:1.3.4-2.1 user: testmf (uid=1350) On the client side, the u…

问题原文

原帖链接 · Alessandro Perucchi · CC BY-SA 4.0

I use the following setup:

NFS Server (Ubuntu 16.04 LTS)

  • nfs-common 1:1.2.8-6ubuntu1.2
  • nfs-kernel-server 1:1.2.8-6ubuntu1.2
  • user: test (uid=1300)

NFS Client

  • nfs-common 1:1.3.4-2.1
  • user: testmf (uid=1350)

On the client side, the user test exists with the same UID as in the server side. But I need to use the user testmf and not the test one.

I have read a lot documentation, and answers from StackOverflow/StackExchange, and for some reasons nothing works for me.

One of the many answers is to change the file /etc/idmapd.conf.

So here it is on both side:

Server

[General]
Verbosity = 0
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
# Domain = localdomain

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

On the client side:

[General]
Verbosity = 9
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if it differs from FQDN minus hostname
# Domain = localdomain
Domain = example.com

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

[Translation]
Method = static

[Static]
[email omitted] = testmf
[email omitted] = testmf
test@nfsserver = testmf

And I use such command to mount the directory on the client:

mount 192.168.0.1:/home/test/my_exp_dir /home/testmf/my_imp_dir

And when I do a ls -l /home/testmf/my_imp_dir I get something like that:

-rw-r--r-- 1 test test  326025780 May  9  2017 allCountries.zip

and NOT

-rw-r--r-- 1 testmf testmf  326025780 May  9  2017 allCountries.zip

If I do a this point a touch testfile I get that:

-rw-r--r-- 1 test test  326025780 May  9  2017 allCountries.zip
-rw-r--r-- 1 testmf testmf      0 Jun  9  18:57 testfile

Or ls -ln

-rw-r--r-- 1 1300 1300  326025780 May  9  2017 allCountries.zip
-rw-r--r-- 1 1350 1350          0 Jun  9  18:57 testfile

I tried to increase the level of verbosity, and nowhere in my logs I can see the mapping of users from one UID to another like I could see on some answers. The two things I could see is that the kernel setting /sys/module/nfs/parameters/nfs4_disable_idmapping was set to Y and even after changing to N, nothing seems to work.

The second thing that I have found is the 2 entries doesn't exist on my client server:

  • /proc/net/rpc/nfs4.nametoid
  • /proc/net/rpc/nfs4.idtoname

And I don't know how to add it, especially if the nfsidmap is not available.

I have read that I also need to restart the idmapd service after that change. But in Debian 9 there it is not possible... Or at least I have not found how to do it...

I have also changed the file /etc/default/nfs-common to set the variable NEED_IDMAPD=yes and it doesn't do anything, even after a reboot...

So my question is maybe quite dumb, but how can I activate nfsidmapd on Debian Stretch? I am really out of option, search keywords and the official documentation of Debian is not really helpful here, except if I am totally blind!

Thank you in advance for your help.

已采纳解答

原帖链接 · Alessandro Perucchi · CC BY-SA 4.0

Well this is my answer, maybe not exactly what I wanted, but at least it solved my problem and I go on.

Basically I have ensured that every users were part of the same group with the same GID on all servers involved. Then I've set the group ID of all directories in the shared directory with a :

find /share-dir -type d -exec chmod g+s {} \;

I've also checked that the umask was set to 007 instead of 022, 027.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。