# HG changeset patch # User Paul Fisher # Date 1751273678 14400 # Node ID f469b8d9ad7825f974b117f97d8c83a5cb033b28 # Parent 98a624cacd8208c90ad50a1c6605da2a63058af5 Add tests for the original X/SSO constants list. diff -r 98a624cacd82 -r f469b8d9ad78 libpam-sys/libpam-sys-test/build.rs --- a/libpam-sys/libpam-sys-test/build.rs Mon Jun 30 04:26:44 2025 -0400 +++ b/libpam-sys/libpam-sys-test/build.rs Mon Jun 30 04:54:38 2025 -0400 @@ -9,41 +9,38 @@ let config = match PamImpl::CURRENT { PamImpl::LinuxPam => TestConfig { headers: vec![ - "security/_pam_types.h".into(), - "security/pam_appl.h".into(), - "security/pam_ext.h".into(), - "security/pam_modules.h".into(), + "", + "", + "", + "", ], ignore_consts: vec![ - "__LINUX_PAM__".into(), - "__LINUX_PAM_MINOR__".into(), - "PAM_AUTHTOK_RECOVER_ERR".into(), + "__LINUX_PAM__", + "__LINUX_PAM_MINOR__", + "PAM_AUTHTOK_RECOVER_ERR", ], ..Default::default() }, PamImpl::OpenPam => TestConfig { headers: vec![ - "security/pam_types.h".into(), - "security/openpam.h".into(), - "security/pam_appl.h".into(), - "security/pam_constants.h".into(), + "", + "", + "", + "", ], - ignore_consts: vec![ - "OPENPAM_VERSION".into(), - "OPENPAM_RELEASE".into(), - "PAM_SOEXT".into(), - ], + ignore_consts: vec!["OPENPAM_VERSION", "OPENPAM_RELEASE", "PAM_SOEXT"], ..Default::default() }, PamImpl::Sun => TestConfig { - headers: vec![ - "security/pam_appl.h".into(), - "security/pam_modules.h".into(), - ], - block_headers: vec!["sys/.*".into()], + headers: vec!["", ""], + block_headers: vec!["sys/.*"], ..Default::default() }, - PamImpl::XSso => Default::default(), + PamImpl::XSso => TestConfig { + headers: vec!["\"xsso_constants.h\""], + ignore_consts: vec!["PAM_CRED_PRELIM_CHECK"], + ..Default::default() + }, other => panic!("Unknown PAM implementation {other:?}"), }; generate_const_test(&config); @@ -100,9 +97,9 @@ #[derive(Default)] struct TestConfig { - headers: Vec, - block_headers: Vec, - ignore_consts: Vec, + headers: Vec<&'static str>, + block_headers: Vec<&'static str>, + ignore_consts: Vec<&'static str>, } impl TestConfig { @@ -110,12 +107,14 @@ let vec: Vec<_> = self .headers .iter() - .map(|h| format!("#include <{h}>\n")) + .map(|h| format!("#include {h}\n")) .collect(); vec.join("") } fn should_check_const(&self, item: &ItemConst) -> bool { - !self.ignore_consts.contains(&item.ident.to_string()) + !self + .ignore_consts + .contains(&item.ident.to_string().as_ref()) } } diff -r 98a624cacd82 -r f469b8d9ad78 libpam-sys/libpam-sys-test/tests/test_constants.rs --- a/libpam-sys/libpam-sys-test/tests/test_constants.rs Mon Jun 30 04:26:44 2025 -0400 +++ b/libpam-sys/libpam-sys-test/tests/test_constants.rs Mon Jun 30 04:54:38 2025 -0400 @@ -1,4 +1,4 @@ -#[allow(overflowing_literals)] +#[allow(deprecated, overflowing_literals)] #[test] fn check_constants() { include!(concat!(env!("OUT_DIR"), "/constant_test.rs")) diff -r 98a624cacd82 -r f469b8d9ad78 libpam-sys/libpam-sys-test/xsso_constants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpam-sys/libpam-sys-test/xsso_constants.h Mon Jun 30 04:54:38 2025 -0400 @@ -0,0 +1,63 @@ +// This list of constants was literally cut-and-pasted from: +// https://pubs.opengroup.org/onlinepubs/8329799/chap5.htm + +#define PAM_SUCCESS 0 +#define PAM_OPEN_ERR 1 +#define PAM_SYMBOL_ERR 2 +#define PAM_SERVICE_ERR 3 +#define PAM_SYSTEM_ERR 4 +#define PAM_BUF_ERR 5 +#define PAM_CONV_ERR 6 +#define PAM_PERM_DENIED 7 +#define PAM_MAXTRIES 8 +#define PAM_AUTH_ERR 9 +#define PAM_NEW_AUTHTOK_REQD 10 +#define PAM_CRED_INSUFFICIENT 11 +#define PAM_AUTHINFO_UNAVAIL 12 +#define PAM_USER_UNKNOWN 13 +#define PAM_CRED_UNAVAIL 14 +#define PAM_CRED_EXPIRED 15 +#define PAM_CRED_ERR 16 +#define PAM_ACCT_EXPIRED 17 +#define PAM_AUTHTOK_EXPIRED 18 +#define PAM_SESSION_ERR 19 +#define PAM_AUTHTOK_ERR 20 +#define PAM_AUTHTOK_RECOVERY_ERR 21 +#define PAM_AUTHTOK_LOCK_BUSY 22 +#define PAM_AUTHTOK_DISABLE_AGING 23 +#define PAM_NO_MODULE_DATA 24 +#define PAM_IGNORE 25 +#define PAM_ABORT 26 +#define PAM_TRY_AGAIN 27 +#define PAM_PROMPT_ECHO_OFF 1 +#define PAM_PROMPT_ECHO_ON 2 +#define PAM_ERROR_MSG 3 +#define PAM_TEXT_INFO 4 +#define PAM_MAX_NUM_MSG 32 +#define PAM_MAX_MSG_SIZE 512 +#define PAM_MAX_RESP_SIZE 512 + +#define PAM_SILENT 0x80000000 +#define PAM_DISALLOW_NULL_AUTHTOK 0x1 +#define PAM_ESTABLISH_CRED 0x1 +#define PAM_DELETE_CRED 0x2 +#define PAM_REINITIALISE_CRED 0x4 +#define PAM_REFRESH_CRED 0x8 +#define PAM_CRED_PRELIM_CHECK 0x1 +#define PAM_UPDATE_AUTHTOK 0x2 +#define PAM_CHANGE_EXPIRED_AUTHTOK 0x4 + +#define PAM_SERVICE 1 +#define PAM_USER 2 +#define PAM_TTY 3 +#define PAM_RHOST 4 +#define PAM_CONV 5 +#define PAM_AUTHTOK 6 +#define PAM_OLDAUTHTOK 7 +#define PAM_RUSER 8 +#define PAM_USER_PROMPT 9 + +// Some of the names in here aren't used by anybody, though. +// These aliases are, though. +#define PAM_REINITIALIZE_CRED PAM_REINITIALISE_CRED +#define PAM_PRELIM_CHECK PAM_CRED_PRELIM_CHECK diff -r 98a624cacd82 -r f469b8d9ad78 libpam-sys/src/constants.rs --- a/libpam-sys/src/constants.rs Mon Jun 30 04:26:44 2025 -0400 +++ b/libpam-sys/src/constants.rs Mon Jun 30 04:54:38 2025 -0400 @@ -194,6 +194,8 @@ PAM_REINITIALIZE_CRED = 0b0100; PAM_REFRESH_CRED = 0b1000; ); + #[deprecated = "everybody spells it with a Z nowadays"] + pub const PAM_REINITIALISE_CRED: i32 = 0b0100; define!( /// A flag for `pam_sm_chauthtok`. @@ -201,6 +203,8 @@ PAM_UPDATE_AUTHTOK = 0b0010; PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; ); + #[deprecated = "modern PAM implementations use PAM_PRELIM_CHECK"] + pub const PAM_CRED_PRELIM_CHECK: i32 = 0b0001; } #[cfg_pam_impl("OpenPam")] @@ -268,3 +272,4 @@ /// A flag for `pam_chauthtok`. pub const PAM_NO_AUTHTOK_CHECK: i32 = 0b1000; } +