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>
32 #ifdef AFS_KERBEROS_ENV
33 #include <sys/types.h>
37 #include "sys_prototypes.h"
39 #include "AFS_component_version_number.c"
44 main(int argc, char *argv[])
48 char *shell = "/bin/sh";
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.
59 sigemptyset(&nsa.sa_mask);
60 nsa.sa_handler = SIG_DFL;
61 nsa.sa_flags = SA_FULLDUMP;
62 sigaction(SIGSEGV, &nsa, NULL);
68 fprintf(stderr, "Intruder alert.\n");
70 /* shell = pwe->pw_shell; */
75 #ifdef AFS_KERBEROS_ENV
83 fprintf(stderr, "No shell\n");
88 #ifdef AFS_KERBEROS_ENV
89 /* stolen from auth/ktc.c */
94 #if defined(AFS_AIX51_ENV)
95 int code = getpagvalue("afs");
96 if (code < 0 && errno == EINVAL)
100 afs_uint32 groups[NGROUPS_MAX];
102 afs_uint32 h, l, ret;
104 if (getgroups(sizeof groups / sizeof groups[0], groups) < 2)
107 g0 = groups[0] & 0xffff;
108 g1 = groups[1] & 0xffff;
111 if ((g0 < 0xc000) && (g1 < 0xc000)) {
112 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
114 h = (g1 >> 14) + h + h + h;
115 ret = ((h << 28) | l);
116 /* Additional testing */
117 if (((ret >> 24) & 0xff) == 'A')
129 extern char **environ;
133 char fname[256], *prefix = "/ticket/";
134 char fname5[256], *prefix5 = "FILE:/ticket/krb5cc_";
136 char **newenv, **senv, **denv;
138 if (stat("/ticket", &sbuf) == -1) {
140 prefix5 = "FILE:/tmp/krb5cc_";
143 pag = curpag() & 0xffffffff;
145 sprintf(fname, "%s%d", prefix, getuid());
146 sprintf(fname5, "%s%d", prefix5, getuid());
148 sprintf(fname, "%sp%lud", prefix, (long unsigned int) pag);
149 sprintf(fname5, "%sp%lud", prefix5, (long unsigned int) pag);
151 /* ktc_set_tkt_string(fname); */
153 for (senv = environ, numenv = 0; *senv; senv++)
155 newenv = (char **)malloc((numenv + 2) * sizeof(char *));
157 for (senv = environ, denv = newenv; *senv; *senv++) {
158 if (strncmp(*senv, "KRBTKFILE=", 10) != 0 &&
159 strncmp(*senv, "KRB5CCNAME=", 11) != 0)
163 *denv = malloc(10+11 + strlen(fname) + strlen(fname5) + 2);
164 strcpy(*denv, "KRBTKFILE=");
165 strcat(*denv, fname);
166 *(denv+1) = *denv + strlen(*denv) + 1;
168 strcpy(*denv, "KRB5CCNAME=");
169 strcat(*denv, fname5);