xref: /dragonfly/contrib/pam_passwdqc/passwdqc.h (revision 7d3e9a5b)
1 /*
2  * Copyright (c) 2000-2002,2016,2019,2020,2021 by Solar Designer
3  * Copyright (c) 2008,2009 by Dmitry V. Levin
4  * See LICENSE
5  */
6 
7 #ifndef PASSWDQC_H__
8 #define PASSWDQC_H__
9 
10 #ifndef _MSC_VER
11 #include <pwd.h>
12 #endif
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #ifdef _MSC_VER
19 /* Partial struct passwd just to accommodate passwdqc code's expectations */
20 struct passwd {
21 	char *pw_name;
22 	char *pw_passwd;
23 	char *pw_gecos;
24 	char *pw_dir;
25 	char *pw_shell;
26 };
27 #endif
28 
29 typedef struct {
30 	int min[5], max;
31 	int passphrase_words;
32 	int match_length;
33 	int similar_deny;
34 	int random_bits;
35 	char *wordlist;
36 	char *denylist;
37 	char *filter;
38 } passwdqc_params_qc_t;
39 
40 typedef struct {
41 	int flags;
42 	int retry;
43 } passwdqc_params_pam_t;
44 
45 typedef struct {
46 	passwdqc_params_qc_t qc;
47 	passwdqc_params_pam_t pam;
48 } passwdqc_params_t;
49 
50 extern const char *passwdqc_check(const passwdqc_params_qc_t *params,
51     const char *newpass, const char *oldpass, const struct passwd *pw);
52 extern char *passwdqc_random(const passwdqc_params_qc_t *params);
53 
54 extern int passwdqc_params_parse(passwdqc_params_t *params,
55     char **reason, int argc, const char *const *argv);
56 extern int passwdqc_params_load(passwdqc_params_t *params,
57     char **reason, const char *pathname);
58 extern void passwdqc_params_reset(passwdqc_params_t *params);
59 extern void passwdqc_params_free(passwdqc_params_t *params);
60 
61 #define F_ENFORCE_MASK			0x00000003
62 #define F_ENFORCE_USERS			0x00000001
63 #define F_ENFORCE_ROOT			0x00000002
64 #define F_ENFORCE_EVERYONE		F_ENFORCE_MASK
65 #define F_NON_UNIX			0x00000004
66 #define F_ASK_OLDAUTHTOK_MASK		0x00000030
67 #define F_ASK_OLDAUTHTOK_PRELIM		0x00000010
68 #define F_ASK_OLDAUTHTOK_UPDATE		0x00000020
69 #define F_CHECK_OLDAUTHTOK		0x00000040
70 #define F_USE_FIRST_PASS		0x00000100
71 #define F_USE_AUTHTOK			0x00000200
72 #define F_NO_AUDIT			0x00000400
73 
74 #define PASSWDQC_VERSION		"2.0.2"
75 
76 extern void (*_passwdqc_memzero)(void *, size_t);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* PASSWDQC_H__ */
83