/* ppp.c -- PPP control for mortals by Phil Hughes
* -- 12-28-96 */
/*
* Call with one argument:
* on -- start PPP
* off -- stop PPP
* Install owned by root.
* If you want anyone to be able to run it, set
* permissions to 4711
* If you only want a set of users to be able to
* run it: chgrp it to the group that should be
* able to run it and set permissions to 4710
*/
#include <stdio.h>
#include <strings.h>
/* define strings for what needs to be run */
#define PPP_ON "/usr/sbin/pseanet" /* turn PPP on */
#define PPP_OFF "/usr/sbin/ppp-off" /* turn PPP off */
/* just for safety, set a sane search path */
char *env[] = {
"PATH=/bin:/usr/bin:/usr/sbin/",
NULL};
int main(int argc, char *argv[])
{
/* must be called with an argument */
if (argc != 2)
{
fprintf(stderr,
"Usage: %s: {on|off}\n", argv[0]);
exit(1);
}
setuid(0); /* become root */
if (strcmp(argv[1], "on") == 0)
{
execle(PPP_ON, (const char *) NULL,
&env);
}
else if (strcmp(argv[1], "off") == 0)
{
execle(PPP_OFF, (const char *) NULL,
&env);
}
else
{
fprintf(stderr, "%s: invalid argument\n",
argv[0]);
exit(2);
}
}
Copyright © 1994 - 2019 Linux Journal. All rights reserved.