LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2005, 07:41 AM   #1
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Rep: Reputation: 15
Unhappy Umask in .bash_profile stopped working


Hi,

I need to set the umask to 007 on files created in my samba shared folders on my CentOS 4.

I added:
Code:
umask 007
in my .bash_profile file in the folder I wanted the umask to be set. I worked. But then, now it does not work any more.

Any clues on why?
 
Old 06-03-2005, 12:22 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally posted by mariusak
my .bash_profile file in the folder I wanted the umask to be set
I'm a little confused about that statement. The way I read it is you've placed a .bash_profile into a directory you want to have a different umask for. That won't work. Bash reads in only one .bash_profile when it starts up, and that file is in your home directory: ~/.bash_profile. Bash will not read any other files; it's not going to scan the current directory to see if there's another .bash_profile to use. So you can't use that as a method to change your umask value.

So you basically have two choices:

1. Change you umask value in ~/.bash_profile. This will change the umask for every file you create.
2. Manually change your umask to 007 when you need to do work in that particular directory, and change it back when you're done.
 
Old 06-03-2005, 03:11 AM   #3
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
Hi,

Sorry about confusing you, the reason why I wrote it like that is that I work with several different home folders. So, I have not made a .bash_profile file in a random folder, I'm speaking about the .bash_profile file in one of my users folders.

The thing is, the changes I make to the .bash_profile file wont work anymore. I even changed the default settings in /etc/bashrc to test, but no effect at all (when doing that I removed the umask in the .bash_profile).

This is my .bash_profile:
Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

umask 007

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
What's wrong?

I have some places read that you have to do umask 007, and other places read that you have to do 0007 (resulting in chmod 770). What's the reason for this. What is correct?

Can please somebody give me an example on how to do a manual umask on a folder?

Thank you for your help!
 
Old 06-03-2005, 05:58 AM   #4
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Hi,

Your .bash_profile looks correct. The only reason your umask should not get exected, is if the file isn't executed at all, or if there is an error in your .bashrc.

I had a similar problem once. To verify that my .bash_profile got executed, I added to the beginning:
Code:
echo -n Loading profile... 1>&2
and to the end
Code:
echo done 1>&2

[ -r ~/.bashrc ] && . ~/.bashrc
And then similar in my .bashrc.

Now, whenever I login, I'm greeted with:
Code:
Loading profile...done
Loading bashrc...done
and know that everything is ok.

It doesn't really matter if you do "umask 007" or "umask 0007". Both 007 and 0007 (and 07, for that matter) represent the same (octal) value: 7.

As far as I know, there is no way to limit the effects of an umask to a single folder. Depending on what you try to do, you can work around this by creating appropriate groups and adding users to them.

You say that umask is not working for you. How do you test this? Somewhere in the beginning of your post, you mention that you are working on samba directoryies. You do know that when accessing directories through samba, your .bash_profile isn't read and hence umask doesn't work? From the smb.conf documentation:

Quote:
create mask (S)

When a file is created, the necessary permissions are calculated according to the mapping from DOS modes to UNIX permissions, and the resulting UNIX mode is then bit-wise 'AND'ed with this parameter. This parameter may be thought of as a bit-wise MASK for the UNIX modes of a file. Any bit not set here will be removed from the modes set on a file when it is created.

The default value of this parameter removes the 'group' and 'other' write and execute bits from the UNIX modes.

Following this Samba will bit-wise 'OR' the UNIX mode created from this parameter with the value of the force create mode parameter which is set to 000 by default.

This parameter does not affect directory modes. See the parameter directory mode for details.
Groetjes,

Kees-Jan
 
Old 06-03-2005, 07:53 AM   #5
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
Hi!

You have no idea how much your reply helped. Until now I did not really understand hos .bash_profile and umask works. I also made another significant discovery; the crate mask = XXX option in smb.conf... -shich for some reason wont work :-)

I really have to buy me a proper samba book now..

Anyway, thanks for your help!

-Off to the book store!

-Marius
 
Old 06-03-2005, 08:05 AM   #6
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
:-)
You're very welcome. Good luck, and please let us know of your progress :-)

Groetjes,

Kees-Jan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
su stopped working bulldogzerofive Linux - Software 5 01-17-2005 02:05 AM
X stopped working sueno Fedora 15 10-02-2004 12:23 PM
It stopped working. UmneyDurak Fedora 8 08-15-2004 02:41 PM
vsftpd umask not working k-bot Linux - Software 1 03-10-2004 04:29 PM
My X just stopped working??? freeindy Linux - Newbie 4 11-30-2002 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration