This is asroot.c in view mode; [Download] [Up]
/* -*-C-*- ******************************************************************************* * * File: asroot.c * RCS: $Header: $ * Description: Allow members of the group wheel to run programs as root * Author: Carl Edman * Created: Wed Feb 17 16:42:47 1993 * Modified: Fri May 14 09:14:22 1993 (Carl Edman) cedman@capitalist * Language: C * Package: N/A * Status: Distribution * * (C) Copyright 1993, but otherwise this file is perfect freeware. * ******************************************************************************* */ #include <libc.h> #include <sys/param.h> void main(int argc,char *argv[]) { int gidset[NGROUPS],i; if ((i=getgroups(NGROUPS,gidset))==-1) { perror("getgroups"); exit(1); } for(i--;i>=0;i--) if (gidset[i]==0) break; if (i<0) { fprintf(stderr,"Sorry\n"); exit(2); } if (setregid(getegid(),getegid())==-1) { perror("setregid"); exit(3); } if (setreuid(geteuid(),geteuid())==-1) { perror("setreuid"); exit(4); } if (execvp(argv[1],argv+1)==-1) { perror("execvp"); exit(5); } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.