DEVEL15-curpag-via-pioctl-20090603
[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 RCSID
14     ("$Header$");
15
16 #ifdef  AFS_AIX32_ENV
17 #include <signal.h>
18 #ifdef AFS_AIX51_ENV
19 #include <sys/cred.h>
20 #ifdef HAVE_SYS_PAG_H
21 #include <sys/pag.h>
22 #endif
23 #include <errno.h>
24 #endif
25 #endif
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <limits.h>
29 #ifndef AFS_NT40_ENV
30 #include <unistd.h>
31 #endif
32 #include <string.h>
33 #include <pwd.h>
34 #ifdef AFS_KERBEROS_ENV
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #endif
38 #include "rx/rx.h"
39 #include "sys_prototypes.h"
40
41 #include "AFS_component_version_number.c"
42
43 int
44 main(int argc, char *argv[])
45 {
46     struct passwd *pwe;
47     int uid, gid;
48     char *shell = "/bin/sh";
49
50 #ifdef  AFS_AIX32_ENV
51     /*
52      * The following signal action for AIX is necessary so that in case of a 
53      * crash (i.e. core is generated) we can include the user's data section 
54      * in the core dump. Unfortunately, by default, only a partial core is
55      * generated which, in many cases, isn't too useful.
56      */
57     struct sigaction nsa;
58
59     sigemptyset(&nsa.sa_mask);
60     nsa.sa_handler = SIG_DFL;
61     nsa.sa_flags = SA_FULLDUMP;
62     sigaction(SIGSEGV, &nsa, NULL);
63 #endif
64     gid = getgid();
65     uid = getuid();
66     pwe = getpwuid(uid);
67     if (pwe == 0) {
68         fprintf(stderr, "Intruder alert.\n");
69     } else {
70 /*              shell = pwe->pw_shell; */
71     }
72     if (setpag() == -1) {
73         perror("setpag");
74     }
75 #ifdef AFS_KERBEROS_ENV
76     ktc_newpag();
77 #endif
78     (void)setuid(uid);
79     (void)setgid(gid);
80     argv[0] = shell;
81     execvp(shell, argv);
82     perror(shell);
83     fprintf(stderr, "No shell\n");
84     exit(1);
85 }