I wrote a small C utility called killSPR to kill the following processes in my RHEL field. The idea is that anyone who enters this Linux box can use this utility to kill the processes described below (which does not work is explained below).
cadmn@rhel /tmp > ps -eaf | grep -v grep | grep " SPR " cadmn 5822 5821 99 17:19 ? 00:33:13 SPR 4 cadmn cadmn 10466 10465 99 17:25 ? 00:26:34 SPR 4 cadmn cadmn 13431 13430 99 17:32 ? 00:19:55 SPR 4 cadmn cadmn 17320 17319 99 17:39 ? 00:13:04 SPR 4 cadmn cadmn 20589 20588 99 16:50 ? 01:01:30 SPR 4 cadmn cadmn 22084 22083 99 17:45 ? 00:06:34 SPR 4 cadmn cadmn@rhel /tmp >
This utility belongs to the cadmn user (under which these processes are executed), and the setuid flag is set on it (shown below).
cadmn@rhel /tmp > ls -l killSPR -rwsr-xr-x 1 cadmn cusers 9925 Dec 17 17:51 killSPR cadmn@rhel /tmp >
C code is given below:
A user ( pmn ) other than cadmn tries to kill the above processes with this utility and does not work (shown below):
pmn@rhel /tmp > ./killSPR Before you proceed, find out under which ID I'm running. Hit enter when you are done... sh: line 0: kill: (5822) - Operation not permitted sh: line 0: kill: (10466) - Operation not permitted sh: line 0: kill: (13431) - Operation not permitted sh: line 0: kill: (17320) - Operation not permitted sh: line 0: kill: (20589) - Operation not permitted sh: line 0: kill: (22084) - Operation not permitted pmn@rhel /tmp >
While the user is waiting to press Enter, the killSPR process killSPR checked and, as seen, works as the cadmn user (shown below), despite the fact that killSPR cannot terminate the processes.
cadmn@rhel /tmp > ps -eaf | grep -v grep | grep killSPR cadmn 24851 22918 0 17:51 pts/36 00:00:00 ./killSPR cadmn@rhel /tmp >
By the way, none of the main sections have nosuid on them
pmn@rhel /tmp > mount | grep nosuid pmn@rhel /tmp >
The setuid flag in the executable does not seem to have the desired effect. What am I missing here? I misunderstood how setuid works?
source share