home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / NextLibrary / PrivateFrameworks / Uucp.framework / Versions / A / Resources / contrib / amiga.c next >
C/C++ Source or Header  |  1994-03-22  |  1KB  |  44 lines

  1. /* Wrapper code for Taylor UUCP on Amiga Unix (SVR4) for cron invoked UUCP */
  2. /* processes.                                                              */
  3.  
  4. /* The problem:  Cron is not a "licensed" process. any process that grabs a 
  5.    controlling terminal needs to be licensed.  Taylor UUCP needs controlling
  6.    terminals.  Taylor UUCP does relinquish the controlling terminal before 
  7.    fork(), so the "UUCP" license is appropriate. 
  8.    This simple program does the "right" thing, but *MUST* be SETUID ROOT */
  9.  
  10. /* Written by: Lawrence E. Rosenman <ler@lerami.lerctr.org> */
  11.  
  12. #include <sys/sysm68k.h>
  13. #include <sys/types.h>
  14. #include <stdio.h>
  15. #include <errno.h>
  16. #include <unistd.h>
  17. #include <pwd.h>
  18.  
  19. int main(int argc,char *argv[],char *envp)
  20. {
  21.   struct passwd *pw;
  22.   char   name[256];
  23.  
  24.   strcpy(name,"/usr/local/lib/uucp/uucico");
  25.   if (sysm68k(_m68k_LIMUSER,EUA_GET_LIC) == 0 ) { /* are we unlicensed? */
  26.       if (sysm68k(_m68k_LIMUSER,EUA_UUCP) == -1) { /* yes, get a "uucp" license */
  27.          fprintf(stderr,"sysm68k failed, errno=%d\n",errno); /* we didn't? crab it */
  28.          exit(errno);
  29.       }
  30.   }
  31.  
  32.   pw = getpwnam("uucp"); /* get the Password Entry for uucp */
  33.   if (pw == NULL)
  34.   {
  35.      fprintf(stderr,"User ID \"uucp\" doesn't exist.\n");
  36.      exit(1);
  37.   }
  38.   setgid(pw->pw_gid); /* set gid to uucp */
  39.   setuid(pw->pw_uid); /* set uid to uucp */ 
  40.   argv[0]=name; /* have PS not lie... */
  41.   execv("/usr/local/lib/uucp/uucico",argv); /* go to the real program */
  42.   exit(errno);
  43. }
  44.