This is LoadPPPDriver.c in view mode; [Download] [Up]
// ------------------------------------------------------------------------------------- // LoadPPPDriver - load PPP LKS (loadable kernel server) // This module should be compiled, set 'root' suid, and copied to "/usr/local/bin" // This will execute the file "/usr/local/ppp/rc.ppp" provided with the ppp-2.2 package. // // To compile: // cc -o LoadPPPDriver LoadPPPDriver.c // // To set 'root' suid: // chown root LoadPPPDriver; chmod 4755 LoadPPPDriver; // // ------------------------------------------------------------------------------------- #include <libc.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <pwd.h> /* command to determine if ppp driver has been loaded */ static const char *cmdCheck = "/usr/etc/kl_util -s | /bin/grep ' ppp Loaded' >/dev/null"; /* 'rc.ppp' is provided with the ppp2.2 package */ static const char *cmdLoad = "/bin/sh /usr/local/ppp/rc.ppp >/dev/console 2>&1"; /* main */ int main() { struct passwd *rpw = getpwnam("root"); /* check for PPP Driver already loaded */ if (!system(cmdCheck)) { fprintf(stderr," PPP Driver already loaded.\n"); exit(0); } /* switch to superuser */ if ((setgid(rpw->pw_gid) < 0) || (initgroups(rpw->pw_name,rpw->pw_gid)) || (setuid(rpw->pw_uid) < 0)) { fprintf(stderr," ERROR: Cannot switch to superuser.\n"); exit(2); } /* load PPP LKS */ if (system(cmdLoad)) { fprintf(stderr," ERROR: load failed.\n"); exit(1); } fprintf(stdout," driver loaded.\n"); exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.