sys: Tidy up header includes
[openafs.git] / src / sys / pagsh.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 #include <roken.h>
14
15 #ifdef  AFS_AIX32_ENV
16 # ifdef AFS_AIX51_ENV
17 #  include <sys/cred.h>
18 #  ifdef HAVE_SYS_PAG_H
19 #   include <sys/pag.h>
20 #  endif
21 # endif
22 #endif
23
24 #include <limits.h>
25 #include <rx/rx.h>
26 #include <afs/auth.h>
27
28 #include "sys_prototypes.h"
29
30 #include "AFS_component_version_number.c"
31
32 int
33 main(int argc, char *argv[])
34 {
35     struct passwd *pwe;
36     int uid, gid;
37     char *shell = "/bin/sh";
38
39 #ifdef  AFS_AIX32_ENV
40     /*
41      * The following signal action for AIX is necessary so that in case of a
42      * crash (i.e. core is generated) we can include the user's data section
43      * in the core dump. Unfortunately, by default, only a partial core is
44      * generated which, in many cases, isn't too useful.
45      */
46     struct sigaction nsa;
47
48     sigemptyset(&nsa.sa_mask);
49     nsa.sa_handler = SIG_DFL;
50     nsa.sa_flags = SA_FULLDUMP;
51     sigaction(SIGSEGV, &nsa, NULL);
52 #endif
53     gid = getgid();
54     uid = getuid();
55     pwe = getpwuid(uid);
56     if (pwe == 0) {
57         fprintf(stderr, "Intruder alert.\n");
58     } else {
59 /*              shell = pwe->pw_shell; */
60     }
61     if (setpag() == -1) {
62         perror("setpag");
63     }
64 #ifdef AFS_KERBEROS_ENV
65     ktc_newpag();
66 #endif
67     (void)setuid(uid);
68     (void)setgid(gid);
69     argv[0] = shell;
70     execvp(shell, argv);
71     perror(shell);
72     fprintf(stderr, "No shell\n");
73     exit(1);
74 }