Remove extra whitespace at the end of some lines.
[dragonfly.git] / contrib / libpam / modules / pam_unix / support.h
1 /*
2  * $Id: support.h,v 1.3 2000/12/20 05:15:05 vorlon Exp $
3  * $FreeBSD: src/contrib/libpam/modules/pam_unix/support.h,v 1.1.1.1.2.2 2001/06/11 15:28:30 markm Exp $
4  * $DragonFly: src/contrib/libpam/modules/pam_unix/Attic/support.h,v 1.2 2003/06/17 04:24:03 dillon Exp $
5  */
6
7 #ifndef _PAM_UNIX_SUPPORT_H
8 #define _PAM_UNIX_SUPPORT_H
9
10
11 /*
12  * here is the string to inform the user that the new passwords they
13  * typed were not the same.
14  */
15
16 #define MISTYPED_PASS "Sorry, passwords do not match"
17
18 /* type definition for the control options */
19
20 typedef struct {
21         const char *token;
22         unsigned int mask;      /* shall assume 32 bits of flags */
23         unsigned int flag;
24 } UNIX_Ctrls;
25
26 /*
27  * macro to determine if a given flag is on
28  */
29
30 #define on(x,ctrl)  (unix_args[x].flag & ctrl)
31
32 /*
33  * macro to determine that a given flag is NOT on
34  */
35
36 #define off(x,ctrl) (!on(x,ctrl))
37
38 /*
39  * macro to turn on/off a ctrl flag manually
40  */
41
42 #define set(x,ctrl)   (ctrl = ((ctrl)&unix_args[x].mask)|unix_args[x].flag)
43 #define unset(x,ctrl) (ctrl &= ~(unix_args[x].flag))
44
45 /* the generic mask */
46
47 #define _ALL_ON_  (~0U)
48
49 /* end of macro definitions definitions for the control flags */
50
51 /* ****************************************************************** *
52  * ctrl flags proper..
53  */
54
55 /*
56  * here are the various options recognized by the unix module. They
57  * are enumerated here and then defined below. Internal arguments are
58  * given NULL tokens.
59  */
60
61 #define UNIX__OLD_PASSWD          0     /* internal */
62 #define UNIX__VERIFY_PASSWD       1     /* internal */
63 #define UNIX__IAMROOT             2     /* internal */
64
65 #define UNIX_AUDIT                3     /* print more things than debug..
66                                            some information may be sensitive */
67 #define UNIX_USE_FIRST_PASS       4
68 #define UNIX_TRY_FIRST_PASS       5
69 #define UNIX_NOT_SET_PASS         6     /* don't set the AUTHTOK items */
70
71 #define UNIX__PRELIM              7     /* internal */
72 #define UNIX__UPDATE              8     /* internal */
73 #define UNIX__NONULL              9     /* internal */
74 #define UNIX__QUIET              10     /* internal */
75 #define UNIX_USE_AUTHTOK         11     /* insist on reading PAM_AUTHTOK */
76 #define UNIX_SHADOW              12     /* signal shadow on */
77 #define UNIX_MD5_PASS            13     /* force the use of MD5 passwords */
78 #define UNIX__NULLOK             14     /* Null token ok */
79 #define UNIX_DEBUG               15     /* send more info to syslog(3) */
80 #define UNIX_NODELAY             16     /* admin does not want a fail-delay */
81 #define UNIX_NIS                 17     /* wish to use NIS for pwd */
82 #define UNIX_BIGCRYPT            18     /* use DEC-C2 crypt()^x function */
83 #define UNIX_LIKE_AUTH           19     /* need to auth for setcred to work */
84 #define UNIX_REMEMBER_PASSWD     20     /* Remember N previous passwords */
85 /* -------------- */
86 #define UNIX_CTRLS_              21     /* number of ctrl arguments defined */
87
88
89 static const UNIX_Ctrls unix_args[UNIX_CTRLS_] =
90 {
91 /* symbol                  token name          ctrl mask             ctrl     *
92  * ----------------------- ------------------- --------------------- -------- */
93
94 /* UNIX__OLD_PASSWD */     {NULL,              _ALL_ON_,                  01},
95 /* UNIX__VERIFY_PASSWD */  {NULL,              _ALL_ON_,                  02},
96 /* UNIX__IAMROOT */        {NULL,              _ALL_ON_,                  04},
97 /* UNIX_AUDIT */           {"audit",           _ALL_ON_,                 010},
98 /* UNIX_USE_FIRST_PASS */  {"use_first_pass",  _ALL_ON_^(060),           020},
99 /* UNIX_TRY_FIRST_PASS */  {"try_first_pass",  _ALL_ON_^(060),           040},
100 /* UNIX_NOT_SET_PASS */    {"not_set_pass",    _ALL_ON_,                0100},
101 /* UNIX__PRELIM */         {NULL,              _ALL_ON_^(0600),         0200},
102 /* UNIX__UPDATE */         {NULL,              _ALL_ON_^(0600),         0400},
103 /* UNIX__NONULL */         {NULL,              _ALL_ON_,               01000},
104 /* UNIX__QUIET */          {NULL,              _ALL_ON_,               02000},
105 /* UNIX_USE_AUTHTOK */     {"use_authtok",     _ALL_ON_,               04000},
106 /* UNIX_SHADOW */          {"shadow",          _ALL_ON_,              010000},
107 /* UNIX_MD5_PASS */        {"md5",             _ALL_ON_^(0400000),    020000},
108 /* UNIX__NULLOK */         {"nullok",          _ALL_ON_^(01000),           0},
109 /* UNIX_DEBUG */           {"debug",           _ALL_ON_,              040000},
110 /* UNIX_NODELAY */         {"nodelay",         _ALL_ON_,             0100000},
111 /* UNIX_NIS */             {"nis",             _ALL_ON_^(010000),    0200000},
112 /* UNIX_BIGCRYPT */        {"bigcrypt",        _ALL_ON_^(020000),    0400000},
113 /* UNIX_LIKE_AUTH */       {"likeauth",        _ALL_ON_,            01000000},
114 /* UNIX_REMEMBER_PASSWD */ {"remember=",       _ALL_ON_,            02000000},
115 };
116
117 #define UNIX_DEFAULTS  (unix_args[UNIX__NONULL].flag)
118
119
120 /* use this to free strings. ESPECIALLY password strings */
121
122 #define _pam_delete(xx)         \
123 {                               \
124         _pam_overwrite(xx);     \
125         _pam_drop(xx);          \
126 }
127
128 extern char *PAM_getlogin(void);
129 extern void _log_err(int err, pam_handle_t *pamh, const char *format,...);
130 extern int _make_remark(pam_handle_t * pamh, unsigned int ctrl
131                        ,int type, const char *text);
132 extern int _set_ctrl(pam_handle_t * pamh, int flags, int *remember, int argc,
133                      const char **argv);
134 extern int _unix_blankpasswd(unsigned int ctrl, const char *name);
135 extern int _unix_verify_password(pam_handle_t * pamh, const char *name
136                           ,const char *p, unsigned int ctrl);
137 extern int _unix_read_password(pam_handle_t * pamh
138                         ,unsigned int ctrl
139                         ,const char *comment
140                         ,const char *prompt1
141                         ,const char *prompt2
142                         ,const char *data_name
143                         ,const char **pass);
144
145 #endif /* _PAM_UNIX_SUPPORT_H */
146