Mercurial > crates > nonstick
comparison libpam-sys/src/constants.rs @ 118:39760dfc9b3b
Detect PAM library based only on system lib; rename minimal lib to XSso.
Also formats and assorted other cleanup.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 29 Jun 2025 20:13:03 -0400 |
parents | 178310336596 |
children | f469b8d9ad78 |
comparison
equal
deleted
inserted
replaced
117:20f7712a6857 | 118:39760dfc9b3b |
---|---|
37 (($n:expr) $(#[$attr:meta])*) => {}; | 37 (($n:expr) $(#[$attr:meta])*) => {}; |
38 } | 38 } |
39 | 39 |
40 // There are a few truly universal constants. | 40 // There are a few truly universal constants. |
41 // They are defined here directly. | 41 // They are defined here directly. |
42 /// The successful return code. | |
42 pub const PAM_SUCCESS: i32 = 0; | 43 pub const PAM_SUCCESS: i32 = 0; |
43 | 44 |
44 c_enum!( | 45 c_enum!( |
45 /// An item type. | 46 /// An item type. |
46 PAM_SERVICE = 1, | 47 PAM_SERVICE = 1, |
49 PAM_RHOST, | 50 PAM_RHOST, |
50 PAM_CONV, | 51 PAM_CONV, |
51 PAM_AUTHTOK, | 52 PAM_AUTHTOK, |
52 PAM_OLDAUTHTOK, | 53 PAM_OLDAUTHTOK, |
53 PAM_RUSER, | 54 PAM_RUSER, |
55 PAM_USER_PROMPT, | |
54 ); | 56 ); |
55 | 57 |
56 c_enum!( | 58 c_enum!( |
57 /// A message style. | 59 /// A message style. |
58 PAM_PROMPT_ECHO_OFF = 1, | 60 PAM_PROMPT_ECHO_OFF = 1, |
71 #[cfg_pam_impl("LinuxPam")] | 73 #[cfg_pam_impl("LinuxPam")] |
72 pub use linux_pam::*; | 74 pub use linux_pam::*; |
73 #[cfg_pam_impl("LinuxPam")] | 75 #[cfg_pam_impl("LinuxPam")] |
74 mod linux_pam { | 76 mod linux_pam { |
75 c_enum!( | 77 c_enum!( |
76 /// An error code. | 78 /// An error return code. |
77 PAM_OPEN_ERR = 1, | 79 PAM_OPEN_ERR = 1, |
78 PAM_SYMBOL_ERR, | 80 PAM_SYMBOL_ERR, |
79 PAM_SERVICE_ERR, | 81 PAM_SERVICE_ERR, |
80 PAM_SYSTEM_ERR, | 82 PAM_SYSTEM_ERR, |
81 PAM_BUF_ERR, | 83 PAM_BUF_ERR, |
105 PAM_BAD_ITEM, | 107 PAM_BAD_ITEM, |
106 PAM_CONV_AGAIN, | 108 PAM_CONV_AGAIN, |
107 PAM_INCOMPLETE, | 109 PAM_INCOMPLETE, |
108 _PAM_RETURN_VALUES, | 110 _PAM_RETURN_VALUES, |
109 ); | 111 ); |
110 /// An error code. | |
111 pub const PAM_AUTHTOK_RECOVER_ERR: i32 = 21; | |
112 | 112 |
113 define!( | 113 define!( |
114 /// A flag value. | 114 /// A flag value. |
115 PAM_SILENT = 0x8000; | 115 PAM_SILENT = 0x8000; |
116 PAM_DISALLOW_NULL_AUTHTOK = 0x0001; | 116 PAM_DISALLOW_NULL_AUTHTOK = 0x0001; |
125 PAM_UPDATE_AUTHTOK = 0x2000; | 125 PAM_UPDATE_AUTHTOK = 0x2000; |
126 PAM_DATA_REPLACE = 0x20000000; | 126 PAM_DATA_REPLACE = 0x20000000; |
127 ); | 127 ); |
128 | 128 |
129 c_enum!( | 129 c_enum!( |
130 PAM_USER_PROMPT = 9, | 130 PAM_FAIL_DELAY = 10, |
131 PAM_FAIL_DELAY, | |
132 PAM_XDISPLAY, | 131 PAM_XDISPLAY, |
133 PAM_XAUTHDATA, | 132 PAM_XAUTHDATA, |
134 PAM_AUTHTOK_TYPE, | 133 PAM_AUTHTOK_TYPE, |
135 ); | 134 ); |
136 | 135 |
143 PAM_RADIO_TYPE = 5; | 142 PAM_RADIO_TYPE = 5; |
144 PAM_BINARY_PROMPT = 7; | 143 PAM_BINARY_PROMPT = 7; |
145 ); | 144 ); |
146 } | 145 } |
147 | 146 |
148 #[cfg_pam_impl(any("OpenPam", "OpenPamMinimal", "Sun"))] | 147 #[cfg_pam_impl(any("OpenPam", "Sun", "XSso"))] |
149 pub use openpam_sun::*; | 148 pub use xsso_shared::*; |
150 #[cfg_pam_impl(any("OpenPam", "OpenPamMinimal", "Sun"))] | 149 #[cfg_pam_impl(any("OpenPam", "Sun", "XSso"))] |
151 mod openpam_sun { | 150 mod xsso_shared { |
152 c_enum!( | 151 c_enum!( |
153 /// An error code. | 152 /// An error return code. |
154 PAM_OPEN_ERR = 1, | 153 PAM_OPEN_ERR = 1, |
155 PAM_SYMBOL_ERR, | 154 PAM_SYMBOL_ERR, |
156 PAM_SERVICE_ERR, | 155 PAM_SERVICE_ERR, |
157 PAM_SYSTEM_ERR, | 156 PAM_SYSTEM_ERR, |
158 PAM_BUF_ERR, | 157 PAM_BUF_ERR, |
177 PAM_NO_MODULE_DATA, | 176 PAM_NO_MODULE_DATA, |
178 PAM_IGNORE, | 177 PAM_IGNORE, |
179 PAM_ABORT, | 178 PAM_ABORT, |
180 PAM_TRY_AGAIN, | 179 PAM_TRY_AGAIN, |
181 ); | 180 ); |
182 | 181 // While `PAM_MODULE_UNKNOWN` and `PAM_DOMAIN_UNKNOWN` are in X/SSO, |
183 define!( | 182 // Sun doesn't use them so we're omitting them here. |
184 /// An item type. | |
185 PAM_USER_PROMPT = 9; | |
186 PAM_REPOSITORY = 10; | |
187 ); | |
188 | 183 |
189 /// A general flag for PAM operations. | 184 /// A general flag for PAM operations. |
190 pub const PAM_SILENT: i32 = 0x80000000u32 as i32; | 185 pub const PAM_SILENT: i32 = 0x80000000u32 as i32; |
191 | 186 |
192 /// The password must be non-null. | 187 /// A flag for `pam_authenticate`. |
193 pub const PAM_DISALLOW_NULL_AUTHTOK: i32 = 0b1; | 188 pub const PAM_DISALLOW_NULL_AUTHTOK: i32 = 0b1; |
194 | 189 |
195 define!( | 190 define!( |
196 /// A flag for `pam_setcred`. | 191 /// A flag for `pam_setcred`. |
197 PAM_ESTABLISH_CRED = 0b0001; | 192 PAM_ESTABLISH_CRED = 0b0001; |
199 PAM_REINITIALIZE_CRED = 0b0100; | 194 PAM_REINITIALIZE_CRED = 0b0100; |
200 PAM_REFRESH_CRED = 0b1000; | 195 PAM_REFRESH_CRED = 0b1000; |
201 ); | 196 ); |
202 | 197 |
203 define!( | 198 define!( |
204 /// A flag for `pam_chauthtok`. | 199 /// A flag for `pam_sm_chauthtok`. |
205 PAM_PRELIM_CHECK = 0b0001; | 200 PAM_PRELIM_CHECK = 0b0001; |
206 PAM_UPDATE_AUTHTOK = 0b0010; | 201 PAM_UPDATE_AUTHTOK = 0b0010; |
207 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; | 202 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; |
208 ); | 203 ); |
209 } | 204 } |
211 #[cfg_pam_impl("OpenPam")] | 206 #[cfg_pam_impl("OpenPam")] |
212 pub use openpam::*; | 207 pub use openpam::*; |
213 #[cfg_pam_impl("OpenPam")] | 208 #[cfg_pam_impl("OpenPam")] |
214 mod openpam { | 209 mod openpam { |
215 c_enum!( | 210 c_enum!( |
216 /// An error code. | 211 /// An error return code. |
217 PAM_MODULE_UNKNOWN = 28, | 212 PAM_MODULE_UNKNOWN = 28, |
218 PAM_DOMAIN_UNKNOWN, | 213 PAM_DOMAIN_UNKNOWN, |
219 PAM_BAD_HANDLE, | 214 PAM_BAD_HANDLE, |
220 PAM_BAD_ITEM, | 215 PAM_BAD_ITEM, |
221 PAM_BAD_FEATURE, | 216 PAM_BAD_FEATURE, |
222 PAM_BAD_CONSTANT, | 217 PAM_BAD_CONSTANT, |
223 ); | 218 ); |
224 /// The total number of PAM error codes. | 219 /// The total number of PAM error codes (including success). |
225 pub const PAM_NUM_ERRORS: i32 = 34; | 220 pub const PAM_NUM_ERRORS: i32 = 34; |
226 | 221 |
227 c_enum!( | 222 c_enum!( |
228 /// An item type. | 223 /// An item type. |
229 PAM_AUTHTOK_PROMPT = 11, | 224 PAM_REPOSITORY = 10, |
225 PAM_AUTHTOK_PROMPT, | |
230 PAM_OLDAUTHTOK_PROMPT, | 226 PAM_OLDAUTHTOK_PROMPT, |
231 PAM_HOST, | 227 PAM_HOST, |
232 ); | 228 ); |
233 /// The total number of PAM items. | 229 /// The total number of PAM items. |
234 pub const PAM_NUM_ITEMS: i32 = 14; | 230 pub const PAM_NUM_ITEMS: i32 = 14; |
260 #[cfg_pam_impl("Sun")] | 256 #[cfg_pam_impl("Sun")] |
261 mod sun { | 257 mod sun { |
262 /// The total number of PAM error codes. | 258 /// The total number of PAM error codes. |
263 pub const PAM_TOTAL_ERRNUM: i32 = 28; | 259 pub const PAM_TOTAL_ERRNUM: i32 = 28; |
264 | 260 |
265 define!( | 261 c_enum!( |
266 /// An item type. | 262 /// An item type. |
267 PAM_RESOURCE = 11; | 263 PAM_REPOSITORY = 10, |
268 PAM_AUSER = 12; | 264 PAM_RESOURCE, |
265 PAM_AUSER, | |
269 ); | 266 ); |
270 | 267 |
271 /// A flag for `pam_chauthtok`. | 268 /// A flag for `pam_chauthtok`. |
272 pub const PAM_NO_AUTHTOK_CHECK: i32 = 0b1000; | 269 pub const PAM_NO_AUTHTOK_CHECK: i32 = 0b1000; |
273 } | 270 } |