home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume6 / shadow-2.pt3 / shell.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  573b  |  38 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4.  
  5. extern    char    *newenvp[];
  6.  
  7. void    shell (file)
  8. char    *file;
  9. {
  10.     char    arg0[BUFSIZ];
  11. #ifndef    SU
  12.     char    *path;
  13. #endif
  14.     char    *strrchr ();
  15.     extern    int    errno;
  16.  
  17.     if (file == (char *) 0)
  18.         exit (1);
  19.  
  20. #ifndef    SU
  21.     if (path = strrchr (file, '/'))
  22.         path++;
  23.     else
  24.         path = file;
  25.  
  26.     (void) strcpy (arg0 + 1, path);
  27.     arg0[0] = '-';
  28. #else
  29.     (void) strcpy (arg0, "-su");
  30. #endif
  31. #ifndef    NDEBUG
  32.     printf ("Executing shell %s\n", file);
  33. #endif
  34.     execle (file, arg0, (char *) 0, newenvp);
  35.     printf ("Can't execute %s\n", file);
  36.     exit (errno);
  37. }
  38.