Text version of this page

PPP Kill SUID Wrapper

The problem this file solves is how to allow users to run a command as root (killall pppd) without giving them root priviledges. The simplest way is to write what is called a C wrapper for the program, which allows the program to be run suid root, but without introducing any extra security holes into your system.

This is a C wrapper for the killall command. Copy the lines between the two rows of ======== into a file called pppoff.c. (Make sure that the < characters come out as less-than characters in the code.) Then, while logged in as root do
gcc -o pppoff pppoff.c
chmod a+x pppoff
chmod +s pppoff

When you want to terminate a connection, just run
Note that this file will allow any user to kill a running pppd, even if they did not start it. If you have users who would abuse this, you have deeper problems than this note is liable to solve, and you probably already have the expertise to solve the problem yourself.

#include <signal.h>
#include <sys/param.h>
#include <pwd.h>
static char *trusted_env[]={"PATH=/usr/bin:/usr/sbin:/sbin:/bin",0};
struct passwd *pwd;
        int i;
        uid_t uid;
for (i=0;i < NSIG;i++){ if(i!= SIGKILL && i!=SIGCHLD)
                                {(void) signal(i,SIG_IGN);}

if ( (pwd = getpwuid(uid))== (struct passwd *)0 )

execle("/usr/bin/killall","/usr/bin/killall","pppd",(char *)0,trusted_env);