From: Todd C. Miller Date: Sat, 17 Oct 1998 22:07:21 +0000 (+0000) Subject: Initial revision X-Git-Tag: SUDO_1_5_7~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=176c73421b62dd0237378aefd55a026090341dbb;p=sudo Initial revision --- diff --git a/secureware.c b/secureware.c new file mode 100644 index 000000000..01c01a11c --- /dev/null +++ b/secureware.c @@ -0,0 +1,112 @@ +/* + * CU sudo version 1.5.7 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Please send bugs, changes, problems to sudo-bugs@courtesan.com + * + ******************************************************************* + * + * secureware.c -- check a user's password when using SecureWare C2 + * + * Todd C. Miller (millert@colorado.edu) Sat Oct 17 14:42:44 MDT 1998 + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif /* lint */ + +#include "config.h" + +#ifdef HAVE_GETPRPWUID + +#include +#ifdef STDC_HEADERS +#include +#endif /* STDC_HEADERS */ +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ +#ifdef HAVE_STRINGS_H +#include +#endif /* HAVE_STRINGS_H */ +#include +#include +#include +#include +#include "sudo.h" +#ifdef __hpux +# include +#else +# include +#endif /* __hpux */ +#include + + +/* + * Globals + */ +#ifdef __alpha +extern int crypt_type; +#endif /* __alpha */ + +/******************************************************************** + * + * check_secureware() + * + * This function checks a password against the user's encrypted one + * using the SecureWare crypt functions. + */ + +int check_secureware(pass) + char *pass; +{ +#ifndef __alpha +# ifdef HAVE_BIGCRYPT + if (strcmp(user_passwd, bigcrypt(pass, user_passwd)) == 0) + return(1); +# endif /* HAVE_BIGCRYPT */ +#else /* __alpha */ + switch (crypt_type) { + case AUTH_CRYPT_BIGCRYPT: + if (!strcmp(user_passwd, bigcrypt(pass, user_passwd))) + return(1); + break; + case AUTH_CRYPT_CRYPT16: + if (!strcmp(user_passwd, crypt16(pass, user_passwd))) + return(1); + break; +# ifdef AUTH_CRYPT_OLDCRYPT + case AUTH_CRYPT_OLDCRYPT: + case AUTH_CRYPT_C1CRYPT: +# endif + case -1: + if (!strcmp(user_passwd, crypt(pass, user_passwd))) + return(1); + break; + default: + (void) fprintf(stderr, + "%s: Sorry, I don't know how to deal with crypt type %d.\n", + Argv[0], crypt_type); + exit(1); + } + return(0); +#endif /* __alpha */ +} + +#endif /* HAVE_GETPRPWUID */