"Fossies" - the Fresh Open Source Software Archive

Member "sudo-1.9.11p3/plugins/sudoers/auth/afs.c" (12 Jun 2022, 2717 Bytes) of package /linux/misc/sudo-1.9.11p3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "afs.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.9.9_vs_1.9.10.

    1 /*
    2  * SPDX-License-Identifier: ISC
    3  *
    4  * Copyright (c) 1999, 2001-2005, 2007, 2010-2012, 2014-2015
    5  *  Todd C. Miller <Todd.Miller@sudo.ws>
    6  *
    7  * Permission to use, copy, modify, and distribute this software for any
    8  * purpose with or without fee is hereby granted, provided that the above
    9  * copyright notice and this permission notice appear in all copies.
   10  *
   11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   18  *
   19  * Sponsored in part by the Defense Advanced Research Projects
   20  * Agency (DARPA) and Air Force Research Laboratory, Air Force
   21  * Materiel Command, USAF, under agreement number F39502-99-1-0512.
   22  */
   23 
   24 /*
   25  * This is an open source non-commercial project. Dear PVS-Studio, please check it.
   26  * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
   27  */
   28 
   29 #include <config.h>
   30 
   31 #ifdef HAVE_AFS
   32 
   33 #include <sys/types.h>
   34 #include <stdio.h>
   35 #include <stdlib.h>
   36 #include <string.h>
   37 #include <unistd.h>
   38 #include <pwd.h>
   39 
   40 #include <afs/stds.h>
   41 #include <afs/kautils.h>
   42 
   43 #include "sudoers.h"
   44 #include "sudo_auth.h"
   45 #include "check.h"
   46 
   47 int
   48 sudo_afs_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)
   49 {
   50     struct ktc_encryptionKey afs_key;
   51     struct ktc_token afs_token;
   52     debug_decl(sudo_afs_verify, SUDOERS_DEBUG_AUTH);
   53 
   54     if (IS_NONINTERACTIVE(auth))
   55     debug_return_int(AUTH_NONINTERACTIVE);
   56 
   57     /* Display lecture if needed and we haven't already done so. */
   58     display_lecture(callback);
   59 
   60     /* Try to just check the password */
   61     ka_StringToKey(pass, NULL, &afs_key);
   62     if (ka_GetAdminToken(pw->pw_name,       /* name */
   63              NULL,          /* instance */
   64              NULL,          /* realm */
   65              &afs_key,      /* key (contains password) */
   66              0,         /* lifetime */
   67              &afs_token,        /* token */
   68              0) == 0)       /* new */
   69     debug_return_int(AUTH_SUCCESS);
   70 
   71     /* Fall back on old method XXX - needed? */
   72     setpag();
   73     if (ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION+KA_USERAUTH_DOSETPAG,
   74                    pw->pw_name, /* name */
   75                    NULL,    /* instance */
   76                    NULL,    /* realm */
   77                    pass,    /* password */
   78                    0,       /* lifetime */
   79                    NULL,    /* expiration ptr (unused) */
   80                    0,       /* spare */
   81                    NULL) == 0)  /* reason */
   82     debug_return_int(AUTH_SUCCESS);
   83 
   84     debug_return_int(AUTH_FAILURE);
   85 }
   86 
   87 #endif HAVE_AFS