添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more

I am new to fuse. I have mounted fuse by the following command.

/mnt/fuse -o default_permissions -o allow_other -o nonempty -o hard_remove –d

Now If I login as "test" user and tried to create a file called "testfile".

test@11540302:/registration> touch testfile
touch: setting times of `testfile': Permission denied

Strace output:

uname({sys="Linux", node="11540302", ...}) = 0
brk(0)                                  = 0x8055000
brk(0x8076000)                          = 0x8076000
open("testfile", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0666) =    3
dup2(3, 0)                              = 0
close(3)                                = 0
utimensat(0, NULL, NULL, 0)             = -1 EACCES (Permission denied)
close(0)                                = 0

But "testfile" creation is successful with owner as root user,

-rw-r--r--  1 root trusted     0 Jan 19 13:51 testfile

I can understand that fuse application is running in root level, file creation happened with the owner as root. Because of that test user cannot perform any operation on "testfile".

My question:

Since I have given "allow_other" while mounting, why test user cannot having privileges to access the "testfile"?

Please correct me if my understanding is wrong.

Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops? – jww Jan 10 '17 at 21:13 @jww this question is definitely about programming and development, specifically programming a user-space filesystem. – Ahmed Masud May 21 at 2:48

Detailed explanation for this issue.

Solution:

As @dirkt said we need to handle permissions on our own.

Code to get the caller uid and gid:

fuse_get_context()->uid;

fuse_get_context()->gid;

Get the caller user id and group id and set the ownership of the file/directory while creating via fuse API's.

Always there is room for improvement. Kindly correct me if I am not correct.

Thank you dirkt for your explanation.

Also, make sure that #user_allow_other is uncommented on the fuse configuration file (generally on /etc/fuse.conf):

sed -i -e "s/#user_allow_other/user_allow_other/gi" /etc/fuse.conf

After running either of those, reboot the computer and try again.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.