4 * Copyright 1990,1991 by the Massachusetts Institute of Technology
5 * For distribution and copying rights, see the file "mit-copyright.h"
8 #if !defined(lint) && !defined(SABER)
9 static char *rcsid = "$Id$";
10 #endif /* lint || SABER */
15 #include <sys/types.h>
30 #include <kerberosIV/krb.h>
43 #if !defined(HAVE_UNISTD_H) || (defined(__sun__) && ! defined(__svr4__))
44 extern int readlink ARGS((char *, char *, size_t));
46 /* extern int lstat ARGS((char *, struct stat *)); */
47 extern char *getwd ARGS((char *));
50 static krb5_ccache _krb425_ccache = 0;
52 #ifndef WINDOWS /* Don't have lstat() */
54 static int isdir(char *path, unsigned char *val)
56 static int isdir(path, val)
63 if (lstat(path, &statbuf) < 0)
66 if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
76 static int get_cred(krb5_context context,
77 char *name, char *inst, char *realm, CREDENTIALS *c,
80 static int get_cred(context, name, inst, realm, c, creds)
91 static krb5_principal client_principal = 0;
93 memset((char *)&increds, 0, sizeof(increds));
94 /* ANL - instance may be ptr to a null string. Pass null then */
95 if ((r = krb5_build_principal(context, &increds.server,
98 (inst && strlen(inst)) ? inst : (void *) NULL,
104 krb5_cc_default(context, &_krb425_ccache);
105 if (!client_principal)
106 krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
108 increds.client = client_principal;
109 increds.times.endtime = 0;
110 /* Ask for DES since that is what V4 understands */
111 increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC;
113 r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds);
117 /* This requires krb524d to be running with the KDC */
118 r = krb5_524_convert_creds(context, *creds, c);
124 static int get_user_realm(krb5_context context,char *realm)
126 static int get_user_realm(context, realm)
127 krb5_context context;
130 #endif /* __STDC__ */
132 static krb5_principal client_principal = 0;
136 krb5_cc_default(context, &_krb425_ccache);
137 if (!client_principal)
138 krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
140 i = krb5_princ_realm(context, client_principal)->length;
141 if (i > REALM_SZ-1) i = REALM_SZ-1;
142 strncpy(realm,krb5_princ_realm(context, client_principal)->data,i);
151 static void pstderr(char *string)
153 static void pstderr(string)
155 #endif /* __STDC__ */
157 write(2, string, strlen(string));
162 static void pstdout(char *string)
164 static void pstdout(string)
166 #endif /* __STDC__ */
168 write(1, string, strlen(string));
173 static void pstderr(char *string)
175 if (_isatty(_fileno(stderr)))
176 fprintf(stderr, "%s\r\n", string);
178 MessageBox(NULL, string, AKLOG_DIALOG_NAME, MB_OK | MB_ICONSTOP);
181 static void pstdout(char *string)
183 if (_isatty(_fileno(stdout)))
184 fprintf(stdout, "%s\r\n", string);
186 MessageBox(NULL, string, AKLOG_DIALOG_NAME, MB_OK);
192 static void exitprog(char status)
194 static void exitprog(status)
196 #endif /* __STDC__ */
203 void aklog_init_params(aklog_params *params)
205 void aklog_init_params(params)
206 aklog_params *params;
207 #endif /* __STDC__ */
210 params->readlink = readlink;
211 params->isdir = isdir;
212 params->getwd = getwd;
214 params->get_cred = get_cred;
215 params->get_user_realm = get_user_realm;
216 params->pstderr = pstderr;
217 params->pstdout = pstdout;
218 params->exitprog = exitprog;