Link to home
Start Free TrialLog in
Avatar of NorCal1876
NorCal1876

asked on

basic umask and /etc/fstab question

Hello all,

I have about 2 years of Linux experience, but I haven't had a reason to learn about umask until just recently.
I am working on a RedHat 2.1 Advanced Server box.
I am trying to set up a non-root user for routine system maintenance, and I need new files created on the box to allow full permissions to both root and members of the file's group.

# umask
# 022
# >newfile
# ll -ha newfile
# rw-r--r-- newfile .... etc....

The output above is what I get normally.
Now, I changed the umask manually and tested it like this:

# umask 002
# 002
# >newfile-afterchange
# ll -ha newfile-afterchange
# rw-rw-r-- newfile-afterchange .... etc....

Now... this is perfect; however, I'm not exactly sure I'm doing this correctly because I sometimes see umask formats as three digits and sometimes as four? i.e. 022 or 0022

1. Is there a difference in format? And, if so, what is it?

Secondly, I attempted, on a test server, to set up the umask in fstab in order to persist between reboots.
My root partition had the options field in the /etc/fstab file set to "defaults" before the change.
I changed the options field by deleting the "defaults" option and adding the following:

umask=0002

I rebooted and now it thinks the FS is read-only... so....

2. How do I correctly set up fstab to mount my root partition with the desired umask of 0002?

And...

3. How can I fix the test server and get it working again?? And, is there something I'm missing about umask in general? I thought it was just something to set the file permissions on newly created files but it seems to be causing strange errors....

Thank you very much in advance!

-t
SOLUTION
Avatar of xDamox
xDamox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NorCal1876
NorCal1876

ASKER

Okay, so do you have any idea why after setting the umask in fstab, it mounted my filesystem as read-only?

What does "defaults" imply in the /etc/fstab file?

Thanks!

-t
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1) Ah okay thanks.

2) Well, if I manually set the umask to 002, files created have the correct permissions; however, after reboot, the umask returns to the default value of 022.

The scenario is as follows:

the /usr/interbase/databases directory - owned by root, admin group, has the setguid bit set, permissions 775

All files in the /usr/interbase/databases directory are owned by root, admin group, with permissions 664

my new user is a member of the admin group

I need all new files created in this directory to have 664 permissions... with the default umask of 022, new files are created with 644 permissions

Does this clarify things at all??

Thanks for the help!

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> To have the umask survive a reboot you need to set the umask in the user's login init script (typically ~/.bashrc). I'd recommend against changing it system wide as that may open security holes in other places.

Brilliant!!

Alright guys, thanks! :P
As EinarTh already pointed out - first number in 4-digit umask is for special bits.

As for the read-only filesystem - defaults parameter says mount to use the following parameters: rw, suid, dev, exec, auto, nouser and async. Since you deleted the defaults parameter, you removed rw parameter as well. That's why your FS is read only.

Furthermore, you said you try to set umask parameter for your root filesystem. I guess your filesystem is something like ext2/ext3. AFAIK umask parameter is not supported on ext2/ext3 filesystem (check 'man mount'). Check dmesg or /var/log/messages. You'll probably find something like:
...
EXT3-fs: Unrecognized mount option umask
...

P.S.
If I'm wrong and umask is supported on ext2/ext3 filesystem, then just readd defaults to your /etc/fstab entry and you should have no problem!