2 * Copyright (c) 1999, 2001 Todd C. Miller <Todd.Miller@courtesan.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * 4. Products derived from this software may not be called "Sudo" nor
20 * may "Sudo" appear in their names without specific prior written
21 * permission from the author.
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/types.h>
38 #include <sys/param.h>
47 #endif /* STDC_HEADERS */
51 # ifdef HAVE_STRINGS_H
54 #endif /* HAVE_STRING_H */
57 #endif /* HAVE_UNISTD_H */
62 #include "sudo_auth.h"
65 static const char rcsid[] = "$Sudo: kerb4.c,v 1.6 2001/12/14 19:52:53 millert Exp $";
69 kerb4_init(pw, promptp, auth)
74 static char realm[REALM_SZ];
76 /* Don't try to verify root */
80 /* Get the local realm, or retrun failure (no krb.conf) */
81 if (krb_get_lrealm(realm, 1) != KSUCCESS)
84 /* Stash a pointer to the realm (used in kerb4_verify) */
85 auth->data = (VOID *) realm;
91 kerb4_verify(pw, pass, auth)
96 char tkfile[sizeof(_PATH_SUDO_TIMEDIR) + 4 + MAX_UID_T_LEN];
97 char *realm = (char *) auth->data;
101 * Set the ticket file to be in sudo sudo timedir so we don't
102 * wipe out other (real) kerberos tickets.
104 (void) sprintf(tkfile, "%s/tkt%ld", _PATH_SUDO_TIMEDIR, (long) pw->pw_uid);
105 (void) krb_set_tkt_string(tkfile);
107 /* Convert the password to a ticket given. */
108 error = krb_get_pw_in_tkt(pw->pw_name, "", realm, "krbtgt", realm,
109 DEFAULT_TKT_LIFE, pass);
113 dest_tkt(); /* we are done with the temp ticket */
114 return(AUTH_SUCCESS);
120 (void) fprintf(stderr, "Warning: Kerberos error: %s\n",
124 return(AUTH_FAILURE);