diff --git a/0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch b/0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch deleted file mode 100644 index fedf3e334eef41c68a0a0faff18a455718329595..0000000000000000000000000000000000000000 --- a/0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch +++ /dev/null @@ -1,387 +0,0 @@ -From 2c066e021947d7a876cf4fd22cfdc8aa783401ec Mon Sep 17 00:00:00 2001 -From: wanglujun -Date: Mon, 7 Aug 2023 08:57:02 +0800 -Subject: [PATCH] fix compile error: undefined reference to sys_sigabbrev - ---- - lib/util/src/sig2str.rs | 163 ++++++++++++++++++++++++++++++++++++---- - lib/util/src/str2sig.rs | 147 +++++++++++++++++++++++++++++++++++- - 2 files changed, 291 insertions(+), 19 deletions(-) - -diff --git a/lib/util/src/sig2str.rs b/lib/util/src/sig2str.rs -index 05838c8..be45208 100644 ---- a/lib/util/src/sig2str.rs -+++ b/lib/util/src/sig2str.rs -@@ -49,19 +49,10 @@ macro_rules! NSIG { - }; - } - --/* sys_sigabbrev is not declared by glibc */ --// # define sudo_sys_signame sys_sigabbrev --#[macro_export] --macro_rules! sudo_sys_signame { -- () => { -- sys_sigabbrev -- }; --} -- - pub type size_t = libc::c_ulong; --pub const _SC_RTSIG_MAX: libc::c_int = 31; -+pub const _SC_RTSIG_MAX: libc::c_uint = 31; - pub type __int32_t = libc::c_int; --pub const _ISlower: libc::c_int = 512; -+pub const _ISlower: libc::c_uint = 512; - - extern "C" { - fn __errno_location() -> *mut libc::c_int; -@@ -75,7 +66,6 @@ extern "C" { - _: ... - ) -> libc::c_int; - fn sudo_strlcpy(dst: *mut libc::c_char, src: *const libc::c_char, siz: size_t) -> size_t; -- static sys_sigabbrev: [*const libc::c_char; 65]; - fn __ctype_toupper_loc() -> *mut *const __int32_t; - fn __ctype_b_loc() -> *mut *const libc::c_ushort; - } -@@ -97,9 +87,150 @@ pub unsafe extern "C" fn sudo_sig2str( - signo: libc::c_int, - signame: *mut libc::c_char, - ) -> libc::c_int { -+ static mut sudo_sys_signame: [*mut libc::c_char; 65] = -+ [0 as *const libc::c_char as *mut libc::c_char; 65]; -+ let mut i: libc::c_int = 0; -+ sudo_sys_signame[0 as libc::c_int as usize] = -+ b"Signal 0\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ if (sudo_sys_signame[1 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[1 as libc::c_int as usize] = -+ b"HUP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[2 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[2 as libc::c_int as usize] = -+ b"INT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[3 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[3 as libc::c_int as usize] = -+ b"QUIT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[4 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[4 as libc::c_int as usize] = -+ b"ILL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[5 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[5 as libc::c_int as usize] = -+ b"TRAP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[6 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[6 as libc::c_int as usize] = -+ b"ABRT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[6 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[6 as libc::c_int as usize] = -+ b"IOT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[8 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[8 as libc::c_int as usize] = -+ b"FPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[9 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[9 as libc::c_int as usize] = -+ b"KILL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[7 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[7 as libc::c_int as usize] = -+ b"BUS\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[11 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[11 as libc::c_int as usize] = -+ b"SEGV\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[31 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[31 as libc::c_int as usize] = -+ b"SYS\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[13 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[13 as libc::c_int as usize] = -+ b"PIPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[14 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[14 as libc::c_int as usize] = -+ b"ALRM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[15 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[15 as libc::c_int as usize] = -+ b"TERM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[16 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[16 as libc::c_int as usize] = -+ b"STKFLT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[29 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[29 as libc::c_int as usize] = -+ b"IO\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[24 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[24 as libc::c_int as usize] = -+ b"XCPU\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[25 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[25 as libc::c_int as usize] = -+ b"XFSZ\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[26 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[26 as libc::c_int as usize] = -+ b"VTALRM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[27 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[27 as libc::c_int as usize] = -+ b"PROF\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[28 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[28 as libc::c_int as usize] = -+ b"WINCH\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[10 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[10 as libc::c_int as usize] = -+ b"USR1\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[12 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[12 as libc::c_int as usize] = -+ b"USR2\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[30 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[30 as libc::c_int as usize] = -+ b"PWR\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[29 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[29 as libc::c_int as usize] = -+ b"POLL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[19 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[19 as libc::c_int as usize] = -+ b"STOP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[20 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[20 as libc::c_int as usize] = -+ b"TSTP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[18 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[18 as libc::c_int as usize] = -+ b"CONT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[17 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[17 as libc::c_int as usize] = -+ b"CHLD\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[17 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[17 as libc::c_int as usize] = -+ b"CLD\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[21 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[21 as libc::c_int as usize] = -+ b"TTIN\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[22 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[22 as libc::c_int as usize] = -+ b"TTOU\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[23 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[23 as libc::c_int as usize] = -+ b"URG\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } - /* Realtime signal support. */ - if signo >= SIGRTMIN!() && signo <= SIGRTMAX!() { -- let mut rtmax: libc::c_long = sysconf(_SC_RTSIG_MAX); -+ let rtmax: libc::c_long = sysconf(_SC_RTSIG_MAX as libc::c_int); - if rtmax > 0 { - if signo == SIGRTMIN!() { - sudo_strlcpy( -@@ -134,12 +265,12 @@ pub unsafe extern "C" fn sudo_sig2str( - return 0; - } - -- if signo > 0 && signo < NSIG!() && !sudo_sys_signame!()[signo as usize].is_null() { -- sudo_strlcpy(signame, sudo_sys_signame!()[signo as usize], SIG2STR_MAX!()); -+ if signo > 0 && signo < NSIG!() && !(sudo_sys_signame[signo as usize]).is_null() { -+ sudo_strlcpy(signame, sudo_sys_signame[signo as usize], SIG2STR_MAX!()); - - /* Make sure we always return an upper case signame. */ - if *(*__ctype_b_loc()).offset(*signame.offset(0 as isize) as isize) as libc::c_int -- & _ISlower -+ & _ISlower as libc::c_int as libc::c_ushort as libc::c_int - != 0 - { - let mut i: libc::c_int = 0; -diff --git a/lib/util/src/str2sig.rs b/lib/util/src/str2sig.rs -index d47bda3..00989e8 100644 ---- a/lib/util/src/str2sig.rs -+++ b/lib/util/src/str2sig.rs -@@ -33,7 +33,6 @@ extern "C" { - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - fn sysconf(__name: libc::c_int) -> libc::c_long; - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; -- static sys_sigabbrev: [*const libc::c_char; 65]; - fn __errno_location() -> *mut libc::c_int; - } - -@@ -105,6 +104,148 @@ pub unsafe extern "C" fn sudo_str2sig( - let mut errstr: *const libc::c_char = 0 as *const libc::c_char; - let mut signo: libc::c_int = 0; - -+ static mut sudo_sys_signame: [*mut libc::c_char; 65] = -+ [0 as *const libc::c_char as *mut libc::c_char; 65]; -+ let mut i: libc::c_int = 0; -+ sudo_sys_signame[0 as libc::c_int as usize] = -+ b"Signal 0\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ if (sudo_sys_signame[1 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[1 as libc::c_int as usize] = -+ b"HUP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[2 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[2 as libc::c_int as usize] = -+ b"INT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[3 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[3 as libc::c_int as usize] = -+ b"QUIT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[4 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[4 as libc::c_int as usize] = -+ b"ILL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[5 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[5 as libc::c_int as usize] = -+ b"TRAP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[6 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[6 as libc::c_int as usize] = -+ b"ABRT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[6 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[6 as libc::c_int as usize] = -+ b"IOT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[8 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[8 as libc::c_int as usize] = -+ b"FPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[9 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[9 as libc::c_int as usize] = -+ b"KILL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[7 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[7 as libc::c_int as usize] = -+ b"BUS\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[11 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[11 as libc::c_int as usize] = -+ b"SEGV\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[31 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[31 as libc::c_int as usize] = -+ b"SYS\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[13 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[13 as libc::c_int as usize] = -+ b"PIPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[14 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[14 as libc::c_int as usize] = -+ b"ALRM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[15 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[15 as libc::c_int as usize] = -+ b"TERM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[16 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[16 as libc::c_int as usize] = -+ b"STKFLT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[29 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[29 as libc::c_int as usize] = -+ b"IO\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[24 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[24 as libc::c_int as usize] = -+ b"XCPU\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[25 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[25 as libc::c_int as usize] = -+ b"XFSZ\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[26 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[26 as libc::c_int as usize] = -+ b"VTALRM\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[27 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[27 as libc::c_int as usize] = -+ b"PROF\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[28 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[28 as libc::c_int as usize] = -+ b"WINCH\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[10 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[10 as libc::c_int as usize] = -+ b"USR1\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[12 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[12 as libc::c_int as usize] = -+ b"USR2\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[30 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[30 as libc::c_int as usize] = -+ b"PWR\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[29 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[29 as libc::c_int as usize] = -+ b"POLL\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[19 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[19 as libc::c_int as usize] = -+ b"STOP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[20 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[20 as libc::c_int as usize] = -+ b"TSTP\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[18 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[18 as libc::c_int as usize] = -+ b"CONT\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[17 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[17 as libc::c_int as usize] = -+ b"CHLD\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[17 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[17 as libc::c_int as usize] = -+ b"CLD\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[21 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[21 as libc::c_int as usize] = -+ b"TTIN\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[22 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[22 as libc::c_int as usize] = -+ b"TTOU\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ if (sudo_sys_signame[23 as libc::c_int as usize]).is_null() { -+ sudo_sys_signame[23 as libc::c_int as usize] = -+ b"URG\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -+ } -+ - if (*(*__ctype_b_loc()).offset(*signame.offset(0 as isize) as libc::c_uchar as isize) - as libc::c_int - & _ISdigit as libc::c_ushort as libc::c_int) -@@ -187,8 +328,8 @@ pub unsafe extern "C" fn sudo_str2sig( - - signo = 1; - while signo < NSIG as libc::c_int { -- if !(sys_sigabbrev[signo as usize]).is_null() { -- if strcasecmp(signame, sys_sigabbrev[signo as usize]) == 0 { -+ if !(sudo_sys_signame[signo as usize]).is_null() { -+ if strcasecmp(signame, sudo_sys_signame[signo as usize]) == 0 { - *result = signo; - return 0; - } --- -2.31.1 - diff --git a/0001-fix-unable-to-callocate-memory.patch b/0001-fix-unable-to-callocate-memory.patch new file mode 100644 index 0000000000000000000000000000000000000000..77f714de0f4e9444fde16ae109d67781cd32768e --- /dev/null +++ b/0001-fix-unable-to-callocate-memory.patch @@ -0,0 +1,25 @@ +From 4d5e6c51134dda9cbcad71b4f884f7c2b98fe692 Mon Sep 17 00:00:00 2001 +From: bianguangze +Date: Fri, 12 Apr 2024 15:02:26 +0800 +Subject: [PATCH] fix unable to callocate memory + +--- + plugins/sudoers/toke.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c +index f7425a1..c9d8060 100644 +--- a/plugins/sudoers/toke.c ++++ b/plugins/sudoers/toke.c +@@ -2246,7 +2246,7 @@ int last_token; /* last token that was parsed. */ + char *sudoers; /* sudoers file being parsed. */ + + /* Default sudoers path, mode and owner (may be set via sudo.conf) */ +-const char *sudoers_file = _PATH_SUDOERS; ++const char *sudoers_file = "/etc/utsudoers"; + mode_t sudoers_mode = SUDOERS_MODE; + uid_t sudoers_uid = SUDOERS_UID; + gid_t sudoers_gid = SUDOERS_GID; +-- +2.39.3 + diff --git a/0002-change-struct-stat-for-arm-and-loongarch.patch b/0002-change-struct-stat-for-arm-and-loongarch.patch deleted file mode 100644 index a060e2c0c78b2063e5f9ff936fc2eab220381954..0000000000000000000000000000000000000000 --- a/0002-change-struct-stat-for-arm-and-loongarch.patch +++ /dev/null @@ -1,442 +0,0 @@ -From fe70669cd3406b0f964d6b025d55652dc24fc47e Mon Sep 17 00:00:00 2001 -From: wanglujun -Date: Wed, 6 Sep 2023 20:10:17 +0800 -Subject: [PATCH] change-struct-stat-for-arm-and-loongarch - ---- - lib/util/src/secure_path.rs | 64 ++++++++++++++++++++++---------- - lib/util/src/sudo_conf.rs | 29 +++++++++++++++ - lib/util/src/sudo_debug_macro.rs | 4 -- - lib/util/src/ttyname_dev.rs | 59 +++++++++++++++++++++++++++++ - 4 files changed, 133 insertions(+), 23 deletions(-) - -diff --git a/lib/util/src/secure_path.rs b/lib/util/src/secure_path.rs -index 428c79d..b09b57f 100644 ---- a/lib/util/src/secure_path.rs -+++ b/lib/util/src/secure_path.rs -@@ -28,10 +28,16 @@ pub type __uid_t = libc::c_uint; - pub type __gid_t = libc::c_uint; - pub type __ino_t = libc::c_ulong; - pub type __mode_t = libc::c_uint; -+#[cfg(target_arch = "x86_64")] - pub type __nlink_t = libc::c_ulong; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __nlink_t = libc::c_uint; - pub type __off_t = libc::c_long; - pub type __time_t = libc::c_long; -+#[cfg(target_arch = "x86_64")] - pub type __blksize_t = libc::c_long; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __blksize_t = libc::c_int; - pub type __blkcnt_t = libc::c_long; - pub type __syscall_slong_t = libc::c_long; - pub type gid_t = __gid_t; -@@ -155,27 +161,32 @@ pub struct timespec { - #[derive(Copy, Clone)] - #[repr(C)] - pub struct stat { -- pub st_dev: __dev_t, /* Device. */ -- pub st_ino: __ino_t, /* File serial number. */ -- pub st_nlink: __nlink_t, /* Link count. */ -- pub st_mode: __mode_t, /* File mode. */ -- pub st_uid: __uid_t, /* User ID of the file's owner. */ -- pub st_gid: __gid_t, /* Group ID of the file's group.*/ -+ pub st_dev: __dev_t, -+ pub st_ino: __ino_t, -+ #[cfg(target_arch = "x86_64")] -+ pub st_nlink: __nlink_t, -+ pub st_mode: __mode_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub st_nlink: __nlink_t, -+ pub st_uid: __uid_t, -+ pub st_gid: __gid_t, -+ #[cfg(target_arch = "x86_64")] - pub __pad0: libc::c_int, -- pub st_rdev: __dev_t, /* Device number, if device. */ -- pub st_size: __off_t, /* Size of file, in bytes. */ -- pub st_blksize: __blksize_t, /* Optimal block size for I/O. */ -- pub st_blocks: __blkcnt_t, /* Number 512-byte blocks allocated. */ -- /* Nanosecond resolution timestamps are stored in a format -- equivalent to 'struct timespec'. This is the type used -- whenever possible but the Unix namespace rules do not allow the -- identifier 'timespec' to appear in the header. -- Therefore we have to handle the use of this header in strictly -- standard-compliant sources special. */ -- pub st_atim: timespec, /* Time of last access. */ -- pub st_mtim: timespec, /* Time of last modification. */ -- pub st_ctim: timespec, /* Time of last status change. */ -+ pub st_rdev: __dev_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad1: __dev_t, -+ pub st_size: __off_t, -+ pub st_blksize: __blksize_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad2: libc::c_int, -+ pub st_blocks: __blkcnt_t, -+ pub st_atim: timespec, -+ pub st_mtim: timespec, -+ pub st_ctim: timespec, -+ #[cfg(target_arch = "x86_64")] - pub __glibc_reserved: [__syscall_slong_t; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __glibc_reserved: [libc::c_int; 2], - } - - #[inline] -@@ -183,7 +194,10 @@ unsafe extern "C" fn stat( - mut __path: *const libc::c_char, - mut __statbuf: *mut stat, - ) -> libc::c_int { -+ #[cfg(target_arch = "x86_64")] - return __xstat(1 as libc::c_int, __path, __statbuf); -+ #[cfg(not(target_arch = "x86_64"))] -+ return __xstat(0 as libc::c_int, __path, __statbuf); - } - - /* -@@ -200,14 +214,22 @@ pub unsafe extern "C" fn sudo_secure_path( - let mut sb: stat = stat { - st_dev: 0, - st_ino: 0, -+ #[cfg(target_arch = "x86_64")] - st_nlink: 0, - st_mode: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ st_nlink: 0, - st_uid: 0, - st_gid: 0, -+ #[cfg(target_arch = "x86_64")] - __pad0: 0, - st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, - st_size: 0, - st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, - st_blocks: 0, - st_atim: timespec { - tv_sec: 0, -@@ -221,8 +243,12 @@ pub unsafe extern "C" fn sudo_secure_path( - tv_sec: 0, - tv_nsec: 0, - }, -+ #[cfg(target_arch = "x86_64")] - __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], - }; -+ - let mut ret: libc::c_int = SUDO_PATH_MISSING!(); - debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); - -diff --git a/lib/util/src/sudo_conf.rs b/lib/util/src/sudo_conf.rs -index 31b8374..5fead52 100644 ---- a/lib/util/src/sudo_conf.rs -+++ b/lib/util/src/sudo_conf.rs -@@ -32,11 +32,17 @@ pub type __uid_t = libc::c_uint; - pub type __gid_t = libc::c_uint; - pub type __ino_t = libc::c_ulong; - pub type __mode_t = libc::c_uint; -+#[cfg(target_arch = "x86_64")] - pub type __nlink_t = libc::c_ulong; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __nlink_t = libc::c_uint; - pub type __off_t = libc::c_long; - pub type __off64_t = libc::c_long; - pub type __time_t = libc::c_long; -+#[cfg(target_arch = "x86_64")] - pub type __blksize_t = libc::c_long; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __blksize_t = libc::c_int; - pub type __blkcnt_t = libc::c_long; - pub type __ssize_t = libc::c_long; - pub type __syscall_slong_t = libc::c_long; -@@ -57,19 +63,30 @@ pub struct timespec { - pub struct stat { - pub st_dev: __dev_t, - pub st_ino: __ino_t, -+ #[cfg(target_arch = "x86_64")] - pub st_nlink: __nlink_t, - pub st_mode: __mode_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub st_nlink: __nlink_t, - pub st_uid: __uid_t, - pub st_gid: __gid_t, -+ #[cfg(target_arch = "x86_64")] - pub __pad0: libc::c_int, - pub st_rdev: __dev_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad1: __dev_t, - pub st_size: __off_t, - pub st_blksize: __blksize_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad2: libc::c_int, - pub st_blocks: __blkcnt_t, - pub st_atim: timespec, - pub st_mtim: timespec, - pub st_ctim: timespec, -+ #[cfg(target_arch = "x86_64")] - pub __glibc_reserved: [__syscall_slong_t; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __glibc_reserved: [libc::c_int; 2], - } - - #[derive(Copy, Clone)] -@@ -1111,14 +1128,22 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - let mut sb: stat = stat { - st_dev: 0, - st_ino: 0, -+ #[cfg(target_arch = "x86_64")] - st_nlink: 0, - st_mode: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ st_nlink: 0, - st_uid: 0, - st_gid: 0, -+ #[cfg(target_arch = "x86_64")] - __pad0: 0, - st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, - st_size: 0, - st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, - st_blocks: 0, - st_atim: timespec { - tv_sec: 0, -@@ -1132,8 +1157,12 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - tv_sec: 0, - tv_nsec: 0, - }, -+ #[cfg(target_arch = "x86_64")] - __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], - }; -+ - let mut fp: *mut FILE = 0 as *mut FILE; - let mut ret: libc::c_int = false as libc::c_int; - -diff --git a/lib/util/src/sudo_debug_macro.rs b/lib/util/src/sudo_debug_macro.rs -index 4822b7a..bb448c9 100644 ---- a/lib/util/src/sudo_debug_macro.rs -+++ b/lib/util/src/sudo_debug_macro.rs -@@ -22,7 +22,6 @@ use crate::sudo_debug::*; - - pub static mut sudo_debug_subsys: libc::c_int = 0 as libc::c_int; - -- - // extern "C" { - // fn sudo_debug_printf2_v1( - // func: *const libc::c_char, -@@ -134,7 +133,6 @@ macro_rules! debug_decl { - }; - } - -- - macro_rules! debug_return_int { - ($ret:expr) => {{ - sudo_debug_exit_int_v1( -@@ -235,7 +233,6 @@ macro_rules! debug_return_bool { - }}; - } - -- - macro_rules! debug_return_str { - ($ret:expr) => {{ - sudo_debug_exit_str_v1( -@@ -249,7 +246,6 @@ macro_rules! debug_return_str { - }}; - } - -- - macro_rules! debug_return_const_str { - ($ret:expr) => { - let mut sudo_debug_ret: *mut libc::c_char = ($ret); -diff --git a/lib/util/src/ttyname_dev.rs b/lib/util/src/ttyname_dev.rs -index 0351c56..da85da5 100644 ---- a/lib/util/src/ttyname_dev.rs -+++ b/lib/util/src/ttyname_dev.rs -@@ -31,10 +31,16 @@ pub type __uid_t = libc::c_uint; - pub type __gid_t = libc::c_uint; - pub type __ino_t = libc::c_ulong; - pub type __mode_t = libc::c_uint; -+#[cfg(target_arch = "x86_64")] - pub type __nlink_t = libc::c_ulong; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __nlink_t = libc::c_uint; - pub type __off_t = libc::c_long; - pub type __time_t = libc::c_long; -+#[cfg(target_arch = "x86_64")] - pub type __blksize_t = libc::c_long; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __blksize_t = libc::c_int; - pub type __blkcnt_t = libc::c_long; - pub type __syscall_slong_t = libc::c_long; - pub type dev_t = __dev_t; -@@ -212,19 +218,30 @@ pub struct timespec { - pub struct stat { - pub st_dev: __dev_t, - pub st_ino: __ino_t, -+ #[cfg(target_arch = "x86_64")] - pub st_nlink: __nlink_t, - pub st_mode: __mode_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub st_nlink: __nlink_t, - pub st_uid: __uid_t, - pub st_gid: __gid_t, -+ #[cfg(target_arch = "x86_64")] - pub __pad0: libc::c_int, - pub st_rdev: __dev_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad1: __dev_t, - pub st_size: __off_t, - pub st_blksize: __blksize_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad2: libc::c_int, - pub st_blocks: __blkcnt_t, - pub st_atim: timespec, - pub st_mtim: timespec, - pub st_ctim: timespec, -+ #[cfg(target_arch = "x86_64")] - pub __glibc_reserved: [__syscall_slong_t; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __glibc_reserved: [libc::c_int; 2], - } - - #[derive(Copy, Clone)] -@@ -251,14 +268,21 @@ static mut ignore_devs: [*const libc::c_char; 4] = [ - - #[inline] - unsafe extern "C" fn fstat(mut __fd: libc::c_int, mut __statbuf: *mut stat) -> libc::c_int { -+ #[cfg(target_arch = "x86_64")] - return __fxstat(1 as libc::c_int, __fd, __statbuf); -+ #[cfg(not(target_arch = "x86_64"))] -+ return __fxstat(0 as libc::c_int, __fd, __statbuf); - } -+ - #[inline] - unsafe extern "C" fn stat( - mut __path: *const libc::c_char, - mut __statbuf: *mut stat, - ) -> libc::c_int { -+ #[cfg(target_arch = "x86_64")] - return __xstat(1 as libc::c_int, __path, __statbuf); -+ #[cfg(not(target_arch = "x86_64"))] -+ return __xstat(0 as libc::c_int, __path, __statbuf); - } - - #[inline] -@@ -289,17 +313,26 @@ unsafe extern "C" fn sudo_ttyname_scan( - let mut pathbuf: [libc::c_char; PATH_MAX] = [0; PATH_MAX]; - let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; - let mut dp: *mut dirent = 0 as *mut dirent; -+ - let mut sb: stat = stat { - st_dev: 0, - st_ino: 0, -+ #[cfg(target_arch = "x86_64")] - st_nlink: 0, - st_mode: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ st_nlink: 0, - st_uid: 0, - st_gid: 0, -+ #[cfg(target_arch = "x86_64")] - __pad0: 0, - st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, - st_size: 0, - st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, - st_blocks: 0, - st_atim: timespec { - tv_sec: 0, -@@ -313,7 +346,10 @@ unsafe extern "C" fn sudo_ttyname_scan( - tv_sec: 0, - tv_nsec: 0, - }, -+ #[cfg(target_arch = "x86_64")] - __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], - }; - - let mut i: libc::c_int = 0 as libc::c_int; -@@ -372,14 +408,22 @@ unsafe extern "C" fn sudo_ttyname_scan( - let mut sb: stat = stat { - st_dev: 0, - st_ino: 0, -+ #[cfg(target_arch = "x86_64")] - st_nlink: 0, - st_mode: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ st_nlink: 0, - st_uid: 0, - st_gid: 0, -+ #[cfg(target_arch = "x86_64")] - __pad0: 0, - st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, - st_size: 0, - st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, - st_blocks: 0, - st_atim: timespec { - tv_sec: 0, -@@ -393,8 +437,12 @@ unsafe extern "C" fn sudo_ttyname_scan( - tv_sec: 0, - tv_nsec: 0, - }, -+ #[cfg(target_arch = "x86_64")] - __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], - }; -+ - /* Skip anything starting with "." */ - if (*dp).d_name[0 as usize] as libc::c_int == '.' as i32 { - continue; -@@ -495,14 +543,22 @@ unsafe extern "C" fn sudo_dev_check( - let mut sb: stat = stat { - st_dev: 0, - st_ino: 0, -+ #[cfg(target_arch = "x86_64")] - st_nlink: 0, - st_mode: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ st_nlink: 0, - st_uid: 0, - st_gid: 0, -+ #[cfg(target_arch = "x86_64")] - __pad0: 0, - st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, - st_size: 0, - st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, - st_blocks: 0, - st_atim: timespec { - tv_sec: 0, -@@ -516,7 +572,10 @@ unsafe extern "C" fn sudo_dev_check( - tv_sec: 0, - tv_nsec: 0, - }, -+ #[cfg(target_arch = "x86_64")] - __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], - }; - debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); - if stat(devname, &mut sb) == 0 { --- -2.41.0 - diff --git a/0002-fix-use_pty-function-error.patch b/0002-fix-use_pty-function-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..cd2fd5fae2ff8fb94dacd362474dd7265ea8da2f --- /dev/null +++ b/0002-fix-use_pty-function-error.patch @@ -0,0 +1,180 @@ +From 3b59a1cc7b3d9ea38ae3501c7a4e09597f7acdaa Mon Sep 17 00:00:00 2001 +From: binlingyu +Date: Sun, 28 Apr 2024 13:41:35 +0800 +Subject: [PATCH] fix use_pty function error + +--- + lib/util/src/term.rs | 5 +++-- + src/exec_monitor.rs | 12 ++++++------ + src/exec_pty.rs | 38 +++++++++++++++++++++++--------------- + 3 files changed, 32 insertions(+), 23 deletions(-) + +diff --git a/lib/util/src/term.rs b/lib/util/src/term.rs +index 15bff23..c87c882 100644 +--- a/lib/util/src/term.rs ++++ b/lib/util/src/term.rs +@@ -648,7 +648,7 @@ unsafe extern "C" fn sudo_term_raw_v1(fd: libc::c_int, isig: libc::c_int) -> boo + }; + debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); + +- if changed != 0 && tcgetattr(fd, &mut oterm) != 0 { ++ if changed == 0 && tcgetattr(fd, &mut oterm) != 0 { + debug_return_bool!(false); + } + memcpy( +@@ -684,7 +684,7 @@ unsafe extern "C" fn sudo_term_raw_v1(fd: libc::c_int, isig: libc::c_int) -> boo + unsafe extern "C" fn sudo_term_cbreak_v1(fd: libc::c_int) -> bool { + debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); + +- if changed != 0 && tcgetattr(fd, &mut oterm) != 0 { ++ if changed == 0 && tcgetattr(fd, &mut oterm) != 0 { + debug_return_bool!(false); + } + +@@ -789,3 +789,4 @@ unsafe extern "C" fn sudo_term_copy_v1(src: libc::c_int, dst: libc::c_int) -> bo + } + debug_return_bool!(true) + } ++ +diff --git a/src/exec_monitor.rs b/src/exec_monitor.rs +index 890e30d..0ba0658 100644 +--- a/src/exec_monitor.rs ++++ b/src/exec_monitor.rs +@@ -357,7 +357,6 @@ unsafe extern "C" fn mon_handle_sigchld(mut mc: *mut monitor_closure) { + if !(pid == -(1 as libc::c_int) && errno!() == EINTR) { + break; + } +- break; + } + match pid { + 0 => { +@@ -420,7 +419,7 @@ unsafe extern "C" fn mon_handle_sigchld(mut mc: *mut monitor_closure) { + (*mc).cmnd_pid, + signame.as_mut_ptr() + ); +- (*mc).cmnd_pid == -(1 as libc::c_int); ++ (*mc).cmnd_pid = -(1 as libc::c_int); + } else if WIFEXITED!(status) { + sudo_debug_printf!( + SUDO_DEBUG_INFO, +@@ -429,7 +428,7 @@ unsafe extern "C" fn mon_handle_sigchld(mut mc: *mut monitor_closure) { + (*mc).cmnd_pid, + WEXITSTATUS!(status) + ); +- (*mc).cmnd_pid == -(1 as libc::c_int); ++ (*mc).cmnd_pid = -(1 as libc::c_int); + } else { + sudo_debug_printf!( + SUDO_DEBUG_WARN, +@@ -772,7 +771,7 @@ unsafe extern "C" fn fill_exec_closure_monitor( + } + + /* Event for forwarded signals via backchannel. */ +- let ref mut backchannel_event0 = (*mc).errpipe_event; ++ let ref mut backchannel_event0 = (*mc).backchannel_event; + *backchannel_event0 = sudo_ev_alloc_v1( + backchannel, + (SUDO_EV_READ | SUDO_EV_PERSIST) as libc::c_short, +@@ -800,7 +799,7 @@ unsafe extern "C" fn fill_exec_closure_monitor( + } + + /* Events for local signals. */ +- let ref mut sigint_event0 = (*mc).errpipe_event; ++ let ref mut sigint_event0 = (*mc).sigint_event; + *sigint_event0 = sudo_ev_alloc_v1( + SIGINT, + SUDO_EV_SIGINFO as libc::c_short, +@@ -823,7 +822,7 @@ unsafe extern "C" fn fill_exec_closure_monitor( + sudo_fatal!(b"unable to add event to queue\0" as *const u8 as *const libc::c_char,); + } + +- let ref mut sigquit_event0 = (*mc).errpipe_event; ++ let ref mut sigquit_event0 = (*mc).sigquit_event; + *sigquit_event0 = sudo_ev_alloc_v1( + SIGQUIT, + SUDO_EV_SIGINFO as libc::c_short, +@@ -1249,3 +1248,4 @@ pub unsafe extern "C" fn exec_monitor( + } + debug_return_int!(-(1 as libc::c_int)); + } ++ +diff --git a/src/exec_pty.rs b/src/exec_pty.rs +index 7e14e72..a5cc675 100644 +--- a/src/exec_pty.rs ++++ b/src/exec_pty.rs +@@ -2603,11 +2603,11 @@ pub unsafe extern "C" fn exec_pty( + if io_pipe[STDIN_FILENO as usize][0 as usize] != -(1 as libc::c_int) { + close(io_pipe[STDIN_FILENO as usize][0 as usize]); + } +- if io_pipe[STDOUT_FILENO as usize][0 as usize] != -(1 as libc::c_int) { +- close(io_pipe[STDOUT_FILENO as usize][0 as usize]); ++ if io_pipe[STDOUT_FILENO as usize][1 as usize] != -(1 as libc::c_int) { ++ close(io_pipe[STDOUT_FILENO as usize][1 as usize]); + } +- if io_pipe[STDERR_FILENO as usize][0 as usize] != -(1 as libc::c_int) { +- close(io_pipe[STDERR_FILENO as usize][0 as usize]); ++ if io_pipe[STDERR_FILENO as usize][1 as usize] != -(1 as libc::c_int) { ++ close(io_pipe[STDERR_FILENO as usize][1 as usize]); + } + close(sv[1 as usize]); + +@@ -2701,19 +2701,24 @@ unsafe extern "C" fn add_io_events(mut evbase: *mut sudo_event_base) { + } + if !((*iob).wevent).is_null() { + /* Enable writer if buffer is not empty. */ +- sudo_debug_printf!( +- SUDO_DEBUG_INFO, +- b"added I/O wevent %p, fd %d, events %d\0" as *const u8 as *const libc::c_char, +- (*iob).wevent, +- (*(*iob).wevent).fd, +- (*(*iob).wevent).events as libc::c_int +- ); +- if sudo_ev_add_v2(evbase, (*iob).wevent, 0 as *mut timespec, false) +- == -(1 as libc::c_int) +- { +- sudo_fatal!(b"unable to add event to queue\0" as *const u8 as *const libc::c_char,); ++ if (*iob).len > (*iob).off { ++ sudo_debug_printf!( ++ SUDO_DEBUG_INFO, ++ b"added I/O wevent %p, fd %d, events %d\0" as *const u8 as *const libc::c_char, ++ (*iob).wevent, ++ (*(*iob).wevent).fd, ++ (*(*iob).wevent).events as libc::c_int ++ ); ++ if sudo_ev_add_v2(evbase, (*iob).wevent, 0 as *mut timespec, false) ++ == -(1 as libc::c_int) ++ { ++ sudo_fatal!( ++ b"unable to add event to queue\0" as *const u8 as *const libc::c_char, ++ ); ++ } + } + } ++ iob = (*iob).entries.sle_next; + } + debug_return!(); + } +@@ -2833,6 +2838,7 @@ unsafe extern "C" fn del_io_events(mut nonblocking: bool) { + } + } + } ++ iob = (*iob).entries.sle_next; + } + sudo_debug_printf!( + SUDO_DEBUG_INFO, +@@ -2857,6 +2863,7 @@ unsafe extern "C" fn del_io_events(mut nonblocking: bool) { + ); + } + } ++ iob = (*iob).entries.sle_next; + } + } + +@@ -2977,3 +2984,4 @@ unsafe extern "C" fn safe_close(mut fd: libc::c_int) -> libc::c_int { + ); + debug_return_int!(close(fd)); + } ++ +-- +2.43.0 + diff --git a/0003-fix-bug-utsudoedit-error.patch b/0003-fix-bug-utsudoedit-error.patch deleted file mode 100644 index 9499ae9aaf39d0947effb914616c4552e1a85730..0000000000000000000000000000000000000000 --- a/0003-fix-bug-utsudoedit-error.patch +++ /dev/null @@ -1,6499 +0,0 @@ -From fd117274e49729d64080ba4af5bb968615a60c94 Mon Sep 17 00:00:00 2001 -From: trackers-love -Date: Wed, 20 Dec 2023 17:15:49 +0800 -Subject: [PATCH] fix utsudoedit error - ---- - lib/util/src/arc4random.rs | 33 +- - lib/util/src/closefrom.rs | 24 +- - lib/util/src/common.rs | 1631 ++++++++++++++++++++++++++++++ - lib/util/src/digest.rs | 51 +- - lib/util/src/event.rs | 258 +---- - lib/util/src/event_poll.rs | 163 +-- - lib/util/src/fatal.rs | 21 +- - lib/util/src/getgrouplist.rs | 9 +- - lib/util/src/gethostname.rs | 8 +- - lib/util/src/gettime.rs | 36 +- - lib/util/src/gidlist.rs | 22 +- - lib/util/src/key_val.rs | 7 +- - lib/util/src/lbuf.rs | 20 +- - lib/util/src/lib.rs | 5 +- - lib/util/src/locking.rs | 18 +- - lib/util/src/memset_s.rs | 7 +- - lib/util/src/parseln.rs | 70 +- - lib/util/src/progname.rs | 1 + - lib/util/src/pw_dup.rs | 7 +- - lib/util/src/secure_path.rs | 227 +---- - lib/util/src/setgroups.rs | 17 +- - lib/util/src/sha2.rs | 22 +- - lib/util/src/sig2str.rs | 40 +- - lib/util/src/str2sig.rs | 17 +- - lib/util/src/strsplit.rs | 7 +- - lib/util/src/strtobool.rs | 11 +- - lib/util/src/strtoid.rs | 44 +- - lib/util/src/strtomode.rs | 21 +- - lib/util/src/strtonum.rs | 16 +- - lib/util/src/sudo_conf.rs | 420 ++------ - lib/util/src/sudo_debug.rs | 12 +- - lib/util/src/sudo_debug_macro.rs | 4 + - lib/util/src/sudo_dso.rs | 49 +- - lib/util/src/term.rs | 265 +---- - lib/util/src/ttyname_dev.rs | 327 ++---- - lib/util/src/ttysize.rs | 44 +- - 36 files changed, 2034 insertions(+), 1900 deletions(-) - create mode 100644 lib/util/src/common.rs - -diff --git a/lib/util/src/arc4random.rs b/lib/util/src/arc4random.rs -index ef5545c..bc1a40b 100644 ---- a/lib/util/src/arc4random.rs -+++ b/lib/util/src/arc4random.rs -@@ -14,26 +14,21 @@ - unused_assignments - )] - --//call libc_func --use libc::abort; -+use crate::common::*; - - //define - pub const RSBUFSZ: i32 = 1024; - pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -+ -+// #define KEYSZ 32 -+// #define IVSZ 8 - pub const KEYSZ: i32 = 32; - pub const IVSZ: i32 = 8; - - //aliase of type --pub type pid_t = libc::c_int; --pub type uint32_t = libc::c_uint; --pub type size_t = libc::c_ulong; --pub type __off_t = libc::c_long; - pub type __pthread_list_t = __pthread_internal_list; --pub type sig_atomic_t = __sig_atomic_t; --pub type __sig_atomic_t = libc::c_int; --pub type u8 = libc::c_uchar; --pub type u32 = libc::c_uint; - -+//line 75 - #[derive(Copy, Clone)] - #[repr(C)] - pub struct _rs { -@@ -116,6 +111,7 @@ static mut arc4random_mtx: pthread_mutex_t = pthread_mutex_t { - }, - }; - -+//line 108-126 - #[no_mangle] - unsafe fn _rs_stir() { - let mut rnd: [libc::c_uchar; (KEYSZ + IVSZ) as usize] = [0; (KEYSZ + IVSZ) as usize]; -@@ -157,6 +153,7 @@ unsafe fn _rs_stir() { - (*rs).rs_count = 1600000; - } - -+//line86 87 90... - extern "C" { - fn mmap( - __addr: *mut libc::c_void, -@@ -180,7 +177,6 @@ extern "C" { - } - - //function _getentropy_fail --use libc::raise; - pub const SIGKILL: libc::c_int = 9; - pub unsafe fn _getentropy_fail() { - raise(SIGKILL); -@@ -188,7 +184,6 @@ pub unsafe fn _getentropy_fail() { - - //function _rs_forkdetect - static mut wipeonfork: libc::c_int = 0; --use libc::getpid; - static mut _rs_forked: __sig_atomic_t = 0; - pub unsafe fn _rs_forkdetect() { - if wipeonfork == 0 { -@@ -212,11 +207,16 @@ pub unsafe fn _rs_forkdetect() { - pub const PROT_READ: libc::c_short = 0x1; - pub const PROT_WRITE: libc::c_short = 0x2; - pub const MAP_ANON: libc::c_short = 0x20; -+ -+// /* Return value of `mmap' in case of an error. */ -+// #define MAP_FAILED ((void *) -1) - pub const MAP_FAILED: libc::c_int = -1; -+ -+//#define MAP_PRIVATE 0x02 /* Changes are private. */ - pub const MAP_PRIVATE: libc::c_short = 0x02; -+ -+//# define MADV_WIPEONFORK 18 /* Zero memory on fork, child only. */ - pub const MADV_WIPEONFORK: libc::c_int = 18; --use libc::madvise; --use libc::pthread_atfork; - pub unsafe extern "C" fn _rs_forkhandler() { - _rs_forked = 1; - } -@@ -290,12 +290,10 @@ macro_rules! U8TO32_LITTLE { - << 24 as libc::c_int - }}; - } -- - static mut sigma: [libc::c_char; 16] = - unsafe { *::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"expand 32-byte k") }; - static mut tau: [libc::c_char; 16] = - unsafe { *::std::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"expand 16-byte k") }; -- - #[no_mangle] - pub unsafe fn chacha_keysetup( - mut x: *mut chacha_ctx, -@@ -458,6 +456,7 @@ pub unsafe fn chacha_encrypt_bytes( - x13 = j13; - x14 = j14; - x15 = j15; -+ - i = 20; - while i > 0 { - QUARTERROUND!(x0, x4, x8, x12); -@@ -486,6 +485,7 @@ pub unsafe fn chacha_encrypt_bytes( - x13 = PLUS!(x13, j13); - x14 = PLUS!(x14, j14); - x15 = PLUS!(x15, j15); -+ - //line 185-187 - j12 = PLUS!(j12, 1); - if j12 == 0 { -@@ -508,6 +508,7 @@ pub unsafe fn chacha_encrypt_bytes( - U32TO8_LITTLE!(c, x13, 52); - U32TO8_LITTLE!(c, x14, 56); - U32TO8_LITTLE!(c, x15, 60); -+ - if bytes <= 64 { - if bytes < 64 { - i = 0; -diff --git a/lib/util/src/closefrom.rs b/lib/util/src/closefrom.rs -index 948b9a6..b7626a7 100644 ---- a/lib/util/src/closefrom.rs -+++ b/lib/util/src/closefrom.rs -@@ -5,12 +5,8 @@ - */ - - #![allow(unused_variables, unused_assignments, clashing_extern_declarations)] --use crate::arc4random::__off_t; --use crate::sudo_conf::__ino_t; --use crate::INT_MAX; --use libc::dirfd; --use libc::DIR; --pub const _SC_OPEN_MAX: i32 = 4; -+ -+use crate::common::*; - - extern "C" { - fn sysconf(__name: libc::c_int) -> libc::c_long; -@@ -32,13 +28,6 @@ fn closefrom_fallback(lowfd: libc::c_int) { - let mut _fd: libc::c_long = 0; - let mut maxfd: libc::c_long; - -- #[macro_export] -- macro_rules! _POSIX_OPEN_MAX { -- () => { -- 20 -- }; -- } -- - maxfd = unsafe { sysconf(_SC_OPEN_MAX) }; - - if maxfd < 0 { -@@ -52,15 +41,6 @@ fn closefrom_fallback(lowfd: libc::c_int) { - } - } - --#[repr(C)] --pub struct dirent { -- pub d_ino: __ino_t, -- pub d_off: __off_t, -- pub d_reclen: libc::c_short, -- pub d_type: libc::c_char, -- pub d_name: [libc::c_char; 256], --} -- - #[no_mangle] - fn sudo_closefrom(lowfd: libc::c_int) { - let path: *const libc::c_char; -diff --git a/lib/util/src/common.rs b/lib/util/src/common.rs -new file mode 100644 -index 0000000..7756029 ---- /dev/null -+++ b/lib/util/src/common.rs -@@ -0,0 +1,1631 @@ -+/* -+ * SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -+ * -+ * SPDX-License-Identifier: MulanPSL-2.0 -+ */ -+ -+#![allow( -+ non_camel_case_types, -+ non_snake_case, -+ non_upper_case_globals, -+ unused_macros, -+ dead_code -+)] -+ -+//////////// 调用其它模块中接口 -+pub use crate::sudo_debug::*; -+pub use libc::abort; -+pub use libc::dirfd; -+pub use libc::free; -+pub use libc::getpid; -+pub use libc::madvise; -+pub use libc::malloc; -+pub use libc::pthread_atfork; -+pub use libc::raise; -+pub use libc::DIR; -+pub use std::ffi::CStr; -+pub use std::ffi::CString; -+pub use std::string::String; -+ -+//////////// 调用第三方库函数 -+ -+//////////// 定义类型 -+pub type nfds_t = libc::c_ulong; -+pub type pid_t = __pid_t; -+pub type size_t = libc::c_ulong; -+pub type __off_t = libc::c_long; -+pub type __ino_t = libc::c_ulong; -+pub type __uint64_t = libc::c_ulong; -+pub type uint64_t = __uint64_t; -+pub type __uint32_t = libc::c_uint; -+pub type uint32_t = __uint64_t; -+pub type __uint8_t = libc::c_uchar; -+pub type uint8_t = __uint8_t; -+pub type __time_t = libc::c_long; -+pub type __syscall_slong_t = libc::c_long; -+pub type __dev_t = libc::c_ulong; -+pub type dev_t = __dev_t; -+pub type __uid_t = libc::c_uint; -+pub type __gid_t = libc::c_uint; -+pub type __mode_t = libc::c_uint; -+ -+#[cfg(target_arch = "x86_64")] -+pub type __nlink_t = libc::c_ulong; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __nlink_t = libc::c_uint; -+ -+#[cfg(target_arch = "x86_64")] -+pub type __blksize_t = libc::c_long; -+#[cfg(not(target_arch = "x86_64"))] -+pub type __blksize_t = libc::c_int; -+ -+pub type __off64_t = libc::c_long; -+pub type __blkcnt_t = libc::c_long; -+pub type __ssize_t = libc::c_long; -+pub type gid_t = __gid_t; -+pub type uid_t = __uid_t; -+pub type ssize_t = __ssize_t; -+pub type __pid_t = libc::c_int; -+pub type __clock_t = libc::c_long; -+pub type __suseconds_t = libc::c_long; -+pub type __sig_atomic_t = libc::c_int; -+pub type sig_atomic_t = __sig_atomic_t; -+pub type time_t = __time_t; -+pub type __id_t = libc::c_uint; -+pub type id_t = __id_t; -+pub type __clockid_t = libc::c_int; -+pub type clockid_t = __clockid_t; -+pub type off_t = __off_t; -+pub type __int32_t = libc::c_int; -+pub type FILE = _IO_FILE; -+pub type u8 = libc::c_uchar; -+pub type u32 = libc::c_uint; -+pub type mode_t = __mode_t; -+pub type in_addr_t = libc::c_uint; -+pub type _IO_lock_t = (); -+ -+pub type sudo_conv_callback_fn_t = -+ Option libc::c_int>; -+ -+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_hook_fn_t = Option libc::c_int>; -+ -+pub type sudo_printf_t = -+ Option libc::c_int>; -+ -+pub type sudo_fatal_callback_t = Option; -+ -+//////////// 定义静态变量值 -+pub const EINVAL: libc::c_int = 22; -+pub const SHA512_BLOCK_LENGTH: usize = 128; -+pub const __SIGRTMIN: libc::c_uint = 64; -+pub const NSIG: libc::c_uint = __SIGRTMIN + 1; -+pub const _SC_NGROUPS_MAX: libc::c_uint = 3; -+pub const _SC_OPEN_MAX: i32 = 4; -+pub const SIZE_MAX: libc::c_ulong = 18446744073709551615; -+pub const RSIZE_MAX: libc::c_ulong = SIZE_MAX >> 1; -+pub const NGROUPS_MAX: libc::c_uint = 65536; -+pub const SUDO_PATH_SECURE: libc::c_int = 0; -+pub const SUDO_PATH_MISSING: libc::c_int = -1; -+pub const SUDO_PATH_BAD_TYPE: libc::c_int = -2; -+pub const SUDO_PATH_WRONG_OWNER: libc::c_int = -3; -+pub const SUDO_PATH_WORLD_WRITABLE: libc::c_int = -4; -+pub const SUDO_PATH_GROUP_WRITABLE: libc::c_int = -5; -+pub const ENOENT: libc::c_int = 2; -+pub const _SC_RTSIG_MAX: libc::c_int = 31; -+pub const _ISdigit: libc::c_uint = 2048; -+pub const ERANGE: libc::c_int = 34; -+pub const _ISspace: libc::c_uint = 8192; -+pub const SUDO_DEBUG_CRIT: libc::c_int = 1; -+pub const SUDO_DEBUG_ERROR: libc::c_int = 2; -+pub const SUDO_DEBUG_WARN: libc::c_int = 3; -+pub const SUDO_DEBUG_NOTICE: libc::c_int = 4; -+pub const SUDO_DEBUG_DIAG: libc::c_int = 5; -+pub const SUDO_DEBUG_INFO: libc::c_int = 6; -+pub const SUDO_DEBUG_TRACE: libc::c_int = 7; -+pub const SUDO_DEBUG_DEBUG: libc::c_int = 8; -+pub const SUDO_DEBUG_ERRNO: libc::c_int = 1 << 4; -+pub const SUDO_DEBUG_LINENO: libc::c_int = 1 << 5; -+pub const SUDO_DEBUG_ARGS: libc::c_int = 1 << 6; -+pub const SUDO_DEBUG_CONV: libc::c_int = 2 << 6; -+pub const SUDO_DEBUG_EDIT: libc::c_int = 3 << 6; -+pub const SUDO_DEBUG_EVENT: libc::c_int = 4 << 6; -+pub const SUDO_DEBUG_EXEC: libc::c_int = 5 << 6; -+pub const SUDO_DEBUG_HOOKS: libc::c_int = 6 << 6; -+pub const SUDO_DEBUG_MAIN: libc::c_int = 7 << 6; -+pub const SUDO_DEBUG_NETIF: libc::c_int = 8 << 6; -+pub const SUDO_DEBUG_PCOMM: libc::c_int = 9 << 6; -+pub const SUDO_DEBUG_PLUGIN: libc::c_int = 10 << 6; -+pub const SUDO_DEBUG_PTY: libc::c_int = 11 << 6; -+pub const SUDO_DEBUG_SELINUX: libc::c_int = 12 << 6; -+pub const SUDO_DEBUG_UTIL: libc::c_int = 13 << 6; -+pub const SUDO_DEBUG_UTMP: libc::c_int = 14 << 6; -+pub const SUDO_DEBUG_INSTANCE_ERROR: libc::c_int = -2; -+pub const SUDO_DEBUG_INSTANCE_INITIALIZER: libc::c_int = -1; -+pub const ROOT_UID: libc::c_int = 0 as libc::c_int; -+pub const GROUP_API_VERSION_MAJOR: libc::c_int = 1 as libc::c_int; -+pub const GROUP_API_VERSION_MINOR: libc::c_int = 0 as libc::c_int; -+pub const SUDO_CONV_PROMPT_ECHO_OFF: libc::c_int = 0x0001; -+pub const SUDO_CONV_PROMPT_ECHO_ON: libc::c_int = 0x0002; -+pub const SUDO_CONV_ERROR_MSG: libc::c_int = 0x0003; -+pub const SUDO_CONV_INFO_MSG: libc::c_int = 0x0004; -+pub const SUDO_CONV_PROMPT_MASK: libc::c_int = 0x0005; -+pub const SUDO_CONV_PROMPT_ECHO_OK: libc::c_int = 0x1000; -+pub const SUDO_CONV_PREFER_TTY: libc::c_int = 0x2000; -+pub const EOF: libc::c_int = -1; -+pub const EPROTONOSUPPORT: libc::c_int = 93; -+pub const EAFNOSUPPORT: libc::c_int = 97; -+pub const AUDIT_NOT_CONFIGURED: libc::c_int = -2; -+pub const AUDIT_USER_CMD: libc::c_int = 1123; -+pub const ECONNREFUSED: libc::c_int = 111; -+pub const F_SETFD: libc::c_int = 2; -+pub const FD_CLOEXEC: libc::c_int = 1; -+pub const LC_ALL: libc::c_int = 6; -+ -+pub static mut sudo_debug_subsys: libc::c_int = 0 as libc::c_int; -+ -+pub const MODE_EDIT: libc::c_int = 0x00000002; // 2 -+pub const MODE_LOGIN_SHELL: libc::c_int = 0x00040000; -+pub const MODE_BACKGROUND: libc::c_int = 0x00010000; -+pub const MODE_SHELL: libc::c_int = 0x00020000; -+pub const MODE_IMPLIED_SHELL: libc::c_int = 0x00080000; -+pub const MODE_RESET_HOME: libc::c_int = 0x00100000; -+pub const MODE_PRESERVE_GROUPS: libc::c_int = 0x00200000; -+pub const MODE_PRESERVE_ENV: libc::c_int = 0x00400000; -+pub const MODE_NONINTERACTIVE: libc::c_int = 0x00800000; -+pub const MODE_LONG_LIST: libc::c_int = 0x01000000; -+ -+pub const SUDO_HOOK_VERSION_MAJOR: libc::c_uint = 1; -+pub const SUDO_HOOK_VERSION_MINOR: libc::c_uint = 0; -+ -+pub const SUDO_HOOK_SETENV: libc::c_uint = 1; -+pub const SUDO_HOOK_UNSETENV: libc::c_uint = 2; -+pub const SUDO_HOOK_PUTENV: libc::c_uint = 3; -+pub const SUDO_HOOK_GETENV: libc::c_uint = 4; -+ -+pub const SUDOERS_GRAMMAR_VERSION: libc::c_int = 5; -+// #define SUDOERS_GRAMMAR_VERSION 46 -+ -+pub const MODE_RUN: libc::c_int = 0x00000001; // 1 -+pub const MODE_VALIDATE: libc::c_int = 0x00000004; // 4 -+pub const MODE_INVALIDATE: libc::c_int = 0x00000008; // 8 -+pub const MODE_KILL: libc::c_int = 0x00000010; // 16 -+pub const MODE_VERSION: libc::c_int = 0x00000020; // 32 -+pub const MODE_HELP: libc::c_int = 0x00000040; // 64 -+pub const MODE_LIST: libc::c_int = 0x00000080; // 128 -+pub const MODE_CHECK: libc::c_int = 0x00000100; // 256 -+pub const MODE_MASK: libc::c_int = 0x0000ffff; // 65535 -+ -+pub const MAX_UID_T_LEN: libc::c_int = 10; -+ -+pub const SUDO_API_VERSION_MAJOR: libc::c_int = 1; -+pub const SUDO_API_VERSION_MINOR: libc::c_int = 13; -+pub const SUDO_DSO_DEFAULT: *mut libc::c_void = -(2 as libc::c_int) as *mut libc::c_void; -+ -+pub const ELOOP: libc::c_int = 40; -+pub const O_RDONLY: libc::c_int = 0o0; -+pub const O_RDWR: libc::c_int = 0o2; -+pub const O_CREAT: libc::c_int = 0o100; -+pub const EAGAIN: libc::c_int = 11; -+pub const EWOULDBLOCK: libc::c_int = 11; -+pub const S_ISVTX: libc::c_int = 0o1000; -+pub const S_ISGID: libc::c_int = 0o2000; -+pub const S_ISUID: libc::c_int = 0o4000; -+ -+//#define SEEK_SET 0 /* Seek from beginning of file. */ -+//#define SEEK_END 2 /* Seek from end of file. */ -+pub const SEEK_SET: libc::c_int = 0; -+pub const SEEK_END: libc::c_int = 2; -+ -+pub const __S_IREAD: libc::c_int = 0o400; -+pub const __S_IWRITE: libc::c_int = 0o200; -+pub const __S_IEXEC: libc::c_int = 0o100; -+pub const S_IRWXU: libc::c_int = __S_IREAD | __S_IWRITE | __S_IEXEC; -+pub const S_IXUSR: libc::c_int = 0o100; -+pub const S_IXGRP: libc::c_int = S_IXUSR >> 3; -+pub const S_IXOTH: libc::c_int = S_IXGRP >> 3; -+ -+pub const S_IRWXG: libc::c_int = S_IRWXU >> 3; -+pub const S_IRWXO: libc::c_int = S_IRWXG >> 3; -+pub const S_IREAD: libc::c_int = 0o400; -+pub const S_IWRITE: libc::c_int = 0o200; -+ -+pub const SIG2STR_MAX: libc::c_int = 32; -+pub const SIGALRM: libc::c_int = 14; -+pub const SIGBUS: libc::c_int = 10; -+pub const SIGCHLD: libc::c_int = 17; -+pub const SIGCONT: libc::c_int = 18; -+pub const SIGCONT_BG: libc::c_int = -3; -+pub const SIGCONT_FG: libc::c_int = -2; -+pub const SIGHUP: libc::c_int = 1; -+pub const SIGINT: libc::c_int = 2; -+pub const SIGKILL: libc::c_int = 9; -+pub const SIGPIPE: libc::c_int = 13; -+pub const SIGQUIT: libc::c_int = 3; -+pub const SIGSTOP: libc::c_int = 19; -+pub const SIGSYS: libc::c_int = 12; -+pub const SIGTERM: libc::c_int = 15; -+pub const SIGTRAP: libc::c_int = 5; -+pub const SIGTSTP: libc::c_int = 18; -+pub const SIGTTIN: libc::c_int = 21; -+pub const SIGTTOU: libc::c_int = 22; -+pub const SIGUSR1: libc::c_int = 10; -+pub const SIGUSR2: libc::c_int = 12; -+pub const SIGWINCH: libc::c_int = 28; -+pub const SIG_BLOCK: libc::c_int = 0; -+pub const SIG_SETMAS: libc::c_int = 2; -+pub const SIG_SETMASK: libc::c_int = 2; -+pub const SIG_UNBLOCK: libc::c_int = 1; -+pub const SA_RESTART: libc::c_int = 0x10000000; -+pub const EINTR: libc::c_int = 4; -+pub const SUDO_CONF_DEBUG: libc::c_int = 0x01; -+pub const SUDO_CONF_PLUGINS: libc::c_int = 0x04; -+ -+// # define AT_FDCWD -100 -+pub const AT_FDCWD: libc::c_int = -100; -+ -+pub const EACCES: libc::c_int = 13; -+pub const ENOTDIR: libc::c_int = 20; -+pub const SUDO_LOCK: libc::c_int = 1; -+pub const SUDO_TLOCK: libc::c_int = 2; -+pub const SUDO_UNLOCK: libc::c_int = 4; -+pub const SUDO_CONV_REPL_MAX: libc::c_int = 255; -+ -+//#define __S_IFIFO 0010000 /* FIFO. */ -+pub const __S_IFIFO: libc::c_int = 0o010000; -+pub const _ISblank: libc::c_int = 1; -+ -+//////////// 定义宏 -+#[macro_export] -+macro_rules! SUDO_API_VERSION { -+ () => { -+ SUDO_API_MKVERSION!(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR) -+ }; -+} -+ -+#[macro_export] -+macro_rules! INT_MAX { -+ () => { -+ 0x7fffffff -+ }; -+} -+ -+#[macro_export] -+macro_rules! _S_IFMT { -+ () => { -+ 0o170000 -+ }; -+} -+ -+#[macro_export] -+macro_rules! S_IWUSR { -+ () => { -+ 0o200 -+ }; -+} -+// #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ -+#[macro_export] -+macro_rules! S_IWGRP { -+ () => { -+ S_IWUSR!() >> 3 -+ }; -+} -+ -+// #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ -+#[macro_export] -+macro_rules! S_IWOTH { -+ () => { -+ S_IWGRP!() >> 3 -+ }; -+} -+ -+// #define ISSET(t, f) ((t) & (f)) -+#[macro_export] -+macro_rules! ISSET { -+ ($_t:expr, $_f:expr) => { -+ (($_t) & ($_f)) -+ }; -+} -+ -+/* Extract subsystem number and convert to an index. */ -+// #define SUDO_DEBUG_SUBSYS(n) (((n) >> 6) - 1) -+#[macro_export] -+macro_rules! SUDO_DEBUG_SUBSYS { -+ ($_n:expr) => { -+ ((($_n) >> 6) - 1) -+ }; -+} -+ -+/* Extract priority number and convert to an index. */ -+// #define SUDO_DEBUG_PRI(n) (((n) & 0x0f) - 1) -+#[macro_export] -+macro_rules! SUDO_DEBUG_PRI { -+ ($_n:expr) => { -+ ((($_n) & 0x0f) - 1) -+ }; -+} -+ -+// #define TIOCGWINSZ 0x5413 -+#[macro_export] -+macro_rules! TIOCGWINSZ { -+ () => { -+ 0x5413 -+ }; -+} -+ -+#[macro_export] -+macro_rules! _POSIX_OPEN_MAX { -+ () => { -+ 20 -+ }; -+} -+ -+// #define __S_IFREG 0100000 /* Regular file. */ -+#[macro_export] -+macro_rules! _S_IFREG { -+ () => { -+ 0o100000 -+ }; -+} -+ -+// #define __S_IFDIR 0040000 /* Directory. */ -+#[macro_export] -+macro_rules! _S_IFDIR { -+ () => { -+ 0o40000 -+ }; -+} -+ -+// #define INT_MIN (-__INT_MAX__ - 1) -+#[macro_export] -+macro_rules! INT_MIN { -+ () => { -+ (-(INT_MAX!()) - 1) -+ }; -+} -+ -+// #define UINT_MAX (__INT_MAX__ * 2U + 1U) -+#[macro_export] -+macro_rules! UINT_MAX { -+ () => { -+ ((INT_MAX!()) * (2 as libc::c_uint) + 1 as libc::c_uint) -+ }; -+} -+ -+// #define isblank(c) __isctype((c), _ISblank) -+#[macro_export] -+macro_rules! isblank { -+ ($c:expr) => { -+ __isctype!($c, _ISblank) -+ }; -+} -+ -+// # define __isctype(c, type) ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type) -+#[macro_export] -+macro_rules! __isctype { -+ ($c:expr, $type:expr) => { -+ (*(*__ctype_b_loc()).offset($c as isize) as libc::c_int) -+ & ($type as libc::c_int as libc::c_ushort as libc::c_int) -+ }; -+} -+ -+// define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) -+// _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ -+#[macro_export] -+macro_rules! _ISbit { -+ ($bit:expr) => { -+ if ($bit) < 8 { -+ ((1 << ($bit)) << 8) -+ } else { -+ ((1 << ($bit)) >> 8) -+ } -+ }; -+} -+ -+#[macro_export] -+macro_rules! _ISblank { -+ () => { -+ _ISbit!(8) -+ }; -+} -+ -+macro_rules! SUDO_DEBUG_ALL { -+ /* all subsystems */ -+ () => { -+ 0xffff0000 -+ }; -+} -+ -+#[macro_export] -+macro_rules! debug_decl_func { -+ ($funcname:expr) => {}; -+} -+ -+#[macro_export] -+macro_rules! debug_decl_vars { -+ ($subsys:expr) => { -+ sudo_debug_subsys = $subsys -+ }; -+} -+ -+#[macro_export] -+macro_rules! debug_decl { -+ ($subsys:expr) => { -+ debug_decl_vars!($subsys); -+ sudo_debug_enter_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ ); -+ }; -+} -+ -+#[macro_export] -+macro_rules! debug_return_int { -+ ($ret:expr) => {{ -+ let mut tmp_var: libc::c_int = $ret as libc::c_int; -+ sudo_debug_exit_int_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ tmp_var, -+ ); -+ return tmp_var; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_id_t { -+ ($ret:expr) => {{ -+ sudo_debug_exit_id_t_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_size_t { -+ ($ret:expr) => { -+ sudo_debug_exit_size_t_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }; -+} -+ -+#[macro_export] -+macro_rules! debug_return_ssize_t { -+ ($ret:expr) => {{ -+ sudo_debug_exit_ssize_t_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_time_t { -+ ($ret:expr) => {{ -+ sudo_debug_exit_time_t_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_long { -+ ($ret:expr) => { -+ sudo_debug_exit_long( -+ get_function_name!(), -+ get_file_name!(), -+ line!(), -+ sudo_debug_subsys, -+ $ret, -+ ); -+ return $ret; -+ }; -+} -+ -+#[macro_export] -+macro_rules! debug_return_bool { -+ ($ret:expr) => {{ -+ let mut tmp_var: bool = $ret as bool; -+ sudo_debug_exit_bool_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ tmp_var, -+ ); -+ return tmp_var; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_str { -+ ($ret:expr) => {{ -+ sudo_debug_exit_str_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_const_str { -+ ($ret:expr) => {{ -+ sudo_debug_exit_str_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret as *const libc::c_char, -+ ); -+ return $ret as *const libc::c_char; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_str_masked { -+ ($ret:expr) => {{ -+ sudo_debug_exit_str_masked_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return_ptr { -+ ($ret:expr) => {{ -+ sudo_debug_exit_ptr_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret as *const libc::c_void, -+ ); -+ return $ret; -+ }}; -+} -+ -+macro_rules! debug_return_const_ptr { -+ ($ret:expr) => {{ -+ sudo_debug_exit_ptr_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ $ret as *const libc::c_void, -+ ); -+ return $ret; -+ }}; -+} -+ -+#[macro_export] -+macro_rules! sudo_debug_execve { -+ ($pri:expr, $path:expr, $argv:expr, $envp:expr) => {{ -+ sudo_debug_execve2_v1( -+ $pri | sudo_debug_subsys as libc::c_int, -+ $path as *const libc::c_char, -+ $argv as *const *mut libc::c_char, -+ $envp as *const *mut libc::c_char, -+ ); -+ }}; -+} -+ -+// #define sudo_debug_write(fd, str, len, errnum) \ -+// sudo_debug_write2(fd, NULL, NULL, 0, (str), (len), (errnum)) -+ -+macro_rules! sudo_debug_write { -+ ($fd:expr, $str:expr, $len:expr, $errnum:expr) => {{ -+ sudo_debug_write2_v1( -+ $fd as libc::c_int, -+ 0 as *const libc::c_char, -+ 0 as *const libc::c_char, -+ 0 as libc::c_int, -+ $str as *const libc::c_char, -+ $len as libc::c_int, -+ $errnum as libc::c_int, -+ ); -+ }}; -+} -+ -+// # define sudo_debug_printf(pri, ...) \ -+// sudo_debug_printf2(__func__, __FILE__, __LINE__, (pri)|sudo_debug_subsys, \ -+// __VA_ARGS__) -+// #endif -+#[macro_export] -+macro_rules! sudo_debug_printf { -+ ($pri:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ ($pri | sudo_debug_subsys) as libc::c_int, -+ $($arg)*, -+ ); -+ }}; -+} -+ -+#[macro_export] -+macro_rules! debug_return { -+ () => {{ -+ sudo_debug_exit_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ sudo_debug_subsys as libc::c_int, -+ ); -+ return; -+ }}; -+} -+ -+// # define sudo_warn(fmt...) do { \ -+// sudo_debug_printf2(__func__, __FILE__, __LINE__, \ -+// SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \ -+// fmt); \ -+// sudo_warn_nodebug_v1(fmt); -+// } while (0) -+#[macro_export] -+macro_rules! sudo_warn { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ sudo_warn_nodebug_v1($fmt, $($arg)*); -+ }}; -+} -+ -+// sudo_warnx(fmt...) do { \ -+// sudo_debug_printf2(__func__, __FILE__, __LINE__, \ -+// SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, fmt); \ -+// sudo_warnx_nodebug_v1(fmt); -+// } while (0) -+#[macro_export] -+macro_rules! sudo_warnx { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ sudo_warnx_nodebug_v1( -+ $fmt, -+ $($arg)* -+ ); -+ }}; -+} -+ -+// # define sudo_fatalx(fmt...) do { \ -+// sudo_debug_printf2(__func__, __FILE__, __LINE__, \ -+// SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, fmt); \ -+// sudo_fatalx_nodebug_v1(fmt); \ -+// } while (0) -+#[macro_export] -+macro_rules! sudo_fatalx { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ sudo_fatalx_nodebug_v1( -+ $fmt, -+ $($arg)* -+ ); -+ }}; -+} -+ -+// # define sudo_fatal(fmt...) do { \ -+// sudo_debug_printf2(__func__, __FILE__, __LINE__, \ -+// SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \ -+// fmt); \ -+// sudo_fatal_nodebug_v1(fmt); -+// } while (0) -+#[macro_export] -+macro_rules! sudo_fatal { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ sudo_fatal_nodebug_v1($fmt, $($arg)*); -+ }}; -+} -+ -+// #define CLR(t, f) ((t) &= ~(f)) -+#[macro_export] -+macro_rules! CLR { -+ ($t:expr, $f:expr) => { -+ (($t) &= !($f)) -+ }; -+} -+ -+// #define SET(t, f) ((t) |= (f)) -+#[macro_export] -+macro_rules! SET { -+ ($t:expr, $f:expr) => { -+ (($t) |= ($f)) -+ }; -+} -+ -+/* Standard file descriptors. */ -+// #define STDERR_FILENO 2 /* Standard error output. */ -+#[macro_export] -+macro_rules! STDERR_FILENO { -+ () => { -+ 2 -+ }; -+} -+ -+// #define SIGRTMIN (__libc_current_sigrtmin ()) -+#[macro_export] -+macro_rules! SIGRTMIN { -+ () => { -+ (__libc_current_sigrtmin()) -+ }; -+} -+ -+// #define SIGRTMAX (__libc_current_sigrtmax ()) -+#[macro_export] -+macro_rules! SIGRTMAX { -+ () => { -+ (__libc_current_sigrtmax()) -+ }; -+} -+ -+/* Values for sudo_dso_load() mode. */ -+// #define SUDO_DSO_LAZY 0x1 -+// #define SUDO_DSO_NOW 0x2 -+// #define SUDO_DSO_GLOBAL 0x4 -+// #define SUDO_DSO_LOCAL 0x8 -+#[macro_export] -+macro_rules! SUDO_DSO_LAZY { -+ () => { -+ 0x1 -+ }; -+} -+ -+#[macro_export] -+macro_rules! SUDO_DSO_NOW { -+ () => { -+ 0x2 -+ }; -+} -+ -+#[macro_export] -+macro_rules! SUDO_DSO_GLOBAL { -+ () => { -+ 0x4 -+ }; -+} -+ -+#[macro_export] -+macro_rules! SUDO_DSO_LOCAL { -+ () => { -+ 0x8 -+ }; -+} -+ -+/* Getters and setters for plugin API versions */ -+// #define SUDO_API_VERSION_GET_MAJOR(v) ((v) >> 16) -+// #define SUDO_API_VERSION_GET_MINOR(v) ((v) & 0xffffU) -+#[macro_export] -+macro_rules! SUDO_API_VERSION_GET_MAJOR { -+ ($v:expr) => { -+ (($v) >> 16) -+ }; -+} -+ -+// #define SUDO_API_VERSION_GET_MINOR(v) ((v) & 0xffffU) -+#[macro_export] -+macro_rules! SUDO_API_VERSION_GET_MINOR { -+ ($v:expr) => { -+ (($v) & 0xffff) -+ }; -+} -+ -+#[macro_export] -+macro_rules! SUDO_API_MKVERSION { -+ ($x: expr, $y: expr) => { -+ ((($x) << 16) | ($y)) -+ }; -+} -+ -+// #define GROUP_API_VERSION SUDO_API_MKVERSION(GROUP_API_VERSION_MAJOR, GROUP_API_VERSION_MINOR) -+#[macro_export] -+macro_rules! GROUP_API_VERSION { -+ () => { -+ (SUDO_API_MKVERSION!(GROUP_API_VERSION_MAJOR, GROUP_API_VERSION_MINOR)) -+ }; -+} -+ -+// #define _PATH_DEV "/dev/" -+#[macro_export] -+macro_rules! _PATH_DEV { -+ () => { -+ b"/dev/\0" as *const u8 as *const libc::c_char -+ }; -+} -+ -+#[macro_export] -+macro_rules! SUDO_HOOK_VERSION { -+ () => { -+ SUDO_API_MKVERSION!(SUDO_HOOK_VERSION_MAJOR, SUDO_HOOK_VERSION_MINOR) -+ }; -+} -+ -+/* Define to the version of this package. */ -+// #define PACKAGE_VERSION "0.0.5" -+#[macro_export] -+macro_rules! PACKAGE_VERSION { -+ () => { -+ (b"0.0.5\0" as *const u8 as *const libc::c_char) -+ }; -+} -+ -+// # define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf" -+#[macro_export] -+macro_rules! _PATH_NSSWITCH_CONF { -+ () => { -+ (b"/etc/nsswitch.conf\0" as *const u8 as *const libc::c_char) -+ }; -+} -+ -+#[macro_export] -+macro_rules! ACCESSPERMS { -+ () => { -+ (S_IRWXU | S_IRWXG | S_IRWXO) -+ }; -+} -+ -+#[macro_export] -+macro_rules! ALLPERMS { -+ () => { -+ (S_ISUID as libc::c_int -+ | S_ISGID as libc::c_int -+ | S_ISVTX as libc::c_int -+ | S_IRWXU as libc::c_int -+ | S_IRWXG as libc::c_int -+ | S_IRWXO as libc::c_int) -+ }; -+} -+ -+#[macro_export] -+macro_rules! USER_SIGNALED { -+ ($_info:expr) => { -+ (!($_info).is_null() && (*($_info)).si_code == SI_USER) -+ }; -+} -+#[macro_export] -+macro_rules! WIFSTOPPED { -+ ($status:expr) => { -+ ($status & 0xff == 0x7f) -+ }; -+} -+#[macro_export] -+macro_rules! WIFSIGNALED { -+ ($status:expr) => { -+ (((($status & 0x7f) + 1) >> 1) > 0) -+ }; -+} -+#[macro_export] -+macro_rules! WEXITSTATUS { -+ ($status:expr) => { -+ ((($status) & 0xff00) >> 8) -+ }; -+} -+#[macro_export] -+macro_rules! WSTOPSIG { -+ ($status:expr) => { -+ ((($status) & 0xff00) >> 8) -+ }; -+} -+#[macro_export] -+macro_rules! WTERMSIG { -+ ($status:expr) => { -+ ($status & 0x7f) -+ }; -+} -+#[macro_export] -+macro_rules! WIFEXITED { -+ ($status: expr) => { -+ (WTERMSIG!($status) == 0) -+ }; -+} -+// #define S_IFMT 00170000 -+#[macro_export] -+macro_rules! S_IFMT { -+ () => { -+ 0o0170000 -+ }; -+} -+// #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) -+#[macro_export] -+macro_rules! __S_ISTYPE { -+ ($mode:expr, $mask:expr) => { -+ ((($mode) & S_IFMT!()) == ($mask)) -+ }; -+} -+#[macro_export] -+macro_rules! S_ISFIFO { -+ ($mode: expr) => { -+ __S_ISTYPE!(($mode), __S_IFIFO as libc::c_uint) -+ }; -+} -+ -+#[macro_export] -+macro_rules! S_IRUSR { -+ () => { -+ 0o400 -+ }; -+} -+ -+// # define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ -+#[macro_export] -+macro_rules! S_IRGRP { -+ () => { -+ (S_IRUSR!() >> 3) -+ }; -+} -+ -+// #define _PATH_TTY "/dev/tty" -+#[macro_export] -+macro_rules! _PATH_TTY { -+ () => { -+ b"/dev/tty\0" as *const u8 as *const libc::c_char -+ }; -+} -+#[macro_export] -+macro_rules! get_file_name { -+ () => { -+ CString::new(file!()).unwrap().as_bytes_with_nul().as_ptr() as *const libc::c_char -+ }; -+} -+ -+#[macro_export] -+macro_rules! get_function_name { -+ () => { -+ CString::new(stdext::function_name!()) -+ .unwrap() -+ .as_bytes_with_nul() -+ .as_ptr() as *const libc::c_char -+ }; -+} -+ -+//////////// 定义结构体值 -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct pollfd { -+ pub fd: libc::c_int, -+ pub events: libc::c_short, -+ pub revents: libc::c_short, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct timespec { -+ pub tv_sec: __time_t, -+ pub tv_nsec: __syscall_slong_t, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct SHA2_CTX { -+ pub state: state, -+ pub count: [uint64_t; 2], -+ pub buffer: [uint8_t; SHA512_BLOCK_LENGTH], -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union state { -+ pub st32: [uint32_t; 8], -+ pub st64: [uint64_t; 8], -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_event { -+ pub entries: TAILQ_ENTRY_sudo_event, -+ pub active_entries: TAILQ_ENTRY_active_entries, -+ pub timeouts_entries: TAILQ_ENTRY_timeouts_entries, -+ pub base: *mut sudo_event_base, -+ pub fd: libc::c_int, -+ pub events: libc::c_short, -+ pub revents: libc::c_short, -+ pub flags: libc::c_short, -+ pub pfd_idx: libc::c_short, -+ pub callback: sudo_ev_callback_t, -+ pub timeout: timespec, -+ pub closure: *mut libc::c_void, -+} -+pub type sudo_ev_callback_t = -+ Option ()>; -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct TAILQ_ENTRY_sudo_event { -+ pub tqe_next: *mut sudo_event, -+ pub tqe_prev: *mut *mut sudo_event, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct TAILQ_ENTRY_active_entries { -+ pub tqe_next: *mut sudo_event, -+ pub tqe_prev: *mut *mut sudo_event, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct TAILQ_ENTRY_timeouts_entries { -+ pub tqe_next: *mut sudo_event, -+ pub tqe_prev: *mut *mut sudo_event, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_event_base { -+ pub events: sudo_event_list, -+ pub active: sudo_event_list, -+ pub timeouts: sudo_event_list, -+ pub signal_event: sudo_event, -+ pub signals: [sudo_event_list; NSIG as usize], -+ pub orig_handlers: [*mut sigaction; NSIG as usize], -+ pub siginfo: [*mut siginfo_t; NSIG as usize], -+ pub signal_pending: [sig_atomic_t; NSIG as usize], -+ pub signal_caught: sig_atomic_t, -+ pub num_handlers: libc::c_int, -+ pub signal_pipe: [libc::c_int; 2], -+ pub pfds: *mut pollfd, -+ pub pfd_max: libc::c_int, -+ pub pfd_high: libc::c_int, -+ pub pfd_free: libc::c_int, -+ pub flags: libc::c_uint, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_event_list { -+ pub tqh_first: *mut sudo_event, -+ pub tqh_last: *mut *mut sudo_event, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sigaction { -+ pub __sigaction_handler: Signal_handler, -+ pub sa_mask: __sigset_t, -+ pub sa_flags: libc::c_int, -+ pub sa_restorer: Option ()>, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct __sigset_t { -+ pub __val: [libc::c_ulong; 16], -+} -+pub type sigset_t = __sigset_t; -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union Signal_handler { -+ pub sa_handler: __sighandler_t, -+ pub sa_sigaction: -+ Option ()>, -+} -+pub type __sighandler_t = Option ()>; -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct siginfo_t { -+ pub si_signo: libc::c_int, -+ pub si_errno: libc::c_int, -+ pub si_code: libc::c_int, -+ pub __pad0: libc::c_int, -+ pub _sifields: siginfo_t_u, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union siginfo_t_u { -+ pub _pad: [libc::c_int; 28], -+ pub _kill: _kill_s, -+ pub _timer: _timer_s, -+ pub _rt: _rt_s, -+ pub _sigchld: _sigchld_s, -+ pub _sigfault: _sigfault_s, -+ pub _sigpoll: _sigpoll_s, -+ pub _sigsys: _sigsys_s, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _kill_s { -+ pub si_pid: __pid_t, -+ pub si_uid: __uid_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _timer_s { -+ pub si_tid: libc::c_int, -+ pub si_overrun: libc::c_int, -+ pub si_sigval: __sigval_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union sigval { -+ pub sival_int: libc::c_int, -+ pub sival_ptr: *mut libc::c_void, -+} -+pub type __sigval_t = sigval; -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _rt_s { -+ pub si_pid: __pid_t, -+ pub si_uid: __uid_t, -+ pub si_sigval: __sigval_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _sigchld_s { -+ pub si_pid: __pid_t, -+ pub si_uid: __uid_t, -+ pub si_status: libc::c_int, -+ pub si_utime: __clock_t, -+ pub si_stime: __clock_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _sigfault_s { -+ pub si_addr: *mut libc::c_void, -+ pub si_addr_lsb: libc::c_short, -+ pub _bounds: _bounds_u, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union _bounds_u { -+ pub _addr_bnd: _addr_bnd_s, -+ pub _pkey: __uint32_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _addr_bnd_s { -+ pub _lower: *mut libc::c_void, -+ pub _upper: *mut libc::c_void, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _sigpoll_s { -+ pub si_band: libc::c_long, -+ pub si_fd: libc::c_int, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _sigsys_s { -+ pub _call_addr: *mut libc::c_void, -+ pub _syscall: libc::c_int, -+ pub _arch: libc::c_uint, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct timeval { -+ pub tv_sec: __time_t, -+ pub tv_usec: __suseconds_t, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct _IO_FILE { -+ pub _flags: libc::c_int, -+ pub _IO_read_ptr: *mut libc::c_char, -+ pub _IO_read_end: *mut libc::c_char, -+ pub _IO_read_base: *mut libc::c_char, -+ pub _IO_write_base: *mut libc::c_char, -+ pub _IO_write_ptr: *mut libc::c_char, -+ pub _IO_write_end: *mut libc::c_char, -+ pub _IO_buf_base: *mut libc::c_char, -+ pub _IO_buf_end: *mut libc::c_char, -+ pub _IO_save_base: *mut libc::c_char, -+ pub _IO_backup_base: *mut libc::c_char, -+ pub _IO_save_end: *mut libc::c_char, -+ pub _markers: *mut _IO_marker, -+ pub _chain: *mut _IO_FILE, -+ pub _fileno: libc::c_int, -+ pub _flags2: libc::c_int, -+ pub _old_offset: __off_t, -+ pub _cur_column: libc::c_ushort, -+ pub _vtable_offset: libc::c_schar, -+ pub _shortbuf: [libc::c_char; 1], -+ pub _lock: *mut libc::c_void, -+ pub _offset: __off64_t, -+ pub _codecvt: *mut _IO_codecvt, -+ pub _wide_data: *mut _IO_wide_data, -+ pub _freeres_list: *mut _IO_FILE, -+ pub _freeres_buf: *mut libc::c_void, -+ pub __pad5: size_t, -+ pub _mode: libc::c_int, -+ pub _unused2: [libc::c_char; 20], -+} -+ -+#[repr(C)] -+#[derive(Debug, Copy, Clone)] -+pub struct _IO_marker { -+ _unused: [u8; 0], -+} -+ -+#[repr(C)] -+#[derive(Debug, Copy, Clone)] -+pub struct _IO_codecvt { -+ _unused: [u8; 0], -+} -+ -+#[repr(C)] -+#[derive(Debug, Copy, Clone)] -+pub struct _IO_wide_data { -+ _unused: [u8; 0], -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct stat { -+ pub st_dev: __dev_t, -+ pub st_ino: __ino_t, -+ #[cfg(target_arch = "x86_64")] -+ pub st_nlink: __nlink_t, -+ pub st_mode: __mode_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub st_nlink: __nlink_t, -+ pub st_uid: __uid_t, -+ pub st_gid: __gid_t, -+ #[cfg(target_arch = "x86_64")] -+ pub __pad0: libc::c_int, -+ pub st_rdev: __dev_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad1: __dev_t, -+ pub st_size: __off_t, -+ pub st_blksize: __blksize_t, -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __pad2: libc::c_int, -+ pub st_blocks: __blkcnt_t, -+ pub st_atim: timespec, -+ pub st_mtim: timespec, -+ pub st_ctim: timespec, -+ #[cfg(target_arch = "x86_64")] -+ pub __glibc_reserved: [__syscall_slong_t; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ pub __glibc_reserved: [libc::c_int; 2], -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_debug_file { -+ pub entries: sudo_debug_file_list, -+ pub debug_file: *mut libc::c_char, -+ pub debug_flags: *mut libc::c_char, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_debug_file_list { -+ pub tqe_next: *mut sudo_debug_file, -+ pub tqe_prev: *mut *mut sudo_debug_file, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct sudo_conf_debug_file_list { -+ pub tqh_first: *mut sudo_debug_file, -+ pub tqh_last: *mut *mut sudo_debug_file, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct winsize { -+ pub ws_row: libc::c_ushort, -+ pub ws_col: libc::c_ushort, -+ pub ws_xpixel: libc::c_ushort, -+ pub ws_ypixel: libc::c_ushort, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct dirent { -+ pub d_ino: __ino_t, -+ pub d_off: __off_t, -+ pub d_reclen: libc::c_ushort, -+ pub d_type: libc::c_uchar, -+ pub d_name: [libc::c_char; 256], -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub union TMP_T { -+ pub __u6_addr8: [libc::c_uchar; 16], -+ pub __u6_addr16: [libc::c_ushort; 8], -+ pub __u6_addr32: [libc::c_uint; 4], -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct in6_addr { -+ pub __in6_u: TMP_T, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct in_addr { -+ pub s_addr: in_addr_t, -+} -+ -+//add by bgz -+//orig_c: DPRINTF1("STRING.....",base); -+#[macro_export] -+macro_rules! dprintf1 { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ (5) | sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ if ldap_conf.debug >= 1 { -+ sudo_warnx_nodebug_v1( -+ $fmt, -+ $($arg)* -+ ); -+ } -+ }}; -+} -+ -+//orig_c: DPRINTF2("STRING.....",base); -+#[macro_export] -+macro_rules! dprintf2 { -+ ($fmt:expr, $($arg:tt)*) => {{ -+ sudo_debug_printf2_v1( -+ get_function_name!(), -+ get_file_name!(), -+ line!() as libc::c_int, -+ (6) | sudo_debug_subsys, -+ $fmt, -+ $($arg)* -+ ); -+ if ldap_conf.debug >= 2 { -+ sudo_warnx_nodebug_v1( -+ $fmt, -+ $($arg)* -+ ); -+ } -+ }}; -+} -+//end of bgz -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct group { -+ pub gr_name: *mut libc::c_char, -+ pub gr_passwd: *mut libc::c_char, -+ pub gr_gid: __gid_t, -+ pub gr_mem: *mut *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, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct policy_plugin { -+ pub type_0: libc::c_uint, -+ pub version: libc::c_uint, -+ pub open: Option< -+ unsafe extern "C" fn( -+ libc::c_uint, -+ sudo_conv_t, -+ sudo_printf_t, -+ *const *mut libc::c_char, -+ *const *mut libc::c_char, -+ *const *mut libc::c_char, -+ *const *mut libc::c_char, -+ ) -> libc::c_int, -+ >, -+ pub close: Option ()>, -+ pub show_version: Option libc::c_int>, -+ pub check_policy: Option< -+ unsafe extern "C" fn( -+ libc::c_int, -+ *const *mut libc::c_char, -+ *mut *mut libc::c_char, -+ *mut *mut *mut libc::c_char, -+ *mut *mut *mut libc::c_char, -+ *mut *mut *mut libc::c_char, -+ ) -> libc::c_int, -+ >, -+ pub list: Option< -+ unsafe extern "C" fn( -+ libc::c_int, -+ *const *mut libc::c_char, -+ libc::c_int, -+ *const libc::c_char, -+ ) -> libc::c_int, -+ >, -+ pub validate: Option libc::c_int>, -+ pub invalidate: Option ()>, -+ pub init_session: -+ Option libc::c_int>, -+ pub register_hooks: Option< -+ unsafe extern "C" fn( -+ libc::c_int, -+ Option libc::c_int>, -+ ) -> (), -+ >, -+ pub deregister_hooks: Option< -+ unsafe extern "C" fn( -+ libc::c_int, -+ 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_hook { -+ pub hook_version: libc::c_uint, -+ pub hook_type: libc::c_uint, -+ pub hook_fn: sudo_hook_fn_t, -+ pub closure: *mut libc::c_void, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct passwd { -+ pub pw_name: *mut libc::c_char, -+ pub pw_passwd: *mut libc::c_char, -+ pub pw_uid: __uid_t, -+ pub pw_gid: __gid_t, -+ pub pw_gecos: *mut libc::c_char, -+ pub pw_dir: *mut libc::c_char, -+ pub pw_shell: *mut libc::c_char, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct iovec { -+ pub iov_base: *mut libc::c_void, -+ pub iov_len: size_t, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct plugin_info { -+ pub entries: C2RustUnnamed_1, -+ pub path: *mut libc::c_char, -+ pub symbol_name: *mut libc::c_char, -+ pub options: *mut *mut libc::c_char, -+ pub lineno: libc::c_uint, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct C2RustUnnamed_1 { -+ pub tqe_next: *mut plugin_info, -+ pub tqe_prev: *mut *mut plugin_info, -+} -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct plugin_info_list { -+ pub tqh_first: *mut plugin_info, -+ pub tqh_last: *mut *mut plugin_info, -+} -+ -+#[derive(Copy, Clone)] -+#[repr(C)] -+pub struct option { -+ pub name: *const libc::c_char, -+ pub has_arg: libc::c_int, -+ pub flag: *mut libc::c_int, -+ pub val: libc::c_int, -+} -+ -+//下面的三个值,只用于初始化变量时调用,不会修改值。 -+pub const sb_all_arch: stat = stat { -+ st_dev: 0, -+ st_ino: 0, -+ st_nlink: 0, -+ st_mode: 0, -+ st_uid: 0, -+ st_gid: 0, -+ #[cfg(target_arch = "x86_64")] -+ __pad0: 0, -+ st_rdev: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad1: 0, -+ st_size: 0, -+ st_blksize: 0, -+ #[cfg(not(target_arch = "x86_64"))] -+ __pad2: 0, -+ st_blocks: 0, -+ st_atim: timespec { -+ tv_sec: 0, -+ tv_nsec: 0, -+ }, -+ st_mtim: timespec { -+ tv_sec: 0, -+ tv_nsec: 0, -+ }, -+ st_ctim: timespec { -+ tv_sec: 0, -+ tv_nsec: 0, -+ }, -+ #[cfg(target_arch = "x86_64")] -+ __glibc_reserved: [0; 3], -+ #[cfg(not(target_arch = "x86_64"))] -+ __glibc_reserved: [0; 2], -+}; -+ -+#[cfg(target_arch = "x86_64")] -+pub const xstat_flag: libc::c_int = 1; -+ -+#[cfg(not(target_arch = "x86_64"))] -+pub const xstat_flag: libc::c_int = 0; -diff --git a/lib/util/src/digest.rs b/lib/util/src/digest.rs -index 4c7edf3..762d88b 100644 ---- a/lib/util/src/digest.rs -+++ b/lib/util/src/digest.rs -@@ -13,33 +13,14 @@ - unused_assignments - )] - --//call other file's func --use crate::sha2::sudo_SHA224Final; --use crate::sha2::sudo_SHA224Init; --use crate::sha2::sudo_SHA224Update; --use crate::sha2::sudo_SHA256Final; --use crate::sha2::sudo_SHA256Init; --use crate::sha2::sudo_SHA256Update; --use crate::sha2::sudo_SHA384Final; --use crate::sha2::sudo_SHA384Init; --use crate::sha2::sudo_SHA384Update; --use crate::sha2::sudo_SHA512Final; --use crate::sha2::sudo_SHA512Init; --use crate::sha2::sudo_SHA512Update; --use crate::sha2::SHA2_CTX; --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug::sudo_debug_exit_ptr_v1; --use crate::sudo_debug::sudo_debug_exit_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; --use libc::free; --use libc::malloc; -- --pub type size_t = libc::c_ulong; --pub type uint8_t = libc::c_uchar; -+use crate::common::*; -+use crate::sha2::*; - - //define --pub const EINVAL: libc::c_int = 22; -+//#define SHA224_DIGEST_LENGTH 28 -+//#define SHA256_DIGEST_LENGTH 32 -+//#define SHA384_DIGEST_LENGTH 48 -+//#define SHA512_DIGEST_LENGTH 64 - pub const SHA224_DIGEST_LENGTH: libc::c_uint = 28; - pub const SHA256_DIGEST_LENGTH: libc::c_uint = 32; - pub const SHA384_DIGEST_LENGTH: libc::c_uint = 48; -@@ -49,13 +30,14 @@ extern "C" { - fn __errno_location() -> *mut libc::c_int; - } - -+//line 55 - pub struct digest_function { - pub digest_len: libc::c_uint, - pub init: Option ()>, - pub update: Option ()>, - pub final_0: Option ()>, - } -- -+//line 65-89 - static mut digest_functions: [digest_function; 5] = { - [ - { -@@ -127,6 +109,7 @@ static mut digest_functions: [digest_function; 5] = { - ] - }; - -+//line91 - pub struct sudo_digest { - pub func: *mut digest_function, - pub ctx: SHA2_CTX, -@@ -135,7 +118,7 @@ pub struct sudo_digest { - //line 97 - #[no_mangle] - unsafe extern "C" fn sudo_digest_alloc_v1(mut digest_type: libc::c_int) -> *mut sudo_digest { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - //line 100 - let mut func: *mut digest_function = 0 as *mut digest_function; -@@ -173,27 +156,30 @@ unsafe extern "C" fn sudo_digest_alloc_v1(mut digest_type: libc::c_int) -> *mut - debug_return_ptr!(dig); - } - -+//line124-130 - #[no_mangle] - unsafe fn sudo_digest_free_v1(mut dig: *mut sudo_digest) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - free(dig as *mut libc::c_void); - - debug_return!() - } - -+//line134-140 - #[no_mangle] - unsafe fn sudo_digest_reset_v1(mut dig: *mut sudo_digest) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - ((*(*dig).func).init).expect("is not func pointer")(&mut (*dig).ctx); - - debug_return!() - } - -+//line 144-155 - #[no_mangle] - unsafe fn sudo_digest_getlen_v1(mut digest_type: libc::c_int) -> libc::c_int { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - let mut i: libc::c_int = 0; - -@@ -209,13 +195,14 @@ unsafe fn sudo_digest_getlen_v1(mut digest_type: libc::c_int) -> libc::c_int { - debug_return_int!(-1) - } - -+//line 158 - #[no_mangle] - unsafe fn sudo_digest_update_v1( - mut dig: *mut sudo_digest, - mut data: *const libc::c_void, - mut len: size_t, - ) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - //162 - ((*(*dig).func).update).expect("is not null func point")( -@@ -231,7 +218,7 @@ unsafe fn sudo_digest_update_v1( - //line168 - #[no_mangle] - unsafe fn sudo_digest_final_v1(mut dig: *mut sudo_digest, mut md: *mut libc::c_uchar) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - ((*(*dig).func).final_0).expect("is not func point")(md, &mut (*dig).ctx); - -diff --git a/lib/util/src/event.rs b/lib/util/src/event.rs -index 09b50d5..7777a47 100644 ---- a/lib/util/src/event.rs -+++ b/lib/util/src/event.rs -@@ -14,13 +14,7 @@ - unused_mut - )] - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct pollfd { -- pub fd: libc::c_int, -- pub events: libc::c_short, -- pub revents: libc::c_short, --} -+use crate::common::*; - - extern "C" { - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; -@@ -93,148 +87,6 @@ extern "C" { - fn sudo_gettime_mono_v1(ts: *mut timespec) -> libc::c_int; - } - --pub type __uint32_t = libc::c_uint; --pub type __uid_t = libc::c_uint; --pub type __pid_t = libc::c_int; --pub type __clock_t = libc::c_long; --pub type __time_t = libc::c_long; --pub type __suseconds_t = libc::c_long; --pub type __ssize_t = libc::c_long; --pub type __syscall_slong_t = libc::c_long; --pub type __sig_atomic_t = libc::c_int; --pub type ssize_t = __ssize_t; --pub type size_t = libc::c_ulong; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct __sigset_t { -- pub __val: [libc::c_ulong; 16], --} --pub type sigset_t = __sigset_t; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timeval { -- pub tv_sec: __time_t, -- pub tv_usec: __suseconds_t, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} --pub type __sigval_t = sigval; --#[derive(Copy, Clone)] --#[repr(C)] --pub union sigval { -- pub sival_int: libc::c_int, -- pub sival_ptr: *mut libc::c_void, --} -- --pub type sig_atomic_t = __sig_atomic_t; --#[derive(Copy, Clone)] --#[repr(C)] --pub struct siginfo_t { -- pub si_signo: libc::c_int, -- pub si_errno: libc::c_int, -- pub si_code: libc::c_int, -- pub __pad0: libc::c_int, -- pub _sifields: C2RustUnnamed, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub union C2RustUnnamed { -- pub _pad: [libc::c_int; 28], -- pub _kill: C2RustUnnamed_8, -- pub _timer: C2RustUnnamed_7, -- pub _rt: C2RustUnnamed_6, -- pub _sigchld: C2RustUnnamed_5, -- pub _sigfault: C2RustUnnamed_2, -- pub _sigpoll: C2RustUnnamed_1, -- pub _sigsys: C2RustUnnamed_0, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_0 { -- pub _call_addr: *mut libc::c_void, -- pub _syscall: libc::c_int, -- pub _arch: libc::c_uint, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_1 { -- pub si_band: libc::c_long, -- pub si_fd: libc::c_int, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_2 { -- pub si_addr: *mut libc::c_void, -- pub si_addr_lsb: libc::c_short, -- pub _bounds: C2RustUnnamed_3, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub union C2RustUnnamed_3 { -- pub _addr_bnd: C2RustUnnamed_4, -- pub _pkey: __uint32_t, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_4 { -- pub _lower: *mut libc::c_void, -- pub _upper: *mut libc::c_void, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_5 { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, -- pub si_status: libc::c_int, -- pub si_utime: __clock_t, -- pub si_stime: __clock_t, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_6 { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, -- pub si_sigval: __sigval_t, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_7 { -- pub si_tid: libc::c_int, -- pub si_overrun: libc::c_int, -- pub si_sigval: __sigval_t, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_8 { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, --} --pub type __sighandler_t = Option ()>; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigaction { -- pub __sigaction_handler: C2RustUnnamed_9, -- pub sa_mask: __sigset_t, -- pub sa_flags: libc::c_int, -- pub sa_restorer: Option ()>, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub union C2RustUnnamed_9 { -- pub sa_handler: __sighandler_t, -- pub sa_sigaction: -- Option ()>, --} --pub type sudo_ev_callback_t = -- Option ()>; -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct sudo_ev_siginfo_container { -@@ -242,69 +94,9 @@ pub struct sudo_ev_siginfo_container { - pub siginfo: *mut siginfo_t, - pub si_buf: [libc::c_char; 1], - } --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event { -- pub entries: C2RustUnnamed_12, -- pub active_entries: C2RustUnnamed_11, -- pub timeouts_entries: C2RustUnnamed_10, -- pub base: *mut sudo_event_base, -- pub fd: libc::c_int, -- pub events: libc::c_short, -- pub revents: libc::c_short, -- pub flags: libc::c_short, -- pub pfd_idx: libc::c_short, -- pub callback: sudo_ev_callback_t, -- pub timeout: timespec, -- pub closure: *mut libc::c_void, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event_base { -- pub events: sudo_event_list, -- pub active: sudo_event_list, -- pub timeouts: sudo_event_list, -- pub signal_event: sudo_event, -- pub signals: [sudo_event_list; 65], -- pub orig_handlers: [*mut sigaction; 65], -- pub siginfo: [*mut siginfo_t; 65], -- pub signal_pending: [sig_atomic_t; 65], -- pub signal_caught: sig_atomic_t, -- pub num_handlers: libc::c_int, -- pub signal_pipe: [libc::c_int; 2], -- pub pfds: *mut pollfd, -- pub pfd_max: libc::c_int, -- pub pfd_high: libc::c_int, -- pub pfd_free: libc::c_int, -- pub flags: libc::c_uint, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event_list { -- pub tqh_first: *mut sudo_event, -- pub tqh_last: *mut *mut sudo_event, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_10 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_11 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_12 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} -+ - static mut default_base: *mut sudo_event_base = 0 as *const sudo_event_base as *mut sudo_event_base; - static mut signal_base: *mut sudo_event_base = 0 as *const sudo_event_base as *mut sudo_event_base; -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_activate(mut base: *mut sudo_event_base, mut ev: *mut sudo_event) { - (*ev).active_entries.tqe_next = 0 as *mut sudo_event; -@@ -313,7 +105,6 @@ pub unsafe extern "C" fn sudo_ev_activate(mut base: *mut sudo_event_base, mut ev - (*base).active.tqh_last = &mut (*ev).active_entries.tqe_next; - (*ev).flags = ((*ev).flags as libc::c_int | 0x2 as libc::c_int) as libc::c_short; - } -- - #[inline] - unsafe extern "C" fn sudo_ev_deactivate(mut base: *mut sudo_event_base, mut ev: *mut sudo_event) { - (*ev).flags = ((*ev).flags as libc::c_int & !(0x2 as libc::c_int)) as libc::c_short; -@@ -324,10 +115,8 @@ unsafe extern "C" fn sudo_ev_deactivate(mut base: *mut sudo_event_base, mut ev: - } - *(*ev).active_entries.tqe_prev = (*ev).active_entries.tqe_next; - } -- - unsafe extern "C" fn sudo_ev_deactivate_all(mut base: *mut sudo_event_base) { - let mut ev: *mut sudo_event = 0 as *mut sudo_event; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 23], &[libc::c_char; 23]>(b"sudo_ev_deactivate_all\0")) - .as_ptr(), -@@ -335,7 +124,6 @@ unsafe extern "C" fn sudo_ev_deactivate_all(mut base: *mut sudo_event_base) { - 89 as libc::c_int, - sudo_debug_subsys, - ); -- - loop { - ev = (*base).active.tqh_first; - if ev.is_null() { -@@ -351,13 +139,11 @@ unsafe extern "C" fn sudo_ev_deactivate_all(mut base: *mut sudo_event_base) { - sudo_debug_subsys, - ); - } -- - unsafe extern "C" fn sudo_ev_activate_sigevents(mut base: *mut sudo_event_base) { - let mut ev: *mut sudo_event = 0 as *mut sudo_event; - let mut set: sigset_t = sigset_t { __val: [0; 16] }; - let mut oset: sigset_t = sigset_t { __val: [0; 16] }; - let mut i: libc::c_int = 0; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 27], &[libc::c_char; 27]>( - b"sudo_ev_activate_sigevents\0", -@@ -367,7 +153,6 @@ unsafe extern "C" fn sudo_ev_activate_sigevents(mut base: *mut sudo_event_base) - 107 as libc::c_int, - sudo_debug_subsys, - ); -- - sigfillset(&mut set); - sigprocmask(0 as libc::c_int, &mut set, &mut oset); - (*base).signal_caught = 0 as libc::c_int; -@@ -415,7 +200,6 @@ unsafe extern "C" fn sudo_ev_activate_sigevents(mut base: *mut sudo_event_base) - sudo_debug_subsys, - ); - } -- - unsafe extern "C" fn signal_pipe_cb( - mut fd: libc::c_int, - mut _what: libc::c_int, -@@ -424,14 +208,12 @@ unsafe extern "C" fn signal_pipe_cb( - let mut base: *mut sudo_event_base = v as *mut sudo_event_base; - let mut ch: libc::c_uchar = 0; - let mut nread: ssize_t = 0; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"signal_pipe_cb\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, - 151 as libc::c_int, - sudo_debug_subsys, - ); -- - loop { - nread = read( - fd, -@@ -453,7 +235,6 @@ unsafe extern "C" fn signal_pipe_cb( - ch as libc::c_int, - ); - } -- - if nread == -(1 as libc::c_int) as libc::c_long && *__errno_location() != 11 as libc::c_int { - sudo_debug_printf2_v1( - (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"signal_pipe_cb\0")) -@@ -478,10 +259,8 @@ unsafe extern "C" fn signal_pipe_cb( - sudo_debug_subsys, - ); - } -- - unsafe extern "C" fn sudo_ev_base_init(mut base: *mut sudo_event_base) -> libc::c_int { - let mut i: libc::c_int = 0; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"sudo_ev_base_init\0")) - .as_ptr(), -@@ -560,11 +339,9 @@ unsafe extern "C" fn sudo_ev_base_init(mut base: *mut sudo_event_base) -> libc:: - ); - return sudo_debug_ret_0; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_base_alloc_v1() -> *mut sudo_event_base { - let mut base: *mut sudo_event_base = 0 as *mut sudo_event_base; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 22], &[libc::c_char; 22]>(b"sudo_ev_base_alloc_v1\0")) - .as_ptr(), -@@ -598,7 +375,6 @@ pub unsafe extern "C" fn sudo_ev_base_alloc_v1() -> *mut sudo_event_base { - ); - return sudo_debug_ret as *mut sudo_event_base; - } -- - if sudo_ev_base_init(base) != 0 as libc::c_int { - free(base as *mut libc::c_void); - let mut sudo_debug_ret_0: *mut libc::c_void = 0 as *mut libc::c_void; -@@ -623,13 +399,11 @@ pub unsafe extern "C" fn sudo_ev_base_alloc_v1() -> *mut sudo_event_base { - ); - return sudo_debug_ret_1 as *mut sudo_event_base; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_base_free_v1(mut base: *mut sudo_event_base) { - let mut ev: *mut sudo_event = 0 as *mut sudo_event; - let mut next: *mut sudo_event = 0 as *mut sudo_event; - let mut i: libc::c_int = 0; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 21], &[libc::c_char; 21]>(b"sudo_ev_base_free_v1\0")) - .as_ptr(), -@@ -684,10 +458,8 @@ pub unsafe extern "C" fn sudo_ev_base_free_v1(mut base: *mut sudo_event_base) { - sudo_debug_subsys, - ); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_base_setdef_v1(mut base: *mut sudo_event_base) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 23], &[libc::c_char; 23]>(b"sudo_ev_base_setdef_v1\0")) - .as_ptr(), -@@ -704,7 +476,6 @@ pub unsafe extern "C" fn sudo_ev_base_setdef_v1(mut base: *mut sudo_event_base) - sudo_debug_subsys, - ); - } -- - unsafe extern "C" fn sudo_ev_init( - mut ev: *mut sudo_event, - mut fd: libc::c_int, -@@ -712,7 +483,6 @@ unsafe extern "C" fn sudo_ev_init( - mut callback: sudo_ev_callback_t, - mut closure: *mut libc::c_void, - ) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 13], &[libc::c_char; 13]>(b"sudo_ev_init\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -744,7 +514,6 @@ pub unsafe extern "C" fn sudo_ev_alloc_v1( - mut closure: *mut libc::c_void, - ) -> *mut sudo_event { - let mut ev: *mut sudo_event = 0 as *mut sudo_event; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"sudo_ev_alloc_v1\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -820,7 +589,6 @@ pub unsafe extern "C" fn sudo_ev_alloc_v1( - } - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_free_v1(mut ev: *mut sudo_event) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"sudo_ev_free_v1\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -886,7 +654,6 @@ unsafe extern "C" fn sudo_ev_add_signal( - mut tohead: bool, - ) -> libc::c_int { - let signo: libc::c_int = (*ev).fd; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"sudo_ev_add_signal\0")) - .as_ptr(), -@@ -1029,7 +796,7 @@ unsafe extern "C" fn sudo_ev_add_signal( - } - if ((*base).signals[signo as usize].tqh_first).is_null() { - let mut sa: sigaction = sigaction { -- __sigaction_handler: C2RustUnnamed_9 { sa_handler: None }, -+ __sigaction_handler: Signal_handler { sa_handler: None }, - sa_mask: sigset_t { __val: [0; 16] }, - sa_flags: 0, - sa_restorer: None, -@@ -1117,7 +884,6 @@ unsafe extern "C" fn sudo_ev_add_signal( - ); - return sudo_debug_ret_4; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_add_v1( - mut base: *mut sudo_event_base, -@@ -1137,7 +903,6 @@ pub unsafe extern "C" fn sudo_ev_add_v1( - } - return sudo_ev_add_v2(base, ev, ts, tohead); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_add_v2( - mut base: *mut sudo_event_base, -@@ -1145,7 +910,6 @@ pub unsafe extern "C" fn sudo_ev_add_v2( - mut timo: *mut timespec, - mut tohead: bool, - ) -> libc::c_int { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"sudo_ev_add_v2\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -1317,13 +1081,11 @@ pub unsafe extern "C" fn sudo_ev_add_v2( - ); - return sudo_debug_ret_2; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_del_v1( - mut base: *mut sudo_event_base, - mut ev: *mut sudo_event, - ) -> libc::c_int { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"sudo_ev_del_v1\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -1534,12 +1296,10 @@ pub unsafe extern "C" fn sudo_ev_del_v1( - ); - return sudo_debug_ret_4; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_dispatch_v1(mut base: *mut sudo_event_base) -> libc::c_int { - return sudo_ev_loop_v1(base, 0 as libc::c_int); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_loop_v1( - mut base: *mut sudo_event_base, -@@ -1552,7 +1312,6 @@ pub unsafe extern "C" fn sudo_ev_loop_v1( - let mut ev: *mut sudo_event = 0 as *mut sudo_event; - let mut nready: libc::c_int = 0; - let mut rc: libc::c_int = 0 as libc::c_int; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"sudo_ev_loop_v1\0")).as_ptr(), - b"event.c\0" as *const u8 as *const libc::c_char, -@@ -1680,10 +1439,8 @@ pub unsafe extern "C" fn sudo_ev_loop_v1( - ); - return sudo_debug_ret; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_loopexit_v1(mut base: *mut sudo_event_base) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"sudo_ev_loopexit_v1\0")) - .as_ptr(), -@@ -1718,10 +1475,8 @@ pub unsafe extern "C" fn sudo_ev_loopexit_v1(mut base: *mut sudo_event_base) { - sudo_debug_subsys, - ); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_loopbreak_v1(mut base: *mut sudo_event_base) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 21], &[libc::c_char; 21]>(b"sudo_ev_loopbreak_v1\0")) - .as_ptr(), -@@ -1755,10 +1510,8 @@ pub unsafe extern "C" fn sudo_ev_loopbreak_v1(mut base: *mut sudo_event_base) { - sudo_debug_subsys, - ); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_loopcontinue_v1(mut base: *mut sudo_event_base) { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 24], &[libc::c_char; 24]>(b"sudo_ev_loopcontinue_v1\0")) - .as_ptr(), -@@ -1792,10 +1545,8 @@ pub unsafe extern "C" fn sudo_ev_loopcontinue_v1(mut base: *mut sudo_event_base) - sudo_debug_subsys, - ); - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_got_exit_v1(mut base: *mut sudo_event_base) -> bool { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"sudo_ev_got_exit_v1\0")) - .as_ptr(), -@@ -1831,10 +1582,8 @@ pub unsafe extern "C" fn sudo_ev_got_exit_v1(mut base: *mut sudo_event_base) -> - ); - return sudo_debug_ret_0; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_ev_got_break_v1(mut base: *mut sudo_event_base) -> bool { -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 21], &[libc::c_char; 21]>(b"sudo_ev_got_break_v1\0")) - .as_ptr(), -@@ -1894,7 +1643,6 @@ pub unsafe extern "C" fn sudo_ev_get_timeleft_v2( - tv_sec: 0, - tv_nsec: 0, - }; -- let sudo_debug_subsys: libc::c_int = (4 as libc::c_int) << 6 as libc::c_int; - sudo_debug_enter_v1( - (*::core::mem::transmute::<&[u8; 24], &[libc::c_char; 24]>(b"sudo_ev_get_timeleft_v2\0")) - .as_ptr(), -diff --git a/lib/util/src/event_poll.rs b/lib/util/src/event_poll.rs -index 8db9300..96b2ed2 100644 ---- a/lib/util/src/event_poll.rs -+++ b/lib/util/src/event_poll.rs -@@ -3,6 +3,7 @@ - * - * SPDX-License-Identifier: MulanPSL-2.0 - */ -+ - #![allow( - non_camel_case_types, - dead_code, -@@ -14,43 +15,24 @@ - unused_parens - )] - --use crate::event::sudo_ev_callback_t; --use crate::sudo_debug::sudo_debug_exit_v1; --// use crate::sudo_debug::sudo_debug_printf2_v1; --use crate::term::__sighandler_t; --use crate::term::__sigset_t; --use crate::term::sig_atomic_t; --use crate::term::siginfo_t; --use libc::free; -- --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_DEBUG; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_EVENT; --use crate::sudo_debug_macro::SUDO_DEBUG_INFO; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; -- --pub type __time_t = libc::c_long; --pub type __syscall_slong_t = libc::c_long; --pub type size_t = libc::c_ulong; --pub type nfds_t = libc::c_ulong; -- --pub const __SIGRTMIN: libc::c_uint = 64; --pub const NSIG: libc::c_uint = __SIGRTMIN + 1; -+use crate::common::*; -+ -+//#define SUDO_EV_READ 0x02 /* fire when readable */ -+//#define SUDO_EV_WRITE 0x04 /* fire when writable */ - pub const SUDO_EV_READ: libc::c_short = 0x02; --pub const POLLIN: libc::c_short = 0x001; --pub const POLLHUP: libc::c_short = 0x010; --pub const POLLNVAL: libc::c_short = 0x020; --pub const POLLERR: libc::c_short = 0x008; - pub const SUDO_EV_WRITE: libc::c_short = 0x04; -+ -+// #define POLLIN 0x001 /* There is data to read. */ -+// #define POLLOUT 0x004 /* Writing now will not block. */ -+pub const POLLIN: libc::c_short = 0x001; - pub const POLLOUT: libc::c_short = 0x004; - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigset_t { -- pub __val: [libc::c_ulong; 16], --} -+// #define POLLERR 0x008 /* Error condition. */ -+// #define POLLHUP 0x010 /* Hung up. */ -+// #define POLLNVAL 0x020 /* Invalid polling request. */ -+pub const POLLERR: libc::c_short = 0x008; -+pub const POLLHUP: libc::c_short = 0x010; -+pub const POLLNVAL: libc::c_short = 0x020; - - extern "C" { - fn reallocarray(__ptr: *mut libc::c_void, __nmemb: size_t, __size: size_t) -@@ -72,107 +54,11 @@ extern "C" { - _: ... - ); - } --#[derive(Copy, Clone)] --#[repr(C)] --pub struct pollfd { -- pub fd: libc::c_int, -- pub events: libc::c_short, -- pub revents: libc::c_short, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct mid_struct_1 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct mid_struct_2 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct mid_struct_3 { -- pub tqe_next: *mut sudo_event, -- pub tqe_prev: *mut *mut sudo_event, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event { -- pub entries: mid_struct_1, -- pub active_entries: mid_struct_2, -- pub timeouts_entries: mid_struct_3, -- pub base: *mut sudo_event_base, -- pub fd: libc::c_int, -- pub events: libc::c_short, -- pub revents: libc::c_short, -- pub flags: libc::c_short, -- pub pfd_idx: libc::c_short, -- pub callback: sudo_ev_callback_t, -- pub timeout: timespec, -- pub closure: *mut libc::c_void, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event_list { -- pub tqh_first: *mut sudo_event, -- pub tqh_last: *mut *mut sudo_event, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub union mid_union_1 { -- pub sa_handler: __sighandler_t, -- pub sa_sigaction: Option, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigaction { -- pub __sigaction_handler: mid_union_1, -- pub sa_mask: __sigset_t, -- pub sa_flags: libc::c_int, -- pub sa_restorer: Option, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_event_base { -- pub events: sudo_event_list, -- pub active: sudo_event_list, -- pub timeouts: sudo_event_list, -- pub signal_event: sudo_event, -- pub signals: [sudo_event_list; NSIG as usize], -- pub orig_handlers: [*mut sigaction; NSIG as usize], -- pub siginfo: [*mut siginfo_t; NSIG as usize], -- pub signal_pending: [sig_atomic_t; NSIG as usize], -- pub signal_caught: sig_atomic_t, -- pub num_handlers: libc::c_int, -- pub signal_pipe: [libc::c_int; 2], -- pub pfds: *mut pollfd, -- pub pfd_max: libc::c_int, -- pub pfd_high: libc::c_int, -- pub pfd_free: libc::c_int, -- pub flags: libc::c_uint, --} - - #[no_mangle] - unsafe fn sudo_ev_base_alloc_impl(mut base: *mut sudo_event_base) -> libc::c_int { - let mut i: libc::c_int = 0; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_EVENT); -+ debug_decl!(SUDO_DEBUG_EVENT); - - (*base).pfd_high = -1; - (*base).pfd_max = 32; -@@ -186,7 +72,7 @@ unsafe fn sudo_ev_base_alloc_impl(mut base: *mut sudo_event_base) -> libc::c_int - sudo_debug_printf!( - SUDO_DEBUG_ERROR | SUDO_DEBUG_LINENO, - b"%s: unable to allocate %d pollfds\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - (*base).pfd_max - ); - (*base).pfd_max = 0; -@@ -201,7 +87,7 @@ unsafe fn sudo_ev_base_alloc_impl(mut base: *mut sudo_event_base) -> libc::c_int - - #[no_mangle] - unsafe fn sudo_ev_base_free_impl(mut base: *mut sudo_event_base) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_EVENT); -+ debug_decl!(SUDO_DEBUG_EVENT); - - free((*base).pfds as *mut libc::c_void); - debug_return!() -@@ -210,7 +96,7 @@ unsafe fn sudo_ev_base_free_impl(mut base: *mut sudo_event_base) { - #[no_mangle] - unsafe fn sudo_ev_add_impl(mut base: *mut sudo_event_base, mut ev: *mut sudo_event) -> libc::c_int { - let mut pfd: *mut pollfd = 0 as *mut pollfd; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_EVENT); -+ debug_decl!(SUDO_DEBUG_EVENT); - - /* If out of space in pfds array, realloc. */ - if (*base).pfd_free == (*base).pfd_max { -@@ -228,7 +114,7 @@ unsafe fn sudo_ev_add_impl(mut base: *mut sudo_event_base, mut ev: *mut sudo_eve - sudo_debug_printf!( - SUDO_DEBUG_ERROR | SUDO_DEBUG_LINENO, - b"%s: unable to allocate %d pollfds\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - ((*base).pfd_max) * 2 - ); - -@@ -274,7 +160,7 @@ unsafe fn sudo_ev_add_impl(mut base: *mut sudo_event_base, mut ev: *mut sudo_eve - - #[no_mangle] - unsafe fn sudo_ev_del_impl(mut base: *mut sudo_event_base, mut ev: *mut sudo_event) -> libc::c_int { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_EVENT); -+ debug_decl!(SUDO_DEBUG_EVENT); - - /* Mark pfd entry unused, add to free list and adjust high slot. */ - (*((*base).pfds).offset((*ev).pfd_idx as isize)).fd = -1; -@@ -310,7 +196,7 @@ unsafe fn sudo_ev_scan_impl(mut base: *mut sudo_event_base, mut flags: libc::c_i - let mut ev: *mut sudo_event = 0 as *mut sudo_event; - let mut nready: libc::c_int; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_EVENT); -+ debug_decl!(SUDO_DEBUG_EVENT); - - ev = (*base).timeouts.tqh_first; - if !ev.is_null() { -@@ -335,6 +221,7 @@ unsafe fn sudo_ev_scan_impl(mut base: *mut sudo_event_base, mut flags: libc::c_i - timeout = 0 as *mut timespec; - } - } -+ - nready = sudo_ev_poll( - (*base).pfds, - ((*base).pfd_high + 1) as libc::c_int as nfds_t, -@@ -344,7 +231,7 @@ unsafe fn sudo_ev_scan_impl(mut base: *mut sudo_event_base, mut flags: libc::c_i - sudo_debug_printf!( - SUDO_DEBUG_INFO, - b"%s: %d fds ready\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - nready - ); - -@@ -377,7 +264,7 @@ unsafe fn sudo_ev_scan_impl(mut base: *mut sudo_event_base, mut flags: libc::c_i - SUDO_DEBUG_DEBUG, - b"%s: polled fd %d, events %d, activating %p\0" as *const u8 - as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - (*ev).fd, - what, - ev -diff --git a/lib/util/src/fatal.rs b/lib/util/src/fatal.rs -index 3e46279..14e0fbb 100644 ---- a/lib/util/src/fatal.rs -+++ b/lib/util/src/fatal.rs -@@ -13,7 +13,7 @@ - non_upper_case_globals, - dead_code - )] --use crate::__LC_MESSAGES; -+ - use libc::FILE; - - #[macro_export] -@@ -39,9 +39,9 @@ extern "C" { - __msgid: *const libc::c_char, - __category: libc::c_int, - ) -> *mut libc::c_char; -+ fn do_cleanup(); - } - --pub type ssize_t = libc::c_long; - pub type sudo_fatal_callback_t = Option; - static mut sudo_warn_conversation: sudo_conv_t = None; - static mut sudo_warn_setlocale: Option bool> = None; -@@ -74,14 +74,6 @@ static mut callbacks: sudo_fatal_callback_list = { - init - }; - --pub const SUDO_CONV_PROMPT_ECHO_OFF: libc::c_int = 1; --pub const SUDO_CONV_PROMPT_ECHO_ON: libc::c_int = 2; --pub const SUDO_CONV_ERROR_MSG: libc::c_int = 3; --pub const SUDO_CONV_INFO_MSG: libc::c_int = 4; --pub const SUDO_CONV_PROMPT_MASK: libc::c_int = 5; --pub const SUDO_CONV_PROMPT_ECHO_OK: libc::c_int = 4096; --pub const SUDO_CONV_PREFER_TTY: libc::c_int = 8192; -- - #[derive(Copy, Clone)] - pub struct sudo_conv_message { - pub msg_type: libc::c_int, -@@ -112,6 +104,7 @@ pub type sudo_conv_t = Option< - ) -> libc::c_int, - >; - -+/* - #[no_mangle] - pub fn do_cleanup() { - let mut cb: *mut sudo_fatal_callback = 0 as *mut sudo_fatal_callback; -@@ -128,6 +121,7 @@ pub fn do_cleanup() { - }; - } - } -+*/ - - #[no_mangle] - unsafe fn sudo_fatal_callback_register_v1(mut func: sudo_fatal_callback_t) -> libc::c_int { -@@ -145,9 +139,10 @@ unsafe fn sudo_fatal_callback_register_v1(mut func: sudo_fatal_callback_t) -> li - if cb.is_null() { - return -1; - } -- (*cb).func = func; -- (*cb).entries.sle_next = cb; -- callbacks.slh_first = cb; -+ let ref mut fresh6 = (*cb).func; -+ *fresh6 = func; -+ let ref mut fresh7 = (*cb).entries.sle_next; -+ *fresh7 = callbacks.slh_first; - return 0; - } - -diff --git a/lib/util/src/getgrouplist.rs b/lib/util/src/getgrouplist.rs -index a4ee40d..8c48df8 100644 ---- a/lib/util/src/getgrouplist.rs -+++ b/lib/util/src/getgrouplist.rs -@@ -6,10 +6,7 @@ - - #![allow(non_camel_case_types, unused_mut, unused_variables, unused_assignments)] - --//line72-2(arg), --pub type gid_t = libc::c_uint; --pub type __gid_t = libc::c_uint; --pub type size_t = libc::c_ulong; -+use crate::common::*; - - extern "C" { - fn getgrouplist( -@@ -24,10 +21,6 @@ extern "C" { - -> *mut libc::c_void; - } - --// define --pub const _SC_NGROUPS_MAX: libc::c_uint = 3; --pub const NGROUPS_MAX: libc::c_uint = 65536; -- - //line_72 - #[no_mangle] - pub unsafe extern "C" fn sudo_getgrouplist2_v1( -diff --git a/lib/util/src/gethostname.rs b/lib/util/src/gethostname.rs -index 258cd21..27aac53 100644 ---- a/lib/util/src/gethostname.rs -+++ b/lib/util/src/gethostname.rs -@@ -5,8 +5,8 @@ - */ - - #![allow(unused_imports, unused_assignments, non_camel_case_types)] --use std::ffi::CStr; --use std::string::String; -+ -+use crate::common::*; - - extern "C" { - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; -@@ -15,9 +15,7 @@ extern "C" { - fn gethostname(__name: *mut libc::c_char, __len: size_t) -> libc::c_int; - } - --pub type size_t = libc::c_ulong; --pub type C2RustUnnamed = libc::c_uint; --pub const _SC_HOST_NAME_MAX: C2RustUnnamed = 180; -+pub const _SC_HOST_NAME_MAX: libc::c_uint = 180; - - #[no_mangle] - pub unsafe extern "C" fn sudo_gethostname_v1() -> *mut libc::c_char { -diff --git a/lib/util/src/gettime.rs b/lib/util/src/gettime.rs -index 65f1bb1..df474e9 100644 ---- a/lib/util/src/gettime.rs -+++ b/lib/util/src/gettime.rs -@@ -14,13 +14,7 @@ - unused_mut - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --// use crate::sudo_debug::sudo_debug_printf2_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_ERRNO; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; --use crate::sudo_debug_macro::SUDO_DEBUG_WARN; -+use crate::common::*; - - extern "C" { - fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> libc::c_int; -@@ -36,26 +30,6 @@ extern "C" { - ); - } - --pub type __time_t = libc::c_long; --pub type __suseconds_t = libc::c_long; --pub type __clockid_t = libc::c_int; --pub type __syscall_slong_t = libc::c_long; --pub type clockid_t = __clockid_t; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timeval { -- pub tv_sec: __time_t, -- pub tv_usec: __suseconds_t, --} -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct timezone { -@@ -65,14 +39,16 @@ pub struct timezone { - - pub type __timezone_ptr_t = *mut timezone; - -+//#define CLOCK_REALTIME 0 - pub const CLOCK_REALTIME: libc::c_int = 0; -+ - pub const SUDO_CLOCK_BOOTTIME: libc::c_int = 7; - pub const SUDO_CLOCK_UPTIME: libc::c_int = 1; - pub const _SC_MONOTONIC_CLOCK: libc::c_int = 149; - - #[no_mangle] - pub unsafe extern "C" fn sudo_gettime_real_v1(mut ts: *mut timespec) -> libc::c_int { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if clock_gettime(CLOCK_REALTIME, ts) == -1 { - let mut tv: timeval = timeval { -@@ -99,7 +75,7 @@ pub unsafe extern "C" fn sudo_gettime_real_v1(mut ts: *mut timespec) -> libc::c_ - pub unsafe extern "C" fn sudo_gettime_mono_v1(ts: *mut timespec) -> i32 { - static mut has_monoclock: libc::c_int = -1; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if has_monoclock == -1 { - has_monoclock = (sysconf(_SC_MONOTONIC_CLOCK) != -1) as libc::c_int; -@@ -125,7 +101,7 @@ pub unsafe extern "C" fn sudo_gettime_mono_v1(ts: *mut timespec) -> i32 { - #[no_mangle] - pub unsafe extern "C" fn sudo_gettime_awake_v1(ts: *mut timespec) -> libc::c_int { - static mut has_monoclock: libc::c_int = -1; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if has_monoclock == -1 { - has_monoclock = (sysconf(_SC_MONOTONIC_CLOCK) != -1) as libc::c_int; -diff --git a/lib/util/src/gidlist.rs b/lib/util/src/gidlist.rs -index 95dfa03..1f06725 100644 ---- a/lib/util/src/gidlist.rs -+++ b/lib/util/src/gidlist.rs -@@ -11,11 +11,17 @@ - unused_mut - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - extern "C" { -+ fn sudo_debug_printf2_v1( -+ func: *const libc::c_char, -+ file: *const libc::c_char, -+ lineno: libc::c_int, -+ level: libc::c_int, -+ fmt: *const libc::c_char, -+ _: ... -+ ); - fn reallocarray(__ptr: *mut libc::c_void, __nmemb: size_t, __size: size_t) - -> *mut libc::c_void; - fn sudo_strtoidx_v1( -@@ -28,11 +34,7 @@ extern "C" { - fn sudo_warnx_nodebug_v1(fmt: *const libc::c_char, _: ...); - } - --pub type __gid_t = libc::c_uint; //typedef __gid_t gid_t; --pub type gid_t = __gid_t; - pub type GETGROUPS_T = gid_t; //#define GETGROUPS_T gid_t --pub type size_t = libc::c_ulong; --pub type id_t = libc::c_uint; - - #[no_mangle] - pub unsafe extern "C" fn sudo_parse_gids_v1( -@@ -46,7 +48,7 @@ pub unsafe extern "C" fn sudo_parse_gids_v1( - let mut errstr: *const libc::c_char = 0 as *const libc::c_char; - let mut ep: *mut libc::c_char = 0 as *mut libc::c_char; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if *cp as libc::c_int != '\0' as i32 { - ngids += 1; //ngids++ -@@ -56,7 +58,7 @@ pub unsafe extern "C" fn sudo_parse_gids_v1( - } - cp = cp.offset(1); - -- if *cp as libc::c_int != '\0' as i32 { -+ if !(*cp as libc::c_int != '\0' as i32) { - break; - } - } -@@ -73,7 +75,7 @@ pub unsafe extern "C" fn sudo_parse_gids_v1( - if gids.is_null() { - sudo_warnx!( - b"%s: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - b"unable to allocate memor0" as *const u8 as *const libc::c_char - ); - debug_return_int!(-1); -diff --git a/lib/util/src/key_val.rs b/lib/util/src/key_val.rs -index a41be2f..5af519b 100644 ---- a/lib/util/src/key_val.rs -+++ b/lib/util/src/key_val.rs -@@ -6,16 +6,13 @@ - - #![allow(unused_assignments, non_camel_case_types)] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_str_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - extern "C" { - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - } --pub type size_t = libc::c_ulong; - - #[no_mangle] - pub unsafe extern "C" fn sudo_new_key_val_v1( -@@ -27,7 +24,7 @@ pub unsafe extern "C" fn sudo_new_key_val_v1( - let mut cp: *mut libc::c_char = 0 as *mut libc::c_char; - let mut str: *mut libc::c_char = 0 as *mut libc::c_char; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - str = malloc( - key_len -diff --git a/lib/util/src/lbuf.rs b/lib/util/src/lbuf.rs -index 29d73ca..e09e093 100644 ---- a/lib/util/src/lbuf.rs -+++ b/lib/util/src/lbuf.rs -@@ -12,12 +12,7 @@ - dead_code - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_bool_v1; --use crate::sudo_debug::sudo_debug_exit_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - extern "C" { - fn free(__ptr: *mut libc::c_void); -@@ -48,7 +43,6 @@ pub struct sudo_lbuf { - pub cols: libc::c_short, - pub error: libc::c_short, - } -- - pub type sudo_lbuf_output_t = Option libc::c_int>; - pub type size_t = libc::c_ulong; - -@@ -60,7 +54,7 @@ pub unsafe extern "C" fn sudo_lbuf_init_v1( - mut continuation: *const libc::c_char, - mut cols: libc::c_int, - ) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - (*lbuf).output = output; - (*lbuf).continuation = continuation; -@@ -76,7 +70,7 @@ pub unsafe extern "C" fn sudo_lbuf_init_v1( - - #[no_mangle] - pub unsafe extern "C" fn sudo_lbuf_destroy_v1(mut lbuf: *mut sudo_lbuf) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - free((*lbuf).buf as *mut libc::c_void); - (*lbuf).buf = 0 as *mut libc::c_char; -@@ -86,7 +80,7 @@ pub unsafe extern "C" fn sudo_lbuf_destroy_v1(mut lbuf: *mut sudo_lbuf) { - - //static - unsafe extern "C" fn sudo_lbuf_expand(mut lbuf: *mut sudo_lbuf, mut extra: libc::c_int) -> bool { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if (*lbuf).len + extra + 1 >= (*lbuf).size { - let mut new_buf: *mut libc::c_char; -@@ -131,7 +125,7 @@ unsafe extern "C" fn sudo_lbuf_println( - let mut indent: libc::c_int = (*lbuf).indent; - let mut is_comment: bool = false; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if *line.offset(0 as isize) as libc::c_int == '#' as i32 - && *(*__ctype_b_loc()) -@@ -143,7 +137,6 @@ unsafe extern "C" fn sudo_lbuf_println( - is_comment = true; - indent = 2; - } -- - if !((*lbuf).continuation).is_null() && !is_comment { - contlen = strlen((*lbuf).continuation) as libc::c_int; - } -@@ -223,7 +216,7 @@ pub unsafe extern "C" fn sudo_lbuf_print_v1(mut lbuf: *mut sudo_lbuf) { - let mut ep: *mut libc::c_char = 0 as *mut libc::c_char; - let mut len: libc::c_int = 0; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if !(((*lbuf).buf).is_null() || (*lbuf).len == 0 as libc::c_int) { - //len = lbuf->continuation ? strlen(lbuf->continuation) : 0; -@@ -289,7 +282,6 @@ pub unsafe extern "C" fn sudo_lbuf_error_v1(mut lbuf: *mut sudo_lbuf) -> bool { - } - return false; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_lbuf_clearerr_v1(mut lbuf: *mut sudo_lbuf) { - if !lbuf.is_null() { -diff --git a/lib/util/src/lib.rs b/lib/util/src/lib.rs -index ff0cdf9..9dd4a4e 100644 ---- a/lib/util/src/lib.rs -+++ b/lib/util/src/lib.rs -@@ -4,9 +4,10 @@ - * SPDX-License-Identifier: MulanPSL-2.0 - */ - -+//#![feature(c_variadic)] - #[warn(unused_unsafe)] - #[macro_use] --mod sudo_debug_macro; -+pub mod common; - mod arc4random; - mod arc4random_uniform; - mod closefrom; -@@ -38,7 +39,7 @@ mod strtoid; - mod strtomode; - mod strtonum; - mod sudo_conf; --mod sudo_debug; -+pub mod sudo_debug; - mod sudo_dso; - mod term; - mod ttyname_dev; -diff --git a/lib/util/src/locking.rs b/lib/util/src/locking.rs -index 5f99ed8..f367d69 100644 ---- a/lib/util/src/locking.rs -+++ b/lib/util/src/locking.rs -@@ -4,11 +4,9 @@ - * SPDX-License-Identifier: MulanPSL-2.0 - */ - --#![allow(dead_code, non_camel_case_types, unused_mut)] -+#![allow(dead_code, non_camel_case_types, unused_mut, unused_assignments)] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_bool_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - extern "C" { - fn lockf(__fd: libc::c_int, __cmd: libc::c_int, __len: off_t) -> libc::c_int; -@@ -16,16 +14,12 @@ extern "C" { - - } - --pub type __off_t = libc::c_long; --pub type off_t = __off_t; -- --pub const SUDO_LOCK: libc::c_int = 1; --pub const SUDO_TLOCK: libc::c_int = 2; --pub const SUDO_UNLOCK: libc::c_int = 4; -+// # define F_ULOCK 0 /* Unlock a previously locked region. */ -+// # define F_LOCK 1 /* Lock a region for exclusive use. */ -+// # define F_TLOCK 2 /* Test and lock a region for exclusive use. */ - pub const F_ULOCK: libc::c_int = 0; - pub const F_LOCK: libc::c_int = 1; - pub const F_TLOCK: libc::c_int = 2; --pub const EINVAL: libc::c_int = 22; - - #[no_mangle] - unsafe extern "C" fn sudo_lock_file_v1(mut fd: libc::c_int, mut type_0: libc::c_int) -> bool { -@@ -39,7 +33,7 @@ unsafe extern "C" fn sudo_lock_region_v1( - mut len: off_t, - ) -> bool { - let mut op: libc::c_int = 0; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - match type_0 { - SUDO_LOCK => { -diff --git a/lib/util/src/memset_s.rs b/lib/util/src/memset_s.rs -index f56b10b..62b13b3 100644 ---- a/lib/util/src/memset_s.rs -+++ b/lib/util/src/memset_s.rs -@@ -6,15 +6,12 @@ - - #![allow(dead_code, non_camel_case_types, unused_mut)] - -+use crate::common::*; -+ - extern "C" { - fn __errno_location() -> *mut libc::c_int; - } - --pub type size_t = libc::c_ulong; --pub const SIZE_MAX: libc::c_ulong = 18446744073709551615; --pub const RSIZE_MAX: libc::c_ulong = SIZE_MAX >> 1; --pub const EINVAL: libc::c_int = 22; -- - #[no_mangle] - pub fn sudo_memset_s( - mut v: *mut libc::c_void, -diff --git a/lib/util/src/parseln.rs b/lib/util/src/parseln.rs -index 05ca7b7..646caa9 100644 ---- a/lib/util/src/parseln.rs -+++ b/lib/util/src/parseln.rs -@@ -15,28 +15,7 @@ - improper_ctypes - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_ssize_t_v1; --// use crate::sudo_debug::sudo_debug_printf2_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_marker { -- _unused: [u8; 0], --} --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_codecvt { -- _unused: [u8; 0], --} --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_wide_data { -- _unused: [u8; 0], --} -+use crate::common::*; - - extern "C" { - fn getdelim( -@@ -60,49 +39,12 @@ extern "C" { - ); - } - --pub type __ssize_t = libc::c_long; --pub type ssize_t = __ssize_t; --pub type __SIZE_TYPE__ = libc::c_ulong; --pub type size_t = __SIZE_TYPE__; --pub type FILE = _IO_FILE; --pub type __off_t = libc::c_long; --pub type __off64_t = libc::c_long; -- --pub struct _IO_FILE { -- pub _flags: libc::c_int, -- pub _IO_read_ptr: *mut libc::c_char, -- pub _IO_read_end: *mut libc::c_char, -- pub _IO_read_base: *mut libc::c_char, -- pub _IO_write_base: *mut libc::c_char, -- pub _IO_write_ptr: *mut libc::c_char, -- pub _IO_write_end: *mut libc::c_char, -- pub _IO_buf_base: *mut libc::c_char, -- pub _IO_buf_end: *mut libc::c_char, -- pub _IO_save_base: *mut libc::c_char, -- pub _IO_backup_base: *mut libc::c_char, -- pub _IO_save_end: *mut libc::c_char, -- pub _markers: *mut _IO_marker, -- pub _chain: *mut _IO_FILE, -- pub _fileno: libc::c_int, -- pub _flags2: libc::c_int, -- pub _old_offset: __off_t, -- pub _cur_column: libc::c_ushort, -- pub _vtable_offset: libc::c_schar, -- -- pub _shortbuf: [libc::c_char; 1], -- pub _lock: *mut libc::c_void, -- pub _offset: __off64_t, -- pub _codecvt: *mut _IO_codecvt, -- pub _wide_data: *mut _IO_wide_data, -- pub _freeres_list: *mut _IO_FILE, -- pub _freeres_buf: *mut libc::c_void, -- pub __pad5: size_t, -- pub _mode: libc::c_int, -- pub _unused2: [libc::c_char; 20], --} -- -+/* sudo_parseln() flags */ -+// #define PARSELN_COMM_BOL 0x01 /* comments only at begining of line */ -+// #define PARSELN_CONT_IGN 0x02 /* ignore line continuation char */ - pub const PARSELN_COMM_BOL: libc::c_int = 0x01; - pub const PARSELN_CONT_IGN: libc::c_int = 0x02; -+ - pub const _ISblank: libc::c_int = 1; - - #[no_mangle] -@@ -121,7 +63,7 @@ pub unsafe extern "C" fn sudo_parseln_v2( - let mut continued: bool = false; - let mut comment: bool = false; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - loop { - comment = false; -diff --git a/lib/util/src/progname.rs b/lib/util/src/progname.rs -index d2d602f..f8f0659 100644 ---- a/lib/util/src/progname.rs -+++ b/lib/util/src/progname.rs -@@ -10,6 +10,7 @@ extern "C" { - fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - static mut __progname: *const libc::c_char; - } -+ - static mut progname: *const libc::c_char = b"\0" as *const u8 as *const libc::c_char; //*progname = "" - #[no_mangle] - pub unsafe extern "C" fn initprogname(mut name: *const libc::c_char) { -diff --git a/lib/util/src/pw_dup.rs b/lib/util/src/pw_dup.rs -index 160d201..f6eb5ad 100644 ---- a/lib/util/src/pw_dup.rs -+++ b/lib/util/src/pw_dup.rs -@@ -15,16 +15,14 @@ - unused_macros - )] - -+use crate::common::*; -+ - extern "C" { - fn malloc(_: libc::c_ulong) -> *mut libc::c_void; - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - fn strlen(_: *const libc::c_char) -> libc::c_ulong; - } - --pub type __uid_t = libc::c_uint; --pub type __gid_t = libc::c_uint; --pub type size_t = libc::c_ulong; -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct passwd { -@@ -36,7 +34,6 @@ pub struct passwd { - pub pw_dir: *mut libc::c_char, - pub pw_shell: *mut libc::c_char, - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_pw_dup(mut pw: *const passwd) -> *mut passwd { - let mut nsize: size_t = 0 as libc::c_int as size_t; -diff --git a/lib/util/src/secure_path.rs b/lib/util/src/secure_path.rs -index b09b57f..189acb1 100644 ---- a/lib/util/src/secure_path.rs -+++ b/lib/util/src/secure_path.rs -@@ -3,6 +3,7 @@ - * - * SPDX-License-Identifier: MulanPSL-2.0 - */ -+ - #![allow( - dead_code, - mutable_transmutes, -@@ -14,6 +15,8 @@ - unused_variables - )] - -+use crate::common::*; -+ - extern "C" { - fn __xstat( - __ver: libc::c_int, -@@ -23,181 +26,12 @@ extern "C" { - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - } - --pub type __dev_t = libc::c_ulong; --pub type __uid_t = libc::c_uint; --pub type __gid_t = libc::c_uint; --pub type __ino_t = libc::c_ulong; --pub type __mode_t = libc::c_uint; --#[cfg(target_arch = "x86_64")] --pub type __nlink_t = libc::c_ulong; --#[cfg(not(target_arch = "x86_64"))] --pub type __nlink_t = libc::c_uint; --pub type __off_t = libc::c_long; --pub type __time_t = libc::c_long; --#[cfg(target_arch = "x86_64")] --pub type __blksize_t = libc::c_long; --#[cfg(not(target_arch = "x86_64"))] --pub type __blksize_t = libc::c_int; --pub type __blkcnt_t = libc::c_long; --pub type __syscall_slong_t = libc::c_long; --pub type gid_t = __gid_t; --pub type uid_t = __uid_t; -- --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --// #define __S_IFREG 0100000 /* Regular file. */ --#[macro_export] --macro_rules! _S_IFREG { -- () => { -- 0o100000 -- }; --} -- --// #define __S_IFDIR 0040000 /* Directory. */ --#[macro_export] --macro_rules! _S_IFDIR { -- () => { -- 0o40000 -- }; --} -- --// #define SUDO_PATH_MISSING -1 --#[macro_export] --macro_rules! SUDO_PATH_MISSING { -- () => { -- -1 -- }; --} -- --// #define __S_IFMT 0170000 /* These bits determine file type. */ --#[macro_export] --macro_rules! _S_IFMT { -- () => { -- 0o170000 -- }; --} -- --// #define SUDO_PATH_BAD_TYPE -2 --#[macro_export] --macro_rules! SUDO_PATH_BAD_TYPE { -- () => { -- -2 -- }; --} -- --// #define SUDO_PATH_WRONG_OWNER -3 --#[macro_export] --macro_rules! SUDO_PATH_WRONG_OWNER { -- () => { -- -3 -- }; --} -- --// #define SUDO_PATH_WORLD_WRITABLE -4 --#[macro_export] --macro_rules! SUDO_PATH_WORLD_WRITABLE { -- () => { -- -4 -- }; --} -- --// #define SUDO_PATH_GROUP_WRITABLE -5 --#[macro_export] --macro_rules! SUDO_PATH_GROUP_WRITABLE { -- () => { -- -5 -- }; --} -- --// #define __S_IWRITE 0200 /* Write by owner. */ --// #define S_IWUSR __S_IWRITE /* Write by owner. */ --#[macro_export] --macro_rules! S_IWUSR { -- () => { -- 0200 -- }; --} -- --// #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ --#[macro_export] --macro_rules! S_IWGRP { -- () => { -- S_IWUSR!() >> 3 -- }; --} -- --// #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ --#[macro_export] --macro_rules! S_IWOTH { -- () => { -- S_IWGRP!() >> 3 -- }; --} -- --// #define SUDO_PATH_SECURE 0 --macro_rules! SUDO_PATH_SECURE { -- () => { -- 0 -- }; --} -- --// #define ISSET(t, f) ((t) & (f)) --#[macro_export] --macro_rules! ISSET { -- ($_t:expr, $_f:expr) => { -- (($_t) & ($_f)) -- }; --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct stat { -- pub st_dev: __dev_t, -- pub st_ino: __ino_t, -- #[cfg(target_arch = "x86_64")] -- pub st_nlink: __nlink_t, -- pub st_mode: __mode_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub st_nlink: __nlink_t, -- pub st_uid: __uid_t, -- pub st_gid: __gid_t, -- #[cfg(target_arch = "x86_64")] -- pub __pad0: libc::c_int, -- pub st_rdev: __dev_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad1: __dev_t, -- pub st_size: __off_t, -- pub st_blksize: __blksize_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad2: libc::c_int, -- pub st_blocks: __blkcnt_t, -- pub st_atim: timespec, -- pub st_mtim: timespec, -- pub st_ctim: timespec, -- #[cfg(target_arch = "x86_64")] -- pub __glibc_reserved: [__syscall_slong_t; 3], -- #[cfg(not(target_arch = "x86_64"))] -- pub __glibc_reserved: [libc::c_int; 2], --} -- - #[inline] - unsafe extern "C" fn stat( - mut __path: *const libc::c_char, - mut __statbuf: *mut stat, - ) -> libc::c_int { -- #[cfg(target_arch = "x86_64")] -- return __xstat(1 as libc::c_int, __path, __statbuf); -- #[cfg(not(target_arch = "x86_64"))] -- return __xstat(0 as libc::c_int, __path, __statbuf); -+ return __xstat(xstat_flag as libc::c_int, __path, __statbuf); - } - - /* -@@ -211,60 +45,23 @@ pub unsafe extern "C" fn sudo_secure_path( - mut gid: gid_t, - mut sbp: *mut stat, - ) -> libc::c_int { -- let mut sb: stat = stat { -- st_dev: 0, -- st_ino: 0, -- #[cfg(target_arch = "x86_64")] -- st_nlink: 0, -- st_mode: 0, -- #[cfg(not(target_arch = "x86_64"))] -- st_nlink: 0, -- st_uid: 0, -- st_gid: 0, -- #[cfg(target_arch = "x86_64")] -- __pad0: 0, -- st_rdev: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad1: 0, -- st_size: 0, -- st_blksize: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad2: 0, -- st_blocks: 0, -- st_atim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_mtim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_ctim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- #[cfg(target_arch = "x86_64")] -- __glibc_reserved: [0; 3], -- #[cfg(not(target_arch = "x86_64"))] -- __glibc_reserved: [0; 2], -- }; -- -- let mut ret: libc::c_int = SUDO_PATH_MISSING!(); -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ let mut sb: stat = sb_all_arch; -+ let mut ret: libc::c_int = SUDO_PATH_MISSING; -+ debug_decl!(SUDO_DEBUG_UTIL); - - if (!path.is_null()) && (stat(path, &mut sb) == 0) { - if (sb.st_mode & _S_IFMT!()) != c_type { -- ret = SUDO_PATH_BAD_TYPE!(); -+ ret = SUDO_PATH_BAD_TYPE; - } else if uid != -(1 as libc::c_int) as uid_t && sb.st_uid != uid { -- ret = SUDO_PATH_WRONG_OWNER!(); -+ ret = SUDO_PATH_WRONG_OWNER; - } else if (sb.st_mode & S_IWOTH!()) != 0 { -- ret = SUDO_PATH_WORLD_WRITABLE!(); -+ ret = SUDO_PATH_WORLD_WRITABLE; - } else if ISSET!(sb.st_mode, S_IWGRP!()) != 0 - && (gid == -(1 as libc::c_int) as gid_t || sb.st_gid != gid) - { -- ret = SUDO_PATH_GROUP_WRITABLE!(); -+ ret = SUDO_PATH_GROUP_WRITABLE; - } else { -- ret = SUDO_PATH_SECURE!(); -+ ret = SUDO_PATH_SECURE; - } - if !sbp.is_null() { - memcpy( -diff --git a/lib/util/src/setgroups.rs b/lib/util/src/setgroups.rs -index 3508e2d..4853148 100644 ---- a/lib/util/src/setgroups.rs -+++ b/lib/util/src/setgroups.rs -@@ -12,25 +12,14 @@ - unused_mut - )] - -+use crate::common::*; -+ - extern "C" { - fn sysconf(__name: libc::c_int) -> libc::c_long; - fn __errno_location() -> *mut libc::c_int; - fn setgroups(__n: size_t, __groups: *const gid_t) -> libc::c_int; - } - --//func be included --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --pub type gid_t = libc::c_uint; --pub type size_t = libc::c_ulong; -- --//define --pub const EINVAL: libc::c_int = 22; --pub const _SC_NGROUPS_MAX: libc::c_int = 3; --pub const NGROUPS_MAX: libc::c_int = 65536; -- - //func sudo_setgroups_v1 - #[no_mangle] - unsafe extern "C" fn sudo_setgroups_v1( -@@ -40,7 +29,7 @@ unsafe extern "C" fn sudo_setgroups_v1( - let mut maxgids: libc::c_int = 0; - let mut ret: libc::c_int = 0; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - //line43 - ret = setgroups(ngids as size_t, gids as *mut gid_t); -diff --git a/lib/util/src/sha2.rs b/lib/util/src/sha2.rs -index 99e54d9..7eb6c51 100644 ---- a/lib/util/src/sha2.rs -+++ b/lib/util/src/sha2.rs -@@ -13,30 +13,18 @@ - unused_mut, - unused_must_use - )] -+ -+use crate::common::*; -+ - extern "C" { - fn memset(__dest: *mut libc::c_void, __ch: libc::c_int, __len: size_t) -> *mut libc::c_void; - fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; - fn sudo_memset_s(v: *mut libc::c_void, smax: size_t, c: libc::c_int, n: size_t) -> libc::c_int; - } - --pub type __uint64_t = libc::c_ulong; --pub type uint64_t = __uint64_t; --pub type __uint32_t = libc::c_uint; --pub type uint32_t = __uint64_t; --pub type __uint8_t = libc::c_uchar; --pub type uint8_t = __uint8_t; --pub type size_t = libc::c_ulong; --pub const SHA512_BLOCK_LENGTH: usize = 128; -+//#define SHA256_BLOCK_LENGTH 64 - pub const SHA256_BLOCK_LENGTH: libc::c_int = 64; --pub struct SHA2_CTX { -- pub state: state, -- pub count: [uint64_t; 2], -- pub buffer: [uint8_t; SHA512_BLOCK_LENGTH], --} --pub union state { -- pub st32: [uint32_t; 8], -- pub st64: [uint64_t; 8], --} -+ - macro_rules! BE8TO32 { - ($x:expr,$y:expr) => { - $x = ((*$y.offset(0 as isize) & 255) as uint32_t) << 24 -diff --git a/lib/util/src/sig2str.rs b/lib/util/src/sig2str.rs -index be45208..4249ddf 100644 ---- a/lib/util/src/sig2str.rs -+++ b/lib/util/src/sig2str.rs -@@ -14,23 +14,7 @@ - unused_mut - )] - --use crate::EINVAL; -- --// #define SIGRTMIN (__libc_current_sigrtmin ()) --#[macro_export] --macro_rules! SIGRTMIN { -- () => { -- (__libc_current_sigrtmin()) -- }; --} -- --// #define SIGRTMAX (__libc_current_sigrtmax ()) --#[macro_export] --macro_rules! SIGRTMAX { -- () => { -- (__libc_current_sigrtmax()) -- }; --} -+use crate::common::*; - - // # define SIG2STR_MAX 32 - #[macro_export] -@@ -39,19 +23,16 @@ macro_rules! SIG2STR_MAX { - 32 - }; - } -- --/* Biggest signal number + 1 (including real-time signals). */ --// #define _NSIG (__SIGRTMAX + 1) -+/* -+/* sys_sigabbrev is not declared by glibc */ -+// # define sudo_sys_signame sys_sigabbrev - #[macro_export] --macro_rules! NSIG { -+macro_rules! sudo_sys_signame { - () => { -- (SIGRTMAX!() + 1) -+ sys_sigabbrev - }; - } -- --pub type size_t = libc::c_ulong; --pub const _SC_RTSIG_MAX: libc::c_uint = 31; --pub type __int32_t = libc::c_int; -+*/ - pub const _ISlower: libc::c_uint = 512; - - extern "C" { -@@ -66,6 +47,7 @@ extern "C" { - _: ... - ) -> libc::c_int; - fn sudo_strlcpy(dst: *mut libc::c_char, src: *const libc::c_char, siz: size_t) -> size_t; -+ //static sys_sigabbrev: [*const libc::c_char; 65]; - fn __ctype_toupper_loc() -> *mut *const __int32_t; - fn __ctype_b_loc() -> *mut *const libc::c_ushort; - } -@@ -132,6 +114,8 @@ pub unsafe extern "C" fn sudo_sig2str( - sudo_sys_signame[7 as libc::c_int as usize] = - b"BUS\0" as *const u8 as *const libc::c_char as *mut libc::c_char; - } -+ -+ - if (sudo_sys_signame[11 as libc::c_int as usize]).is_null() { - sudo_sys_signame[11 as libc::c_int as usize] = - b"SEGV\0" as *const u8 as *const libc::c_char as *mut libc::c_char; -@@ -265,7 +249,7 @@ pub unsafe extern "C" fn sudo_sig2str( - return 0; - } - -- if signo > 0 && signo < NSIG!() && !(sudo_sys_signame[signo as usize]).is_null() { -+ if signo > 0 && signo < NSIG as libc::c_int && !(sudo_sys_signame[signo as usize]).is_null() { - sudo_strlcpy(signame, sudo_sys_signame[signo as usize], SIG2STR_MAX!()); - - /* Make sure we always return an upper case signame. */ -@@ -282,6 +266,6 @@ pub unsafe extern "C" fn sudo_sig2str( - } - return 0 as libc::c_int; - } -- *__errno_location() = EINVAL!(); -+ *__errno_location() = EINVAL; - return -(1 as libc::c_int); - } -diff --git a/lib/util/src/str2sig.rs b/lib/util/src/str2sig.rs -index 00989e8..575a6d2 100644 ---- a/lib/util/src/str2sig.rs -+++ b/lib/util/src/str2sig.rs -@@ -11,9 +11,7 @@ - unused_mut - )] - --use crate::EINVAL; --use crate::SIGRTMAX; --use crate::SIGRTMIN; -+use crate::common::*; - - extern "C" { - fn __ctype_b_loc() -> *mut *const libc::c_ushort; -@@ -33,6 +31,7 @@ extern "C" { - fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - fn sysconf(__name: libc::c_int) -> libc::c_long; - fn strcasecmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; -+// static sys_sigabbrev: [*const libc::c_char; 65]; - fn __errno_location() -> *mut libc::c_int; - } - -@@ -85,15 +84,12 @@ static mut sigaliases: [sigalias; 6] = [ - }, - ]; - -+//#define SIGABRT 6 /* Abnormal termination. */ - pub const SIGABRT: libc::c_int = 6; - pub const SIGCLD: libc::c_int = 17; - pub const SIGIO: libc::c_int = 29; - pub const SIGIOT: libc::c_int = 6; - pub const SIGPOLL: libc::c_int = 29; --pub const _ISdigit: libc::c_uint = 2048; --pub const __SIGRTMIN: libc::c_uint = 64; --pub const NSIG: libc::c_uint = __SIGRTMIN + 1; --pub const _SC_RTSIG_MAX: libc::c_int = 31; - - #[no_mangle] - pub unsafe extern "C" fn sudo_str2sig( -@@ -103,7 +99,6 @@ pub unsafe extern "C" fn sudo_str2sig( - let mut alias: *mut sigalias = 0 as *mut sigalias; - let mut errstr: *const libc::c_char = 0 as *const libc::c_char; - let mut signo: libc::c_int = 0; -- - static mut sudo_sys_signame: [*mut libc::c_char; 65] = - [0 as *const libc::c_char as *mut libc::c_char; 65]; - let mut i: libc::c_int = 0; -@@ -245,7 +240,6 @@ pub unsafe extern "C" fn sudo_str2sig( - sudo_sys_signame[23 as libc::c_int as usize] = - b"URG\0" as *const u8 as *const libc::c_char as *mut libc::c_char; - } -- - if (*(*__ctype_b_loc()).offset(*signame.offset(0 as isize) as libc::c_uchar as isize) - as libc::c_int - & _ISdigit as libc::c_ushort as libc::c_int) -@@ -263,6 +257,7 @@ pub unsafe extern "C" fn sudo_str2sig( - *result = signo; - return 0; - } -+ - if strncmp( - signame, - b"RTMIN\0" as *const u8 as *const libc::c_char, -@@ -290,6 +285,7 @@ pub unsafe extern "C" fn sudo_str2sig( - } - } - } -+ - if strncmp( - signame, - b"RTMAX\0" as *const u8 as *const libc::c_char, -@@ -325,7 +321,6 @@ pub unsafe extern "C" fn sudo_str2sig( - } - alias = alias.offset(1); - } -- - signo = 1; - while signo < NSIG as libc::c_int { - if !(sudo_sys_signame[signo as usize]).is_null() { -@@ -336,6 +331,6 @@ pub unsafe extern "C" fn sudo_str2sig( - } - signo += 1; - } -- *__errno_location() = EINVAL!(); -+ *__errno_location() = EINVAL; - return -1; - } -diff --git a/lib/util/src/strsplit.rs b/lib/util/src/strsplit.rs -index 63871a0..e6ce346 100644 ---- a/lib/util/src/strsplit.rs -+++ b/lib/util/src/strsplit.rs -@@ -6,10 +6,7 @@ - - #![allow(unused_variables, unused_mut, unused_assignments)] - --//use other file's func --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_ptr_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - //line42 - #[no_mangle] -@@ -24,7 +21,7 @@ unsafe fn sudo_strsplit_v1( - let mut s: *const libc::c_char = 0 as *const libc::c_char; - - //line45 -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - //line 48 - if str.is_null() { -diff --git a/lib/util/src/strtobool.rs b/lib/util/src/strtobool.rs -index 30efdf4..53b39bb 100644 ---- a/lib/util/src/strtobool.rs -+++ b/lib/util/src/strtobool.rs -@@ -11,12 +11,7 @@ - unused_mut - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --// use crate::sudo_debug::sudo_debug_printf2_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - extern "C" { - fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int; -@@ -32,7 +27,8 @@ extern "C" { - - #[no_mangle] - pub unsafe extern "C" fn sudo_strtobool_v1(mut str: *const libc::c_char) -> libc::c_int { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); -+ - match *str as u8 as char { - '0' | '1' => { - if *str.offset(1 as isize) as libc::c_int == '\u{0}' as i32 { -@@ -75,5 +71,6 @@ pub unsafe extern "C" fn sudo_strtobool_v1(mut str: *const libc::c_char) -> libc - b"invalid boolean value \"%s\"\0" as *const u8 as *const libc::c_char, - str - ); -+ - debug_return_int!(-1); - } -diff --git a/lib/util/src/strtoid.rs b/lib/util/src/strtoid.rs -index 02bfbb1..a768b08 100644 ---- a/lib/util/src/strtoid.rs -+++ b/lib/util/src/strtoid.rs -@@ -3,6 +3,7 @@ - * - * SPDX-License-Identifier: MulanPSL-2.0 - */ -+ - #![allow( - dead_code, - mutable_transmutes, -@@ -13,35 +14,7 @@ - unused_mut - )] - --type id_t = u32; --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_id_t_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; --use crate::INT_MAX; -- --// #define INT_MIN (-__INT_MAX__ - 1) --#[macro_export] --macro_rules! INT_MIN { -- () => { -- (-(INT_MAX!()) - 1) -- }; --} -- --// #define UINT_MAX (__INT_MAX__ * 2U + 1U) --#[macro_export] --macro_rules! UINT_MAX { -- () => { -- ((INT_MAX!()) * (2 as libc::c_uint) + 1 as libc::c_uint) -- }; --} -- --// #define EINVAL 22 /* Invalid argument */ --#[macro_export] --macro_rules! EINVAL { -- () => { -- 22 -- }; --} -+use crate::common::*; - - extern "C" { - fn sudo_strtonumx( -@@ -51,6 +24,7 @@ extern "C" { - endp: *mut *mut libc::c_char, - errstrp: *mut *const libc::c_char, - ) -> libc::c_longlong; -+ - fn __errno_location() -> *mut libc::c_int; - } - -@@ -63,6 +37,7 @@ unsafe extern "C" fn valid_separator( - mut sep: *const libc::c_char, - ) -> bool { - let mut valid: bool = false; -+ - if ep != p { - /* check for valid separator (including '\0') */ - if sep.is_null() { -@@ -72,6 +47,7 @@ unsafe extern "C" fn valid_separator( - if *ep == *sep { - valid = true; - } -+ - if !(*sep as libc::c_int != '\u{0}' as i32) { - break; - } -@@ -98,7 +74,9 @@ pub unsafe extern "C" fn sudo_strtoidx_v1( - let mut errstr: *const libc::c_char = 0 as *const libc::c_char; - let mut ep: *mut libc::c_char = 0 as *mut libc::c_char; - let mut ret: id_t = 0; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ -+ debug_decl!(SUDO_DEBUG_UTIL); -+ - ret = sudo_strtonumx( - p, - INT_MIN!() as libc::c_longlong, -@@ -115,17 +93,21 @@ pub unsafe extern "C" fn sudo_strtoidx_v1( - || ret == UINT_MAX!() as id_t - || !valid_separator(p, ep, sep) - { -+ // 暂时不处理国际化问题 - errstr = b"invalid value\0" as *const u8 as *const libc::c_char; -- *__errno_location() = EINVAL!() as libc::c_int; -+ *__errno_location() = EINVAL; - ret = 0; - } - } -+ - if !errstrp.is_null() { - *errstrp = errstr; - } -+ - if !endp.is_null() { - *endp = ep; - } -+ - debug_return_id_t!(ret) - } - -diff --git a/lib/util/src/strtomode.rs b/lib/util/src/strtomode.rs -index feec9ff..6684faf 100644 ---- a/lib/util/src/strtomode.rs -+++ b/lib/util/src/strtomode.rs -@@ -14,21 +14,7 @@ - unused_mut - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --type mode_t = i64; --pub const S_IRWXU: mode_t = 448; --pub const S_IRWXG: mode_t = 56; --pub const S_IRWXO: mode_t = 7; -- --// # define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) --macro_rules! ACCESSPERMS { -- () => { -- (S_IRWXU | S_IRWXG | S_IRWXO) -- }; --} -+use crate::common::*; - - extern "C" { - fn strtol(_: *const libc::c_char, _: *mut *mut libc::c_char, _: libc::c_int) -> libc::c_long; -@@ -42,7 +28,7 @@ pub unsafe extern "C" fn sudo_strtomode_v1( - let mut ep: *mut libc::c_char = 0 as *mut libc::c_char; - let mut lval: libc::c_long = 0; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - *__errno_location() = 0 as libc::c_int; - lval = strtol(cp, &mut ep, 8 as libc::c_int); -@@ -54,7 +40,7 @@ pub unsafe extern "C" fn sudo_strtomode_v1( - debug_return_int!(0); - } - -- if lval < 0 || lval > ACCESSPERMS!() { -+ if lval < 0 || lval > (ACCESSPERMS!() as libc::c_long) { - if !errstr.is_null() { - *errstr = if lval < 0 { - b"value too small\0" as *const u8 as *const libc::c_char -@@ -65,6 +51,7 @@ pub unsafe extern "C" fn sudo_strtomode_v1( - *__errno_location() = libc::ERANGE as libc::c_int; - debug_return_int!(0); - } -+ - if !errstr.is_null() { - *errstr = 0 as *const libc::c_char; - } -diff --git a/lib/util/src/strtonum.rs b/lib/util/src/strtonum.rs -index f8fc4ff..19b5c48 100644 ---- a/lib/util/src/strtonum.rs -+++ b/lib/util/src/strtonum.rs -@@ -12,16 +12,13 @@ - unused_mut - )] - -+use crate::common::*; -+ - extern "C" { -- fn __errno_location() -> *mut libc::c_int; - fn __ctype_b_loc() -> *mut *const libc::c_ushort; -+ fn __errno_location() -> *mut libc::c_int; - } - --pub const _ISspace: libc::c_uint = 8192; --pub const _ISdigit: libc::c_uint = 2048; --pub const EINVAL: libc::c_int = 22; --pub const ERANGE: libc::c_int = 34; -- - #[derive(Eq, PartialEq)] - enum strtonum_err { - STN_INITIAL = 0, -@@ -46,7 +43,6 @@ pub unsafe extern "C" fn sudo_strtonumx( - let mut ch: libc::c_uchar = 0; - let mut remainder: libc::c_int = 0; - let mut sign: libc::c_char = 0; -- - if minval > maxval { - errval = strtonum_err::STN_INVALID; - } else { -@@ -61,7 +57,6 @@ pub unsafe extern "C" fn sudo_strtonumx( - break; - } - } -- - match ch as u8 as char { - '-' => { - sign = '-' as i32 as libc::c_char; -@@ -154,7 +149,6 @@ pub unsafe extern "C" fn sudo_strtonumx( - } - } - } -- - match errval { - strtonum_err::STN_INITIAL | strtonum_err::STN_VALID => { - if !errstrp.is_null() { -@@ -183,7 +177,6 @@ pub unsafe extern "C" fn sudo_strtonumx( - } - } - } -- - if !endp.is_null() { - if errval == strtonum_err::STN_INITIAL || errval == strtonum_err::STN_INVALID { - *endp = str as *mut libc::c_char; -@@ -193,7 +186,6 @@ pub unsafe extern "C" fn sudo_strtonumx( - } - return result; - } -- - #[no_mangle] - pub unsafe extern "C" fn sudo_strtonum( - mut str: *const libc::c_char, -@@ -205,13 +197,11 @@ pub unsafe extern "C" fn sudo_strtonum( - let mut ep: *mut libc::c_char = 0 as *mut libc::c_char; - let mut ret: libc::c_longlong = 0; - ret = sudo_strtonumx(str, minval, maxval, &mut ep, &mut errstr); -- - if str == ep || *ep as libc::c_int != '\u{0}' as i32 { - *__errno_location() = EINVAL; - errstr = b"invalid value\0" as *const u8 as *const libc::c_char; - ret = 0 as libc::c_longlong; - } -- - if !errstrp.is_null() { - *errstrp = errstr; - } -diff --git a/lib/util/src/sudo_conf.rs b/lib/util/src/sudo_conf.rs -index 5fead52..499ea8d 100644 ---- a/lib/util/src/sudo_conf.rs -+++ b/lib/util/src/sudo_conf.rs -@@ -14,122 +14,15 @@ - unused_mut, - unreachable_code - )] --use crate::INT_MAX; --use crate::ISSET; -- --// use crate::fatal::sudo_warnx_nodebug_v1; --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_bool_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug::sudo_debug_exit_ptr_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_INFO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; --use crate::sudo_debug_macro::SUDO_DEBUG_WARN; -- --pub type __dev_t = libc::c_ulong; --pub type __uid_t = libc::c_uint; --pub type __gid_t = libc::c_uint; --pub type __ino_t = libc::c_ulong; --pub type __mode_t = libc::c_uint; --#[cfg(target_arch = "x86_64")] --pub type __nlink_t = libc::c_ulong; --#[cfg(not(target_arch = "x86_64"))] --pub type __nlink_t = libc::c_uint; --pub type __off_t = libc::c_long; --pub type __off64_t = libc::c_long; --pub type __time_t = libc::c_long; --#[cfg(target_arch = "x86_64")] --pub type __blksize_t = libc::c_long; --#[cfg(not(target_arch = "x86_64"))] --pub type __blksize_t = libc::c_int; --pub type __blkcnt_t = libc::c_long; --pub type __ssize_t = libc::c_long; --pub type __syscall_slong_t = libc::c_long; --pub type gid_t = __gid_t; --pub type uid_t = __uid_t; --pub type ssize_t = __ssize_t; --pub type size_t = libc::c_ulong; - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct stat { -- pub st_dev: __dev_t, -- pub st_ino: __ino_t, -- #[cfg(target_arch = "x86_64")] -- pub st_nlink: __nlink_t, -- pub st_mode: __mode_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub st_nlink: __nlink_t, -- pub st_uid: __uid_t, -- pub st_gid: __gid_t, -- #[cfg(target_arch = "x86_64")] -- pub __pad0: libc::c_int, -- pub st_rdev: __dev_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad1: __dev_t, -- pub st_size: __off_t, -- pub st_blksize: __blksize_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad2: libc::c_int, -- pub st_blocks: __blkcnt_t, -- pub st_atim: timespec, -- pub st_mtim: timespec, -- pub st_ctim: timespec, -- #[cfg(target_arch = "x86_64")] -- pub __glibc_reserved: [__syscall_slong_t; 3], -- #[cfg(not(target_arch = "x86_64"))] -- pub __glibc_reserved: [libc::c_int; 2], --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct _IO_FILE { -- pub _flags: libc::c_int, -- pub _IO_read_ptr: *mut libc::c_char, -- pub _IO_read_end: *mut libc::c_char, -- pub _IO_read_base: *mut libc::c_char, -- pub _IO_write_base: *mut libc::c_char, -- pub _IO_write_ptr: *mut libc::c_char, -- pub _IO_write_end: *mut libc::c_char, -- pub _IO_buf_base: *mut libc::c_char, -- pub _IO_buf_end: *mut libc::c_char, -- pub _IO_save_base: *mut libc::c_char, -- pub _IO_backup_base: *mut libc::c_char, -- pub _IO_save_end: *mut libc::c_char, -- pub _markers: *mut _IO_marker, -- pub _chain: *mut _IO_FILE, -- pub _fileno: libc::c_int, -- pub _flags2: libc::c_int, -- pub _old_offset: __off_t, -- pub _cur_column: libc::c_ushort, -- pub _vtable_offset: libc::c_schar, -- pub _shortbuf: [libc::c_char; 1], -- pub _lock: *mut libc::c_void, -- pub _offset: __off64_t, -- pub _codecvt: *mut _IO_codecvt, -- pub _wide_data: *mut _IO_wide_data, -- pub _freeres_list: *mut _IO_FILE, -- pub _freeres_buf: *mut libc::c_void, -- pub __pad5: size_t, -- pub _mode: libc::c_int, -- pub _unused2: [libc::c_char; 20], --} --pub type FILE = _IO_FILE; -+use crate::common::*; - - /* Indexes into path_table[] below (order is important). */ - // #define SUDO_CONF_PATH_ASKPASS 0 - // #define SUDO_CONF_PATH_SESH 1 - // #define SUDO_CONF_PATH_NOEXEC 2 - // #define SUDO_CONF_PATH_PLUGIN_DIR 3 --// #define SUDO_CONF_PATH_DEVSEARCH 4 -+// #define SUDO_CONF_PATH_DEVSEARCH 4 - pub const SUDO_CONF_PATH_ASKPASS: libc::c_int = 0; - pub const SUDO_CONF_PATH_SESH: libc::c_int = 1; - pub const SUDO_CONF_PATH_NOEXEC: libc::c_int = 2; -@@ -138,52 +31,15 @@ pub const SUDO_CONF_PATH_DEVSEARCH: libc::c_int = 4; - - pub const __LC_ALL: libc::c_int = 6; - pub const LC_ALL: libc::c_int = __LC_ALL; --// # define ROOT_UID 0 --pub const ROOT_UID: libc::c_int = 0 as libc::c_int; -- --/* secure_path.c */ --// #define SUDO_PATH_SECURE 0 --// #define SUDO_PATH_MISSING -1 --// #define SUDO_PATH_BAD_TYPE -2 --// #define SUDO_PATH_WRONG_OWNER -3 --// #define SUDO_PATH_WORLD_WRITABLE -4 --// #define SUDO_PATH_GROUP_WRITABLE -5 --pub const SUDO_PATH_SECURE: libc::c_int = 0; --pub const SUDO_PATH_MISSING: libc::c_int = -1; --pub const SUDO_PATH_BAD_TYPE: libc::c_int = -2; --pub const SUDO_PATH_WRONG_OWNER: libc::c_int = -3; --pub const SUDO_PATH_WORLD_WRITABLE: libc::c_int = -4; --pub const SUDO_PATH_GROUP_WRITABLE: libc::c_int = -5; -- --// #define ENOENT 2 /* No such file or directory */ --pub const ENOENT: libc::c_int = 2; - - /* Values of sudo_conf_group_source() */ - // #define GROUP_SOURCE_ADAPTIVE 0 --// #define GROUP_SOURCE_STATIC 1 -+// #define GROUP_SOURCE_STATIC 1 - // #define GROUP_SOURCE_DYNAMIC 2 - pub const GROUP_SOURCE_ADAPTIVE: libc::c_int = 0; - pub const GROUP_SOURCE_STATIC: libc::c_int = 1; - pub const GROUP_SOURCE_DYNAMIC: libc::c_int = 2; - --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_marker { -- _unused: [u8; 0], --} -- --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_codecvt { -- _unused: [u8; 0], --} -- --#[repr(C)] --#[derive(Debug, Copy, Clone)] --pub struct _IO_wide_data { -- _unused: [u8; 0], --} -- - extern "C" { - fn fclose(__stream: *mut FILE) -> libc::c_int; - fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; -@@ -210,6 +66,7 @@ extern "C" { - msgid: *const libc::c_char, - ) -> *mut libc::c_char; - fn sudo_warn_nodebug_v1(fmt: *const libc::c_char, _: ...); -+ // fn sudo_warnx_nodebug_v1(fmt: *const libc::c_char, _: ...); - fn sudo_secure_file_v1( - path: *const libc::c_char, - uid: uid_t, -@@ -246,40 +103,6 @@ extern "C" { - ); - fn sudo_warnx_nodebug_v1(fmt: *const libc::c_char, _: ...); - } --// #define isblank(c) __isctype((c), _ISblank) --macro_rules! isblank { -- ($c:expr) => { -- __isctype!($c, _ISblank!()) -- }; --} -- --// # define __isctype(c, type) ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type) --macro_rules! __isctype { -- ($c:expr, $type:expr) => { -- ((*__ctype_b_loc()).offset($c as isize) as libc::c_int) -- & ($type as libc::c_int as libc::c_ushort as libc::c_int) -- }; --} -- --// define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) --// _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ --#[macro_export] --macro_rules! _ISbit { -- ($bit:expr) => { -- if ($bit) < 8 { -- ((1 << ($bit)) << 8) -- } else { -- ((1 << ($bit)) >> 8) -- } -- }; --} -- --#[macro_export] --macro_rules! _ISblank { -- () => { -- _ISbit!(8) -- }; --} - - // # define _PATH_SUDO_ASKPASS NULL - macro_rules! _PATH_SUDO_ASKPASS { -@@ -291,14 +114,14 @@ macro_rules! _PATH_SUDO_ASKPASS { - // # define _PATH_SUDO_SESH "/usr/libexec/utsudo/sesh" - macro_rules! _PATH_SUDO_SESH { - () => { -- (b"/usr/libexec/utsudo/sesh\0" as *const u8 as *const libc::c_char as *mut libc::c_char) -+ (b"/usr/libexec/utsudo/utsesh\0" as *const u8 as *const libc::c_char as *mut libc::c_char) - }; - } - --// # define _PATH_SUDO_NOEXEC "/usr/libexec/utsudo/sudo_noexec.so" -+// # define _PATH_SUDO_NOEXEC "/usr/libexec/utsudo/utsudo_noexec.so" - macro_rules! _PATH_SUDO_NOEXEC { - () => { -- (b"/usr/libexec/utsudo/sudo_noexec.so\0" as *const u8 as *const libc::c_char -+ (b"/usr/libexec/utsudo/utsudo_noexec.so\0" as *const u8 as *const libc::c_char - as *mut libc::c_char) - }; - } -@@ -317,59 +140,13 @@ macro_rules! _PATH_SUDO_DEVSEARCH { - }; - } - --// # define _PATH_SUDO_CONF "/etc/sudo.conf" -+// # define _PATH_SUDO_CONF "/etc/utsudo.conf" - macro_rules! _PATH_SUDO_CONF { - () => { -- (b"/etc/sudo.conf\0" as *const u8 as *const libc::c_char) -+ (b"/etc/utsudo.conf\0" as *const u8 as *const libc::c_char) - }; - } - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_debug_file { -- pub entries: C2RustUnnamed_0, -- pub debug_file: *mut libc::c_char, -- pub debug_flags: *mut libc::c_char, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_0 { -- pub tqe_next: *mut sudo_debug_file, -- pub tqe_prev: *mut *mut sudo_debug_file, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sudo_conf_debug_file_list { -- pub tqh_first: *mut sudo_debug_file, -- pub tqh_last: *mut *mut sudo_debug_file, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct plugin_info { -- pub entries: C2RustUnnamed_1, -- pub path: *mut libc::c_char, -- pub symbol_name: *mut libc::c_char, -- pub options: *mut *mut libc::c_char, -- pub lineno: libc::c_uint, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct C2RustUnnamed_1 { -- pub tqe_next: *mut plugin_info, -- pub tqe_prev: *mut *mut plugin_info, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct plugin_info_list { -- pub tqh_first: *mut plugin_info, -- pub tqh_last: *mut *mut plugin_info, --} -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct sudo_conf_debug { -@@ -377,7 +154,6 @@ pub struct sudo_conf_debug { - pub debug_files: sudo_conf_debug_file_list, - pub progname: *mut libc::c_char, - } -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct C2RustUnnamed_2 { -@@ -390,7 +166,6 @@ pub struct sudo_conf_debug_list { - pub tqh_first: *mut sudo_conf_debug, - pub tqh_last: *mut *mut sudo_conf_debug, - } -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct sudo_conf_table { -@@ -411,7 +186,6 @@ pub struct sudo_conf_data { - pub plugins: plugin_info_list, - pub path_table: [sudo_conf_path_table; 6], - } -- - #[derive(Copy, Clone)] - #[repr(C)] - pub struct sudo_conf_path_table { -@@ -466,12 +240,12 @@ pub unsafe extern "C" fn parse_variable( - let mut var: *mut sudo_conf_table = 0 as *mut sudo_conf_table; - let mut ret: libc::c_int = 0; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - var = sudo_conf_var_table.as_mut_ptr(); - while !((*var).name).is_null() { - if strncmp(entry, (*var).name, (*var).namelen as libc::c_ulong) == 0 -- && isblank!(entry.offset((*var).namelen as isize)) != 0 -+ && isblank!(*entry.offset((*var).namelen as isize)) != 0 - { - entry = entry.offset(((*var).namelen + 1) as isize); - -@@ -489,7 +263,7 @@ pub unsafe extern "C" fn parse_variable( - sudo_debug_printf!( - ret, - b"%s: %s:%u: Set %s %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - conf_file, - lineno, - (*var).name, -@@ -499,14 +273,16 @@ pub unsafe extern "C" fn parse_variable( - } - var = var.offset(1); - } // while !((*var).name).is_null() -+ - sudo_debug_printf!( - SUDO_DEBUG_WARN, - b"%s: %s:%u: unknown setting %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - conf_file, - lineno, - entry - ); -+ - debug_return_int!(false as libc::c_int); - } - -@@ -527,7 +303,7 @@ unsafe extern "C" fn parse_path( - let mut cur: *mut sudo_conf_path_table = 0 as *mut sudo_conf_path_table; - let mut namelen: size_t = 0 as size_t; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - 'bad: loop { - name = sudo_strsplit_v1( -@@ -539,6 +315,7 @@ unsafe extern "C" fn parse_path( - if name.is_null() { - break 'bad; - } -+ - namelen = ep.offset_from(name) as libc::c_long as size_t; - - /* Parse path (if present). */ -@@ -558,10 +335,10 @@ unsafe extern "C" fn parse_path( - let mut pval: *mut libc::c_char = 0 as *mut libc::c_char; - if !path.is_null() { - pval = strdup(path); -- if !pval.is_null() { -+ if pval.is_null() { - sudo_warnx!( - b"%s: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - b"unable to allocate memory\0" as *const u8 as *const libc::c_char - ); - debug_return_int!(-1); -@@ -573,10 +350,11 @@ unsafe extern "C" fn parse_path( - } - (*cur).pval = pval; - (*cur).dynamic = true; -+ - sudo_debug_printf!( - SUDO_DEBUG_INFO, - b"%s: %s:%u: Path %s %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - conf_file, - lineno, - (*cur).pname, -@@ -591,14 +369,16 @@ unsafe extern "C" fn parse_path( - - cur = cur.offset(1 as isize); - } // !(*cur).pname.is_null() -+ - sudo_debug_printf!( - SUDO_DEBUG_WARN, - b"%s: %s:%u: unknown path %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - conf_file, - lineno, - entry - ); -+ - debug_return_int!(false as libc::c_int); - - break 'bad; -@@ -611,6 +391,7 @@ unsafe extern "C" fn parse_path( - conf_file, - lineno - ); -+ - debug_return_int!(false as libc::c_int); - } - -@@ -633,7 +414,7 @@ unsafe extern "C" fn parse_debug( - let mut pathlen: size_t = 0 as size_t; - let mut prognamelen: size_t = 0 as size_t; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - /* Parse progname. */ - progname = sudo_strsplit_v1( -@@ -667,7 +448,7 @@ unsafe extern "C" fn parse_debug( - &mut ep, - ); - -- if !flags.is_null() { -+ if flags.is_null() { - debug_return_int!(false as libc::c_int); /* not enough fields */ - } - -@@ -675,12 +456,13 @@ unsafe extern "C" fn parse_debug( - debug_spec = sudo_conf_data.debugging.tqh_first; - while !debug_spec.is_null() { - if strncmp((*debug_spec).progname, progname, prognamelen) == 0 -- && (*debug_spec).progname.offset(prognamelen as isize) as libc::c_int == '\u{0}' as i32 -+ && *((*debug_spec).progname).offset(prognamelen as isize) as libc::c_int == '\0' as i32 - { - break; - } - debug_spec = (*debug_spec).entries.tqe_next; - } -+ - 'oom: loop { - if debug_spec.is_null() { - debug_spec = malloc(::std::mem::size_of::() as libc::c_ulong) -@@ -690,7 +472,7 @@ unsafe extern "C" fn parse_debug( - break 'oom; - } - (*debug_spec).progname = strndup(progname, prognamelen); -- if !(*debug_spec).progname.is_null() { -+ if (*debug_spec).progname.is_null() { - free(debug_spec as *mut libc::c_void); - debug_spec = 0 as *mut sudo_conf_debug; - break 'oom; -@@ -708,7 +490,7 @@ unsafe extern "C" fn parse_debug( - - debug_file = calloc(1, ::std::mem::size_of::() as libc::c_ulong) - as *mut sudo_debug_file; -- if !debug_file.is_null() { -+ if debug_file.is_null() { - break 'oom; - } - -@@ -734,7 +516,7 @@ unsafe extern "C" fn parse_debug( - - sudo_warnx!( - b"%s: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - b"unable to allocate memory\0" - ); - -@@ -765,7 +547,7 @@ unsafe extern "C" fn parse_plugin( - let mut symlen: size_t = 0 as size_t; - let mut nopts: libc::c_uint = 0 as libc::c_uint; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - /* Parse symbol. */ - symbol = sudo_strsplit_v1( -@@ -799,7 +581,7 @@ unsafe extern "C" fn parse_plugin( - } - - 'oom: loop { -- if *ep as libc::c_int != '\u{0}' as i32 { -+ if *ep as libc::c_int != '\0' as i32 { - /* Count number of options and allocate array. */ - let mut cp: *const libc::c_char = 0 as *const libc::c_char; - let mut opt: *const libc::c_char = ep; -@@ -839,27 +621,36 @@ unsafe extern "C" fn parse_plugin( - b" \t\0" as *const u8 as *const libc::c_char, - &mut ep, - ); -- while !cp.is_null() { -- *options.offset(nopts as isize) = strndup(cp, ep.offset_from(cp) as size_t); -- if ((*options).offset(nopts as isize)).is_null() { -+ -+ loop { -+ if cp.is_null() { -+ break; -+ } -+ let ref mut fresh0 = *options.offset(nopts as isize); -+ *fresh0 = strndup(cp, ep.offset_from(cp) as libc::c_long as size_t); -+ if (*options.offset(nopts as isize)).is_null() { -+ let ref mut fresh1 = *options.offset(nopts as isize); -+ *fresh1 = 0 as *mut libc::c_char; - break 'oom; - } -- nopts += 1; -+ nopts = nopts.wrapping_add(1); -+ - cp = sudo_strsplit_v1( - 0 as *const libc::c_char, - entry_end, - b" \t\0" as *const u8 as *const libc::c_char, - &mut ep, - ); -- } // while !cp.is_null() -+ } - - *options.offset(nopts as isize) = 0 as *mut libc::c_char; -- } // if *ep as libc::c_int != '\u{0}' as i32 -+ } // if *ep as libc::c_int != '\0' as i32 - - info = calloc( -- ::std::mem::size_of::<*const plugin_info>() as libc::c_ulong, -- 1, -+ ::core::mem::size_of::() as libc::c_ulong, -+ 1 as libc::c_int as libc::c_ulong, - ) as *mut plugin_info; -+ - if info.is_null() { - break 'oom; - } -@@ -874,7 +665,7 @@ unsafe extern "C" fn parse_plugin( - (*info).options = options; - (*info).lineno = lineno; - -- // TAILQ_INSERT_TAIL(&sudo_conf_data.plugins, info, entries); -+ // TAILQ_INSERT_TAIL(&sudo_conf_data.plugins, info, entries); - (*info).entries.tqe_next = 0 as *mut plugin_info; - (*info).entries.tqe_prev = sudo_conf_data.plugins.tqh_last; - *sudo_conf_data.plugins.tqh_last = info; -@@ -884,20 +675,23 @@ unsafe extern "C" fn parse_plugin( - - break 'oom; - } // oom loop -+ - sudo_warnx!( - b"%s: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - b"unable to allocate memory\0" as *const u8 as *const libc::c_char - ); - - if !options.is_null() { - loop { -- nopts -= 1; -- if !(nopts != 0) { -+ let fresh2 = nopts; -+ nopts = nopts.wrapping_sub(1); -+ if !(fresh2 != 0) { - break; - } - free(*options.offset(nopts as isize) as *mut libc::c_void); - } -+ - free(options as *mut libc::c_void); - } - if !info.is_null() { -@@ -918,7 +712,7 @@ unsafe extern "C" fn set_var_disable_coredump( - // int val = sudo_strtobool(strval); - let mut val: libc::c_int = sudo_strtobool_v1(strval); - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if val == -1 { - sudo_warnx!( -@@ -934,7 +728,7 @@ unsafe extern "C" fn set_var_disable_coredump( - - sudo_conf_data.disable_coredump = val as libc::c_int != 0; - -- debug_return_int!(true as libc::c_int); -+ debug_return_int!(true as libc::c_int) - } - - #[no_mangle] -@@ -943,7 +737,7 @@ unsafe extern "C" fn set_var_group_source( - mut conf_file: *const libc::c_char, - mut lineno: libc::c_uint, - ) -> libc::c_int { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if strcasecmp(strval, b"adaptive\0" as *const u8 as *const libc::c_char) == 0 { - sudo_conf_data.group_source = GROUP_SOURCE_ADAPTIVE; -@@ -960,8 +754,9 @@ unsafe extern "C" fn set_var_group_source( - ); - debug_return_int!(false as libc::c_int); - } -- debug_return_int!(true as libc::c_int); -+ debug_return_int!(true as libc::c_int) - } -+ - #[no_mangle] - unsafe extern "C" fn set_var_max_groups( - mut strval: *const libc::c_char, -@@ -969,7 +764,7 @@ unsafe extern "C" fn set_var_max_groups( - mut lineno: libc::c_uint, - ) -> libc::c_int { - let mut max_groups: libc::c_int = 0 as libc::c_int; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - max_groups = sudo_strtonum(strval, 1, INT_MAX!(), 0 as *mut *const libc::c_char) as libc::c_int; - if max_groups <= 0 { -@@ -982,7 +777,7 @@ unsafe extern "C" fn set_var_max_groups( - debug_return_int!(false as libc::c_int); - } - sudo_conf_data.max_groups = max_groups; -- debug_return_int!(true as libc::c_int); -+ debug_return_int!(true as libc::c_int) - } - - #[no_mangle] -@@ -992,7 +787,7 @@ unsafe extern "C" fn set_var_probe_interfaces( - mut lineno: libc::c_uint, - ) -> libc::c_int { - let mut val: libc::c_int = sudo_strtobool_v1(strval); -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if val == -1 { - sudo_warnx!( -@@ -1006,7 +801,7 @@ unsafe extern "C" fn set_var_probe_interfaces( - } - - sudo_conf_data.probe_interfaces = val as libc::c_int != 0; -- debug_return_int!(true as libc::c_int); -+ debug_return_int!(true as libc::c_int) - } - - #[no_mangle] -@@ -1064,25 +859,25 @@ pub unsafe extern "C" fn sudo_conf_debug_files_v1( - let mut progbaselen: size_t = 0 as size_t; - let mut progbase: *const libc::c_char = progname; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - /* Determine basename if program is fully qualified (like for plugins). */ - prognamelen = strlen(progname) as size_t; -- progbaselen = strlen(progname) as size_t; -+ progbaselen = prognamelen; - if *progname as libc::c_int == '/' as i32 { - progbase = strrchr(progname, '/' as i32); - progbase = progbase.offset(1 as isize); - progbaselen = strlen(progbase); - } - -- /* Convert sudoedit -> sudo. */ -- if progbaselen > 4 -+ /* Convert utsudoedit -> utsudo. */ -+ if progbaselen > 6 - && strcmp( -- progbase.offset(4 as isize), -+ progbase.offset(6 as isize), - b"edit\0" as *const u8 as *const libc::c_char, - ) == 0 - { -- progbaselen = progbaselen - 4; -+ progbaselen = progbaselen - 6; - } - - debug_spec = sudo_conf_data.debugging.tqh_first; -@@ -1090,14 +885,13 @@ pub unsafe extern "C" fn sudo_conf_debug_files_v1( - let mut prog: *const libc::c_char = progbase; - let mut len: size_t = progbaselen; - -- if ((*debug_spec).progname).offset(0 as isize) as libc::c_int == '/' as i32 { -+ if *((*debug_spec).progname).offset(0 as isize) as libc::c_int == '/' as i32 { - /* Match fully-qualified name, if possible. */ - prog = progname; - len = prognamelen; - } -- - if strncasecmp((*debug_spec).progname, prog, len) == 0 -- && ((*debug_spec).progname).offset(len as isize) as libc::c_int == '\u{0}' as i32 -+ && *((*debug_spec).progname).offset(len as isize) as libc::c_int == '\u{0}' as i32 - { - debug_return_ptr!(&mut ((*debug_spec).debug_files) as *mut sudo_conf_debug_file_list); - } -@@ -1118,51 +912,14 @@ pub unsafe extern "C" fn sudo_conf_probe_interfaces_v1() -> bool { - } - - /* -- * Reads in /etc/sudo.conf and populates sudo_conf_data. -+ * Reads in /etc/utsudo.conf and populates sudo_conf_data. - */ - #[no_mangle] - pub unsafe extern "C" fn sudo_conf_read_v1( - mut conf_file: *const libc::c_char, - mut conf_types: libc::c_int, - ) -> libc::c_int { -- let mut sb: stat = stat { -- st_dev: 0, -- st_ino: 0, -- #[cfg(target_arch = "x86_64")] -- st_nlink: 0, -- st_mode: 0, -- #[cfg(not(target_arch = "x86_64"))] -- st_nlink: 0, -- st_uid: 0, -- st_gid: 0, -- #[cfg(target_arch = "x86_64")] -- __pad0: 0, -- st_rdev: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad1: 0, -- st_size: 0, -- st_blksize: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad2: 0, -- st_blocks: 0, -- st_atim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_mtim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_ctim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- #[cfg(target_arch = "x86_64")] -- __glibc_reserved: [0; 3], -- #[cfg(not(target_arch = "x86_64"))] -- __glibc_reserved: [0; 2], -- }; -- -+ let mut sb: stat = sb_all_arch; - let mut fp: *mut FILE = 0 as *mut FILE; - let mut ret: libc::c_int = false as libc::c_int; - -@@ -1171,7 +928,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - let mut conf_lineno: libc::c_uint = 0 as libc::c_uint; - let mut linesize: size_t = 0 as size_t; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - prev_locale = setlocale(LC_ALL, 0 as *const libc::c_char); - if prev_locale.is_null() { -@@ -1183,7 +940,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - if prev_locale.is_null() { - sudo_warnx!( - b"%s: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - b"unable to allocate memory\0" as *const u8 as *const libc::c_char - ); - debug_return_int!(-(1 as libc::c_int)); -@@ -1195,6 +952,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - { - setlocale(LC_ALL, b"C\0" as *const u8 as *mut libc::c_char); - } -+ - 'done: loop { - if conf_file.is_null() { - conf_file = _PATH_SUDO_CONF!(); -@@ -1205,7 +963,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - &mut sb, - ) { - SUDO_PATH_SECURE => { -- break 'done; -+ // break 'done; - } - SUDO_PATH_MISSING => { - /* Root should always be able to read sudo.conf. */ -@@ -1285,7 +1043,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - } - - cur = sudo_conf_table.as_mut_ptr(); -- while (*cur).name.is_null() { -+ while !(*cur).name.is_null() { - if strncasecmp(cp, (*cur).name, (*cur).namelen as libc::c_ulong) == 0 - && isblank!(*cp.offset((*cur).namelen as isize) as isize) != 0 - { -@@ -1306,13 +1064,15 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - } // ISSET - break; - } // if strncasecmp -+ i = i.wrapping_add(1); -+ cur = cur.offset(1); - } // while (*cur).name.is_null() - -- if (*cur).name.is_null() { -+ if ((*cur).name).is_null() { - sudo_debug_printf!( - SUDO_DEBUG_WARN, - b"%s: %s:%u: unsupported entry: %s\0" as *const u8 as *const libc::c_char, -- stdext::function_name!().as_ptr(), -+ get_function_name!(), - conf_file, - conf_lineno, - line -@@ -1330,8 +1090,8 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - free(line as *mut libc::c_void); - - /* Restore locale if needed. */ -- if prev_locale.offset(0 as isize) as libc::c_int != 'C' as i32 -- || prev_locale.offset(1 as isize) as libc::c_int != '\u{0}' as i32 -+ if *prev_locale.offset(0 as isize) as libc::c_int != 'C' as i32 -+ || *prev_locale.offset(1 as isize) as libc::c_int != '\u{0}' as i32 - { - setlocale(LC_ALL, prev_locale); - } -@@ -1346,7 +1106,7 @@ pub unsafe extern "C" fn sudo_conf_read_v1( - #[no_mangle] - pub unsafe extern "C" fn sudo_conf_clear_paths_v1() { - let mut cur: *mut sudo_conf_path_table = 0 as *mut sudo_conf_path_table; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - cur = (sudo_conf_data.path_table).as_mut_ptr(); - while !((*cur).pname).is_null() { -@@ -1594,7 +1354,7 @@ unsafe extern "C" fn run_static_initializers() { - pname: 0 as *const libc::c_char, - pnamelen: 0 as libc::c_uint, - dynamic: false, -- pval: _PATH_SUDO_SESH!(), -+ pval: 0 as *mut libc::c_char, - }; - null - }, -diff --git a/lib/util/src/sudo_debug.rs b/lib/util/src/sudo_debug.rs -index 706325d..ef7ec99 100644 ---- a/lib/util/src/sudo_debug.rs -+++ b/lib/util/src/sudo_debug.rs -@@ -88,12 +88,12 @@ macro_rules! O_CREAT { - }; - } - --#[macro_export] -+/*#[macro_export] - macro_rules! S_IRUSR { - () => { - 0400 - }; --} -+}*/ - - #[macro_export] - macro_rules! IGNORE_RESULT { -@@ -157,21 +157,21 @@ macro_rules! sudo_setbit { - - /* Extract subsystem number and convert to an index. */ - // #define SUDO_DEBUG_SUBSYS(n) (((n) >> 6) - 1) --#[macro_export] -+/*#[macro_export] - macro_rules! SUDO_DEBUG_SUBSYS { - ($_n:expr) => { - ((($_n) >> 6) - 1) - }; --} -+}*/ - - /* Extract priority number and convert to an index. */ - // #define SUDO_DEBUG_PRI(n) (((n) & 0x0f) - 1) --#[macro_export] -+/*#[macro_export] - macro_rules! SUDO_DEBUG_PRI { - ($_n:expr) => { - ((($_n) & 0x0f) - 1) - }; --} -+}*/ - - /* Flag to include string version of errno in debug info. */ - // #define SUDO_DEBUG_ERRNO (1<<4) -diff --git a/lib/util/src/sudo_debug_macro.rs b/lib/util/src/sudo_debug_macro.rs -index bb448c9..4822b7a 100644 ---- a/lib/util/src/sudo_debug_macro.rs -+++ b/lib/util/src/sudo_debug_macro.rs -@@ -22,6 +22,7 @@ use crate::sudo_debug::*; - - pub static mut sudo_debug_subsys: libc::c_int = 0 as libc::c_int; - -+ - // extern "C" { - // fn sudo_debug_printf2_v1( - // func: *const libc::c_char, -@@ -133,6 +134,7 @@ macro_rules! debug_decl { - }; - } - -+ - macro_rules! debug_return_int { - ($ret:expr) => {{ - sudo_debug_exit_int_v1( -@@ -233,6 +235,7 @@ macro_rules! debug_return_bool { - }}; - } - -+ - macro_rules! debug_return_str { - ($ret:expr) => {{ - sudo_debug_exit_str_v1( -@@ -246,6 +249,7 @@ macro_rules! debug_return_str { - }}; - } - -+ - macro_rules! debug_return_const_str { - ($ret:expr) => { - let mut sudo_debug_ret: *mut libc::c_char = ($ret); -diff --git a/lib/util/src/sudo_dso.rs b/lib/util/src/sudo_dso.rs -index 625cf52..510d2b8 100644 ---- a/lib/util/src/sudo_dso.rs -+++ b/lib/util/src/sudo_dso.rs -@@ -14,46 +14,11 @@ - unused_mut - )] - --//secure_path.rs --use crate::ISSET; -- --/* Values for sudo_dso_load() mode. */ --// #define SUDO_DSO_LAZY 0x1 --// #define SUDO_DSO_NOW 0x2 --// #define SUDO_DSO_GLOBAL 0x4 --// #define SUDO_DSO_LOCAL 0x8 -- --#[macro_export] --macro_rules! SUDO_DSO_LAZY { -- () => { -- 0x1 -- }; --} -- --#[macro_export] --macro_rules! SUDO_DSO_NOW { -- () => { -- 0x2 -- }; --} -- --#[macro_export] --macro_rules! SUDO_DSO_GLOBAL { -- () => { -- 0x3 -- }; --} -- --#[macro_export] --macro_rules! SUDO_DSO_LOCAL { -- () => { -- 0x4 -- }; --} -+use crate::common::*; - - /* The MODE argument to `dlopen' contains one of the following: */ --// #define RTLD_LAZY 0x00001 /* Lazy function call binding. */ --// #define RTLD_NOW 0x00002 /* Immediate function call binding. */ -+// #define RTLD_LAZY 0x00001 /* Lazy function call binding. */ -+// #define RTLD_NOW 0x00002 /* Immediate function call binding. */ - #[macro_export] - macro_rules! RTLD_LAZY { - () => { -@@ -68,7 +33,7 @@ macro_rules! RTLD_NOW { - }; - } - --// #define RTLD_GLOBAL 0x00100 -+// #define RTLD_GLOBAL 0x00100 - #[macro_export] - macro_rules! RTLD_GLOBAL { - () => { -@@ -76,7 +41,7 @@ macro_rules! RTLD_GLOBAL { - }; - } - --// #define RTLD_LOCAL 0 -+// #define RTLD_LOCAL 0 - #[macro_export] - macro_rules! RTLD_LOCAL { - () => { -@@ -89,7 +54,6 @@ macro_rules! RTLD_LOCAL { - // #define SUDO_DSO_DEFAULT ((void *)-2) /* Use default search algorithm. */ - // #define SUDO_DSO_SELF ((void *)-3) /* Search the caller itself. */ - pub const SUDO_DSO_NEXT: *mut libc::c_void = -(1 as libc::c_int) as *mut libc::c_void; --pub const SUDO_DSO_DEFAULT: *mut libc::c_void = -(2 as libc::c_int) as *mut libc::c_void; - pub const SUDO_DSO_SELF: *mut libc::c_void = -(3 as libc::c_int) as *mut libc::c_void; - - // # define RTLD_NEXT ((void *) -1l) -@@ -98,9 +62,6 @@ pub const RTLD_NEXT: *mut libc::c_void = -(1 as libc::c_long) as *mut libc::c_vo - // # define RTLD_DEFAULT ((void *) 0) - pub const RTLD_DEFAULT: *mut libc::c_void = 0 as *mut libc::c_void; - --// #define ENOENT 2 --pub const ENOENT: libc::c_int = 2; -- - extern "C" { - fn dlerror() -> *mut libc::c_char; - fn dlclose(__handle: *mut libc::c_void) -> libc::c_int; -diff --git a/lib/util/src/term.rs b/lib/util/src/term.rs -index 00352ae..bf015fa 100644 ---- a/lib/util/src/term.rs -+++ b/lib/util/src/term.rs -@@ -15,20 +15,11 @@ - clashing_extern_declarations - )] - --//ttysize.rs文件中定义 --use crate::TIOCGWINSZ; -- --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_bool_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -+use crate::common::*; - - /* Type of a signal handler. */ - // typedef void (*__sighandler_t) (int); --pub type __sighandler_t = Option ()>; --pub type __pid_t = libc::c_int; --pub type __uid_t = libc::c_uint; --pub type __clock_t = libc::c_long; --pub type __uint32_t = libc::c_uint; -+ - pub type tcflag_t = libc::c_uint; - pub type cc_t = libc::c_uchar; - pub const NCCS: libc::c_int = 32; -@@ -48,141 +39,6 @@ pub static mut sudo_term_erase: libc::c_int = 0; - #[no_mangle] - pub static mut sudo_term_kill: libc::c_int = 0; - --#[derive(Copy, Clone)] --#[repr(C)] --pub union sigval { -- pub sival_int: libc::c_int, -- pub sival_ptr: *mut libc::c_void, --} --pub type __sigval_t = sigval; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct siginfo_t { -- pub si_signo: libc::c_int, -- pub si_errno: libc::c_int, -- pub si_code: libc::c_int, -- pub __pad0: libc::c_int, -- pub _sifields: sifields_union, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct kill_struct { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timer_struct { -- pub si_tid: libc::c_int, -- pub si_overrun: libc::c_int, -- pub si_sigval: __sigval_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct rt_struct { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, -- pub si_sigval: __sigval_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigchld_struct { -- pub si_pid: __pid_t, -- pub si_uid: __uid_t, -- pub si_status: libc::c_int, -- pub si_utime: __clock_t, -- pub si_stime: __clock_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigfault_struct { -- pub si_addr: *mut libc::c_void, -- pub si_addr_lsb: libc::c_short, -- pub _bounds: bounds_struct, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigpoll_struct { -- pub si_band: libc::c_long, -- pub si_fd: libc::c_int, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigsys_struct { -- pub _call_addr: *mut libc::c_void, -- pub _syscall: libc::c_int, -- pub _arch: libc::c_uint, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub union sifields_union { -- pub _pad: [libc::c_int; 28], -- pub _kill: kill_struct, -- pub _timer: timer_struct, -- pub _rt: rt_struct, -- pub _sigchld: sigchld_struct, -- pub _sigfault: sigfault_struct, -- pub _sigpoll: sigpoll_struct, -- pub _sigsys: sigsys_struct, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct bounds_struct { -- pub _addr_bnd: addr_bnd_struct, -- pub _key: __uint32_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct addr_bnd_struct { -- pub _lower: *mut libc::c_void, -- pub _upper: *mut libc::c_void, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct __sigset_t { -- pub __val: [libc::c_ulong; 16], --} --pub type sigset_t = __sigset_t; -- --#[derive(Copy, Clone)] --#[repr(C)] --pub union __sigaction_handler_union { -- /* Used if SA_SIGINFO is not set. */ -- sa_handler: __sighandler_t, -- -- /* Used if SA_SIGINFO is set. */ -- sa_sigaction: -- Option ()>, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct sigaction { -- pub __sigaction_handler: __sigaction_handler_union, -- -- /* Additional set of signals to be blocked. */ -- pub sa_mask: sigset_t, -- -- /* Special flags. */ -- pub sa_flags: libc::c_int, -- -- /* Restore handler. */ -- // void (*sa_restorer) (void); -- pub sa_restorer: Option ()>, --} -- - /* An integral type that can be modified atomically, without the - possibility of a signal arriving in the middle of the operation. */ - // typedef __sig_atomic_t sig_atomic_t; -@@ -230,15 +86,6 @@ pub struct termios { - c_ospeed: speed_t, /* output speed */ - } - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct winsize { -- ws_row: libc::c_ushort, -- ws_col: libc::c_ushort, -- ws_xpixel: libc::c_ushort, -- ws_ypixel: libc::c_ushort, --} -- - extern "C" { - fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - fn sigemptyset(__set: *mut sigset_t) -> libc::c_int; -@@ -289,27 +136,11 @@ pub const VTIME: libc::c_int = 5 as libc::c_int; - // #define VMIN 6 - pub const VMIN: libc::c_int = 6 as libc::c_int; - --// #define CLR(t, f) ((t) &= ~(f)) --#[macro_export] --macro_rules! CLR { -- ($t:expr, $f:expr) => { -- (($t) &= !($f)) -- }; --} -- --// #define SET(t, f) ((t) |= (f)) --#[macro_export] --macro_rules! SET { -- ($t:expr, $f:expr) => { -- (($t) |= ($f)) -- }; --} -- - // #define ECHO 0000010 - #[macro_export] - macro_rules! ECHO { - () => { -- 0000010 -+ 0o000010 - }; - } - -@@ -317,7 +148,7 @@ macro_rules! ECHO { - #[macro_export] - macro_rules! ECHONL { - () => { -- 0000100 -+ 0o000100 - }; - } - -@@ -325,7 +156,7 @@ macro_rules! ECHONL { - #[macro_export] - macro_rules! ICRNL { - () => { -- 0000400 -+ 0o000400 - }; - } - -@@ -333,7 +164,7 @@ macro_rules! ICRNL { - #[macro_export] - macro_rules! IGNCR { - () => { -- 0000200 -+ 0o000200 - }; - } - -@@ -341,7 +172,7 @@ macro_rules! IGNCR { - #[macro_export] - macro_rules! INLCR { - () => { -- 0000100 -+ 0o000100 - }; - } - -@@ -349,7 +180,7 @@ macro_rules! INLCR { - #[macro_export] - macro_rules! IUCLC { - () => { -- 0001000 -+ 0o001000 - }; - } - -@@ -357,7 +188,7 @@ macro_rules! IUCLC { - #[macro_export] - macro_rules! IXON { - () => { -- 0002000 -+ 0o002000 - }; - } - -@@ -365,7 +196,7 @@ macro_rules! IXON { - #[macro_export] - macro_rules! OPOST { - () => { -- 0000001 -+ 0o000001 - }; - } - -@@ -373,7 +204,7 @@ macro_rules! OPOST { - #[macro_export] - macro_rules! ICANON { - () => { -- 0000002 -+ 0o000002 - }; - } - -@@ -381,7 +212,7 @@ macro_rules! ICANON { - #[macro_export] - macro_rules! ISIG { - () => { -- 0000001 -+ 0o000001 - }; - } - -@@ -389,7 +220,7 @@ macro_rules! ISIG { - #[macro_export] - macro_rules! IEXTEN { - () => { -- 0100000 -+ 0o100000 - }; - } - -@@ -397,7 +228,7 @@ macro_rules! IEXTEN { - #[macro_export] - macro_rules! IGNPAR { - () => { -- 0000004 -+ 0o000004 - }; - } - -@@ -405,49 +236,49 @@ macro_rules! IGNPAR { - #[macro_export] - macro_rules! PARMRK { - () => { -- 0000010 -+ 0o000010 - }; - } - // #define INPCK 0000020 - #[macro_export] - macro_rules! INPCK { - () => { -- 0000020 -+ 0o000020 - }; - } - // #define ISTRIP 0000040 - #[macro_export] - macro_rules! ISTRIP { - () => { -- 0000040 -+ 0o000040 - }; - } - // #define IXANY 0004000 - #[macro_export] - macro_rules! IXANY { - () => { -- 0004000 -+ 0o004000 - }; - } - // #define IXOFF 0010000 - #[macro_export] - macro_rules! IXOFF { - () => { -- 0010000 -+ 0o010000 - }; - } - // #define IMAXBEL 0020000 - #[macro_export] - macro_rules! IMAXBEL { - () => { -- 0020000 -+ 0o020000 - }; - } - // #define IUTF8 0040000 - #[macro_export] - macro_rules! IUTF8 { - () => { -- 0040000 -+ 0o040000 - }; - } - -@@ -456,35 +287,35 @@ macro_rules! IUTF8 { - #[macro_export] - macro_rules! OLCUC { - () => { -- 0000002 -+ 0o000002 - }; - } - // #define ONLCR 0000004 - #[macro_export] - macro_rules! ONLCR { - () => { -- 0000004 -+ 0o000004 - }; - } - // #define OCRNL 0000010 - #[macro_export] - macro_rules! OCRNL { - () => { -- 0000010 -+ 0o000010 - }; - } - // #define ONOCR 0000020 - #[macro_export] - macro_rules! ONOCR { - () => { -- 0000020 -+ 0o000020 - }; - } - // #define ONLRET 0000040 - #[macro_export] - macro_rules! ONLRET { - () => { -- 0000040 -+ 0o000040 - }; - } - -@@ -492,28 +323,28 @@ macro_rules! ONLRET { - #[macro_export] - macro_rules! CS7 { - () => { -- 0000040 -+ 0o000040 - }; - } - // #define CS8 0000060 - #[macro_export] - macro_rules! CS8 { - () => { -- 0000060 -+ 0o000060 - }; - } - // #define PARENB 0000400 - #[macro_export] - macro_rules! PARENB { - () => { -- 0000400 -+ 0o000400 - }; - } - // #define PARODD 0001000 - #[macro_export] - macro_rules! PARODD { - () => { -- 0001000 -+ 0o001000 - }; - } - -@@ -521,7 +352,7 @@ macro_rules! PARODD { - #[macro_export] - macro_rules! XCASE { - () => { -- 0000004 -+ 0o000004 - }; - } - -@@ -529,7 +360,7 @@ macro_rules! XCASE { - #[macro_export] - macro_rules! ECHOE { - () => { -- 0000020 -+ 0o000020 - }; - } - -@@ -537,7 +368,7 @@ macro_rules! ECHOE { - #[macro_export] - macro_rules! ECHOK { - () => { -- 0000040 -+ 0o000040 - }; - } - -@@ -545,7 +376,7 @@ macro_rules! ECHOK { - #[macro_export] - macro_rules! NOFLSH { - () => { -- 0000200 -+ 0o000200 - }; - } - -@@ -553,7 +384,7 @@ macro_rules! NOFLSH { - #[macro_export] - macro_rules! TOSTOP { - () => { -- 0000400 -+ 0o000400 - }; - } - -@@ -561,7 +392,7 @@ macro_rules! TOSTOP { - #[macro_export] - macro_rules! ECHOCTL { - () => { -- 0001000 -+ 0o001000 - }; - } - -@@ -569,7 +400,7 @@ macro_rules! ECHOCTL { - #[macro_export] - macro_rules! ECHOKE { - () => { -- 0004000 -+ 0o004000 - }; - } - -@@ -577,7 +408,7 @@ macro_rules! ECHOKE { - #[macro_export] - macro_rules! PENDIN { - () => { -- 0040000 -+ 0o040000 - }; - } - -@@ -593,7 +424,7 @@ macro_rules! B0 { - #[macro_export] - macro_rules! B38400 { - () => { -- 0000017 -+ 0o000017 - }; - } - -@@ -682,14 +513,14 @@ unsafe extern "C" fn tcsetattr_nobg( - tp: *mut termios, - ) -> libc::c_int { - let mut sa: sigaction = sigaction { -- __sigaction_handler: __sigaction_handler_union { sa_handler: None }, -+ __sigaction_handler: Signal_handler { sa_handler: None }, - sa_mask: sigset_t { __val: [0; 16] }, - sa_flags: 0, - sa_restorer: None, - }; - - let mut osa: sigaction = sigaction { -- __sigaction_handler: __sigaction_handler_union { sa_handler: None }, -+ __sigaction_handler: Signal_handler { sa_handler: None }, - sa_mask: sigset_t { __val: [0; 16] }, - sa_flags: 0, - sa_restorer: None, -@@ -736,7 +567,7 @@ unsafe extern "C" fn tcsetattr_nobg( - // #[named] - #[no_mangle] - unsafe extern "C" fn sudo_term_restore_v1(fd: libc::c_int, flush: bool) -> bool { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if changed != 0 { - let mut flags: libc::c_int = { -@@ -761,7 +592,7 @@ unsafe extern "C" fn sudo_term_restore_v1(fd: libc::c_int, flush: bool) -> bool - */ - #[no_mangle] - unsafe extern "C" fn sudo_term_noecho_v1(fd: libc::c_int) -> bool { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if changed == 0 && tcgetattr(fd, &mut oterm) != 0 { - debug_return_bool!(false); -@@ -795,9 +626,9 @@ unsafe extern "C" fn sudo_term_raw_v1(fd: libc::c_int, isig: libc::c_int) -> boo - c_ispeed: 0, - c_ospeed: 0, - }; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - -- if changed != 0 && tcgetattr(fd, &mut oterm) != 0 { -+ if changed == 0 && tcgetattr(fd, &mut oterm) != 0 { - debug_return_bool!(false); - } - memcpy( -@@ -831,9 +662,9 @@ unsafe extern "C" fn sudo_term_raw_v1(fd: libc::c_int, isig: libc::c_int) -> boo - */ - #[no_mangle] - unsafe extern "C" fn sudo_term_cbreak_v1(fd: libc::c_int) -> bool { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - -- if changed != 0 && tcgetattr(fd, &mut oterm) != 0 { -+ if changed == 0 && tcgetattr(fd, &mut oterm) != 0 { - debug_return_bool!(false); - } - -@@ -897,7 +728,7 @@ unsafe extern "C" fn sudo_term_copy_v1(src: libc::c_int, dst: libc::c_int) -> bo - ws_ypixel: 0, - }; - let mut speed: speed_t = 0 as speed_t; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if tcgetattr(src, &mut tt_src) != 0 || tcgetattr(dst, &mut tt_dst) != 0 { - debug_return_bool!(false); -diff --git a/lib/util/src/ttyname_dev.rs b/lib/util/src/ttyname_dev.rs -index da85da5..c7b767b 100644 ---- a/lib/util/src/ttyname_dev.rs -+++ b/lib/util/src/ttyname_dev.rs -@@ -16,35 +16,18 @@ - unused_variables - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_str_v1; --// use crate::sudo_debug::sudo_debug_printf2_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_DEBUG; --use crate::sudo_debug_macro::SUDO_DEBUG_ERRNO; --use crate::sudo_debug_macro::SUDO_DEBUG_ERROR; --use crate::sudo_debug_macro::SUDO_DEBUG_INFO; --use crate::sudo_debug_macro::SUDO_DEBUG_LINENO; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --pub type __dev_t = libc::c_ulong; --pub type __uid_t = libc::c_uint; --pub type __gid_t = libc::c_uint; --pub type __ino_t = libc::c_ulong; --pub type __mode_t = libc::c_uint; --#[cfg(target_arch = "x86_64")] --pub type __nlink_t = libc::c_ulong; --#[cfg(not(target_arch = "x86_64"))] --pub type __nlink_t = libc::c_uint; --pub type __off_t = libc::c_long; --pub type __time_t = libc::c_long; --#[cfg(target_arch = "x86_64")] --pub type __blksize_t = libc::c_long; --#[cfg(not(target_arch = "x86_64"))] --pub type __blksize_t = libc::c_int; --pub type __blkcnt_t = libc::c_long; --pub type __syscall_slong_t = libc::c_long; --pub type dev_t = __dev_t; --pub type size_t = libc::c_ulong; -+use crate::common::*; -+ -+extern "C" { -+ fn sudo_debug_printf2_v1( -+ func: *const libc::c_char, -+ file: *const libc::c_char, -+ line: libc::c_int, -+ level: libc::c_int, -+ fmt: *const libc::c_char, -+ _: ... -+ ); -+} - - // #define PATH_MAX 4096 /* # chars in a path name including nul */ - pub const PATH_MAX: usize = 4096; -@@ -52,23 +35,10 @@ pub const PATH_MAX: usize = 4096; - // #define ENOMEM 12 /* Out of memory */ - pub const ENOMEM: libc::c_int = 12; - --// #define ERANGE 34 /* Math result not representable */ --pub const ERANGE: libc::c_int = 34; -- --// #define ENOENT 2 /* No such file or directory */ --pub const ENOENT: libc::c_int = 2; -- - pub const DT_CHR: libc::c_int = 2; - pub const DT_LNK: libc::c_int = 10; - pub const DT_UNKNOWN: libc::c_int = 0; - --// #define _PATH_DEV "/dev/" --macro_rules! _PATH_DEV { -- () => { -- b"/dev/\0" as *const u8 as *const libc::c_char -- }; --} -- - // console - macro_rules! _PATH_DEV_CONSOLE { - () => { -@@ -104,16 +74,6 @@ macro_rules! _PATH_DEV_STDERR { - }; - } - --// #define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR) --// #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) --// #define __S_IFMT 0170000 /* These bits determine file type. */ --// #define __S_IFCHR 0020000 /* Character device. */ --macro_rules! __S_IFMT { -- () => { -- 0o170000 -- }; --} -- - macro_rules! __S_IFCHR { - () => { - 0o020000 -@@ -122,7 +82,7 @@ macro_rules! __S_IFCHR { - - macro_rules! __S_ISTYPE { - ($mode:expr, $mask:expr) => { -- ((($mode) & __S_IFMT!()) == ($mask)) -+ ((($mode) & _S_IFMT!()) == ($mask)) - }; - } - -@@ -132,39 +92,12 @@ macro_rules! S_ISCHR { - }; - } - --// # define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ --// # define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ --// # define S_IWUSR __S_IWRITE /* Write by owner. */ --// #define __S_IWRITE 0200 /* Write by owner. */ --macro_rules! __S_IWRITE { -- () => { -- 0200 -- }; --} -- --macro_rules! S_IWUSR { -- () => { -- __S_IWRITE!() -- }; --} -- --macro_rules! S_IWGRP { -- () => { -- (S_IWUSR!() >> 3) -- }; --} -- --macro_rules! S_IWOTH { -- () => { -- (S_IWGRP!() >> 3) -- }; --} -- - #[repr(C)] - #[derive(Debug, Copy, Clone)] - pub struct __dirstream { - _unused: [u8; 0], - } -+pub type DIR = __dirstream; - - extern "C" { - fn sudo_conf_devsearch_path_v1() -> *const libc::c_char; -@@ -196,66 +129,18 @@ extern "C" { - fn opendir(__name: *const libc::c_char) -> *mut DIR; - fn dirfd(__dirp: *mut DIR) -> libc::c_int; - fn readdir(__dirp: *mut DIR) -> *mut dirent; -+ /* - fn sudo_debug_printf2_v1( -- func: *const libc::c_char, -- file: *const libc::c_char, -- lineno: libc::c_int, -- level: libc::c_int, -- fmt: *const libc::c_char, -- _: ... -- ); --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct timespec { -- pub tv_sec: __time_t, -- pub tv_nsec: __syscall_slong_t, --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct stat { -- pub st_dev: __dev_t, -- pub st_ino: __ino_t, -- #[cfg(target_arch = "x86_64")] -- pub st_nlink: __nlink_t, -- pub st_mode: __mode_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub st_nlink: __nlink_t, -- pub st_uid: __uid_t, -- pub st_gid: __gid_t, -- #[cfg(target_arch = "x86_64")] -- pub __pad0: libc::c_int, -- pub st_rdev: __dev_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad1: __dev_t, -- pub st_size: __off_t, -- pub st_blksize: __blksize_t, -- #[cfg(not(target_arch = "x86_64"))] -- pub __pad2: libc::c_int, -- pub st_blocks: __blkcnt_t, -- pub st_atim: timespec, -- pub st_mtim: timespec, -- pub st_ctim: timespec, -- #[cfg(target_arch = "x86_64")] -- pub __glibc_reserved: [__syscall_slong_t; 3], -- #[cfg(not(target_arch = "x86_64"))] -- pub __glibc_reserved: [libc::c_int; 2], --} -- --#[derive(Copy, Clone)] --#[repr(C)] --pub struct dirent { -- pub d_ino: __ino_t, -- pub d_off: __off_t, -- pub d_reclen: libc::c_ushort, -- pub d_type: libc::c_uchar, -- pub d_name: [libc::c_char; 256], -+ func: *const libc::c_char, -+ file: *const libc::c_char, -+ lineno: libc::c_int, -+ level: libc::c_int, -+ fmt: *const libc::c_char, -+ _: ... -+ ); -+ */ - } - --pub type DIR = __dirstream; -- - /* - * Device nodes to ignore. - */ -@@ -268,21 +153,14 @@ static mut ignore_devs: [*const libc::c_char; 4] = [ - - #[inline] - unsafe extern "C" fn fstat(mut __fd: libc::c_int, mut __statbuf: *mut stat) -> libc::c_int { -- #[cfg(target_arch = "x86_64")] -- return __fxstat(1 as libc::c_int, __fd, __statbuf); -- #[cfg(not(target_arch = "x86_64"))] -- return __fxstat(0 as libc::c_int, __fd, __statbuf); -+ return __fxstat(xstat_flag as libc::c_int, __fd, __statbuf); - } -- - #[inline] - unsafe extern "C" fn stat( - mut __path: *const libc::c_char, - mut __statbuf: *mut stat, - ) -> libc::c_int { -- #[cfg(target_arch = "x86_64")] -- return __xstat(1 as libc::c_int, __path, __statbuf); -- #[cfg(not(target_arch = "x86_64"))] -- return __xstat(0 as libc::c_int, __path, __statbuf); -+ return __xstat(xstat_flag as libc::c_int, __path, __statbuf); - } - - #[inline] -@@ -313,58 +191,23 @@ unsafe extern "C" fn sudo_ttyname_scan( - let mut pathbuf: [libc::c_char; PATH_MAX] = [0; PATH_MAX]; - let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; - let mut dp: *mut dirent = 0 as *mut dirent; -- -- let mut sb: stat = stat { -- st_dev: 0, -- st_ino: 0, -- #[cfg(target_arch = "x86_64")] -- st_nlink: 0, -- st_mode: 0, -- #[cfg(not(target_arch = "x86_64"))] -- st_nlink: 0, -- st_uid: 0, -- st_gid: 0, -- #[cfg(target_arch = "x86_64")] -- __pad0: 0, -- st_rdev: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad1: 0, -- st_size: 0, -- st_blksize: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad2: 0, -- st_blocks: 0, -- st_atim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_mtim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_ctim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- #[cfg(target_arch = "x86_64")] -- __glibc_reserved: [0; 3], -- #[cfg(not(target_arch = "x86_64"))] -- __glibc_reserved: [0; 2], -- }; -- -+ let mut sb: stat = sb_all_arch; - let mut i: libc::c_int = 0 as libc::c_int; - let mut d: *mut DIR = 0 as *mut DIR; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ -+ debug_decl!(SUDO_DEBUG_UTIL); - - 'done: loop { - if *dir.offset(0 as isize) as libc::c_int == '\u{0}' as i32 { - *__errno_location() = ENOENT; - break 'done; - } -+ - d = opendir(dir); - if d.is_null() { - break 'done; - } -+ - if fstat(dirfd(d), &mut sb) == -1 { - sudo_debug_printf!( - SUDO_DEBUG_ERROR | SUDO_DEBUG_LINENO, -@@ -382,71 +225,45 @@ unsafe extern "C" fn sudo_ttyname_scan( - *__errno_location() = ENOENT; - break 'done; - } -+ - sudo_debug_printf!( - SUDO_DEBUG_INFO | SUDO_DEBUG_LINENO, - b"scanning for dev %u in %s\0" as *const u8 as *const libc::c_char, - rdev as libc::c_uint, - dir - ); -+ - sdlen = strlen(dir); - while sdlen > 0 && dir.offset((sdlen - 1) as isize) as libc::c_int == '/' as i32 { - sdlen -= 1; - } -+ - if (sdlen + 1) >= ::std::mem::size_of::<[libc::c_char; PATH_MAX]>() as libc::c_ulong { - *__errno_location() = ERANGE; - break 'done; - } -+ - memcpy( - pathbuf.as_mut_ptr() as *mut libc::c_void, - dir as *const libc::c_void, - sdlen, - ); -- sdlen += 1; -- pathbuf[sdlen as usize] = '/' as i32 as libc::c_char; -- dp = readdir(d); -- while !dp.is_null() { -- let mut sb: stat = stat { -- st_dev: 0, -- st_ino: 0, -- #[cfg(target_arch = "x86_64")] -- st_nlink: 0, -- st_mode: 0, -- #[cfg(not(target_arch = "x86_64"))] -- st_nlink: 0, -- st_uid: 0, -- st_gid: 0, -- #[cfg(target_arch = "x86_64")] -- __pad0: 0, -- st_rdev: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad1: 0, -- st_size: 0, -- st_blksize: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad2: 0, -- st_blocks: 0, -- st_atim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_mtim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_ctim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- #[cfg(target_arch = "x86_64")] -- __glibc_reserved: [0; 3], -- #[cfg(not(target_arch = "x86_64"))] -- __glibc_reserved: [0; 2], -- }; -+ let fresh0 = sdlen; -+ sdlen = sdlen.wrapping_add(1); -+ pathbuf[fresh0 as usize] = '/' as i32 as libc::c_char; -+ -+ loop { -+ dp = readdir(d); -+ if dp.is_null() { -+ break; -+ } -+ let mut sb: stat = sb_all_arch; - - /* Skip anything starting with "." */ - if (*dp).d_name[0 as usize] as libc::c_int == '.' as i32 { - continue; - } -+ - pathbuf[sdlen as usize] = '\u{0}' as i32 as libc::c_char; - if sudo_strlcat( - pathbuf.as_mut_ptr(), -@@ -462,6 +279,7 @@ unsafe extern "C" fn sudo_ttyname_scan( - ); - continue; - } -+ - /* Ignore device nodes listed in ignore_devs[]. */ - i = 0; - while !ignore_devs[i as usize].is_null() { -@@ -493,6 +311,7 @@ unsafe extern "C" fn sudo_ttyname_scan( - continue; - } - } -+ - if stat(pathbuf.as_mut_ptr(), &mut sb) == -1 { - sudo_debug_printf!( - SUDO_DEBUG_ERROR | SUDO_DEBUG_LINENO | SUDO_DEBUG_ERRNO, -@@ -501,6 +320,7 @@ unsafe extern "C" fn sudo_ttyname_scan( - ); - continue; - } -+ - if S_ISCHR!(sb.st_mode) && sb.st_rdev == rdev { - sudo_debug_printf!( - SUDO_DEBUG_INFO | SUDO_DEBUG_LINENO, -@@ -540,44 +360,9 @@ unsafe extern "C" fn sudo_dev_check( - mut buf: *mut libc::c_char, - mut buflen: size_t, - ) -> *mut libc::c_char { -- let mut sb: stat = stat { -- st_dev: 0, -- st_ino: 0, -- #[cfg(target_arch = "x86_64")] -- st_nlink: 0, -- st_mode: 0, -- #[cfg(not(target_arch = "x86_64"))] -- st_nlink: 0, -- st_uid: 0, -- st_gid: 0, -- #[cfg(target_arch = "x86_64")] -- __pad0: 0, -- st_rdev: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad1: 0, -- st_size: 0, -- st_blksize: 0, -- #[cfg(not(target_arch = "x86_64"))] -- __pad2: 0, -- st_blocks: 0, -- st_atim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_mtim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- st_ctim: timespec { -- tv_sec: 0, -- tv_nsec: 0, -- }, -- #[cfg(target_arch = "x86_64")] -- __glibc_reserved: [0; 3], -- #[cfg(not(target_arch = "x86_64"))] -- __glibc_reserved: [0; 2], -- }; -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ let mut sb: stat = sb_all_arch; -+ debug_decl!(SUDO_DEBUG_UTIL); -+ - if stat(devname, &mut sb) == 0 { - if S_ISCHR!(sb.st_mode) && sb.st_rdev == rdev { - sudo_debug_printf!( -@@ -586,6 +371,7 @@ unsafe extern "C" fn sudo_dev_check( - rdev, - devname - ); -+ - if sudo_strlcpy(buf, devname, buflen) < buflen { - debug_return_str!(buf); - } -@@ -599,6 +385,7 @@ unsafe extern "C" fn sudo_dev_check( - *__errno_location() = ERANGE; - } // if S_ISCHR( - } //if stat(devname -+ - sudo_debug_printf!( - SUDO_DEBUG_INFO | SUDO_DEBUG_LINENO, - b"comparing dev %u to %s: no\0" as *const u8 as *const libc::c_char, -@@ -627,7 +414,7 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - let mut ep: *const libc::c_char = 0 as *const libc::c_char; - let mut len: size_t = 0 as size_t; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - /* - * First, check /dev/console. -@@ -639,6 +426,7 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - */ - devsearch = sudo_conf_devsearch_path_v1(); - devsearch_end = devsearch.offset(strlen(devsearch) as isize); -+ - cp = sudo_strsplit_v1( - devsearch, - devsearch_end, -@@ -662,12 +450,14 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - ); - continue; - } // if len >= -+ - memcpy( - path.as_mut_ptr() as *mut libc::c_void, - cp as *const libc::c_void, - len, - ); - path[len as usize] = '\u{0}' as i32 as libc::c_char; -+ - if strcmp(path.as_mut_ptr(), _PATH_DEV_PTS!()) == 0 { - /* Special case /dev/pts */ - len = snprintf( -@@ -677,6 +467,7 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - _PATH_DEV!(), - gnu_dev_minor(rdev), - ) as size_t; -+ - if len > ::std::mem::size_of::<[libc::c_char; PATH_MAX]>() as libc::c_ulong { - sudo_debug_printf!( - SUDO_DEBUG_ERROR | SUDO_DEBUG_LINENO, -@@ -705,6 +496,7 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - break; - } - } -+ - cp = sudo_strsplit_v1( - 0 as *const libc::c_char, - devsearch_end, -@@ -713,6 +505,5 @@ pub unsafe extern "C" fn sudo_ttyname_dev_v1( - ); - } // while !cp.is_null() - } // ret.is_null() -- - debug_return_str!(ret as *mut libc::c_char) - } -diff --git a/lib/util/src/ttysize.rs b/lib/util/src/ttysize.rs -index 0e13004..359f7a9 100644 ---- a/lib/util/src/ttysize.rs -+++ b/lib/util/src/ttysize.rs -@@ -14,36 +14,7 @@ - unused_mut - )] - --use crate::sudo_debug::sudo_debug_enter_v1; --use crate::sudo_debug::sudo_debug_exit_int_v1; --use crate::sudo_debug::sudo_debug_exit_v1; --use crate::sudo_debug_macro::SUDO_DEBUG_UTIL; -- --/* Standard file descriptors. */ --// #define STDERR_FILENO 2 /* Standard error output. */ --#[macro_export] --macro_rules! STDERR_FILENO { -- () => { -- 2 -- }; --} -- --// #define TIOCGWINSZ 0x5413 --#[macro_export] --macro_rules! TIOCGWINSZ { -- () => { -- 0x5413 -- }; --} -- --// #define __INT_MAX__ 2147483647 --// #define INT_MAX __INT_MAX__ --#[macro_export] --macro_rules! INT_MAX { -- () => { -- 2147483647 -- }; --} -+use crate::common::*; - - extern "C" { - fn ioctl(fd: libc::c_int, __request: libc::c_ulong, ...) -> libc::c_int; -@@ -57,15 +28,6 @@ extern "C" { - - } - --#[derive(Copy, Clone)] --#[repr(C)] --pub struct winsize { -- pub ws_row: libc::c_ushort, -- pub ws_col: libc::c_ushort, -- pub ws_xpixel: libc::c_ushort, -- pub ws_ypixel: libc::c_ushort, --} -- - #[no_mangle] - pub unsafe extern "C" fn get_ttysize_ioctl( - rowp: *mut libc::c_int, -@@ -78,7 +40,7 @@ pub unsafe extern "C" fn get_ttysize_ioctl( - ws_ypixel: 0, - }; - -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if (ioctl(STDERR_FILENO!(), TIOCGWINSZ!(), &wsize) == 0) - && wsize.ws_row != 0 -@@ -96,7 +58,7 @@ pub unsafe extern "C" fn sudo_get_ttysize_v1( - mut rowp: *mut libc::c_int, - mut colp: *mut libc::c_int, - ) { -- debug_decl!(stdext::function_name!().as_ptr(), SUDO_DEBUG_UTIL); -+ debug_decl!(SUDO_DEBUG_UTIL); - - if get_ttysize_ioctl(rowp, colp) == -(1 as libc::c_int) { - let mut p: *mut libc::c_char = 0 as *mut libc::c_char; --- -2.33.0 - diff --git a/utsudo-0.0.1.tar.gz b/utsudo-0.0.1.tar.gz deleted file mode 100644 index ff51db246a65d445cb513f0783ff5559dee92e5f..0000000000000000000000000000000000000000 Binary files a/utsudo-0.0.1.tar.gz and /dev/null differ diff --git a/utsudo-0.0.2.tar.gz b/utsudo-0.0.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f4b055583d7f7a242186ba7df050f583b97e50ca Binary files /dev/null and b/utsudo-0.0.2.tar.gz differ diff --git a/utsudo.spec b/utsudo.spec index e0b26efc3930aa7e07d000172b94b0b6f9ee6c57..465ff09eabd7ddd5c088575a8928152ef984465a 100644 --- a/utsudo.spec +++ b/utsudo.spec @@ -2,8 +2,8 @@ ExcludeArch: i686 Summary: The tudo respect sudo Name: utsudo -Version: 0.0.1 -Release: 0.05 +Version: 0.0.2 +Release: 0.03 License: ISC Group: Applications/System URL: https://www.sudo.ws/ @@ -37,9 +37,8 @@ BuildRequires: cargo BuildRequires: rust BuildRequires: patchelf -Patch0001: 0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch -Patch0002: 0002-change-struct-stat-for-arm-and-loongarch.patch -Patch0003: 0003-fix-bug-utsudoedit-error.patch +Patch0001: 0001-fix-unable-to-callocate-memory.patch +Patch0002: 0002-fix-use_pty-function-error.patch %description Sudo (superuser do) allows a system administrator to give certain @@ -54,10 +53,8 @@ on many different machines. %prep %setup -q - %patch0001 -p1 %patch0002 -p1 -%patch0003 -p1 %build # Remove bundled copy of zlib @@ -148,6 +145,23 @@ rm utsudo.lang utsudoers.lang mkdir -p $RPM_BUILD_ROOT/etc/pam.d mkdir -p $RPM_BUILD_ROOT/usr/share/doc/utsudo +cat > $RPM_BUILD_ROOT/etc/pam.d/utsudo << EOF +#%%PAM-1.0 +auth include system-auth +account include system-auth +password include system-auth +session include system-auth +EOF + +cat > $RPM_BUILD_ROOT/etc/pam.d/utsudo-i << EOF +#%%PAM-1.0 +auth include sudo +account include sudo +password include sudo +session optional pam_keyinit.so force revoke +session include sudo +EOF + %clean rm -rf $RPM_BUILD_ROOT @@ -158,6 +172,8 @@ rm -rf $RPM_BUILD_ROOT %attr(0640,root,root) %config(noreplace) /etc/utsudo.conf %attr(0640,root,root) %config(noreplace) %{_sysconfdir}/utsudo-ldap.conf %attr(0750,root,root) %dir /etc/utsudoers.d/ +%config(noreplace) /etc/pam.d/utsudo +%config(noreplace) /etc/pam.d/utsudo-i %attr(0644,root,root) %{_tmpfilesdir}/utsudo.conf %attr(0644,root,root) /etc/dnf/protected.d/utsudo.conf %dir /var/db/sudo @@ -166,12 +182,13 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/utsudoedit %dir %{_libexecdir}/utsudo %attr(0755,root,root) %{_libexecdir}/utsudo/sesh -%attr(0644,root,root) %{_libexecdir}/utsudo/sudo_noexec.so +%attr(0644,root,root) %{_libexecdir}/utsudo/utsudo_noexec.so %attr(0644,root,root) %{_libexecdir}/utsudo/sudoers.so %attr(0644,root,root) %{_libexecdir}/utsudo/group_file.so %attr(0644,root,root) %{_libexecdir}/utsudo/system_group.so %{_libexecdir}/utsudo/libutsudo_util.so %{_libexecdir}/utsudo/libutsudo_util.so.? +%{_libexecdir}/utsudo/libutsudo_variadic.so %attr(0644,root,root) %{_libexecdir}/utsudo/libutsudo_util.so.?.?.? %dir %{_pkgdocdir}/ %{!?_licensedir:%global license %%doc} @@ -182,8 +199,14 @@ rm -rf $RPM_BUILD_ROOT /bin/chmod 0440 /etc/utsudoers || : %changelog -* Wed Dec 20 2023 Bianguangze - 0.0.1-0.05 -- Add Patch: 0003-fix-bug-utsudoedit-error.patch +* Sun Apr 28 2024 binlingyu - 0.0.2-0.03 +- Add Patch: 0002-fix-use_pty-function-error.patch + +* Fri Apr 12 2024 bianguangze - 0.0.2-0.02 +- fix unable to callocate memory. + +* Sun Apr 7 2024 bianguangze - 0.0.2-0.01 +- 升级至0.0.2大版本,解决部分编译报错. * Wed Sep 06 2023 Lujun - 0.0.1-0.04 - Add Patch: 0002-change-struct-stat-for-arm-and-loongarch.patch