Opened 13 years ago

Closed 9 years ago

#8254 closed bug (fixed)

bfs_fuse needs root privs since hrev41258

Reported by: luroh Owned by: axeld
Priority: normal Milestone: Unscheduled
Component: File Systems/BFS Version: R1/Development
Keywords: Cc: idefix
Blocked By: Blocking:
Platform: All

Description

Before hrev41258, it was possible to mount a Haiku partition in Linux without root privileges.

Attachments (3)

0001-Allow-non-root-to-mount-BFS-partition-with-bfs_fuse.patch (1.5 KB ) - added by idefix 13 years ago.
Only set allow_other fuse option when user is root
bfs_fuse_non-root (499.8 KB ) - added by luroh 13 years ago.
0002-Allow-non-root-to-mount-BFS-partition-with-bfs_fuse.patch (3.1 KB ) - added by idefix 13 years ago.
Only add FUSE options when user is root (updated commit message)

Download all attachments as: .zip

Change History (16)

comment:1 by idefix, 13 years ago

As far as I can remember, I always had to use sudo to mount a Haiku partition in Ubuntu.

Will look into it...

comment:2 by idefix, 13 years ago

I tried to mount an partition in Linux (Ubuntu 11.10) as a normal user, but it wouldn't let me:
With hrev41257:

jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ mkdir bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ ./bfs_fuse_hrev41257 /dev/sda7 bfs_fuse_mount/
bfs: Mount:329: Bad file descriptor
bfs: bfs_mount:172: Bad file descriptor
Error: Mounting FS failed: Bad file descriptor
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ sudo ./bfs_fuse_hrev41257 /dev/sda7 bfs_fuse_mount/
[sudo] password for jeroen: 
bfs: mounted "Build" (root node at 524288, device = /dev/sda7)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ umount bfs_fuse_mount
umount: /home/jeroen/Builds/Haiku/befs_fuse_bug/bfs_fuse_mount is not in the fstab (and you are not root)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ sudo umount bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ 

With hrev43876:

jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ mkdir bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ ./bfs_fuse_hrev43876 /dev/sda7 bfs_fuse_mount
bfs: Mount:340: Bad file descriptor
bfs: bfs_mount:172: Bad file descriptor
Error: Mounting FS failed: Bad file descriptor
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ sudo ./bfs_fuse_hrev43876 /dev/sda7 bfs_fuse_mount
[sudo] password for jeroen: 
bfs: mounted "Build" (root node at 524288, device = /dev/sda7)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ umount bfs_fuse_mount
umount: /home/jeroen/Builds/Haiku/befs_fuse_bug/bfs_fuse_mount is not in the fstab (and you are not root)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ sudo umount bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ 

When mounting an image, it would let me do it as non-user though.
With hrev41257:

jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ mkdir bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ ./bfs_fuse_hrev41257 haiku-nightly.image bfs_fuse_mount
bfs: mounted "Haiku" (root node at 131072, device = haiku-nightly.image)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ umount bfs_fuse_mount
umount: /home/jeroen/Builds/Haiku/befs_fuse_bug/bfs_fuse_mount is not in the fstab (and you are not root)
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ sudo umount bfs_fuse_mount
[sudo] password for jeroen: 
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ 

But not with hrev43876:

jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ mkdir bfs_fuse_mount
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ ./bfs_fuse_hrev43876 haiku-nightly.image bfs_fuse_mount
bfs: mounted "Haiku" (root node at 131072, device = haiku-nightly.image)
fusermount: failed to open /etc/fuse.conf: Permission denied
fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf
jeroen@Gromit:~/Builds/Haiku/befs_fuse_bug$ 

This is caused by the fuse option allow_other, which is - by default - not allowed when mounting as non-root user.

I created a patch that will only set this option when the user is root.

by idefix, 13 years ago

Only set allow_other fuse option when user is root

comment:3 by idefix, 13 years ago

patch: 01

comment:4 by luroh, 13 years ago

With patch 0001, I confirm that it is now possible to mount an image without being root.

It still doesn't let me mount my /dev/sda1 Haiku partition as non-root though:

fusermount: failed to open /etc/fuse.conf: Permission denied
fusermount: option blkdev is privileged

That said, due to a broken display, I'm currently unable to test on the exact same hardware and Ubuntu installation I was using when I created this ticket, so I'll have to do some more testing next week once I get that display sorted.

comment:5 by idefix, 13 years ago

Does it work when you add yourself to the fuse group?

comment:6 by luroh, 13 years ago

No, but the first row "fusermount: failed to open..." is no longer displayed. I remembered I do have another computer where I am able to mount without being root, and I can confirm that I am not added to the 'fuse' group on that computer.
Mostly for my own reference, I'm attaching an old bfs_fuse binary from that other machine that lets me mount without being root.

by luroh, 13 years ago

Attachment: bfs_fuse_non-root added

comment:7 by idefix, 13 years ago

The problem is that to let bfs_fuse better integrate with Linux (as a mount helper), some FUSE options had to be added. But most of them only work when you are root.

I added a new patch that will only add the FUSE options when the user is root. It should now behave the same as the old bfs_fuse.

comment:8 by luroh, 13 years ago

Seems to work fine here. Mystery solved, thanks. :)

comment:9 by idefix, 13 years ago

Good to hear!

by idefix, 13 years ago

Only add FUSE options when user is root (updated commit message)

comment:11 by luroh, 11 years ago

Fwiw, the patch still applies cleanly and works fine here on 64-bit Linux (hrev47303, gcc2).

comment:12 by luroh, 10 years ago

Milestone: R1Unscheduled

comment:13 by waddlesplash, 9 years ago

Resolution: fixed
Status: newclosed

Applied in hrev50364. Thanks (and apologies for the very long delay!)

Note: See TracTickets for help on using tickets.