Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: User

OT: mount so that other users can write to mounted dir?

 

 

Gentoo user RSS feed   Index | Next | Previous | View Threaded


waltdnes at waltdnes

May 22, 2012, 5:26 PM

Post #1 of 4 (570 views)
Permalink
OT: mount so that other users can write to mounted dir?

I'm not really a fan of automount, but I understand that lots of
people are. I'm trying to get it fully functional under mdev, and then
do a write-up on the wiki page. A Google search turns up lots of
examples of code. However, the examples are for embedded devices, and
they assume the only user is root. I've got the automounting and
autounmounting working. Everybody can read the mounted USB stick, but
only root can write. I've tried pmount with the umask option, but it
doesn't help. Assume the scrpt gets passed MDEV="sdb1"

#
# Create the directory in /media
mkdir -p /media/${MDEV}
#
# Change permissions to allow read+write by all
chmod 777 /media/${MDEV}
#
# Mount the directory in /media
pmount --noatime --umask 000 /dev/${MDEV}

But after the mount...
user2 [at] aa /media $ ll
total 3
drwxr-xr-x 3 root root 1024 May 22 19:02 .
drwxr-xr-x 19 root root 1024 May 21 20:41 ..
drwxr-xr-x 5 root root 1024 May 16 01:42 sdb1

Every directory and file belongs to user:group root:root. On the USB
stick all directories are 755 and files are 744. As a heavy-handed ugly
hack, I could...

chgrp -R users /media/${MDEV}
chmod -R g+w /media/${MDEV}

to a USB stick. I obviously don't wnt to do that on the external USB
drive that I rsync my system to every few weeks. Any ideas? And oh
yes, I do realize I'm trying to re-invent the wheel. The old one has
a broken udev :(

--
Walter Dnes <waltdnes [at] waltdnes>


alan.mckinnon at gmail

May 22, 2012, 5:42 PM

Post #2 of 4 (537 views)
Permalink
Re: OT: mount so that other users can write to mounted dir? [In reply to]

On Tue, 22 May 2012 20:26:03 -0400
"Walter Dnes" <waltdnes [at] waltdnes> wrote:

> I'm not really a fan of automount, but I understand that lots of
> people are. I'm trying to get it fully functional under mdev, and
> then do a write-up on the wiki page. A Google search turns up lots of
> examples of code. However, the examples are for embedded devices, and
> they assume the only user is root. I've got the automounting and
> autounmounting working. Everybody can read the mounted USB stick, but
> only root can write. I've tried pmount with the umask option, but it
> doesn't help. Assume the scrpt gets passed MDEV="sdb1"
>
> #
> # Create the directory in /media
> mkdir -p /media/${MDEV}
> #
> # Change permissions to allow read+write by all
> chmod 777 /media/${MDEV}
> #
> # Mount the directory in /media
> pmount --noatime --umask 000 /dev/${MDEV}
>
> But after the mount...
> user2 [at] aa /media $ ll
> total 3
> drwxr-xr-x 3 root root 1024 May 22 19:02 .
> drwxr-xr-x 19 root root 1024 May 21 20:41 ..
> drwxr-xr-x 5 root root 1024 May 16 01:42 sdb1
>
> Every directory and file belongs to user:group root:root. On the
> USB stick all directories are 755 and files are 744. As a
> heavy-handed ugly hack, I could...
>
> chgrp -R users /media/${MDEV}
> chmod -R g+w /media/${MDEV}
>
> to a USB stick. I obviously don't wnt to do that on the external USB
> drive that I rsync my system to every few weeks. Any ideas? And oh
> yes, I do realize I'm trying to re-invent the wheel. The old one has
> a broken udev :(
>

What filesystem is on that stick?

For vfat and ntfs what you are truing should work.
For Unix file systems (ext*, reiser, etc), it will not work. You cannot
override owners and permissions with the mount command on those.




--
Alan McKinnnon
alan.mckinnon [at] gmail


waltdnes at waltdnes

May 23, 2012, 4:25 PM

Post #3 of 4 (534 views)
Permalink
Re: OT: mount so that other users can write to mounted dir? [In reply to]

On Wed, May 23, 2012 at 02:42:46AM +0200, Alan McKinnon wrote

> What filesystem is on that stick?
>
> For vfat and ntfs what you are truing should work. For Unix file
> systems (ext*, reiser, etc), it will not work. You cannot override
> owners and permissions with the mount command on those.

Thanks. That approach won't work in the general case. I'll probably
have to change the command in my "mdev rules" to something like...

sudo -u waltdnes pmount blah blah blah

...where "waltdnes" is my regular user account. That'll also allow me
to unmount it with the pumount command from my regular account.

In the case of my backups to an external USB drive, I have to be root
anyways, so I'll just...

* plug in the external drive
* unmount it after the automount
* remount it manually as root

...and proceed from there.

--
Walter Dnes <waltdnes [at] waltdnes>


waltdnes at waltdnes

May 24, 2012, 12:41 AM

Post #4 of 4 (532 views)
Permalink
Re: OT: mount so that other users can write to mounted dir? [In reply to]

On Wed, May 23, 2012 at 02:42:46AM +0200, Alan McKinnon wrote

> What filesystem is on that stick?
>
> For vfat and ntfs what you are truing should work.
> For Unix file systems (ext*, reiser, etc), it will not work. You cannot
> override owners and permissions with the mount command on those.

Thanks. That does make sense. I wouldn't want my regular user
account to be able to do stuff to root's files on my external backup
(reiserfs). Experimentation confirms that posix/linux filesystems mount
with the mountpoint being user:root and group:root when mounted or
pmounted by root. FAT32 etc mounts as user:root and group:plugdev.
Making my user account a member of the plugdev group, and pmounting with
umask 007 allows me to do whatever I want to files on the USB stick. So
I guess FAT32 has its uses.

One last sticking point is manual unmounting. You obviously want to
unmount properly before disconnecting a USB key or drive, if you've done
any writing to it. If the pmount is done as root, pumount or umount has
to be done as root. What's the proper sudoers wildcard syntax for
unmounting a mountpoint under /media? Does this look OK?

waltdnes d531 = (root) NOPASSWD: /bin/umount /media/sd[a-z][1-9]

--
Walter Dnes <waltdnes [at] waltdnes>

Gentoo user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.