2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include <afs/param.h>
30 #ifdef AFS_KERBEROS_ENV
31 #include <sys/types.h>
35 #include "AFS_component_version_number.c"
37 extern afs_int32 setpag();
40 main(int argc, char *argv[])
44 char *shell = "/bin/sh";
48 * The following signal action for AIX is necessary so that in case of a
49 * crash (i.e. core is generated) we can include the user's data section
50 * in the core dump. Unfortunately, by default, only a partial core is
51 * generated which, in many cases, isn't too useful.
55 sigemptyset(&nsa.sa_mask);
56 nsa.sa_handler = SIG_DFL;
57 nsa.sa_flags = SA_FULLDUMP;
58 sigaction(SIGSEGV, &nsa, NULL);
64 fprintf(stderr, "Intruder alert.\n");
66 /* shell = pwe->pw_shell; */
71 #ifdef AFS_KERBEROS_ENV
79 fprintf(stderr, "No shell\n");
84 #ifdef AFS_KERBEROS_ENV
85 /* stolen from auth/ktc.c */
90 #if defined(AFS_AIX51_ENV)
93 if (get_pag(PAG_AFS, &pag) < 0 || pag == 0)
97 afs_uint32 groups[NGROUPS_MAX];
101 if (getgroups(sizeof groups / sizeof groups[0], groups) < 2)
104 g0 = groups[0] & 0xffff;
105 g1 = groups[1] & 0xffff;
108 if ((g0 < 0xc000) && (g1 < 0xc000)) {
109 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
111 h = (g1 >> 14) + h + h + h;
112 ret = ((h << 28) | l);
113 /* Additional testing */
114 if (((ret >> 24) & 0xff) == 'A')
126 extern char **environ;
130 char fname[256], *prefix = "/ticket/";
131 char fname5[256], *prefix5 = "FILE:/ticket/krb5cc_";
133 char **newenv, **senv, **denv;
135 if (stat("/ticket", &sbuf) == -1) {
137 prefix5 = "FILE:/tmp/krb5cc_";
140 pag = curpag() & 0xffffffff;
142 sprintf(fname, "%s%d", prefix, getuid());
143 sprintf(fname5, "%s%d", prefix5, getuid());
145 sprintf(fname, "%sp%ld", prefix, pag);
146 sprintf(fname5, "%sp%ld", prefix5, pag);
148 /* ktc_set_tkt_string(fname); */
150 for (senv = environ, numenv = 0; *senv; senv++)
152 newenv = (char **)malloc((numenv + 2) * sizeof(char *));
154 for (senv = environ, denv = newenv; *senv; *senv++) {
155 if (strncmp(*senv, "KRBTKFILE=", 10) != 0 &&
156 strncmp(*senv, "KRB5CCNAME=", 11) != 0)
160 *denv = malloc(10+11 + strlen(fname) + strlen(fname5) + 2);
161 strcpy(*denv, "KRBTKFILE=");
162 strcat(*denv, fname);
163 *(denv+1) = *denv + strlen(*denv) + 1;
165 strcpy(*denv, "KRB5CCNAME=");
166 strcat(*denv, fname5);