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 writing a program, and would like it to store a log file. Problem is, the program really shouldn't be ran as root.

So if I wanted to uphold to the traditions of where files are placed, where could I keep the log file if not in /var/log that a normal user would have permissions to?

Edit: I'm using Arch linux.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Since the operating system you are using is missing, a more generic approach could be: Create a directory with the name of your app(say, foo) inside /var/log

# mkdir /var/log/foo

Most of all unix-like OSs will allow you to navigate through var_log folders, but not to view the logfiles contents(as expected).

Give the ownership to the user that you are using to run your program, and permission to this user(only) to see/write those logfiles

# chown userfoo /var/log/foo
# chmod 600 /var/log/foo

You could play with groups too, giving read access to operators for example(and of course, a different permission set of chmod, like 640.

Done. This should be generic enough to any Unix like system, and maybe, a better approach than adding a user to administrative groups.

share|improve this answer
1  
My bad, I should add that I'm using arch linux. I'm not sure I would want method since this will be going into a package. I was really more hoping that there might a folder inside of a users home directory that could be used to hold log files. –  josh Dec 12 '13 at 23:37
1  
Ok, so help me to understand. This program will be run by "normal users"(like password, cd, yes...), or a daemon or some server software that needs to run as a normal user or administrative user to reduce the risks of your system being compromised? I don't se a more appropriated place to put user logs, since even the FHS does not talk about it - refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html. Maybe: /home/user/.your_app/logs like almost all applications do on users home folders to handle config files and stuff ;) –  nwildner Dec 12 '13 at 23:47
    
I think that's just what I'll do, Thanks. –  josh Dec 12 '13 at 23:53
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.