From 9be738dd1f4df5f38b9c17850f4f3dd5b16299d3 Mon Sep 17 00:00:00 2001 From: binlingyu Date: Wed, 12 Jun 2024 10:33:06 +0800 Subject: [PATCH] add cb_maxseq function for iolog.rs file --- utsudo-0.0.3/plugins/sudoers/src/iolog.rs | 62 +++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/utsudo-0.0.3/plugins/sudoers/src/iolog.rs b/utsudo-0.0.3/plugins/sudoers/src/iolog.rs index 347dc24..b9c5d79 100644 --- a/utsudo-0.0.3/plugins/sudoers/src/iolog.rs +++ b/utsudo-0.0.3/plugins/sudoers/src/iolog.rs @@ -234,6 +234,52 @@ pub type __off64_t = libc::c_long; pub type off64_t = __off64_t; pub type voidp = *mut libc::c_void; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct gzFile_s { + pub have: libc::c_uint, + pub next: *mut libc::c_uchar, + pub pos: off64_t, +} +pub type gzFile = *mut gzFile_s; + +pub type sudo_conv_t = Option< + unsafe extern "C" fn( + libc::c_int, + *const sudo_conv_message, + *mut sudo_conv_reply, + *mut sudo_conv_callback, + ) -> libc::c_int, +>; +pub type sudo_printf_t = + Option libc::c_int>; +pub type sudo_hook_fn_t = Option libc::c_int>; + + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sudo_conv_message { + pub msg_type: libc::c_int, + pub timeout: libc::c_int, + pub msg: *const libc::c_char, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sudo_conv_reply { + pub reply: *mut libc::c_char, +} +#[derive(Copy, Clone)] +#[repr(C)] +pub struct sudo_conv_callback { + pub version: libc::c_uint, + pub closure: *mut libc::c_void, + pub on_suspend: sudo_conv_callback_fn_t, + pub on_resume: sudo_conv_callback_fn_t, +} +pub type sudo_conv_callback_fn_t = + Option libc::c_int>; + + #[inline] unsafe extern "C" fn stat( mut __path: *const libc::c_char, @@ -543,3 +589,19 @@ unsafe extern "C" fn io_set_max_sessid(mut maxval: *const libc::c_char) -> bool sessid_max = value; debug_return_bool!(true); } + +/* + * Sudoers callback for maxseq Defaults setting. + */ +#[no_mangle] +pub unsafe extern "C" fn cb_maxseq(mut sd_un: *const sudo_defs_val) -> bool { + debug_decl!(SUDOERS_DEBUG_UTIL!()); + + /* Clamp value to SESSID_MAX as documented. */ + sessid_max = if (*sd_un).uival < SESSID_MAX { + (*sd_un).uival + } else { + SESSID_MAX + }; + debug_return_bool!(true); +} -- Gitee