Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved]Mountpoint shouldn't belong to root after mount.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Sujao
l33t
l33t


Joined: 25 Sep 2004
Posts: 677
Location: Germany

PostPosted: Sat Jun 23, 2007 10:10 am    Post subject: [solved]Mountpoint shouldn't belong to root after mount. Reply with quote

Hi all,

I have a folder hirarchy for my media, were different harddrives are mounted. For example:
Code:
/media
/media/A
/media/B
/media/music (this is a mount point for harddrive 1)
/media/C
/media/D
/media/video (this is a mount point for harddrive 2)


/media itself and everyhing below it belongs to me:media and is 640 (750 for folders). So only I am allowed to write but every member of media is allowed to read. I activated sgid, suid in the /media folder and so now the group-uid is set to every file that is created in /media (the uid is not set, but that is another problem).

OK the problem is this: When the /etc/fstab mounts something to /media/music or /media/video it does that with root so both mountpoints belong to root:root then and me and my media-users cant access this folder anymore.

Is see several solutions:
  1. Force mount to NOT set root as the user and group of a mount point. A friend of mine told me that this is impossible.
  2. Tell fstab to run this mount as me. so that it belongs to me afterwards AND set the group to media.
  3. Just let fstab mount it as root:root and then add "chown me:media /media/music" to /etc/init.d/localmount


Solution 3 should work for sure but is the ugliest of them. So I wonder whether 1 or 2 could be done. Or maybe you have some completely different solution for this problem.


Last edited by Sujao on Sun Jun 24, 2007 3:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Sat Jun 23, 2007 10:32 am    Post subject: Re: Mountpoint shouldn't belong to root after mount. Reply with quote

Sujao wrote:
Force mount to NOT set root as the user and group of a mount point.

E.g. in /etc/fstab
Code:
/dev/pendrive1    /media/pendrive     vfat    noauto,noatime,user,flush,gid=100,umask=007     0 0

Read man mount
Back to top
View user's profile Send private message
Sujao
l33t
l33t


Joined: 25 Sep 2004
Posts: 677
Location: Germany

PostPosted: Sat Jun 23, 2007 11:01 am    Post subject: Re: Mountpoint shouldn't belong to root after mount. Reply with quote

PaulBredbury wrote:
Sujao wrote:
Force mount to NOT set root as the user and group of a mount point.

E.g. in /etc/fstab
Code:
/dev/pendrive1    /media/pendrive     vfat    noauto,noatime,user,flush,gid=100,umask=007     0 0

Read man mount


1.)gid, umask only works for fat
2.)I want the MOUNT POINT to not change its ownership NOT the files within.

I will refrain from writing a polemic:
Read man mount
Read my post
as I assume that it wasn't meant as RTFM. :wink:
Back to top
View user's profile Send private message
didl
Retired Dev
Retired Dev


Joined: 09 Sep 2003
Posts: 1106
Location: Pittsburgh, PA

PostPosted: Sat Jun 23, 2007 12:32 pm    Post subject: Reply with quote

Why not make the mount point root:root with mode 777?
The stuff inside then has the approriate permissions such as
me:group and 750/640 for folders/files.
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1746

PostPosted: Sat Jun 23, 2007 1:23 pm    Post subject: Reply with quote

Try this:

Make sure the mount point is unmounted (e.g. umount /media/music) then:

Make the mount point root:root ( chown root:root /media/music )

Mount the disk ( mount /media/music )

Su to root, then goto the mount point:
su
cd /media/music

Then change ownership of the disk root:
chown me:media .


The first two steps are completely unecessary, but make things a bit more secure (Otherwise there is a possibility of unwanted things getting into the unmounted area).

The trick is making the root of the mounted volume owned by you and your group. Trying to change it via mount is a red herring - The permissions of the root are loaded from the volume itself.

I use this with my USB gear which is ext3 formatted; Don't know how well it works with other formats.

I think you HAVE to go into the volume and set it via . for this to work - If you specify the path, it seems to just change the mount point and not the volume...
Back to top
View user's profile Send private message
Sujao
l33t
l33t


Joined: 25 Sep 2004
Posts: 677
Location: Germany

PostPosted: Sat Jun 23, 2007 4:41 pm    Post subject: Reply with quote

didl wrote:
Why not make the mount point root:root with mode 777?
The stuff inside then has the approriate permissions such as
me:group and 750/640 for folders/files.


Yeah, actually you are right, if the setuid and setgid works properly the content of these folders would be locked. I didn't realize that.

Cyker wrote:
Try this:

Make sure the mount point is unmounted (e.g. umount /media/music) then:

Make the mount point root:root ( chown root:root /media/music )

Mount the disk ( mount /media/music )

Su to root, then goto the mount point:
su
cd /media/music

Then change ownership of the disk root:
chown me:media .


The first two steps are completely unecessary, but make things a bit more secure (Otherwise there is a possibility of unwanted things getting into the unmounted area).

The trick is making the root of the mounted volume owned by you and your group. Trying to change it via mount is a red herring - The permissions of the root are loaded from the volume itself.

I use this with my USB gear which is ext3 formatted; Don't know how well it works with other formats.

I think you HAVE to go into the volume and set it via . for this to work - If you specify the path, it seems to just change the mount point and not the volume...


I was preparing to do it and was checking how exactly the permissions change and what happens now is that the permissions aren't changed to root:root anymore. Maybe my override (see solution 3) was cached and reaplied when remount the hdd. I will check again when I rebooted (can't do that right now) and than try your solution.
Back to top
View user's profile Send private message
Sujao
l33t
l33t


Joined: 25 Sep 2004
Posts: 677
Location: Germany

PostPosted: Sun Jun 24, 2007 3:50 pm    Post subject: Reply with quote

OK seems the problem is gone. I don't know how but the system seems to have remeberd my ownership changes, even after reboot. If somebody knows why then please enlighten me! :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum