升级版本至0.0.2

(cherry picked from commit 71da3ee8fa92eb60929416af02f3bf58911dbdb8)
This commit is contained in:
bianguangze 2024-04-02 17:52:11 +08:00 committed by openeuler-sync-bot
parent 0111e52948
commit f9e4c1ff18
5 changed files with 29 additions and 855 deletions

View File

@ -1,387 +0,0 @@
From 2c066e021947d7a876cf4fd22cfdc8aa783401ec Mon Sep 17 00:00:00 2001
From: wanglujun <wanglujun@uniontech.com>
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

View File

@ -1,442 +0,0 @@
From fe70669cd3406b0f964d6b025d55652dc24fc47e Mon Sep 17 00:00:00 2001
From: wanglujun <wanglujun@uniontech.com>
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 <sys/stat.h> 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

Binary file not shown.

BIN
utsudo-0.0.2.tar.gz Normal file

Binary file not shown.

View File

@ -2,8 +2,8 @@ ExcludeArch: i686
Summary: The tudo respect sudo Summary: The tudo respect sudo
Name: utsudo Name: utsudo
Version: 0.0.1 Version: 0.0.2
Release: 0.04 Release: 0.01
License: ISC License: ISC
Group: Applications/System Group: Applications/System
URL: https://www.sudo.ws/ URL: https://www.sudo.ws/
@ -13,12 +13,11 @@ Source1: utsudoers
Source2: utsudo-ldap.conf Source2: utsudo-ldap.conf
Source3: utsudo.conf Source3: utsudo.conf
Requires: pam Requires: /etc/pam.d/system-auth
Requires: vim-minimal Requires: /usr/bin/vi
Requires(post): coreutils Requires(post): /bin/chmod
Requires: sudo
BuildRequires: sendmail BuildRequires: /usr/sbin/sendmail
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: automake BuildRequires: automake
BuildRequires: bison BuildRequires: bison
@ -37,9 +36,6 @@ BuildRequires: cargo
BuildRequires: rust BuildRequires: rust
BuildRequires: patchelf BuildRequires: patchelf
Patch0001: 0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch
Patch0002: 0002-change-struct-stat-for-arm-and-loongarch.patch
%description %description
Sudo (superuser do) allows a system administrator to give certain Sudo (superuser do) allows a system administrator to give certain
users (or groups of users) the ability to run some (or all) commands users (or groups of users) the ability to run some (or all) commands
@ -54,9 +50,6 @@ on many different machines.
%prep %prep
%setup -q %setup -q
%patch0001 -p1
%patch0002 -p1
%build %build
# Remove bundled copy of zlib # Remove bundled copy of zlib
rm -rf zlib/ rm -rf zlib/
@ -146,6 +139,23 @@ rm utsudo.lang utsudoers.lang
mkdir -p $RPM_BUILD_ROOT/etc/pam.d mkdir -p $RPM_BUILD_ROOT/etc/pam.d
mkdir -p $RPM_BUILD_ROOT/usr/share/doc/utsudo 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 %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -156,6 +166,8 @@ rm -rf $RPM_BUILD_ROOT
%attr(0640,root,root) %config(noreplace) /etc/utsudo.conf %attr(0640,root,root) %config(noreplace) /etc/utsudo.conf
%attr(0640,root,root) %config(noreplace) %{_sysconfdir}/utsudo-ldap.conf %attr(0640,root,root) %config(noreplace) %{_sysconfdir}/utsudo-ldap.conf
%attr(0750,root,root) %dir /etc/utsudoers.d/ %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) %{_tmpfilesdir}/utsudo.conf
%attr(0644,root,root) /etc/dnf/protected.d/utsudo.conf %attr(0644,root,root) /etc/dnf/protected.d/utsudo.conf
%dir /var/db/sudo %dir /var/db/sudo
@ -164,12 +176,13 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/utsudoedit %{_bindir}/utsudoedit
%dir %{_libexecdir}/utsudo %dir %{_libexecdir}/utsudo
%attr(0755,root,root) %{_libexecdir}/utsudo/sesh %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/sudoers.so
%attr(0644,root,root) %{_libexecdir}/utsudo/group_file.so %attr(0644,root,root) %{_libexecdir}/utsudo/group_file.so
%attr(0644,root,root) %{_libexecdir}/utsudo/system_group.so %attr(0644,root,root) %{_libexecdir}/utsudo/system_group.so
%{_libexecdir}/utsudo/libutsudo_util.so %{_libexecdir}/utsudo/libutsudo_util.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.?.?.? %attr(0644,root,root) %{_libexecdir}/utsudo/libutsudo_util.so.?.?.?
%dir %{_pkgdocdir}/ %dir %{_pkgdocdir}/
%{!?_licensedir:%global license %%doc} %{!?_licensedir:%global license %%doc}
@ -180,18 +193,8 @@ rm -rf $RPM_BUILD_ROOT
/bin/chmod 0440 /etc/utsudoers || : /bin/chmod 0440 /etc/utsudoers || :
%changelog %changelog
* Wed Sep 06 2023 Lujun <wanglujun@uniontech.com> - 0.0.1-0.04 * Fri Mar 29 2024 bianguangze <bianguangze@uniontech.com> - 0.0.2-0.01
- Add Patch: 0002-change-struct-stat-for-arm-and-loongarch.patch - passd compiling and sync version.
* Mon Sep 04 2023 Lujun <wanglujun@uniontech.com> - 0.0.1-0.03
- Add Requires: sudo
- Del /etc/pam.d/sudo and /etc/pam.d/sudo-i fix file conflict.
* Sat Aug 19 2023 senlin <xiasenlin1@huawei.com> - 0.0.1-0.02
- Replace command file with rpm to avoid the build-system being unable to recognize it
* Mon Aug 07 2023 Lujun <wanglujun@uniontech.com> - 0.0.1-0.01
- Add Patch: 0001-fix-compile-error-undefined-reference-to-sys_sigabbr.patch
* Tue May 10 2022 Lujun <wanglujun@uniontech.com> - 0.0.1 * Tue May 10 2022 Lujun <wanglujun@uniontech.com> - 0.0.1
- init. - init.