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>
27 #ifdef AFS_KERBEROS_ENV
28 #include <sys/types.h>
32 #include "AFS_component_version_number.c"
34 extern afs_int32 setpag();
37 main(int argc, char *argv[])
41 char *shell = "/bin/sh";
45 * The following signal action for AIX is necessary so that in case of a
46 * crash (i.e. core is generated) we can include the user's data section
47 * in the core dump. Unfortunately, by default, only a partial core is
48 * generated which, in many cases, isn't too useful.
52 sigemptyset(&nsa.sa_mask);
53 nsa.sa_handler = SIG_DFL;
54 nsa.sa_flags = SA_FULLDUMP;
55 sigaction(SIGSEGV, &nsa, NULL);
61 fprintf(stderr, "Intruder alert.\n");
63 /* shell = pwe->pw_shell; */
68 #ifdef AFS_KERBEROS_ENV
76 fprintf(stderr, "No shell\n");
81 #ifdef AFS_KERBEROS_ENV
82 /* stolen from auth/ktc.c */
87 #if defined(AFS_AIX51_ENV)
90 if (kcred_getpag(cred, PAG_AFS, &pag) < 0 || pag == 0)
94 afs_uint32 groups[NGROUPS_MAX];
98 if (getgroups(sizeof groups / sizeof groups[0], groups) < 2)
101 g0 = groups[0] & 0xffff;
102 g1 = groups[1] & 0xffff;
105 if ((g0 < 0xc000) && (g1 < 0xc000)) {
106 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
108 h = (g1 >> 14) + h + h + h;
109 ret = ((h << 28) | l);
110 /* Additional testing */
111 if (((ret >> 24) & 0xff) == 'A')
123 extern char **environ;
127 char fname[256], *prefix = "/ticket/";
128 char fname5[256], *prefix5 = "FILE:/ticket/krb5cc_";
130 char **newenv, **senv, **denv;
132 if (stat("/ticket", &sbuf) == -1) {
134 prefix5 = "FILE:/tmp/krb5cc_";
137 pag = curpag() & 0xffffffff;
139 sprintf(fname, "%s%d", prefix, getuid());
140 sprintf(fname5, "%s%d", prefix5, getuid());
142 sprintf(fname, "%sp%ld", prefix, pag);
143 sprintf(fname5, "%sp%ld", prefix5, pag);
145 /* ktc_set_tkt_string(fname); */
147 for (senv = environ, numenv = 0; *senv; senv++)
149 newenv = (char **)malloc((numenv + 2) * sizeof(char *));
151 for (senv = environ, denv = newenv; *senv; *senv++) {
152 if (strncmp(*senv, "KRBTKFILE=", 10) != 0 &&
153 strncmp(*senv, "KRB5CCNAME=", 11) != 0)
157 *denv = malloc(10+11 + strlen(fname) + strlen(fname5) + 2);
158 strcpy(*denv, "KRBTKFILE=");
159 strcat(*denv, fname);
160 *(denv+1) = *denv + strlen(*denv) + 1;
162 strcpy(*denv, "KRB5CCNAME=");
163 strcat(*denv, fname5);