From a8e4f6437cd337b42df4bb08d3daabd5895e1523 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:50:44 +0200 Subject: [PATCH 1/6] Regenerate pam bindings using bindgen 0.70.1 --- Makefile | 2 +- src/pam/converse.rs | 2 +- src/pam/error.rs | 2 +- src/pam/mod.rs | 33 +++++++++++++---- src/pam/sys.rs | 90 ++++++++++++++++++++++----------------------- 5 files changed, 73 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index 23f153d2c..2da4826b4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PAM_SRC_DIR = src/pam -BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --ctypes-prefix libc +BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-type '.*va_list.*' --ctypes-prefix libc .PHONY: all clean pam-sys pam-sys-diff diff --git a/src/pam/converse.rs b/src/pam/converse.rs index 91859f102..4a9b2be92 100644 --- a/src/pam/converse.rs +++ b/src/pam/converse.rs @@ -25,7 +25,7 @@ impl PamMessageStyle { pub fn from_int(val: libc::c_int) -> Option { use PamMessageStyle::*; - match val { + match val as _ { PAM_PROMPT_ECHO_OFF => Some(PromptEchoOff), PAM_PROMPT_ECHO_ON => Some(PromptEchoOn), PAM_ERROR_MSG => Some(ErrorMessage), diff --git a/src/pam/error.rs b/src/pam/error.rs index 93a808f51..e70e3389f 100644 --- a/src/pam/error.rs +++ b/src/pam/error.rs @@ -68,7 +68,7 @@ impl PamErrorType { pub(super) fn from_int(errno: libc::c_int) -> PamErrorType { use PamErrorType::*; - match errno { + match errno as _ { PAM_SUCCESS => Success, PAM_OPEN_ERR => OpenError, PAM_SYMBOL_ERR => SymbolError, diff --git a/src/pam/mod.rs b/src/pam/mod.rs index 701fc6089..99d573f3f 100644 --- a/src/pam/mod.rs +++ b/src/pam/mod.rs @@ -142,7 +142,7 @@ impl PamContext { /// Get the PAM flag value for the silent flag fn silent_flag(&self) -> i32 { if self.silent { - PAM_SILENT + PAM_SILENT as _ } else { 0 } @@ -153,7 +153,7 @@ impl PamContext { if self.allow_null_auth_token { 0 } else { - PAM_DISALLOW_NULL_AUTHTOK + PAM_DISALLOW_NULL_AUTHTOK as _ } } @@ -202,7 +202,11 @@ impl PamContext { // SAFETY: `self.pamh` contains a correct handle (obtained from `pam_start`); furthermore, // `c_user.as_ptr()` will point to a correct null-terminated string. pam_err(unsafe { - pam_set_item(self.pamh, PAM_USER, c_user.as_ptr() as *const libc::c_void) + pam_set_item( + self.pamh, + PAM_USER as _, + c_user.as_ptr() as *const libc::c_void, + ) }) } @@ -210,7 +214,7 @@ impl PamContext { pub fn get_user(&mut self) -> PamResult { let mut data = std::ptr::null(); // SAFETY: `self.pamh` contains a correct handle (obtained from `pam_start`) - pam_err(unsafe { pam_get_item(self.pamh, PAM_USER, &mut data) })?; + pam_err(unsafe { pam_get_item(self.pamh, PAM_USER as _, &mut data) })?; // safety check to make sure that we were not passed a null pointer by PAM, // or that in fact PAM did not write to `data` at all. @@ -230,7 +234,13 @@ impl PamContext { let data = CString::new(tty_path.as_ref().as_bytes())?; // SAFETY: `self.pamh` contains a correct handle (obtained from `pam_start`); furthermore, // `data.as_ptr()` will point to a correct null-terminated string. - pam_err(unsafe { pam_set_item(self.pamh, PAM_TTY, data.as_ptr() as *const libc::c_void) }) + pam_err(unsafe { + pam_set_item( + self.pamh, + PAM_TTY as _, + data.as_ptr() as *const libc::c_void, + ) + }) } // Set the user that requested the actions in this PAM instance. @@ -238,7 +248,13 @@ impl PamContext { let data = CString::new(user.as_bytes())?; // SAFETY: `self.pamh` contains a correct handle (obtained from `pam_start`); furthermore, // `data.as_ptr()` will point to a correct null-terminated string. - pam_err(unsafe { pam_set_item(self.pamh, PAM_RUSER, data.as_ptr() as *const libc::c_void) }) + pam_err(unsafe { + pam_set_item( + self.pamh, + PAM_RUSER as _, + data.as_ptr() as *const libc::c_void, + ) + }) } /// Re-initialize the credentials stored in PAM @@ -264,7 +280,7 @@ impl PamContext { let mut flags = 0; flags |= self.silent_flag(); if expired_only { - flags |= PAM_CHANGE_EXPIRED_AUTHTOK; + flags |= PAM_CHANGE_EXPIRED_AUTHTOK as libc::c_int; } // SAFETY: `self.pamh` contains a correct handle (obtained from `pam_start`). pam_err(unsafe { pam_chauthtok(self.pamh, flags) }) @@ -382,7 +398,8 @@ impl Drop for PamContext { unsafe { pam_end( self.pamh, - self.last_pam_status.unwrap_or(PAM_SUCCESS as libc::c_int) | PAM_DATA_SILENT, + self.last_pam_status.unwrap_or(PAM_SUCCESS as libc::c_int) + | PAM_DATA_SILENT as libc::c_int, ) }; } diff --git a/src/pam/sys.rs b/src/pam/sys.rs index 2d8029d02..a183d3e2c 100644 --- a/src/pam/sys.rs +++ b/src/pam/sys.rs @@ -1,53 +1,53 @@ -/* automatically generated by rust-bindgen 0.66.1, minified by cargo-minify, edited to be portable */ +/* automatically generated by rust-bindgen 0.70.1, minified by cargo-minify, edited to be portable */ // NOTE: the tests below test the assumptions about the padding that a C compiler will use on the // above structs; if these assumptions are incorrect, the tests will fail, but most likely the // code will still be correct. -pub const PAM_SUCCESS: libc::c_int = 0; -pub const PAM_OPEN_ERR: libc::c_int = 1; -pub const PAM_SYMBOL_ERR: libc::c_int = 2; -pub const PAM_SERVICE_ERR: libc::c_int = 3; -pub const PAM_SYSTEM_ERR: libc::c_int = 4; -pub const PAM_BUF_ERR: libc::c_int = 5; -pub const PAM_PERM_DENIED: libc::c_int = 6; -pub const PAM_AUTH_ERR: libc::c_int = 7; -pub const PAM_CRED_INSUFFICIENT: libc::c_int = 8; -pub const PAM_AUTHINFO_UNAVAIL: libc::c_int = 9; -pub const PAM_USER_UNKNOWN: libc::c_int = 10; -pub const PAM_MAXTRIES: libc::c_int = 11; -pub const PAM_NEW_AUTHTOK_REQD: libc::c_int = 12; -pub const PAM_ACCT_EXPIRED: libc::c_int = 13; -pub const PAM_SESSION_ERR: libc::c_int = 14; -pub const PAM_CRED_UNAVAIL: libc::c_int = 15; -pub const PAM_CRED_EXPIRED: libc::c_int = 16; -pub const PAM_CRED_ERR: libc::c_int = 17; -pub const PAM_NO_MODULE_DATA: libc::c_int = 18; -pub const PAM_CONV_ERR: libc::c_int = 19; -pub const PAM_AUTHTOK_ERR: libc::c_int = 20; -pub const PAM_AUTHTOK_RECOVERY_ERR: libc::c_int = 21; -pub const PAM_AUTHTOK_LOCK_BUSY: libc::c_int = 22; -pub const PAM_AUTHTOK_DISABLE_AGING: libc::c_int = 23; -pub const PAM_TRY_AGAIN: libc::c_int = 24; -pub const PAM_IGNORE: libc::c_int = 25; -pub const PAM_ABORT: libc::c_int = 26; -pub const PAM_AUTHTOK_EXPIRED: libc::c_int = 27; -pub const PAM_MODULE_UNKNOWN: libc::c_int = 28; -pub const PAM_BAD_ITEM: libc::c_int = 29; -pub const PAM_SILENT: libc::c_int = 32768; -pub const PAM_DISALLOW_NULL_AUTHTOK: libc::c_int = 1; -pub const PAM_REINITIALIZE_CRED: libc::c_int = 8; -pub const PAM_CHANGE_EXPIRED_AUTHTOK: libc::c_int = 32; -pub const PAM_USER: libc::c_int = 2; -pub const PAM_TTY: libc::c_int = 3; -pub const PAM_RUSER: libc::c_int = 8; -pub const PAM_DATA_SILENT: libc::c_int = 1073741824; -pub const PAM_PROMPT_ECHO_OFF: libc::c_int = 1; -pub const PAM_PROMPT_ECHO_ON: libc::c_int = 2; -pub const PAM_ERROR_MSG: libc::c_int = 3; -pub const PAM_TEXT_INFO: libc::c_int = 4; -pub const PAM_MAX_RESP_SIZE: libc::c_int = 512; -pub type pam_handle_t = libc::c_void; +pub const PAM_SUCCESS: u32 = 0; +pub const PAM_OPEN_ERR: u32 = 1; +pub const PAM_SYMBOL_ERR: u32 = 2; +pub const PAM_SERVICE_ERR: u32 = 3; +pub const PAM_SYSTEM_ERR: u32 = 4; +pub const PAM_BUF_ERR: u32 = 5; +pub const PAM_PERM_DENIED: u32 = 6; +pub const PAM_AUTH_ERR: u32 = 7; +pub const PAM_CRED_INSUFFICIENT: u32 = 8; +pub const PAM_AUTHINFO_UNAVAIL: u32 = 9; +pub const PAM_USER_UNKNOWN: u32 = 10; +pub const PAM_MAXTRIES: u32 = 11; +pub const PAM_NEW_AUTHTOK_REQD: u32 = 12; +pub const PAM_ACCT_EXPIRED: u32 = 13; +pub const PAM_SESSION_ERR: u32 = 14; +pub const PAM_CRED_UNAVAIL: u32 = 15; +pub const PAM_CRED_EXPIRED: u32 = 16; +pub const PAM_CRED_ERR: u32 = 17; +pub const PAM_NO_MODULE_DATA: u32 = 18; +pub const PAM_CONV_ERR: u32 = 19; +pub const PAM_AUTHTOK_ERR: u32 = 20; +pub const PAM_AUTHTOK_RECOVERY_ERR: u32 = 21; +pub const PAM_AUTHTOK_LOCK_BUSY: u32 = 22; +pub const PAM_AUTHTOK_DISABLE_AGING: u32 = 23; +pub const PAM_TRY_AGAIN: u32 = 24; +pub const PAM_IGNORE: u32 = 25; +pub const PAM_ABORT: u32 = 26; +pub const PAM_AUTHTOK_EXPIRED: u32 = 27; +pub const PAM_MODULE_UNKNOWN: u32 = 28; +pub const PAM_BAD_ITEM: u32 = 29; +pub const PAM_SILENT: u32 = 32768; +pub const PAM_DISALLOW_NULL_AUTHTOK: u32 = 1; +pub const PAM_REINITIALIZE_CRED: u32 = 8; +pub const PAM_CHANGE_EXPIRED_AUTHTOK: u32 = 32; +pub const PAM_USER: u32 = 2; +pub const PAM_TTY: u32 = 3; +pub const PAM_RUSER: u32 = 8; +pub const PAM_DATA_SILENT: u32 = 1073741824; +pub const PAM_PROMPT_ECHO_OFF: u32 = 1; +pub const PAM_PROMPT_ECHO_ON: u32 = 2; +pub const PAM_ERROR_MSG: u32 = 3; +pub const PAM_TEXT_INFO: u32 = 4; +pub const PAM_MAX_RESP_SIZE: u32 = 512; +pub type pam_handle_t = u8; extern "C" { pub fn pam_set_item( pamh: *mut pam_handle_t, From bd1f91e27ced3851344eeafba91829264e523aba Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:01:28 +0200 Subject: [PATCH 2/6] Disable generation of layout tests The tests generated directly by bindgen are useful as they cross-check the layout computed by the C compiler and by rustc. As they are not portable they were edited however in a way that basically exactly reproduces the layout algorithm rustc uses. This makes them ineffective at finding issues. At the same time they are manually written making automatic regeneration of the bindings in CI harder. --- Makefile | 2 +- src/pam/sys.rs | 133 ++----------------------------------------------- 2 files changed, 4 insertions(+), 131 deletions(-) diff --git a/Makefile b/Makefile index 2da4826b4..f35427dda 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PAM_SRC_DIR = src/pam -BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-type '.*va_list.*' --ctypes-prefix libc +BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-type '.*va_list.*' --ctypes-prefix libc --no-layout-tests .PHONY: all clean pam-sys pam-sys-diff diff --git a/src/pam/sys.rs b/src/pam/sys.rs index a183d3e2c..0476102db 100644 --- a/src/pam/sys.rs +++ b/src/pam/sys.rs @@ -1,8 +1,4 @@ -/* automatically generated by rust-bindgen 0.70.1, minified by cargo-minify, edited to be portable */ - -// NOTE: the tests below test the assumptions about the padding that a C compiler will use on the -// above structs; if these assumptions are incorrect, the tests will fail, but most likely the -// code will still be correct. +/* automatically generated by rust-bindgen 0.70.1, minified by cargo-minify */ pub const PAM_SUCCESS: u32 = 0; pub const PAM_OPEN_ERR: u32 = 1; @@ -74,90 +70,12 @@ pub struct pam_message { pub msg_style: libc::c_int, pub msg: *const libc::c_char, } -#[test] -fn bindgen_test_layout_pam_message() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::align_of::(), - ::std::mem::align_of::<*mut libc::c_void>(), - concat!("Alignment of ", stringify!(pam_message)) - ); - let mut offset: usize = 0; - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).msg_style) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_message), - "::", - stringify!(msg_style) - ) - ); - offset = aligned_offset::<*const libc::c_char>(offset + ::std::mem::size_of::()); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).msg) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_message), - "::", - stringify!(msg) - ) - ); - offset = aligned_offset::<*const libc::c_void>( - offset + ::std::mem::size_of::<*const libc::c_char>(), - ); - assert_eq!( - ::std::mem::size_of::(), - offset, - concat!("Size of: ", stringify!(pam_message)) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pam_response { pub resp: *mut libc::c_char, pub resp_retcode: libc::c_int, } -#[test] -fn bindgen_test_layout_pam_response() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::align_of::(), - ::std::mem::align_of::<*mut libc::c_char>(), - concat!("Alignment of ", stringify!(pam_response)) - ); - let mut offset: usize = 0; - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).resp) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_response), - "::", - stringify!(resp) - ) - ); - offset = aligned_offset::(offset + ::std::mem::size_of::<*mut libc::c_char>()); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).resp_retcode) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_response), - "::", - stringify!(resp_retcode) - ) - ); - offset = aligned_offset::<*mut libc::c_void>(offset + ::std::mem::size_of::()); - assert_eq!( - ::std::mem::size_of::(), - offset, - concat!("Size of: ", stringify!(pam_response)) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pam_conv { @@ -171,46 +89,6 @@ pub struct pam_conv { >, pub appdata_ptr: *mut libc::c_void, } -#[test] -fn bindgen_test_layout_pam_conv() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::align_of::(), - ::std::mem::align_of::<*mut libc::c_void>(), - concat!("Alignment of ", stringify!(pam_conv)) - ); - let mut offset: usize = 0; - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).conv) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_conv), - "::", - stringify!(conv) - ) - ); - offset = - aligned_offset::<*mut libc::c_void>(offset + ::std::mem::size_of::<*mut libc::c_void>()); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).appdata_ptr) as usize - ptr as usize }, - offset, - concat!( - "Offset of field: ", - stringify!(pam_conv), - "::", - stringify!(appdata_ptr) - ) - ); - offset = - aligned_offset::<*mut libc::c_void>(offset + ::std::mem::size_of::<*mut libc::c_void>()); - assert_eq!( - ::std::mem::size_of::(), - offset, - concat!("Size of: ", stringify!(pam_conv)) - ); -} extern "C" { pub fn pam_start( service_name: *const libc::c_char, @@ -240,10 +118,5 @@ extern "C" { extern "C" { pub fn pam_chauthtok(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int; } - -#[cfg(test)] -fn aligned_offset(offset: usize) -> usize { - let offset = offset as isize; - let alignment = ::std::mem::align_of::() as isize; - (offset + (-offset).rem_euclid(alignment)) as usize -} +pub type __uid_t = libc::c_uint; +pub type __gid_t = libc::c_uint; From c045f439c32e996ee7cd56ae6cefb6a427fa9eeb Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:01:59 +0200 Subject: [PATCH 3/6] Fully automate generation of PAM bindings --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index f35427dda..dc2f181be 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ pam-sys: $(PAM_SRC_DIR)/sys.rs $(PAM_SRC_DIR)/sys.rs: $(PAM_SRC_DIR)/wrapper.h $(BINDGEN_CMD) $< --output $@ + cargo minify --apply --allow-dirty + sed -i 's/rust-bindgen \w*\.\w*\.\w*/\0, minified by cargo-minify/' $@ clean: rm $(PAM_SRC_DIR)/sys.rs From a36165857a239320cc59c7de9d5806bd562db953 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:03:47 +0200 Subject: [PATCH 4/6] Enable bindgen's sort-semantically option This will make it easier to compare generated bindings between platforms. --- Makefile | 2 +- src/pam/sys.rs | 56 +++++++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index dc2f181be..1d3c5d714 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PAM_SRC_DIR = src/pam -BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-type '.*va_list.*' --ctypes-prefix libc --no-layout-tests +BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-type '.*va_list.*' --ctypes-prefix libc --no-layout-tests --sort-semantically .PHONY: all clean pam-sys pam-sys-diff diff --git a/src/pam/sys.rs b/src/pam/sys.rs index 0476102db..16c58a1fa 100644 --- a/src/pam/sys.rs +++ b/src/pam/sys.rs @@ -1,5 +1,33 @@ /* automatically generated by rust-bindgen 0.70.1, minified by cargo-minify */ +pub type pam_handle_t = u8; +pub type __uid_t = libc::c_uint; +pub type __gid_t = libc::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pam_message { + pub msg_style: libc::c_int, + pub msg: *const libc::c_char, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pam_response { + pub resp: *mut libc::c_char, + pub resp_retcode: libc::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pam_conv { + pub conv: ::std::option::Option< + unsafe extern "C" fn( + num_msg: libc::c_int, + msg: *mut *const pam_message, + resp: *mut *mut pam_response, + appdata_ptr: *mut libc::c_void, + ) -> libc::c_int, + >, + pub appdata_ptr: *mut libc::c_void, +} pub const PAM_SUCCESS: u32 = 0; pub const PAM_OPEN_ERR: u32 = 1; pub const PAM_SYMBOL_ERR: u32 = 2; @@ -43,7 +71,6 @@ pub const PAM_PROMPT_ECHO_ON: u32 = 2; pub const PAM_ERROR_MSG: u32 = 3; pub const PAM_TEXT_INFO: u32 = 4; pub const PAM_MAX_RESP_SIZE: u32 = 512; -pub type pam_handle_t = u8; extern "C" { pub fn pam_set_item( pamh: *mut pam_handle_t, @@ -64,31 +91,6 @@ extern "C" { extern "C" { pub fn pam_getenvlist(pamh: *mut pam_handle_t) -> *mut *mut libc::c_char; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pam_message { - pub msg_style: libc::c_int, - pub msg: *const libc::c_char, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pam_response { - pub resp: *mut libc::c_char, - pub resp_retcode: libc::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pam_conv { - pub conv: ::std::option::Option< - unsafe extern "C" fn( - num_msg: libc::c_int, - msg: *mut *const pam_message, - resp: *mut *mut pam_response, - appdata_ptr: *mut libc::c_void, - ) -> libc::c_int, - >, - pub appdata_ptr: *mut libc::c_void, -} extern "C" { pub fn pam_start( service_name: *const libc::c_char, @@ -118,5 +120,3 @@ extern "C" { extern "C" { pub fn pam_chauthtok(pamh: *mut pam_handle_t, flags: libc::c_int) -> libc::c_int; } -pub type __uid_t = libc::c_uint; -pub type __gid_t = libc::c_uint; From 694f49a455f1bfb28178fbf3616b5e840ff0f125 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:09:18 +0200 Subject: [PATCH 5/6] Check bindings are up to date on CI --- .github/workflows/ci.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9fb8b1cba..b66fca86e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -284,6 +284,36 @@ jobs: - name: Run tests run: cargo miri test --workspace --all-features miri + check-bindings: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt update + sudo apt install libpam0g-dev + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: "msrv" + + - name: Install rust-bindgen + uses: taiki-e/install-action@v2 + with: + tool: bindgen-cli@0.70.1 + + - name: Install cargo-minify + run: cargo install --locked --git https://github.com/tweedegolf/cargo-minify cargo-minify + + - name: Regenerate bindings + run: make -B pam-sys + + - name: Check for differences + run: git diff --exit-code + format: runs-on: ubuntu-latest env: From 315e2b79b54bf7a911f73c0f989301a936ea07b6 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:39:43 +0200 Subject: [PATCH 6/6] Update sed command to work on FreeBSD --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1d3c5d714..9169485a0 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ pam-sys: $(PAM_SRC_DIR)/sys.rs $(PAM_SRC_DIR)/sys.rs: $(PAM_SRC_DIR)/wrapper.h $(BINDGEN_CMD) $< --output $@ cargo minify --apply --allow-dirty - sed -i 's/rust-bindgen \w*\.\w*\.\w*/\0, minified by cargo-minify/' $@ + sed -i.bak 's/rust-bindgen \w*\.\w*\.\w*/\0, minified by cargo-minify/' $@ + rm $@.bak clean: rm $(PAM_SRC_DIR)/sys.rs