diff options
Diffstat (limited to 'usr.bin/sudo/auth/securid.c')
-rw-r--r-- | usr.bin/sudo/auth/securid.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/usr.bin/sudo/auth/securid.c b/usr.bin/sudo/auth/securid.c index 987862289cd..9da4d5e4e48 100644 --- a/usr.bin/sudo/auth/securid.c +++ b/usr.bin/sudo/auth/securid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com> + * Copyright (c) 1999-2001 Todd C. Miller <Todd.Miller@courtesan.com> * All rights reserved. * * This code is derived from software contributed by Giles Todd @@ -37,21 +37,27 @@ #include "config.h" +#include <sys/types.h> +#include <sys/param.h> #include <stdio.h> #ifdef STDC_HEADERS -#include <stdlib.h> +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif #endif /* STDC_HEADERS */ -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H -#include <string.h> +# include <string.h> +#else +# ifdef HAVE_STRINGS_H +# include <strings.h> +# endif #endif /* HAVE_STRING_H */ -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif /* HAVE_STRINGS_H */ -#include <sys/param.h> -#include <sys/types.h> +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ #include <pwd.h> #include <sdi_athd.h> @@ -62,7 +68,7 @@ #include "sudo_auth.h" #ifndef lint -static const char rcsid[] = "$Sudo: securid.c,v 1.6 1999/12/02 20:21:31 millert Exp $"; +static const char rcsid[] = "$Sudo: securid.c,v 1.8 2001/12/14 19:52:53 millert Exp $"; #endif /* lint */ union config_record configure; @@ -76,8 +82,11 @@ securid_init(pw, promptp, auth) static struct SD_CLIENT sd_dat; /* SecurID data block */ auth->data = (VOID *) &sd_dat; /* For method-specific data */ - creadcfg(); /* Only read config file once */ - return(AUTH_SUCCESS); + + if (creadcfg() == 0) + return(AUTH_SUCCESS); + else + return(AUTH_FATAL); } int @@ -89,9 +98,10 @@ securid_setup(pw, promptp, auth) struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data; /* Re-initialize SecurID every time. */ - if (sd_init(sd) == 0) + if (sd_init(sd) == 0) { + strcpy(sd->username, pw->pw_name); return(AUTH_SUCCESS); - else { + } else { (void) fprintf(stderr, "%s: Cannot contact SecurID server\n", Argv[0]); return(AUTH_FATAL); } @@ -104,8 +114,11 @@ securid_verify(pw, pass, auth) sudo_auth *auth; { struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data; + int rval; - if (sd_auth(sd) == ACM_OK) + rval = sd_auth(sd); + sd_close(); + if (rval == ACM_OK) return(AUTH_SUCCESS); else return(AUTH_FAILURE); |