见例子:
[jacob@macbook-debian ~/Projects/test] getfacl bin/testfile# file: bin/testfile# owner: root# group: rootuser::rwxuser:jacob:rwxuser:jason:rwxgroup::r-xgroup:www-data:rwxmask::rwxother::r-x[jacob@macbook-debian ~/Projects/test] chmod 0755 bin/testfilechmod: changing permissions of 'bin/testfile': Operation not permitted解决方法 在添加用户时使用linux ACL,您不会将它们添加为文件的所有者.只是打开/修改和写入该文件的权限.
当调用chown或chmod时,有效用户ID将是例如. jacob和那个将匹配所有者的价值.如果不匹配,则命令将失败.
从男人2 chmod.
The effective UID of the calling process must match the owner of the file,or the process must be privileged (linux: it must have the CAP_FOWNER capability).
另一种方法是将所描述的能力设置为调用进程/二进制chmod.但这会打开一个很大的安全问题,因为每个人都可以使用此命令来更改权限.
Here是一个关于用户访问功能的细粒度的线程,但它似乎不是很直接.
根据您的用例的限制,您可能希望为用户添加sudo规则以使用chmod,或者您评估用户必须在他们不拥有的文件上运行chmod的原因.也许在文件创建期间使用umask就足够了.
如果您的用户属于对目录具有写入权限的组,您还可以复制有问题的文件,删除原始文件并将副本移动到原始名称.这将导致用户将拥有复制的文件并可以执行chmod.
[user@localhost testdir]$lltotal 12Kdrwxrwxr-x 2 root user 4.0K Jul 14 11:49 .drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..-rw-rw----+ 1 root user 5 Jul 14 11:41 testfile[user@localhost testdir]$getfacl testfile # file: testfile# owner: root# group: useruser::rw-user:user:rw-group::rw-group:user:rw-mask::rw-other::---[user@localhost testdir]$chmod 777 testfilechmod: changing permissions of 'testfile': Operation not permitted[user@localhost testdir]$cp -a testfile testfile.copy[user@localhost testdir]$getfacl *# file: testfile# owner: root# group: useruser::rw-user:user:rw-group::rw-group:user:rw-mask::rw-other::---# file: testfile.copy# owner: user# group: useruser::rw-user:user:rw-group::rw-group:user:rw-mask::rw-other::---[user@localhost testdir]$mv testfile.copy testfile[user@localhost testdir]$lltotal 12Kdrwxrwxr-x 2 root user 4.0K Jul 14 11:50 .drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..-rw-rw----+ 1 user user 5 Jul 14 11:41 testfile[user@localhost testdir]$chmod 777 testfile[user@localhost testdir]$lltotal 12Kdrwxrwxr-x 2 root user 4.0K Jul 14 11:50 .drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..-rwxrwxrwx+ 1 user user 5 Jul 14 11:41 testfile总结
以上是内存溢出为你收集整理的linux – 如何让多个用户访问chmod()相同的文件?全部内容,希望文章能够帮你解决linux – 如何让多个用户访问chmod()相同的文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)