2 * Copyright (c) 1999-2005, 2007, 2010
3 * Todd C. Miller <Todd.Miller@courtesan.com>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * Sponsored in part by the Defense Advanced Research Projects
18 * Agency (DARPA) and Air Force Research Laboratory, Air Force
19 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
24 #include <sys/types.h>
25 #include <sys/param.h>
34 #endif /* STDC_HEADERS */
37 #endif /* HAVE_STRING_H */
40 #endif /* HAVE_STRING_H */
43 #endif /* HAVE_UNISTD_H */
48 #include "sudo_auth.h"
51 kerb4_init(pw, promptp, auth)
56 static char realm[REALM_SZ];
58 /* Don't try to verify root */
62 /* Get the local realm, or retrun failure (no krb.conf) */
63 if (krb_get_lrealm(realm, 1) != KSUCCESS)
66 /* Stash a pointer to the realm (used in kerb4_verify) */
67 auth->data = (void *) realm;
73 kerb4_verify(pw, pass, auth)
78 char tkfile[sizeof(_PATH_SUDO_TIMEDIR) + 4 + MAX_UID_T_LEN];
79 char *realm = (char *) auth->data;
83 * Set the ticket file to be in sudo sudo timedir so we don't
84 * wipe out other (real) kerberos tickets.
86 (void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%lu",
87 _PATH_SUDO_TIMEDIR, (unsigned long) pw->pw_uid);
88 (void) krb_set_tkt_string(tkfile);
90 /* Convert the password to a ticket given. */
91 error = krb_get_pw_in_tkt(pw->pw_name, "", realm, "krbtgt", realm,
92 DEFAULT_TKT_LIFE, pass);
96 dest_tkt(); /* we are done with the temp ticket */
103 (void) fprintf(stderr, "Warning: Kerberos error: %s\n",
107 return(AUTH_FAILURE);