2

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.

4
  • 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, 2011 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, 2011 at 17:05
  • So as XQYZ said, you can make your log files readable only by root, right?
    – Cascabel
    May 10, 2011 at 17:37
  • Hopefully there's a service process keeper like daemontools/runit, upstart, systemd, etc. making sure the process stays running.
    – dhchdhd
    May 11, 2011 at 6:43

3 Answers 3

1

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

1
  • -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, 2011 at 7:06
1

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

0
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.

1
  • -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, 2011 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .