Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running a game server (unreal tournament 2004) on Centos 6 x86. I use a sh script to start it in a background process. This process (game server) creates different files (demos, logs) and they all come with 0600 permission by default. I have to process them with some applications so what I want is to change their default permission (to 0644 for example).

I'm root, I have umask 022 and files I create are 0644 by default. But it seems like this game server process don't inherit my umask. How can I change it? I'm pretty new to linux so a detailed answer would be appreciated.

Script used for running server:

#!/bin/sh
# Set the following to your UT2004 directory.
UT2004HOME=/home/ut2004

LOG=Server1.log

if [ ! -d "$UT2004HOME/Logs" ]; then
mkdir $UT2004HOME/Logs
fi

cd $UT2004HOME/System

while true; do

./ucc-bin server DM-Rankin-FE?game=XGame.xDeathMatch?Mutator=UTzoneTAv1.MutUTzoneTA,utcompv17a.MutUTComp,XWeapons.MutNoSuperWeapon,XGame.MutNoAdrenaline?MaxPlayers=2?DoubleDamage=False?TimedOverTimeLength=0?GameStats=True?AntiTCCSettings=NoMidGameChecks ini=server1.ini -nohomedir -lanplay &> $UT2004HOME/Logs/$LOG

DATE=20`date +%y%m%d`-`date +%H%M%S`
mv $UT2004HOME/Logs/$LOG $UT2004HOME/Logs/crash-$DATE.log

done;

I put it in an sh file and then start it in putty shell as root as a background process using & on the end of string.

UPDATE #1

Output from ls -ld $UT2004HOME/Logs:

drwxr-xr-x 2 root root 4096 Sep 1 10:22 /home/ut2004/Logs

files in this directory are rw-r--r--.

The output for 2 other directories that contain files I need to be rwxr-xr-x is the same:

drwxr-xr-x 2 root root 45056 Sep 26 14:16 /home/ut2004/Demos 
drwxr-xr-x 2 root root 28672 Sep 26 18:03 /home/ut2004/UserLogs 

but files in them are rw-------

When I ran the command file ./ucc-bin it was reported to be a binary file.

share|improve this question
    
Can you either post your script or provide a URL to where you got it? –  slm Sep 25 '13 at 13:19
    
Done. 1st post is updated. –  Dragonheart Sep 26 '13 at 13:58
    
Thanks for the update, can you also include the output of the directory too? ls -ld $UT2004HOME/Logs. also is the file /ucc-bin a script or a binary file? Run the command file ./ucc-bin. –  slm Sep 26 '13 at 15:03
    
The output for it is: drwxr-xr-x 2 root root 4096 Sep 1 10:22 /home/ut2004/Logs files in it are rw-r--r-- The output for 2 other directories that contain files I need to be rwxr-xr-x is the same: drwxr-xr-x 2 root root 45056 Sep 26 14:16 /home/ut2004/Demos drwxr-xr-x 2 root root 28672 Sep 26 18:03 /home/ut2004/UserLogs but files in them are rw------- ucc-bin is a binary file –  Dragonheart Sep 27 '13 at 10:27
add comment

2 Answers

What user is the game server running as? Typically servers/services are run as users other than root so you'll need to figure out which user this is and change that user's umask.

You can set that user's umask in the user's $HOME/.bashrc or $HOME/.bash_profile, though I would caution doing this without thinking about it first.

It might make more sense to set a ACL (Access Control List) on the directories in question so that other users can access them in addition to the user the game server is running as.

For this you'll use the tools setfacl and getfacl. For example:

# for a single user (userA)
$ setfacl -Rm d:u:userA:rwX,u:userA:rwX /var/www

# for a shared group (groupA) 
$ setfacl -Rm d:g:groupA:rwX,u:groupA:rwX /var/www

Or to make the directories read only:

$ setfacl -Rm d:u:www-data:rX,u:www-data:rX /var/www

UPDATE #1

OK so I downloaded what I think you're using. I downloaded the dedicated servers from here, on a page titled: Various useful downloads for Unreal, Unreal Tournament and Unreal Tournament 2004.

When I run a command, similar to yours I'm getting my log created with the permissions,

-rw-r--r-- 1 root root     1140 Sep 27 08:57 sams.log

This is the command I run:

$ ./ucc-bin masterserver -nohomedir -lanplay &> sams.log

And my umask is set to 002 as well. Can you please confirm what I've done here so that I know I'm copying your setup correctly?

References

share|improve this answer
    
For a daemon started by a system user, files like .bashrc and .bash_profile are irrelevant. That user may not even have an existing home directory, and certainly won't be running shell initialization files. –  Gilles Aug 14 '13 at 22:28
    
@slm, currently I run it as root which has 0022 umask by default. I tried adding umask to .bashrc and .bash_profile, but nothing changed. –  Dragonheart Sep 25 '13 at 12:11
    
@Dragonheart - see updates. FYI when I run ./ucc-bin server ... I get an error message: Failed to load 'CityIntro.unr': Can't find file 'CityIntro.unr' –  slm Sep 27 '13 at 13:01
    
@slm, well, I took a dedicated server package of 3339 ver.: link, then updated it with 3369-2 linux patch: link. Info on setting up the server is here:link - you have to use ./ucc-bin server command, not the masterserver, just like in my script, which i've got at: link. –  Dragonheart Sep 27 '13 at 14:15
    
@slm, Log files are created with the same permissions as in your case for me, but UserLogs and Demos are rw------- –  Dragonheart Sep 30 '13 at 9:23
add comment

If that application don't have home directory , then you can define umask in /etc/init.d script, where it from start.

You just need to add at top after shebang, umask 0022 then files will be create with 644 permission.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.