fix use_pty function error
(cherry picked from commit d5765439addb2f7e3d759a904270c009c75b764b)
This commit is contained in:
parent
ddecc5a59e
commit
43ad6e07b6
180
0002-fix-use_pty-function-error.patch
Normal file
180
0002-fix-use_pty-function-error.patch
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
From 3b59a1cc7b3d9ea38ae3501c7a4e09597f7acdaa Mon Sep 17 00:00:00 2001
|
||||||
|
From: binlingyu <binlingyu@uniontech.com>
|
||||||
|
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
|
||||||
|
|
||||||
@ -3,7 +3,7 @@ ExcludeArch: i686
|
|||||||
Summary: The tudo respect sudo
|
Summary: The tudo respect sudo
|
||||||
Name: utsudo
|
Name: utsudo
|
||||||
Version: 0.0.2
|
Version: 0.0.2
|
||||||
Release: 0.02
|
Release: 0.03
|
||||||
License: ISC
|
License: ISC
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: https://www.sudo.ws/
|
URL: https://www.sudo.ws/
|
||||||
@ -38,6 +38,7 @@ BuildRequires: rust
|
|||||||
BuildRequires: patchelf
|
BuildRequires: patchelf
|
||||||
|
|
||||||
Patch0001: 0001-fix-unable-to-callocate-memory.patch
|
Patch0001: 0001-fix-unable-to-callocate-memory.patch
|
||||||
|
Patch0002: 0002-fix-use_pty-function-error.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Sudo (superuser do) allows a system administrator to give certain
|
Sudo (superuser do) allows a system administrator to give certain
|
||||||
@ -53,6 +54,7 @@ on many different machines.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch0001 -p1
|
%patch0001 -p1
|
||||||
|
%patch0002 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
# Remove bundled copy of zlib
|
# Remove bundled copy of zlib
|
||||||
@ -197,6 +199,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
/bin/chmod 0440 /etc/utsudoers || :
|
/bin/chmod 0440 /etc/utsudoers || :
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Apr 28 2024 binlingyu <binlingyu@uniontech.com> - 0.0.2-0.03
|
||||||
|
- Add Patch: 0002-fix-use_pty-function-error.patch
|
||||||
|
|
||||||
* Fri Apr 12 2024 bianguangze <bianguangze@uniontech.com> - 0.0.2-0.02
|
* Fri Apr 12 2024 bianguangze <bianguangze@uniontech.com> - 0.0.2-0.02
|
||||||
- fix unable to callocate memory.
|
- fix unable to callocate memory.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user