1use libc::{gid_t, group, passwd, spwd, uid_t};
4
5pub const PAM_SUCCESS: i32 = 0;
6pub const PAM_OPEN_ERR: i32 = 1;
7pub const PAM_SYMBOL_ERR: i32 = 2;
8pub const PAM_SERVICE_ERR: i32 = 3;
9pub const PAM_SYSTEM_ERR: i32 = 4;
10pub const PAM_BUF_ERR: i32 = 5;
11pub const PAM_PERM_DENIED: i32 = 6;
12pub const PAM_AUTH_ERR: i32 = 7;
13pub const PAM_CRED_INSUFFICIENT: i32 = 8;
14pub const PAM_AUTHINFO_UNAVAIL: i32 = 9;
15pub const PAM_USER_UNKNOWN: i32 = 10;
16pub const PAM_MAXTRIES: i32 = 11;
17pub const PAM_NEW_AUTHTOK_REQD: i32 = 12;
18pub const PAM_ACCT_EXPIRED: i32 = 13;
19pub const PAM_SESSION_ERR: i32 = 14;
20pub const PAM_CRED_UNAVAIL: i32 = 15;
21pub const PAM_CRED_EXPIRED: i32 = 16;
22pub const PAM_CRED_ERR: i32 = 17;
23pub const PAM_NO_MODULE_DATA: i32 = 18;
24pub const PAM_CONV_ERR: i32 = 19;
25pub const PAM_AUTHTOK_ERR: i32 = 20;
26pub const PAM_AUTHTOK_RECOVERY_ERR: i32 = 21;
27pub const PAM_AUTHTOK_LOCK_BUSY: i32 = 22;
28pub const PAM_AUTHTOK_DISABLE_AGING: i32 = 23;
29pub const PAM_TRY_AGAIN: i32 = 24;
30pub const PAM_IGNORE: i32 = 25;
31pub const PAM_ABORT: i32 = 26;
32pub const PAM_AUTHTOK_EXPIRED: i32 = 27;
33pub const PAM_MODULE_UNKNOWN: i32 = 28;
34pub const PAM_BAD_ITEM: i32 = 29;
35pub const PAM_CONV_AGAIN: i32 = 30;
36pub const PAM_INCOMPLETE: i32 = 31;
37pub const PAM_SILENT: i32 = 32768;
38pub const PAM_DISALLOW_NULL_AUTHTOK: i32 = 1;
39pub const PAM_ESTABLISH_CRED: i32 = 2;
40pub const PAM_DELETE_CRED: i32 = 4;
41pub const PAM_REINITIALIZE_CRED: i32 = 8;
42pub const PAM_REFRESH_CRED: i32 = 16;
43pub const PAM_CHANGE_EXPIRED_AUTHTOK: i32 = 32;
44pub const PAM_SERVICE: i32 = 1;
45pub const PAM_USER: i32 = 2;
46pub const PAM_TTY: i32 = 3;
47pub const PAM_RHOST: i32 = 4;
48pub const PAM_CONV: i32 = 5;
49pub const PAM_AUTHTOK: i32 = 6;
50pub const PAM_OLDAUTHTOK: i32 = 7;
51pub const PAM_RUSER: i32 = 8;
52pub const PAM_USER_PROMPT: i32 = 9;
53pub const PAM_FAIL_DELAY: i32 = 10;
54pub const PAM_XDISPLAY: i32 = 11;
55pub const PAM_XAUTHDATA: i32 = 12;
56pub const PAM_AUTHTOK_TYPE: i32 = 13;
57pub const PAM_DATA_SILENT: i32 = 1073741824;
58pub const PAM_PROMPT_ECHO_OFF: i32 = 1;
59pub const PAM_PROMPT_ECHO_ON: i32 = 2;
60pub const PAM_ERROR_MSG: i32 = 3;
61pub const PAM_TEXT_INFO: i32 = 4;
62pub const PAM_RADIO_TYPE: i32 = 5;
63pub const PAM_BINARY_PROMPT: i32 = 7;
64pub const PAM_MAX_NUM_MSG: i32 = 32;
65pub const PAM_MAX_MSG_SIZE: i32 = 512;
66pub const PAM_MAX_RESP_SIZE: i32 = 512;
67pub const PAM_AUTHTOK_RECOVER_ERR: i32 = 21;
68pub const PAM_BP_MAX_LENGTH: i32 = 131072;
69pub const PAM_BPC_FALSE: i32 = 0;
70pub const PAM_BPC_TRUE: i32 = 1;
71pub const PAM_BPC_OK: i32 = 1;
72pub const PAM_BPC_SELECT: i32 = 2;
73pub const PAM_BPC_DONE: i32 = 3;
74pub const PAM_BPC_FAIL: i32 = 4;
75pub const PAM_BPC_GETENV: i32 = 65;
76pub const PAM_BPC_PUTENV: i32 = 66;
77pub const PAM_BPC_TEXT: i32 = 67;
78pub const PAM_BPC_ERROR: i32 = 68;
79pub const PAM_BPC_PROMPT: i32 = 69;
80pub const PAM_BPC_PASS: i32 = 70;
81pub const PAM_PRELIM_CHECK: i32 = 16384;
82pub const PAM_UPDATE_AUTHTOK: i32 = 8192;
83pub const PAM_DATA_REPLACE: i32 = 536870912;
84pub const PAM_MODUTIL_NGROUPS: i32 = 64;
85pub type pam_handle_t = u8;
86unsafe extern "C" {
87 pub fn pam_set_item(
88 pamh: *mut pam_handle_t,
89 item_type: libc::c_int,
90 item: *const libc::c_void,
91 ) -> libc::c_int;
92}
93unsafe extern "C" {
94 pub fn pam_get_item(
95 pamh: *const pam_handle_t,
96 item_type: libc::c_int,
97 item: *mut *const libc::c_void,
98 ) -> libc::c_int;
99}
100unsafe extern "C" {
101 pub fn pam_strerror(pamh: *mut pam_handle_t, errnum: libc::c_int) -> *const libc::c_char;
102}
103unsafe extern "C" {
104 pub fn pam_putenv(pamh: *mut pam_handle_t, name_value: *const libc::c_char) -> libc::c_int;
105}
106unsafe extern "C" {
107 pub fn pam_getenv(pamh: *mut pam_handle_t, name: *const libc::c_char) -> *const libc::c_char;
108}
109unsafe extern "C" {
110 pub fn pam_getenvlist(pamh: *mut pam_handle_t) -> *mut *mut libc::c_char;
111}
112unsafe extern "C" {
113 pub fn pam_fail_delay(pamh: *mut pam_handle_t, musec_delay: libc::c_uint) -> libc::c_int;
114}
115#[repr(C)]
116#[derive(Debug, Copy, Clone)]
117pub struct pam_message {
118 pub msg_style: libc::c_int,
119 pub msg: *const libc::c_char,
120}
121
122const POINTER_SIZE: usize = std::mem::size_of::<*const ()>();
124const INTEGET_SIZE: usize = std::mem::size_of::<libc::c_int>();
125
126#[allow(clippy::unnecessary_operation, clippy::identity_op)]
127const _: () = {
128 ["Size of pam_message"][::std::mem::size_of::<pam_message>() - 2 * POINTER_SIZE];
129 ["Alignment of pam_message"][::std::mem::align_of::<pam_message>() - POINTER_SIZE];
130 ["Offset of field: pam_message::msg_style"]
131 [::std::mem::offset_of!(pam_message, msg_style) - 0usize];
132 ["Offset of field: pam_message::msg"][::std::mem::offset_of!(pam_message, msg) - POINTER_SIZE];
133};
134#[repr(C)]
135#[derive(Debug, Copy, Clone)]
136pub struct pam_response {
137 pub resp: *mut libc::c_char,
138 pub resp_retcode: libc::c_int,
139}
140#[allow(clippy::unnecessary_operation, clippy::identity_op)]
141const _: () = {
142 ["Size of pam_response"][::std::mem::size_of::<pam_response>() - 2usize * POINTER_SIZE];
143 ["Alignment of pam_response"][::std::mem::align_of::<pam_response>() - POINTER_SIZE];
144 ["Offset of field: pam_response::resp"][::std::mem::offset_of!(pam_response, resp) - 0usize];
145 ["Offset of field: pam_response::resp_retcode"]
146 [::std::mem::offset_of!(pam_response, resp_retcode) - POINTER_SIZE];
147};
148#[repr(C)]
149#[derive(Debug, Copy, Clone)]
150pub struct pam_conv {
151 pub conv: ::std::option::Option<
152 unsafe extern "C" fn(
153 num_msg: libc::c_int,
154 msg: *mut *const pam_message,
155 resp: *mut *mut pam_response,
156 appdata_ptr: *mut libc::c_void,
157 ) -> libc::c_int,
158 >,
159 pub appdata_ptr: *mut libc::c_void,
160}
161#[allow(clippy::unnecessary_operation, clippy::identity_op)]
162const _: () = {
163 ["Size of pam_conv"][::std::mem::size_of::<pam_conv>() - 2usize * POINTER_SIZE];
164 ["Alignment of pam_conv"][::std::mem::align_of::<pam_conv>() - POINTER_SIZE];
165 ["Offset of field: pam_conv::conv"][::std::mem::offset_of!(pam_conv, conv) - 0usize];
166 ["Offset of field: pam_conv::appdata_ptr"]
167 [::std::mem::offset_of!(pam_conv, appdata_ptr) - POINTER_SIZE];
168};
169unsafe extern "C" {
170 pub fn pam_start(
171 service_name: *const libc::c_char,
172 user: *const libc::c_char,
173 pam_conversation: *const pam_conv,
174 pamh: *mut *mut pam_handle_t,
175 ) -> libc::c_int;
176}
177unsafe extern "C" {
178 pub fn pam_start_confdir(
179 service_name: *const libc::c_char,
180 user: *const libc::c_char,
181 pam_conversation: *const pam_conv,
182 confdir: *const libc::c_char,
183 pamh: *mut *mut pam_handle_t,
184 ) -> libc::c_int;
185}
186unsafe extern "C" {
187 pub fn pam_end(pamh: *mut pam_handle_t, pam_status: libc::c_int) -> libc::c_int;
188}
189unsafe extern "C" {
190 pub fn pam_authenticate(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
191}
192unsafe extern "C" {
193 pub fn pam_setcred(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
194}
195unsafe extern "C" {
196 pub fn pam_acct_mgmt(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
197}
198unsafe extern "C" {
199 pub fn pam_open_session(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
200}
201unsafe extern "C" {
202 pub fn pam_close_session(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
203}
204unsafe extern "C" {
205 pub fn pam_chauthtok(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int;
206}
207unsafe extern "C" {
208 pub fn pam_syslog(
209 pamh: *const pam_handle_t,
210 priority: libc::c_int,
211 fmt: *const libc::c_char,
212 ...
213 );
214}
215unsafe extern "C" {
216 pub fn pam_prompt(
217 pamh: *mut pam_handle_t,
218 style: libc::c_int,
219 response: *mut *mut libc::c_char,
220 fmt: *const libc::c_char,
221 ...
222 ) -> libc::c_int;
223}
224unsafe extern "C" {
225 pub fn pam_get_authtok(
226 pamh: *mut pam_handle_t,
227 item: libc::c_int,
228 authtok: *mut *const libc::c_char,
229 prompt: *const libc::c_char,
230 ) -> libc::c_int;
231}
232unsafe extern "C" {
233 pub fn pam_get_authtok_noverify(
234 pamh: *mut pam_handle_t,
235 authtok: *mut *const libc::c_char,
236 prompt: *const libc::c_char,
237 ) -> libc::c_int;
238}
239unsafe extern "C" {
240 pub fn pam_get_authtok_verify(
241 pamh: *mut pam_handle_t,
242 authtok: *mut *const libc::c_char,
243 prompt: *const libc::c_char,
244 ) -> libc::c_int;
245}
246unsafe extern "C" {
247 pub fn pam_misc_paste_env(
248 pamh: *mut pam_handle_t,
249 user_env: *const *const libc::c_char,
250 ) -> libc::c_int;
251}
252unsafe extern "C" {
253 pub fn pam_misc_drop_env(env: *mut *mut libc::c_char) -> *mut *mut libc::c_char;
254}
255unsafe extern "C" {
256 pub fn pam_misc_setenv(
257 pamh: *mut pam_handle_t,
258 name: *const libc::c_char,
259 value: *const libc::c_char,
260 readonly: libc::c_int,
261 ) -> libc::c_int;
262}
263unsafe extern "C" {
264 pub fn pam_set_data(
265 pamh: *mut pam_handle_t,
266 module_data_name: *const libc::c_char,
267 data: *mut libc::c_void,
268 cleanup: ::std::option::Option<
269 unsafe extern "C" fn(
270 pamh: *mut pam_handle_t,
271 data: *mut libc::c_void,
272 error_status: libc::c_int,
273 ),
274 >,
275 ) -> libc::c_int;
276}
277unsafe extern "C" {
278 pub fn pam_get_data(
279 pamh: *const pam_handle_t,
280 module_data_name: *const libc::c_char,
281 data: *mut *const libc::c_void,
282 ) -> libc::c_int;
283}
284unsafe extern "C" {
285 pub fn pam_get_user(
286 pamh: *mut pam_handle_t,
287 user: *mut *const libc::c_char,
288 prompt: *const libc::c_char,
289 ) -> libc::c_int;
290}
291unsafe extern "C" {
292 pub fn pam_sm_authenticate(
293 pamh: *mut pam_handle_t,
294 flags: libc::c_int,
295 argc: libc::c_int,
296 argv: *mut *const libc::c_char,
297 ) -> libc::c_int;
298}
299unsafe extern "C" {
300 pub fn pam_sm_setcred(
301 pamh: *mut pam_handle_t,
302 flags: libc::c_int,
303 argc: libc::c_int,
304 argv: *mut *const libc::c_char,
305 ) -> libc::c_int;
306}
307unsafe extern "C" {
308 pub fn pam_sm_acct_mgmt(
309 pamh: *mut pam_handle_t,
310 flags: libc::c_int,
311 argc: libc::c_int,
312 argv: *mut *const libc::c_char,
313 ) -> libc::c_int;
314}
315unsafe extern "C" {
316 pub fn pam_sm_open_session(
317 pamh: *mut pam_handle_t,
318 flags: libc::c_int,
319 argc: libc::c_int,
320 argv: *mut *const libc::c_char,
321 ) -> libc::c_int;
322}
323unsafe extern "C" {
324 pub fn pam_sm_close_session(
325 pamh: *mut pam_handle_t,
326 flags: libc::c_int,
327 argc: libc::c_int,
328 argv: *mut *const libc::c_char,
329 ) -> libc::c_int;
330}
331unsafe extern "C" {
332 pub fn pam_sm_chauthtok(
333 pamh: *mut pam_handle_t,
334 flags: libc::c_int,
335 argc: libc::c_int,
336 argv: *mut *const libc::c_char,
337 ) -> libc::c_int;
338}
339unsafe extern "C" {
340 pub fn pam_modutil_check_user_in_passwd(
341 pamh: *mut pam_handle_t,
342 user_name: *const libc::c_char,
343 file_name: *const libc::c_char,
344 ) -> libc::c_int;
345}
346unsafe extern "C" {
347 pub fn pam_modutil_getpwnam(pamh: *mut pam_handle_t, user: *const libc::c_char) -> *mut passwd;
348}
349unsafe extern "C" {
350 pub fn pam_modutil_getpwuid(pamh: *mut pam_handle_t, uid: uid_t) -> *mut passwd;
351}
352unsafe extern "C" {
353 pub fn pam_modutil_getgrnam(pamh: *mut pam_handle_t, group: *const libc::c_char) -> *mut group;
354}
355unsafe extern "C" {
356 pub fn pam_modutil_getgrgid(pamh: *mut pam_handle_t, gid: gid_t) -> *mut group;
357}
358unsafe extern "C" {
359 pub fn pam_modutil_getspnam(pamh: *mut pam_handle_t, user: *const libc::c_char) -> *mut spwd;
360}
361unsafe extern "C" {
362 pub fn pam_modutil_user_in_group_nam_nam(
363 pamh: *mut pam_handle_t,
364 user: *const libc::c_char,
365 group: *const libc::c_char,
366 ) -> libc::c_int;
367}
368unsafe extern "C" {
369 pub fn pam_modutil_user_in_group_nam_gid(
370 pamh: *mut pam_handle_t,
371 user: *const libc::c_char,
372 group: gid_t,
373 ) -> libc::c_int;
374}
375unsafe extern "C" {
376 pub fn pam_modutil_user_in_group_uid_nam(
377 pamh: *mut pam_handle_t,
378 user: uid_t,
379 group: *const libc::c_char,
380 ) -> libc::c_int;
381}
382unsafe extern "C" {
383 pub fn pam_modutil_user_in_group_uid_gid(
384 pamh: *mut pam_handle_t,
385 user: uid_t,
386 group: gid_t,
387 ) -> libc::c_int;
388}
389unsafe extern "C" {
390 pub fn pam_modutil_getlogin(pamh: *mut pam_handle_t) -> *const libc::c_char;
391}
392unsafe extern "C" {
393 pub fn pam_modutil_read(
394 fd: libc::c_int,
395 buffer: *mut libc::c_char,
396 count: libc::c_int,
397 ) -> libc::c_int;
398}
399unsafe extern "C" {
400 pub fn pam_modutil_write(
401 fd: libc::c_int,
402 buffer: *const libc::c_char,
403 count: libc::c_int,
404 ) -> libc::c_int;
405}
406unsafe extern "C" {
407 pub fn pam_modutil_audit_write(
408 pamh: *mut pam_handle_t,
409 type_: libc::c_int,
410 message: *const libc::c_char,
411 retval: libc::c_int,
412 ) -> libc::c_int;
413}
414#[repr(C)]
415pub struct pam_modutil_privs {
416 pub grplist: *mut gid_t,
417 pub number_of_groups: libc::c_int,
418 pub allocated: libc::c_int,
419 pub old_gid: gid_t,
420 pub old_uid: uid_t,
421 pub is_dropped: libc::c_int,
422}
423#[allow(clippy::unnecessary_operation, clippy::identity_op)]
424const _: () = {
425 ["Size of pam_modutil_privs"][::std::mem::size_of::<pam_modutil_privs>()
426 - (POINTER_SIZE + 5usize * INTEGET_SIZE).div_ceil(POINTER_SIZE) * POINTER_SIZE];
427 ["Alignment of pam_modutil_privs"][::std::mem::align_of::<pam_modutil_privs>() - POINTER_SIZE];
428 ["Offset of field: pam_modutil_privs::grplist"]
429 [::std::mem::offset_of!(pam_modutil_privs, grplist) - 0usize];
430 ["Offset of field: pam_modutil_privs::number_of_groups"]
431 [::std::mem::offset_of!(pam_modutil_privs, number_of_groups) - POINTER_SIZE];
432 ["Offset of field: pam_modutil_privs::allocated"]
433 [::std::mem::offset_of!(pam_modutil_privs, allocated) - (POINTER_SIZE + INTEGET_SIZE)];
434 ["Offset of field: pam_modutil_privs::old_gid"][::std::mem::offset_of!(
435 pam_modutil_privs,
436 old_gid
437 ) - (POINTER_SIZE + 2usize * INTEGET_SIZE)];
438 ["Offset of field: pam_modutil_privs::old_uid"][::std::mem::offset_of!(
439 pam_modutil_privs,
440 old_uid
441 ) - (POINTER_SIZE + 3usize * INTEGET_SIZE)];
442 ["Offset of field: pam_modutil_privs::is_dropped"][::std::mem::offset_of!(
443 pam_modutil_privs,
444 is_dropped
445 ) - (POINTER_SIZE + 4usize * INTEGET_SIZE)];
446};
447unsafe extern "C" {
448 pub fn pam_modutil_drop_priv(
449 pamh: *mut pam_handle_t,
450 p: *mut pam_modutil_privs,
451 pw: *const passwd,
452 ) -> libc::c_int;
453}
454unsafe extern "C" {
455 pub fn pam_modutil_regain_priv(
456 pamh: *mut pam_handle_t,
457 p: *mut pam_modutil_privs,
458 ) -> libc::c_int;
459}
460pub const pam_modutil_redirect_fd_PAM_MODUTIL_IGNORE_FD: pam_modutil_redirect_fd = 0;
461pub const pam_modutil_redirect_fd_PAM_MODUTIL_PIPE_FD: pam_modutil_redirect_fd = 1;
462pub const pam_modutil_redirect_fd_PAM_MODUTIL_NULL_FD: pam_modutil_redirect_fd = 2;
463pub type pam_modutil_redirect_fd = libc::c_uint;
464unsafe extern "C" {
465 pub fn pam_modutil_sanitize_helper_fds(
466 pamh: *mut pam_handle_t,
467 redirect_stdin: pam_modutil_redirect_fd,
468 redirect_stdout: pam_modutil_redirect_fd,
469 redirect_stderr: pam_modutil_redirect_fd,
470 ) -> libc::c_int;
471}
472unsafe extern "C" {
473 pub fn pam_modutil_search_key(
474 pamh: *mut pam_handle_t,
475 file_name: *const libc::c_char,
476 key: *const libc::c_char,
477 ) -> *mut libc::c_char;
478}