Operating System - HP-UX
1753835 Members
7966 Online
108806 Solutions
New Discussion

Re: Can not access into the mounted point

 
yangk
Frequent Advisor

Can not access into the mounted point

Hi All,

 

I have encountered a problem of accsssing the dirs which is mounted in a chroot environment with non-root user.

 

In a chroot environment , i mount

 

# ll -d /test_dir/
drwxr-xr-x   2 root       sys             96 Aug 30 23:30 /test_dir/
# chmod 700 /test_dir/

# mount -F vxfs /dev/vg00/lvol10 /test_dir/

 

/dev/vg00/lvol10    114688    2165  105498    2% /test_dir

 

and then i su to a not-root  user,

# cd /test_dir/
sh: /test_dir/: Permission denied.

 

I will encounter the permission denied problem.

 

But in non-chroot environment, i will not get this error.

 

Could anyone give a help about this?

 

Thanks in advance!

 

Kevin

4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: Can not access into the mounted point

># chmod 700 /test_dir/

 

I thought this would be a problem.  I.e. someone does look at the permissions under the mount point, when doing operations on what's mounted.

rariasn
Honored Contributor

Re: Can not access into the mounted point

Hi Kevin:

 

First "mount":

 

# mount -F vxfs /dev/vg00/lvol10 /test_dir/

 

and second "chmod":

 

# chmod 700 /test_dir/

 

rgs,

 

 

yangk
Frequent Advisor

Re: Can not access into the mounted point

When using the chmod command after the mount operation, then

i will got the same error.

 

BTW

 

# ll -d /test_glo/

drwx------   2 root       sys             96 Aug 31 00:42 /test_glo/

# mount /dev/vg00/lvol12  /test_glo/

# ll -d /test_glo/

drwxr-xr-x   3 root       root            96 Aug 30 23:00 /test_glo/

 

It seems that the mount operation will change the permission and owner of the dirs.

 

 

Matti_Kurkela
Honored Contributor

Re: Can not access into the mounted point

There are two directories involved:

  • the regular directory /test_glo/ on your root filesystem
  • the root directory of the filesystem located on /dev/vg00/lvol12

Before running the mount command, you see the first directory; after mounting, you see the second one. Both directories have independent owner/group/permission attributes.

 

When you're using a directory as a mount point, the permissions of the directory that is used as a mount point don't usually matter very much; the directory just has to exist. In situations where it's likely that a filesystem might be unmounted while someone tries to use it, I sometimes deliberately leave a zero-length file in the mount point directory before mounting a filesystem on it:

 

mkdir /mountpoint

touch /mountpoint/Filesystem_not_mounted

chmod 444 /mountpoint/Filesystem_not_mounted

chmod 555 /mountpoint

 

ll /mountpoint

-r--r--r-- 1 root root 0 Sep  1 08:00 Filesystem_not_mounted

<Now you'll see it...>

 

mount /dev/vgSOME/lvolOTHER /mountpoint

ll /mountpoint

drwx------ 2 root root 60 Sep  1 08:00 lost+found

<...now you won't!>

 

Assuming that /dev/vgSOME/lvolOTHER is a freshly-created filesystem, its root directory will only contain the "lost+found" directory. The original /mountpoint directory is hidden when the mount command pastes the root directory of /dev/vgSOME/lvolOTHER over it; the "Filesystem_not_mounted" file will be visible only when the /dev/vgSOME/lvolOTHER is not mounted. The name of the file should give sleepy night-shift operators a quick clue of what's wrong...

MK