/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 1999, 2001-2005, 2007, 2010-2012, 2014-20154* Todd C. Miller <[email protected]>5*6* Permission to use, copy, modify, and distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*18* Sponsored in part by the Defense Advanced Research Projects19* Agency (DARPA) and Air Force Research Laboratory, Air Force20* Materiel Command, USAF, under agreement number F39502-99-1-0512.21*/2223#include <config.h>2425#ifdef HAVE_AFS2627#include <sys/types.h>28#include <stdio.h>29#include <stdlib.h>30#include <string.h>31#include <unistd.h>32#include <pwd.h>3334#include <afs/stds.h>35#include <afs/kautils.h>3637#include <sudoers.h>38#include "sudo_auth.h"39#include <timestamp.h>4041int42sudo_afs_verify(const struct sudoers_context *ctx, struct passwd *pw,43const char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)44{45struct ktc_encryptionKey afs_key;46struct ktc_token afs_token;47debug_decl(sudo_afs_verify, SUDOERS_DEBUG_AUTH);4849if (IS_NONINTERACTIVE(auth))50debug_return_int(AUTH_NONINTERACTIVE);5152/* Display lecture if needed and we haven't already done so. */53display_lecture(callback);5455/* Try to just check the password */56ka_StringToKey(pass, NULL, &afs_key);57if (ka_GetAdminToken(pw->pw_name, /* name */58NULL, /* instance */59NULL, /* realm */60&afs_key, /* key (contains password) */610, /* lifetime */62&afs_token, /* token */630) == 0) /* new */64debug_return_int(AUTH_SUCCESS);6566/* Fall back on old method XXX - needed? */67setpag();68if (ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION+KA_USERAUTH_DOSETPAG,69pw->pw_name, /* name */70NULL, /* instance */71NULL, /* realm */72pass, /* password */730, /* lifetime */74NULL, /* expiration ptr (unused) */750, /* spare */76NULL) == 0) /* reason */77debug_return_int(AUTH_SUCCESS);7879debug_return_int(AUTH_FAILURE);80}8182#endif HAVE_AFS838485