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

Linux cifs share allow different user than mounted/masked uid to do cp -p

· 52CE 我爱测

I have a specific linux-server that runs several batch jobs at night creating files and copying them to various locations on a NAS, previously mounted with NFS but as of lately with CIFS. The reason for this being our new NAS doe…

问题原文

原帖链接 · Kalle Ling · CC BY-SA 4.0

I have a specific linux-server that runs several batch jobs at night creating files and copying them to various locations on a NAS, previously mounted with NFS but as of lately with CIFS.

The reason for this being our new NAS does not support sharing a filesystem as both nfs and cifs simultaneously (multi-protocol share) in a way that suits us. So I instead mounted the share as a cifs share, with windows credentials in .smbcredentials file.

This share is as old as time it self and it's accessed by many a system (Linux servers and Windows servers). However they all have their own servers, so when I mount the share as cifs on one of those Linux-servers I can just set/mask the uid and gid in the fstab to their respective service user and all is fine and dandy.

On the server that I first mentioned however there are several system running on the same server as their own individual users. So I need to mask the uid/gid in fstab to look like one user, but still allow the others to do stuff.

This mostly works but not cp -p, preserve the time stamps of files. This I just cannot seem to get working.

Any tips I could try? I have of course googled my *ss off, trying anything from here to the moon...

Also I am of course trying to get the dev teams to move to their own servers but that's not gonna happen any time soon.

已采纳解答

原帖链接 · AgentSmith · CC BY-SA 4.0

We have, at times, needed to use posix extended attributes (ACLs) to give multiple users access to a set of files through a CIFS server that does not authenticate to our central directory service. So for example you could try using setfacl on the SMB server, to map permissions onto files/folders, that will give the correct access to users on the Linux client(s). If you try this, don't forget to set the default ACL, too (this mimics the idea of inheritance on CIFS, although not perfectly).

If the users start twiddling the permissions themselves, it can get messy in a hurry. But I think your problem can probably be solved this way.

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

资料来源与适用范围

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

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

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