diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-28 20:59:14 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-28 20:59:14 +0000 |
commit | e3443694d8a58001ae4cffdc910018fcf364e4f4 (patch) | |
tree | 24205b0060581ab811200496e3dd2432dc9880ff /lib | |
parent | b605a8e06b128871ca9dfc37360548b403548215 (diff) |
fix skeygetnext()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libskey/skeylogin.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c index 620378d53c5..2d85b18703d 100644 --- a/lib/libskey/skeylogin.c +++ b/lib/libskey/skeylogin.c @@ -10,7 +10,7 @@ * * S/Key verification check, lookups, and authentication. * - * $OpenBSD: skeylogin.c,v 1.49 2003/04/03 17:48:50 millert Exp $ + * $OpenBSD: skeylogin.c,v 1.50 2003/04/28 20:59:13 millert Exp $ */ #include <sys/param.h> @@ -37,6 +37,7 @@ static void skey_fakeprompt(char *, char *); static char *tgetline(int, char *, size_t, int); +static int skeygetent(struct skey *, const char *); /* * Return an skey challenge string for user 'name'. If successful, @@ -74,15 +75,15 @@ skeychallenge(struct skey *mp, char *name, char *ss) } /* - * Find an entry in the One-time Password database and lock it. + * Get an entry in the One-time Password database and lock it. * * Return codes: * -1: error in opening database or unable to lock entry * 0: entry found, file R/W pointer positioned at beginning of record * 1: entry not found */ -int -skeylookup(struct skey *mp, char *name) +static int +skeygetent(struct skey *mp, const char *name) { struct stat statbuf; size_t nread; @@ -90,8 +91,6 @@ skeylookup(struct skey *mp, char *name) FILE *keyfile; int fd; - memset(mp, 0, sizeof(*mp)); - /* Check to see that /etc/skey has not been disabled. */ if (stat(_PATH_SKEYDIR, &statbuf) != 0) return (-1); @@ -171,6 +170,22 @@ skeylookup(struct skey *mp, char *name) } /* + * Look up an entry in the One-time Password database and lock it. + * Zeroes out the passed in struct skey before using it. + * + * Return codes: + * -1: error in opening database or unable to lock entry + * 0: entry found, file R/W pointer positioned at beginning of record + * 1: entry not found + */ +int +skeylookup(struct skey *mp, char *name) +{ + memset(mp, 0, sizeof(*mp)); + return (skeygetent(mp, name)); +} + +/* * Get the next entry in the One-time Password database. * * Return codes: @@ -197,9 +212,9 @@ skeygetnext(struct skey *mp) while ((readdir_r(mp->keydir, &entry, &dp)) == 0 && dp == &entry) { /* Skip dot files and zero-length files. */ if (entry.d_name[0] != '.' && - (rval = skeylookup(mp, entry.d_name) != 1)) + (rval = skeygetent(mp, entry.d_name)) != 1) break; - }; + } if (dp == NULL) { closedir(mp->keydir); |