LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   stupid permissions! *need your help* (https://www.linuxquestions.org/questions/linux-hardware-18/stupid-permissions-%2Aneed-your-help%2A-342533/)

HKJGN 07-12-2005 02:06 PM

stupid permissions! *need your help*
 
ive been running smooth since i sarted using linux except for one thing, i have absolutely no way to enter my hdb1 storage drive unless i am in root, i understand that theres lots of permissions in linux to keep people from ruining thier pc but i really dislike having to log back in to view the contents of my hard drive, so if someone could tell me how i could view my second hard drive in my username please tell me, im an awful person at googling and i wouldnt come here unless i had no way of finding an answer ~_~ im using slackware 10.1, thanks

Half_Elf 07-12-2005 02:15 PM

what is your drive filesystem?

HKJGN 07-12-2005 02:16 PM

NTFS on hdb1, ext2 on my linux drive, a while back i had windows, my 80 gig hard drive was all just a big dump bin of files

Half_Elf 07-12-2005 03:19 PM

edit /etc/fstab and add "umask=022" to the option (4th column) for that partition, separated by a comma. If you only have "defaults" there, remove it and replace it with "umask=022" instead of adding it.

As example, here is my line about a FAT32 partition (I dont use NTFS here) :
/dev/hda7 /mnt/win_d vfat umask=022 1 2

peter72 07-12-2005 04:08 PM

2 things.
First be warned that writing to NTFS, as you could corrupt that partition totally and blow away your windows install.

2nd is, you can map the NTFS partition to a particular user or group which is a little nicer.

Code:

edit /etc/fstab

to write to that partition ( note above warning )
/dev/hda6 /mnt/win_d ntfs uid=linuxuser,gid=linuxgroup,umask=002 1 2

to just read from partition
/dev/hda6 /mnt/win_d ntfs uid=linuxuser,gid=linuxgroup,umask=222 1 2


The umask gives a the linuxgroup read/write access to that partition also. Also mapping to particular user works for fat32 partitions.

HKJGN 07-12-2005 11:29 PM

thnks, and i dont really have windows installation, and i dont really want to ever use it again, it was just a formatted storage drive i used, all i really want is to read it, thnks tho ^_^

*edit* yeah, niether worked, the umask did absolutley nothing, and apparently ive forgotten what # is the gid, i was sure it was root, but it still wont let me connect.... so i dont know

HKJGN 07-18-2005 12:08 AM

grrr, now even with these settings, it still wont let my user access it x_x please help.....

Half_Elf 07-18-2005 06:30 AM

can you show us the line you added exactly? This should work so I believe there is something wrong about your line.

HKJGN 07-23-2005 12:02 AM

/dev/hdb1 /storage ntfs uid=1001,gid=100,umask=222 1 2

worked, then didnt work, i checked and double checked and double doublechecked the uid gid.... i dunno anymore...

mlp68 07-23-2005 05:20 PM

Try to make your uid 1001 the owner of the /storage directory.

Also, you shoot yourself in the foot with umask=222 instead of 022. Those mean the bits that are OFF in the permissions. So the 222 mask means you get 555, or r-xr-xr-x, but you want rwx for the owner, 755 for the bits, so set 022 for the umask.

Also, you could add "user" to the mount options, allowing yourself, not root, to mount that area if you don't want it all the time. Then also add noauto so it gets mounted only on demand.

Good luck,

mlp

ayteebee 07-26-2005 01:30 PM

I'm a newbie myself, but I know a very small amount about access permissions (ie, what it says in the Suse manual).

These are the things I would try:

Quote:

Also, you could add "user" to the mount options, allowing yourself, not root, to mount that area if you don't want it all the time. Then also add noauto so it gets mounted only on demand.
I would try that first... this is what mlp68 means (I don't know what level you are with linux, so I'll explain as best I can: a newbie is bound to read this at some stage!)

This is an example of the contents from my /etc/fstab file:

Code:

/dev/hdb1            /backup/hdb1        vfat      user,noauto          0 0
/dev/hdb2            /backup/hdb2        ext2      user,noauto,noacl    0 0

The first column is the device name, the second column is where it mounts to, the third column is the filesystem, fourth the mount options... And I don't know what the last column is!

Having "user" specified in the fourth column means that any user can mount it, not just root. However this only means that users can mount it. It doesn't mean that they can access it (I think that's what you were trying to resolve with "umask=222" and stuff, but I don't really understand that yet!)

The second thing I would try is this:

Mount the hard disk
Type the following:
Code:

cd /
ls -l storage

This brings up the following (on my system the directory is empty; I just created it for the demonstration):
Code:

linux:/ # ls -l storage
total 1
drwxr-xr-x  2 root root  48 2005-07-26 18:43 .
drwxr-xr-x  33 root root 784 2005-07-26 18:43 ..
linux:/ #

The "ls -l storage" command shows a detailed list of the contents of the directory "storage".
The part we are concerned about is the second line of the output from the command (that is, the line which has the single full stop at the end):
"drwxr-xr-x 2 root root 48 2005-07-26 18:43 ."
The "drwxr-xr-x" shows the access permissions, this is how to read them:
"d" signifies it is a directory ("-" is a file, "l" is a link, etc)
Then there is a bunch of characters, rwxr-xr-x
The first rwx means the owner can read files from the directory, write to files in the directory (including creating new files/directories) and execute the directory (executing a directory means opening it)
The second and third sets of "r-x" therefore signify that members of the group owning the file, and all other users, can only read files inside the directory, and look at what is in the directory. They cannot modify files or add files to the directory.

The access permissions can be changed using the following command (called from the root (/) directory):
Code:

chmod u+rwx,g+rwx,o+rwx storage
This will give EVERYONE (user, group and all others) permission to access, modify, delete etc anything inside /storage.
If you type "ls -l storage" again, you will see that the changes are reflected in the directory listing:
Code:

linux:/ # ls -l storage
total 1
drwxrwxrwx  2 root root  48 2005-07-26 18:43 .
drwxr-xr-x  33 root root 784 2005-07-26 18:43 ..
linux:/ #

If you now want to DENY other people permission to write to the file, type:
Code:

chmod o-w storage
You can play around with that, but I recommend doing it on an empty file first (just in case! :-P)

Possible problems with this could be:
1) I don't know whether the access permissions will be inheritable within the directory: If you create a new file, for example, I don't know what access permissions it will have. This could be what the whole "umask=022" stuff was about, but like I said, I don't understand that!

2) I don't know if this will work with NTFS filesystems. I think it should but I think you need the Linux ACL (Access Control Lists) on the filesystem, and I don't know much about filesystems so I couldn't tell you.


Well I think that's all I have to say on the issue! Probably nothing you didn't already know, but hey.
I don't know if any of this will work on your distro or anything, but it may be useful to someone.

Oh, This is my first post on a Forum, so if I'm talking Jack will someone please beat it out of me?!
Cheers.

HKJGN 07-27-2005 12:58 PM

the drive is mounted read only. i cant change permissions, even in root, if i could have made
it that easy i would have =P.i tried about a hundred times. its how the device is mounted. but
when i mount it rw it doesnt even mount, maybe because the entire drive is ntfs...

mlp68 07-28-2005 06:58 PM

Let's try again, give us a bit more info. Please send us some output of:

id <nameyouruserwithuid1001>

your current /etc/fstab

after the disk is mounted, the output of

mount

and a few lines of

ls -l /storage


It's true that you cannot *change* permission in a readonly filesystem. The idea is still that the mount options make it so that the files appear with the right permissions and, more importantly, owner from the beginning.

Then, you could recompile your kernel with NTFS write support, but it's still marked as dangerous. If all you need is to read the files that you already have on the disk, it's going to work this way.

mlp

truthstreamdotorg 08-24-2005 12:34 AM

I appear to have the same exact problem as this person. I too have no permission, even as root, to change the permissions of the drive. I have an sata drive that somehow got partitioned into 3 parts that show up under the /windows mount as C, D and E. Here are the answers to the questions you asked the last guy for my situation:

Quote:

Originally posted by mlp68
Let's try again, give us a bit more info. Please send us some output of:

id <nameyouruserwithuid1001>



uid=1000(phish420) gid=100(users) groups=100(users),16(dialout),33(video)

Quote:

your current /etc/fstab
/dev/hdc2 / reiserfs acl,user_xattr 1 1
/dev/hdc1 swap swap pri=42 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
proc /proc proc defaults 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
sysfs /sys sysfs noauto 0 0
/dev/dvdrecorder /media/dvdrecorder subfs fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8 0 0
/dev/fd0 /media/floppy subfs fs=floppyfss,procuid,nodev,nosuid,sync 0 0
/dev/sda4 /windows/c ntfs umask=022 0 0
/dev/sda5 /windows/d ntfs umask=022 0 0
/dev/sda6 /windows/e ntfs umask=022 0 0

Quote:

after the disk is mounted, the output of

mount
linux:/windows # mount
/dev/hdc2 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda on /media/dvdrecorder type subfs (ro,nosuid,nodev,fs=cdfss,procuid,iocharset=utf8)
/dev/fd0 on /media/floppy type subfs (rw,nosuid,nodev,sync,fs=floppyfss,procuid)
/dev/sda4 on /windows/c type ntfs (rw,umask=022)
/dev/sda5 on /windows/d type ntfs (rw,umask=022)
/dev/sda6 on /windows/e type ntfs (rw,umask=022)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdc1 on /media/usb-0200387914:0:0:1p1 type subfs (rw,noexec,nosuid,nodev,sync,procuid,iocharset=utf8)

Quote:

and a few lines of

ls -l /storage
linux:/windows # cd /
linux:/ # ls -l /storage
/bin/ls: /storage: No such file or directory
linux:/ # ls -l /windows
total 21
drwxrwxrwx 5 root root 120 2005-08-23 21:58 .
drwxr-xr-x 23 root root 536 2005-08-24 01:02 ..
dr-xr-xr-x 1 root root 12288 2005-08-23 19:03 c
dr-xr-xr-x 1 root root 4096 2005-08-23 19:03 d
dr-xr-xr-x 1 root root 4096 2005-08-23 19:03 e

Quote:

It's true that you cannot *change* permission in a readonly filesystem. The idea is still that the mount options make it so that the files appear with the right permissions and, more importantly, owner from the beginning.

Then, you could recompile your kernel with NTFS write support, but it's still marked as dangerous. If all you need is to read the files that you already have on the disk, it's going to work this way.

mlp
I still dont know how to 'recompile a kernel' and would love to be pointed to a decent how to on how to do this with this ntfs write support you are talking about.
Also, here is the output of me trying to change the permissions as suggested above:

linux:/windows # chmod u+rwx,g+rwx,o+rwx c
chmod: changing permissions of `c': Read-only file system

Oh, and I am running Suse 9.2 on a 64bit athlon. The drive, as I said is sata and does not have any windows install that I am concerened about - only video files for the most part.

mlp68 08-24-2005 05:43 AM

Again, in a read-only file system, you cannot change anything after it's mounted -- your chmod MUST fail. That's why we make the mount options so that the files ownerships appear right from the get-go. You will be able to read the files, but not be able to change anything, including permissions.

I looked it up on one of "my" machines that has a similar setup; /dev/hda1 is a NTFS winxp partition, the linux installation lives on hdb. I mount hda1 as /winxp.

The designated owner (Peter) is uid=199,gid=100.

Here is the line in /etc/fstab:

/dev/hda1 /winxp ntfs uid=199,gid=100,ro 0 0

This mounts the partition and all files in there appear to be owned by peter:

Code:

# ls -l /winxp/
total 1966052
-r--------  1 peter users          0 Jan 16  2003 AUTOEXEC.BAT
-r--------  1 peter users          0 Jan 16  2003 CONFIG.SYS
dr-x------  1 peter users      4096 Apr 24 01:29 Documents and Settings
-r--------  1 peter users          0 Jan 16  2003 IO.SYS
-r--------  1 peter users        92 Apr  5  2004 IPH.PH
dr-x------  1 peter users      4096 Nov 20  2004 KPCMS
-r--------  1 peter users          0 Jan 16  2003 MSDOS.SYS
dr-x------  1 peter users          0 Dec 13  2003 MWASPI
-r--------  1 peter users      47580 Aug 29  2002 NTDETECT.COM
dr-x------  1 peter users      12288 Dec 24  2004 Palm
dr-x------  1 peter users      12288 May  6 21:52 Program Files
dr-x------  1 peter users      4096 Oct 12  2003 RECYCLER
dr-x------  1 peter users          0 Jan 16  2003 System Volume Information
dr-x------  1 peter users      45056 May  6 22:00 WINDOWS
-r--------  1 peter users        194 Jan 16  2003 boot.ini
dr-x------  1 peter users      4096 Jan 28  2003 cygwin
-r--------  1 peter users  804835328 Jun  3 15:52 hiberfil.sys
-r--------  1 peter users    233632 Aug 29  2002 ntldr
-r--------  1 peter users 1207959552 Jun  3 15:52 pagefile.sys
dr-x------  1 peter users      12288 May  8 20:07 w3av

and Mr Peter can read every file on there - they're his.

In your case, change the lines to

/dev/sda4 /windows/c ntfs uid=1000,gid=100,ro 0 0
/dev/sda5 /windows/d ntfs uid=1000,gid=100,ro 0 0
/dev/sda6 /windows/e ntfs uid=1000,gid=100,ro 0 0

The "ro" is just to be specific.

With the kernel, I have never used SuSE and there may be specific instructions where to find what, but there are plenty of step-by-step guides, e.g. http://www.linuxdocs.org/HOWTOs/Kernel-HOWTO.html

Still I would not mess with the ntfs partition if the above is good enough.

Hope it helps,
mlp


All times are GMT -5. The time now is 03:01 AM.