usched: Allow process to change self cpu affinity
[dragonfly.git] / lib / libopie / opieextra.c
blob0e98841e58e49464d95ea7c24d92c0f01d591f22
1 /*
2 * This file contains routines modified from OpenBSD. Parts are contributed
3 * by Todd Miller <millert@openbsd.org>, Theo De Raadt <deraadt@openbsd.org>
4 * and possibly others.
6 * $FreeBSD: src/lib/libopie/opieextra.c,v 1.1.2.2 2002/07/15 14:17:08 des Exp $
7 */
9 #include <sys/types.h>
10 #include <stdio.h>
11 #include <opie.h>
14 * opie_haopie()
16 * Returns: 1 user doesnt exist, -1 file error, 0 user exists.
19 int
20 opie_haskey(char *username)
22 struct opie opie;
24 return opielookup(&opie, username);
28 * opie_keyinfo()
30 * Returns the current sequence number and
31 * seed for the passed user.
34 char *
35 opie_keyinfo(char *username)
37 int i;
38 static char str[OPIE_CHALLENGE_MAX];
39 struct opie opie;
41 i = opiechallenge(&opie, username, str);
42 if (i == -1)
43 return(0);
45 return(str);
49 * opie_passverify()
51 * Check to see if answer is the correct one to the current
52 * challenge.
54 * Returns: 0 success, -1 failure
57 int
58 opie_passverify(char *username, char *passwd)
60 int i;
61 struct opie opie;
63 i = opielookup(&opie, username);
64 if (i == -1 || i == 1)
65 return(-1);
67 if (opieverify(&opie, passwd) == 0)
68 return(opie.opie_n);
70 return(-1);
73 #define OPIE_HASH_DEFAULT 1
75 /* Current hash type (index into opie_hash_types array) */
76 static int opie_hash_type = OPIE_HASH_DEFAULT;
78 struct opie_algorithm_table {
79 const char *name;
82 static struct opie_algorithm_table opie_algorithm_table[] = {
83 { "md4" }, { "md5" }
86 /* Get current hash type */
87 const char *
88 opie_get_algorithm(void)
90 return(opie_algorithm_table[opie_hash_type].name);