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>
29 #ifdef AFS_KERBEROS_ENV
30 #include <sys/types.h>
34 #include "AFS_component_version_number.c"
36 extern afs_int32 setpag();
39 main(int argc, char *argv[])
43 char *shell = "/bin/sh";
47 * The following signal action for AIX is necessary so that in case of a
48 * crash (i.e. core is generated) we can include the user's data section
49 * in the core dump. Unfortunately, by default, only a partial core is
50 * generated which, in many cases, isn't too useful.
54 sigemptyset(&nsa.sa_mask);
55 nsa.sa_handler = SIG_DFL;
56 nsa.sa_flags = SA_FULLDUMP;
57 sigaction(SIGSEGV, &nsa, NULL);
63 fprintf(stderr, "Intruder alert.\n");
65 /* shell = pwe->pw_shell; */
70 #ifdef AFS_KERBEROS_ENV
78 fprintf(stderr, "No shell\n");
83 #ifdef AFS_KERBEROS_ENV
84 /* stolen from auth/ktc.c */
89 #if defined(AFS_AIX51_ENV)
92 if (kcred_getpag(cred, PAG_AFS, &pag) < 0 || pag == 0)
96 afs_uint32 groups[NGROUPS_MAX];
100 if (getgroups(sizeof groups / sizeof groups[0], groups) < 2)
103 g0 = groups[0] & 0xffff;
104 g1 = groups[1] & 0xffff;
107 if ((g0 < 0xc000) && (g1 < 0xc000)) {
108 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
110 h = (g1 >> 14) + h + h + h;
111 ret = ((h << 28) | l);
112 /* Additional testing */
113 if (((ret >> 24) & 0xff) == 'A')
125 extern char **environ;
129 char fname[256], *prefix = "/ticket/";
130 char fname5[256], *prefix5 = "FILE:/ticket/krb5cc_";
132 char **newenv, **senv, **denv;
134 if (stat("/ticket", &sbuf) == -1) {
136 prefix5 = "FILE:/tmp/krb5cc_";
139 pag = curpag() & 0xffffffff;
141 sprintf(fname, "%s%d", prefix, getuid());
142 sprintf(fname5, "%s%d", prefix5, getuid());
144 sprintf(fname, "%sp%ld", prefix, pag);
145 sprintf(fname5, "%sp%ld", prefix5, pag);
147 /* ktc_set_tkt_string(fname); */
149 for (senv = environ, numenv = 0; *senv; senv++)
151 newenv = (char **)malloc((numenv + 2) * sizeof(char *));
153 for (senv = environ, denv = newenv; *senv; *senv++) {
154 if (strncmp(*senv, "KRBTKFILE=", 10) != 0 &&
155 strncmp(*senv, "KRB5CCNAME=", 11) != 0)
159 *denv = malloc(10+11 + strlen(fname) + strlen(fname5) + 2);
160 strcpy(*denv, "KRBTKFILE=");
161 strcat(*denv, fname);
162 *(denv+1) = *denv + strlen(*denv) + 1;
164 strcpy(*denv, "KRB5CCNAME=");
165 strcat(*denv, fname5);