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-use_utsudo-A-error.patch b/0003-fix-use_utsudo-A-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..52de4d5d002b7ff7e2f0b57b411c42b33ba77d95 --- /dev/null +++ b/0003-fix-use_utsudo-A-error.patch @@ -0,0 +1,34 @@ +From 003b10476eea89178de048fb79e6d4a47109ce85 Mon Sep 17 00:00:00 2001 +From: bianguangze +Date: Tue, 11 Mar 2025 17:30:48 +0800 +Subject: [PATCH] bgz test patch + +--- + src/tgetpass.rs | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/tgetpass.rs b/src/tgetpass.rs +index d519d69..a9e6494 100644 +--- a/src/tgetpass.rs ++++ b/src/tgetpass.rs +@@ -244,7 +244,7 @@ pub unsafe extern "C" fn tgetpass( + + fflush(stdout); + if askpass.is_null() { +- askpass = getenv_unhooked(b"SUDO_ASKPASS\0" as *const u8 as *const libc::c_char); ++ askpass = getenv_unhooked(b"UTSUDO_ASKPASS\0" as *const u8 as *const libc::c_char); + if askpass.is_null() || *askpass as libc::c_int == '\0' as i32 { + askpass = sudo_conf_askpass_path_v1(); + } +@@ -272,7 +272,7 @@ pub unsafe extern "C" fn tgetpass( + if ISSET!(flags, TGP_ASKPASS) != 0 { + if askpass.is_null() || *askpass as libc::c_int == '\0' as i32 { + sudo_fatalx!( +- b"no askpass program specified, try setting SUDO_ASKPASS\0" as *const u8 ++ b"no askpass program specified, try setting UTSUDO_ASKPASS\0" as *const u8 + as *const libc::c_char, + ); + } +-- +2.48.1 + diff --git a/0004-fix-use_utsudo-T-error.patch b/0004-fix-use_utsudo-T-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..d7ec9c99ed692ba8e08b6da4c402296b27ccba4a --- /dev/null +++ b/0004-fix-use_utsudo-T-error.patch @@ -0,0 +1,39 @@ +From 6f0a0eeceb673aaebab4dbb29d556557798963bf Mon Sep 17 00:00:00 2001 +From: bianguangze +Date: Wed, 12 Mar 2025 10:02:27 +0800 +Subject: [PATCH] T + +--- + lib/util/src/sudo_conf.rs | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/lib/util/src/sudo_conf.rs b/lib/util/src/sudo_conf.rs +index 3023640..4078901 100644 +--- a/lib/util/src/sudo_conf.rs ++++ b/lib/util/src/sudo_conf.rs +@@ -174,18 +174,21 @@ macro_rules! _PATH_SUDO_NOEXEC { + } + + // # define _PATH_SUDO_PLUGIN_DIR "/usr/libexec/utsudo/" +-#[cfg(target_arch = "x86_64")] ++//#[cfg(target_arch = "x86_64")] + macro_rules! _PATH_SUDO_PLUGIN_DIR { + () => { + (b"/usr/libexec/utsudo/\0" as *const u8 as *const libc::c_char as *mut libc::c_char) + }; + } ++ ++/* + #[cfg(not(target_arch = "x86_64"))] + macro_rules! _PATH_SUDO_PLUGIN_DIR { + () => { + (b"/usr/libexec/sudo/\0" as *const u8 as *const libc::c_char as *mut libc::c_char) + }; + } ++*/ + + macro_rules! _PATH_SUDO_DEVSEARCH { + () => { +-- +2.48.1 + 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 12c9f9f831a36733ce88c10a5efe8844d078c2e1..98dbc3b1ab12961eb2496f814353097fcde808d5 100644 --- a/utsudo.spec +++ b/utsudo.spec @@ -2,7 +2,7 @@ ExcludeArch: i686 Summary: The tudo respect sudo Name: utsudo -Version: 0.0.1 +Version: 0.0.2 Release: 0.04 License: ISC Group: Applications/System @@ -37,8 +37,10 @@ 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 +Patch0001: 0001-fix-unable-to-callocate-memory.patch +Patch0002: 0002-fix-use_pty-function-error.patch +Patch0003: 0003-fix-use_utsudo-A-error.patch +Patch0004: 0004-fix-use_utsudo-T-error.patch %description Sudo (superuser do) allows a system administrator to give certain @@ -53,9 +55,10 @@ on many different machines. %prep %setup -q - %patch0001 -p1 %patch0002 -p1 +%patch0003 -p1 +%patch0004 -p1 %build # Remove bundled copy of zlib @@ -146,6 +149,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 @@ -156,6 +176,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 @@ -164,12 +186,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} @@ -180,6 +203,19 @@ rm -rf $RPM_BUILD_ROOT /bin/chmod 0440 /etc/utsudoers || : %changelog +* Wed Mar 12 2025 bianguangze - 0.0.2-0.04 +- Add Patch: 0003-fix-use_utsudo-A-error.patch +- Add Patch: 0004-fix-use_utsudo-T-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