|
|
1.1 ! root 1: # include "monitor.h" ! 2: # include <ingres.h> ! 3: # include <aux.h> ! 4: # include <opsys.h> ! 5: # include <sccs.h> ! 6: ! 7: SCCSID(@(#)shell.c 8.1 12/31/84) ! 8: ! 9: ! 10: ! 11: /* ! 12: ** SHELL -- call unix shell ! 13: ** ! 14: ** The UNIX shell is called. Shell() first tries to call an ! 15: ** alternate shell defined by the macro {shell}, and if it fails ! 16: ** calls /bin/sh. ! 17: ** ! 18: ** If an argument is supplied, it is a shell file which is ! 19: ** supplied to the shell. ! 20: ** ! 21: ** Trace Flags: ! 22: ** 34 ! 23: */ ! 24: ! 25: shell() ! 26: { ! 27: register int i; ! 28: register char *p; ! 29: register char *shellfile; ! 30: extern char *getfilenm(); ! 31: extern char *macro(); ! 32: ! 33: shellfile = getfilenm(); ! 34: if (*shellfile == 0) ! 35: shellfile = 0; ! 36: ! 37: fclose(Qryiop); ! 38: if ((Xwaitpid = fork()) == -1) ! 39: syserr("shell: fork"); ! 40: if (Xwaitpid == 0) ! 41: { ! 42: setuid(getuid()); ! 43: # ifndef xB_UNIX ! 44: setgid(getgid()); ! 45: # endif ! 46: for (i = 3; i < NOFILE; i++) ! 47: close(i); ! 48: p = macro("{shell}"); ! 49: # ifdef xMTR3 ! 50: tTfp(34, 0, "{shell} = '%o'\n", p); ! 51: # endif ! 52: if (p != 0) ! 53: { ! 54: execl(p, p, shellfile, Qbname, 0); ! 55: printf("Cannot call %s; using /bin/sh\n", p); ! 56: } ! 57: execl("/bin/sh", "sh", shellfile, Qbname, 0); ! 58: syserr("shell: exec"); ! 59: } ! 60: ! 61: if (Nodayfile >= 0) ! 62: printf(">>shell\n"); ! 63: /* wait for shell to complete */ ! 64: xwait(); ! 65: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.