LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-28-2007, 10:11 AM   #1
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slack(64|32)_v(13.37|14.0), debian6, ubuntu
Posts: 630

Rep: Reputation: 36
how can i do a global umask 0000 ?


hello everyone,
i know this sounds dreadful and scary, but i need to do it.
i need in the debian system i am on to tweak smth somewhere in a config file
that will enable an application that i am writing in c++ and which saves to files in the system, to do so in a manner that everyone is able to RW in those files.

im saving this files in a folder under /var/log/...

i have already changed /etc/profile to have value: umask 000.
but it didnt work. whenever i get a konsole window and i type umask it returns 0022 to me..
any ideas?
nass
 
Old 03-28-2007, 10:34 AM   #2
jim_fields
Member
 
Registered: Nov 2006
Distribution: Slackware 11.0, Debian Lenny, testing
Posts: 32

Rep: Reputation: 16
Are you sure that you are <I>subtracting</I> the value you want from 666 for files or 777 for directories? i.e. If you want a umask of 000 you would use 666 as the value to umask.
 
Old 03-28-2007, 11:03 AM   #3
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 46
I know it's not what you're asking, but couldn't you just have the program "chmod 777" any files it creates, rather than messing around with umask?
 
Old 03-28-2007, 02:11 PM   #4
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slack(64|32)_v(13.37|14.0), debian6, ubuntu
Posts: 630

Original Poster
Rep: Reputation: 36
oneandoneis2, of course what you say is the most proper solution. but the problem is i'm using ofstream and it doesn't seem to be giving me the option to create the file with (0777). as for calling system("chmod 777 "+filename) that is not an option since my application is doing some sampling and system() call would slow it down.

jim_fields, i thought umask is 777- mask ..

so umask =022 means group & other non writeable (= mask = 755)

what do you mean with the
Quote:
If you want a umask of 000 you would use 666 as the value to umask.
that umask should be 666 if i want a ?umask? of 000?
 
Old 03-29-2007, 03:32 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
The umask setting of 000 is fine to make new files rwx for all. I don't recommend putting it in /etc/profile or some other system-wide settings file, as this will affect many applications, create many security issues, etc.
Rather, put it in a specific user's settings file (ie /home/user/.bashrc or /home/user/.bash_profile) or, even better, create a little script (wrapper) that sets the umask value and then calls your executable. Your executable then uses the proper umask and doesn't need to bother with chmod calls.
 
Old 03-29-2007, 10:31 AM   #6
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slack(64|32)_v(13.37|14.0), debian6, ubuntu
Posts: 630

Original Poster
Rep: Reputation: 36
and initaially that was exactly what i had done..
i put umask 000 in a script and then run the executable....
yet when these files are being saved they are -rw-r--r-- root root ....!
could there be smth else?
nass
 
Old 03-29-2007, 01:37 PM   #7
wpn146
Member
 
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
I believe "umask" is a shell command and it will run a "umask 022" every time you enter the shell. (bash, korn, and csh, maybe others.)

And yes, what you are doing is dangerous. Give me a "chmod 777 /etc/shadow" and I can steal your root password.
 
Old 03-30-2007, 02:00 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
If your program indeed does run as "root", you should be double careful with the umask.
Why not start off by telling us a bit more about your program, how it is run (ie if run as root, for what reason?),...

Also, in your script, you should have something like:
Code:
umask 000
if (( $? != 0 )); then
echo "changing umask setting failed."
fi;
#verify that umask was changed, by printing the current umask setting
umask

call_to_your_executable
Is the setGID bit set for the directory where the new file is created?
 
Old 03-30-2007, 05:10 PM   #9
Zention
Member
 
Registered: Mar 2007
Posts: 119

Rep: Reputation: 16
Set umask to 0000 in /etc/profile and then check umask is not being set in any other subsequent setup files (eg .bashrc .bash_profile etc).

Others have mentioned the security problems around this, they are valid.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PCI: Cannot allocate resource region 0 of device 0000:00:12.0 mvo Linux - Hardware 8 12-06-2007 11:12 AM
Oops 0000 eneville Linux - Kernel 0 09-26-2006 07:33 AM
BusyBox v0.60.5 (2003.11.15-11:58+0000) saman123 Linux - Software 15 08-28-2006 11:59 AM
PCI: Cannot allocate resource region 1 of device 0000:00:00.0 dbfoxnh Linux - Hardware 2 04-22-2005 10:01 AM
invalid operand 0000 x2000koh Linux - General 3 07-03-2003 08:50 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration