Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 75825 - captive: mount as user
Summary: captive: mount as user
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Stefan Schweizer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 77239
  Show dependency tree
 
Reported: 2004-12-27 10:42 UTC by Thomas Bettler
Modified: 2005-02-13 13:09 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
lufis-allow-uid-and-gid.patch (lufis-allow-uid-and-gid.patch,909 bytes, patch)
2005-01-02 05:02 UTC, Stefan Schweizer (RETIRED)
Details | Diff
lufis-allow-uid-and-gid.patch (lufis-allow-uid-and-gid.patch,1.06 KB, patch)
2005-01-07 09:41 UTC, Stefan Schweizer (RETIRED)
Details | Diff
/sbin/mount.captive (mount.captive,4.58 KB, text/plain)
2005-01-07 09:44 UTC, Stefan Schweizer (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Bettler 2004-12-27 10:42:52 UTC
common users should also be able to mount captive-partitions accordingly to the definitions
in the /etc/fstab.

Currently neither option user(s) nor uid=<name> works as it should.

A user is only able to mount a device if
1) device is read/write for user
2) mount point is read/write for user

As further error the own user can't even umount it right after:
umount: /mnt/captive mount disagrees with the fstab

/etc/fstab:
/dev/hda1 /mnt/captive captive-ntfs users,uid=1000 0 0

/etc/mtab:
lufis /mnt/captive fuse rw,nosuid,nodev,user=<me> 0 0

one user can't read another users mount, neither root can. In my case I'd like to indicate
that all / multiple users have access to the mounted device. (i.e. with users / uid= )

User support should be improved, but I don't see how to do this best.

Thanks anyway for integrating it into portage and supporting it. I really like your work! Great

Thomas Bettler
Comment 1 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-02 05:02:45 UTC
Created attachment 47369 [details, diff]
lufis-allow-uid-and-gid.patch

patch for lufis to take uid= and gid= parameters, when the program returns
uid=1 or gid=1.
It has no check if the value is valid.

Please test and comment. A valid fstab entry woudl look like:

/dev/hda1 /mnt/captive captive-ntfs defaults,uid=1000,gid=100 0 0
Comment 2 Thomas Bettler 2005-01-02 06:32:14 UTC
Hm, nope. I tried your patch but it didn't help.

I still have to mount the device as the user.

Why do you check uid/gid=1 ? Didn't you mean 0 (root,wheel)?
But I also tried to check uid/gid against 0 - still negative.

In my eyes it would be more consistent to check if uid/gid options are given/valid and depending on that forward these values.

Maybe there is an other part (of lufis or maybe fuse or lufs or captive) involved in setting uid/gid permissions.

If I can help you somehow let me know, I will provide you all the things you'd like.
But I'm no hacker and therefore I'm no way able to fix this bug myself.

Anyway Tanks A Lot for your support so far.
Your advise was really quick and half way helpful on our way to fix it.

Lot of Greetings and a happy new year.
Comment 3 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-02 06:46:43 UTC
What permissions do you have currently? For me it was always the bin group and user, and this patch tries to attach the uid= user when the uid and/or gid is 1(bin).
Comment 4 zhcnmccmzhdvfevooo 2005-01-02 07:32:02 UTC
I also tried the patch now. At my system it is working very good.
Comment 5 Marc Gallagher 2005-01-05 21:17:59 UTC
Two questions:

1) I hate to pollute bugzilla with n00b questions, but how do I apply the patch?  Do I just stick it in the files folder and add a epatch line to the .ebuild?

2) Looking over the patch (and only the patch mind you, as I have no idea where emerge downloads actual files to in order to look at the source), I see these lines:

+    // Take uid= and gid= vars when the filesystem returns 1
+    if(fattr.f_uid == (uid_t) 1) {
+        lu_opt_getint(&lu_cfg, "MOUNT", "uid", &option_uid, 0);
+        fattr.f_uid = (uid_t) option_uid;
+    }
+
+    if(fattr.f_gid == (gid_t) 1) {
+        lu_opt_getint(&lu_cfg, "MOUNT", "gid", &option_gid, 0);
+        fattr.f_gid = (gid_t) option_gid;
+    }

My pure guess as to how lu_opt_getint() works would be that the last param is a default value.  If so, souldn't the above lines of code be reduced to:

lu_opt_getint(&lu_cfg, "MOUNT", "uid", &fattr.f_uid, 0);
lu_opt_getint(&lu_cfg, "MOUNT", "gid", &fattr.f_gid, 0);

If my shot in the dark guess is right, this would set the default owner/group to 0 (root), which seems to be a much better default for the owner/group id's than whatever random numbers NT makes up.
Comment 6 Marc Gallagher 2005-01-05 21:20:54 UTC
On second glance, option_uid and option_gid may still be needed as temp values, but I still suspect we can get rid of the check for 1 as a magic number and always default to root owning the files.
Comment 7 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-06 00:36:46 UTC
Thats one of the problems with the patch .. the last param is no default param, but instead the type of the string->int conversion. I have no default param at all so it takes some nonsense value from the memory when I dont give uid= and gid=.

And sorry, your simplification wont work, because the type is not the same, the type in brackets in the line below is type conversion.

Another problem is, that you cant even read the permissions as user (with or without this patch). They are correct .. but this helps little, when the user cant see and use it.

How to apply the patch?
# emerge lufis
[CTRL+Z] after source unpacked.
# cd /var/tmp/portage/lufis-0.2/work/lufis-0.2
# patch -p1 < /path/to/patch
# fg
Comment 8 Thomas Bettler 2005-01-07 04:12:00 UTC
Still no success, here.
the uid/gid apply, but there is another problem:

if I mount /mnt/captive as root:
and as root ># ls -l /mnt/captive
rw-rw-rw-     1000 100    file1
...
but as user (uid=1000)
>$ ls -l /mnt/captive
ls: /mnt/captive: Permission denied

if I mount /mnt/captive as user everthing works ok and /mnt/captive doen't deny the permission.

Any ideas what might be wrong here?
Comment 9 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-07 09:41:50 UTC
Created attachment 47868 [details, diff]
lufis-allow-uid-and-gid.patch

Better patch, it now avoids strange values if one only gives one of uid= or
gid= or nothing.
Comment 10 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-07 09:44:56 UTC
Created attachment 47869 [details]
/sbin/mount.captive

New /sbin/mount.captive

allows root to mount with full user r/w access, and also allows the user to
umount (if option users is in fstab)
What it not aallows, is mounting as user (yet to come ..)

My fstab entry now:
/dev/hda3		/mnt/captive	captive-ntfs   
defaults,noauto,rw,uid=stefan,users 0 0
Comment 11 Stefan Schweizer (RETIRED) gentoo-dev 2005-01-26 11:28:18 UTC
please test it and comment, tell me that it works for you or give some feedback ..
Comment 12 Lars Petersen 2005-01-27 05:55:43 UTC
Thank you, Stefan! This seems to work for me as far as it should.

Using sys-fs/captive-1.1.5-r1 and sys-fs/lufis-0.2 with your second patch and your new /sbin/mount.captive, I CAN
* mount my NTFS partition as root (but not as user, as you said)
* properly set uid and/or gid by /etc/fstab entry
* unmount my NTFS partition as root and as ANY user
* read from and write to any directory or file as root
* read from and write to directories/files as a normal user according to set permissions

I can NOT
* chmod directories (an "Operation not permitted" error message is issued)
* chmod files (no error message, but no effect either)

FWIW, this is my /etc/fstab entry:
/dev/hdb1  /mnt/winxp  captive-ntfs  rw,users,uid=lars,gid=users,noatime,noauto 0 0
and this is the corresponding output line of `mount`:
/dev/hdb1 on /mnt/winxp type fuse (rw,nosuid,nodev,allow_other,default_permissions)
Comment 13 alistair 2005-02-05 05:30:39 UTC
Stefan - this worked fine for me!

Thanks for all the hard work, i now have full access to NTFS.
Comment 14 zhcnmccmzhdvfevooo 2005-02-05 09:20:39 UTC
It works good here too! :)
Tnx for your work.
Comment 15 Stefan Schweizer (RETIRED) gentoo-dev 2005-02-05 11:46:41 UTC
Is the captive version from
http://dev.gentoo.org/~genstef/files/overlay/sys-fs/captive/
ok for you?

This will also solve bug 77239 as there is no longer a dependancy on gnome-vfs-httpcaptive.
I solved it with an static tarball, if it is not yet on the mirrors, you can get it here:
http://dev.gentoo.org/~genstef/files/overlay/captive-install-static-1.1.5.tar.bz2
Comment 16 Lars Petersen 2005-02-09 00:40:21 UTC
Emerged your ebuild, which pulled in the following:
dev-libs/glib-2.6.2
sys-fs/fuse-2.2
sys-fs/lufis-0.3
sys-fs/captive-1.1.5-r2

Everything works as it used to, PLUS:
I can mount as a normal user now, after creating a /etc/fuse.conf with a line 'user_allow_other'.

Anything else we should test?
Comment 17 Stefan Schweizer (RETIRED) gentoo-dev 2005-02-13 13:09:16 UTC
Thank you all for helping on this bug with testing, its now finally in the tree.