Trouble with mounting USB stick as user

Oliver Fromme olli at lurza.secnetix.de
Thu Feb 9 06:09:24 PST 2006


[LoN]Kamikaze <LoN_Kamikaze at gmx.de> wrote:
 > Oliver Fromme wrote:
 > > [LoN]Kamikaze <LoN_Kamikaze at gmx.de> wrote:
 > > > I think it's enough when the mount point is owned by the group, without
 > > > belonging to a user. Try:
 > > > # chown :operator /mountpoint
 > > > # chmod 0770 /mountpoint
 > > 
 > > No.  The mount point _must_ be owned by the user.
 > > 
 > > How many times does that have to be repeated until
 > > people get it?  :-)
 > 
 > So why does it work fine on my system?

I don't know.  You either modified the kernel sources so it
works with the group alone, or you are confusing things.

The source code is pretty clear.  The following excerpt is
verbatim (including comment) from src/sys/kern/vfs_mount.c
which implements the mount() syscall.

        /*
         * If the user is not root, ensure that they own the directory
         * onto which we are attempting to mount.
         */
        error = VOP_GETATTR(vp, &va, td->td_ucred, td);
        if (error) {
                vput(vp);
                return (error);
        }
        if (va.va_uid != td->td_ucred->cr_uid) {
                if ((error = suser(td)) != 0) {
                        vput(vp);
                        return (error);
                }
        }

Note that the UID attribute (va_uid) of the vnode which
represents the mount point (vp) is compared with the UID
of the user credentials (cr_uid) from the current thread
(td).  No GIDs involved here, only UIDs.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"... there are two ways of constructing a software design:  One way
is to make it so simple that there are _obviously_ no deficiencies and
the other way is to make it so complicated that there are no _obvious_
deficiencies."        -- C.A.R. Hoare, ACM Turing Award Lecture, 1980


More information about the freebsd-stable mailing list