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 have created a process and it is running in the background as a daemon it.Now I want that only root should be able to view the output of that process.My process is something like "top" which accumulate data from the system and show system statistics when asked for and I want is that system statistics should be shown only to the root.

Thanks in advance.

share|improve this question
    
How do you communicate with the daemon? Sockets? Is redirecting the output to a log file only readable by root an option? –  XQYZ May 10 '11 at 16:51
    
No the communication is not done through sockets,I will explain you my work in a simpler manner.I am calculating memory usage and cpu usage of all the processes when the user asks.On the other side my process also keeps record of the same in log files .Values are entered in log files every minute and after each week a graph is generated of cpu usage vs process and memory usage vs process.So i want that only root should be able to do all these thing.I am calculating memory and cpu usage by parsing the files in /proc file system –  nishan May 10 '11 at 17:05
    
So as XQYZ said, you can make your log files readable only by root, right? –  Jefromi May 10 '11 at 17:37
    
Hopefully there's a service process keeper like daemontools/runit, upstart, systemd, etc. making sure the process stays running. –  Barry May 11 '11 at 6:43
add comment

3 Answers

If the problem is the log files, make sure they are owned by root and don't have world read permissions. chmod o-r logfile

If the problem is the executable, make sure it doesn't have world execute permissions. chmod o-x program

share|improve this answer
    
-Thi is ok if I have to run the program but what to do if I have to INstall the program on other systems also.I want to do it programmatically i.e when user enters the name of the program on the terminal my program should check whether the user is root or not if not then ask the root's password and then authenticate it. –  nishan May 11 '11 at 7:06
add comment

To check if it is root that runs the program, you should call getuid().

share|improve this answer
add comment
chown root:root /path/to/logfile /path/to/program
chmod go-strwx /path/to/logfile /path/to/program

If it's that important, might want to isolate the data in a VM, domU, jail/container or on a central box over a dedicated private network. AppArmor or SELinux could be evaluated.

While I was attending RAID2001 at Davis, there was a talk from HP on a fully-instrumented Linux kernel with a hidden NIC logging system calls to a separate master box.

share|improve this answer
    
-Thi is ok if I have to run the program but what to do if I have to INstall the program on other systems also.I want to do it programmatically i.e when user enters the name of the program on the terminal my program should check whether the user is root or not if not then ask the root's password and then authenticate it. –  nishan May 11 '11 at 7:05
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.