Skip to content

Commit 58c2df5

Browse files
bjorn3squell
authored andcommitted
Revert "Implement support for NOEXEC (#1073)"
This is spawning a thread before fork, which is UB. This will need to be fixed, but given that we plan to do a release in a couple of days, let's remove NOEXEC support for now and re-add fixed NOEXEC support after the release. This reverts commit ca76a70, reversing changes made to 5ca07b1.
1 parent d0d53b3 commit 58c2df5

File tree

15 files changed

+16
-534
lines changed

15 files changed

+16
-534
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ name = "visudo"
2929
path = "bin/visudo.rs"
3030

3131
[dependencies]
32-
libc = "0.2.152"
32+
libc = "0.2.149"
3333
glob = "0.3.0"
3434
log = { version = "0.4.11", features = ["std"] }
3535

src/common/context.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub struct Context {
3131
pub process: Process,
3232
// policy
3333
pub use_pty: bool,
34-
pub noexec: bool,
3534
}
3635

3736
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -94,7 +93,6 @@ impl Context {
9493
non_interactive: sudo_options.non_interactive,
9594
process: Process::new(),
9695
use_pty: true,
97-
noexec: false,
9896
})
9997
}
10098

@@ -119,7 +117,6 @@ impl Context {
119117
non_interactive: sudo_options.non_interactive,
120118
process: Process::new(),
121119
use_pty: true,
122-
noexec: false,
123120
})
124121
}
125122

@@ -164,7 +161,6 @@ impl Context {
164161
non_interactive: sudo_options.non_interactive,
165162
process: Process::new(),
166163
use_pty: true,
167-
noexec: false,
168164
})
169165
}
170166

@@ -183,7 +179,6 @@ impl Context {
183179
group: &self.target_group,
184180

185181
use_pty: self.use_pty,
186-
noexec: self.noexec,
187182
})
188183
}
189184
}

src/defaults/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ defaults! {
3636
env_editor = true
3737
rootpw = false
3838
targetpw = false
39-
noexec = false
4039

4140
passwd_tries = 3 [0..=1000]
4241

src/exec/mod.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mod event;
22
mod io_util;
33
mod no_pty;
4-
#[cfg(target_os = "linux")]
5-
mod noexec;
64
mod use_pty;
75

86
use std::{
@@ -26,9 +24,7 @@ use crate::{
2624
signal::{consts::*, signal_name},
2725
wait::{Wait, WaitError, WaitOptions},
2826
},
29-
system::{
30-
kill, set_target_user, signal::SignalNumber, term::UserTerm, FileCloser, Group, User,
31-
},
27+
system::{kill, set_target_user, signal::SignalNumber, term::UserTerm, Group, User},
3228
};
3329

3430
use self::{
@@ -47,7 +43,6 @@ pub struct RunOptions<'a> {
4743
pub group: &'a Group,
4844

4945
pub use_pty: bool,
50-
pub noexec: bool,
5146
}
5247

5348
/// Based on `ogsudo`s `exec_pty` function.
@@ -58,8 +53,6 @@ pub fn run_command(
5853
options: RunOptions<'_>,
5954
env: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>,
6055
) -> io::Result<ExitReason> {
61-
let mut file_closer = FileCloser::new();
62-
6356
// FIXME: should we pipe the stdio streams?
6457
let qualified_path = options.command;
6558
let mut command = Command::new(qualified_path);
@@ -81,16 +74,6 @@ pub fn run_command(
8174
command.arg0(OsStr::from_bytes(&process_name));
8275
}
8376

84-
if options.noexec {
85-
#[cfg(target_os = "linux")]
86-
noexec::add_noexec_filter(&mut command, &mut file_closer);
87-
88-
#[cfg(not(target_os = "linux"))]
89-
return Err(io::Error::other(
90-
"NOEXEC is currently only supported on Linux",
91-
));
92-
}
93-
9477
// Decide if the pwd should be changed. `--chdir` takes precedence over `-i`.
9578
let path = options
9679
.chdir
@@ -125,14 +108,14 @@ pub fn run_command(
125108

126109
if options.use_pty {
127110
match UserTerm::open() {
128-
Ok(user_tty) => exec_pty(sudo_pid, file_closer, command, user_tty),
111+
Ok(user_tty) => exec_pty(sudo_pid, command, user_tty),
129112
Err(err) => {
130113
dev_info!("Could not open user's terminal, not allocating a pty: {err}");
131-
exec_no_pty(sudo_pid, file_closer, command)
114+
exec_no_pty(sudo_pid, command)
132115
}
133116
}
134117
} else {
135-
exec_no_pty(sudo_pid, file_closer, command)
118+
exec_no_pty(sudo_pid, command)
136119
}
137120
}
138121

src/exec/no_pty.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ use crate::{
2626
},
2727
};
2828

29-
pub(super) fn exec_no_pty(
30-
sudo_pid: ProcessId,
31-
mut file_closer: FileCloser,
32-
mut command: Command,
33-
) -> io::Result<ExitReason> {
29+
pub(super) fn exec_no_pty(sudo_pid: ProcessId, mut command: Command) -> io::Result<ExitReason> {
3430
// FIXME (ogsudo): Initialize the policy plugin's session here.
3531

3632
// Block all the signals until we are done setting up the signal handlers so we don't miss
@@ -43,6 +39,8 @@ pub(super) fn exec_no_pty(
4339
}
4440
};
4541

42+
let mut file_closer = FileCloser::new();
43+
4644
// FIXME (ogsudo): Some extra config happens here if selinux is available.
4745

4846
// Use a pipe to get the IO error if `exec` fails.

0 commit comments

Comments
 (0)