LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Question concerning fstab, umask, chmod and executable files (https://www.linuxquestions.org/questions/linux-general-1/question-concerning-fstab-umask-chmod-and-executable-files-713301/)

pmdkh 03-21-2009 01:31 AM

Question concerning fstab, umask, chmod and executable files
 
I have a question concerning umask, chmod, and why files on a certain partition won't become non-executable. I have a FAT partition that holds mostly music. I don't want the music files to be executable, but I can't figure out how to make them non-executable. The partition in questions is /dev/sda6, mounted at /data.

Some things that I have tried are:

Code:

chmod a-x <file name>
E.g.:

Code:

pmdkh@localhost:/data/Music$ ls -al test
-rwxr-xr-x 1 pmdkh pmdkh 0 2009-03-21 00:59 test
pmdkh@localhost:/data/Music$ chmod a-x test
pmdkh@localhost:/data/Music$ ls -al test
-rwxr-xr-x 1 pmdkh pmdkh 0 2009-03-21 00:59 test

I've tried changing the umask in /etc/profile and in /etc/fstab. I've also tried using the umask command directly and then creating a file, but it doesn't seem to work. For example:

Code:

pmdkh@localhost:/data/Music$ umask -S
u=r,g=r,o=r
pmdkh@localhost:/data/Music$ touch test
pmdkh@localhost:/data/Music$ ls -al test
-rwxr-xr-x 1 pmdkh pmdkh 0 2009-03-21 00:59 test

Here is the fstab:

Code:

pmdkh@localhost:/data/Music$ cat /etc/fstab
# /etc/fstab: static file system information
#
# <file system>        <dir>        <type>    <options>          <dump> <pass>
none                  /dev/pts      devpts    defaults            0      0
none                  /dev/shm      tmpfs    defaults            0      0

/dev/cdrom /media/cdrom  auto ro,user,noauto,unhide  0      0
/dev/dvd /media/dvd  udf  ro,user,noauto,unhide  0      0
/dev/sda2 swap swap defaults 0 0
/dev/sda5 / ext3 defaults 0 1
#/dev/sda3 /media/sda3 ext3 defaults 0 1
/dev/sda6 /data vfat noexec,uid=1000,gid=1000 0 0
/dev/sda1 /media/sda1 ntfs-3g defaults,locale=en_US.utf8 0 0

The applicable line in /etc/profile reads:

Code:

umask 022
I don't experience this unexpected behavior under my home directory (/dev/sda5, mounted at /). E.g,:

Code:

pmdkh@localhost:~$ umask -S
u=r,g=r,o=r
pmdkh@localhost:~$ touch test
pmdkh@localhost:~$ ls -al test
-r--r--r-- 1 pmdkh pmdkh 0 2009-03-21 01:23 test

I know that there are other threads about this same subject on Linux Questions (and I've read some of them), but I feel like I'm going around in circles and missing something obvious here, so that's why I've decided to ask the question again.

I'm using Arch Linux. Let me know if I need to provide more information. Thanks for any help.

x_terminat_or_3 03-21-2009 02:58 AM

vfat doesn't support setting/removing Linux type permissions.

To turn of all exec functions on that partition, change your fstab to add to noexec option to the mount that mounts your vfat.

pmdkh 03-21-2009 03:48 AM

Quote:

Originally Posted by x_terminat_or_3 (Post 3482870)
vfat doesn't support setting/removing Linux type permissions.

To turn of all exec functions on that partition, change your fstab to add to noexec option to the mount that mounts your vfat.

Ok. Thanks for the info concerning vfat partitions. I didn't realize that. I searched the Internet some more after learning that and I came across the answer to my problem. Basically, I needed to set a dmask and fmask value in my fstab. Here is the new fstab line:

Code:

/dev/sda6 /data vfat uid=1000,gid=1000,fmask=133,dmask=022 0 0
Everything is working fine now. I took the noexec option out (even though the default is exec) because it wasn't working by itself, and now there is no chance a file will be executable anyways. However, if my reasoning is faulty, please let me know. Thanks for your help.

x_terminat_or_3 03-21-2009 01:06 PM

Please note that, even when a file is not executable, it is still often possible to execute it, certainly if it is not a binary.

Scripts, for one, can be executed by calling the interpreter and giving it as option the name of the script.

For instance

Code:

/bin/bash /data/myscript.sh

/usr/bin/perl /data/myscript.pl

/usr/bin/ruby /data/myscript.ruby

All of the above will work, provided those scripts actually exist.

pmdkh 03-21-2009 11:31 PM

Quote:

Originally Posted by x_terminat_or_3 (Post 3483306)
Please note that, even when a file is not executable, it is still often possible to execute it, certainly if it is not a binary.

Scripts, for one, can be executed by calling the interpreter and giving it as option the name of the script.

For instance

Code:

/bin/bash /data/myscript.sh

/usr/bin/perl /data/myscript.pl

/usr/bin/ruby /data/myscript.ruby

All of the above will work, provided those scripts actually exist.

Ok. Thanks for the heads up.


All times are GMT -5. The time now is 02:57 PM.