Skip to content

Commit b24de8a

Browse files
bjorn3squell
authored andcommitted
Unconditionally enable sudoedit support
sudoedit support has been enabled by default since 0.2.8.
1 parent 50437b2 commit b24de8a

File tree

9 files changed

+3
-25
lines changed

9 files changed

+3
-25
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ libc = "0.2.152"
3434
glob = "0.3.0"
3535

3636
[features]
37-
default = ["sudoedit"]
37+
default = []
3838

3939
# when enabled, use "sudo-i" PAM service name for sudo -i instead of "sudo"
4040
# ONLY ENABLE THIS FEATURE if you know that original sudo uses "sudo-i"
@@ -52,9 +52,7 @@ dev = []
5252
# compilation using "cargo --all-features", which should not be used on sudo-rs
5353
do-not-use-all-features = []
5454

55-
# whether to enable 'sudoedit' (this will become a default feature, or
56-
# perhaps we can just remove the feature flag altogether)
57-
# NOTE: this is currently work in progress and *NOT* implemented
55+
# sudoedit support is now always enabled. this feature only exists for back compat reasons
5856
sudoedit = []
5957

6058
[profile.release]

src/common/context.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{env, io};
22

33
use crate::common::{HARDENED_ENUM_VALUE_0, HARDENED_ENUM_VALUE_1, HARDENED_ENUM_VALUE_2};
44
use crate::exec::{RunOptions, Umask};
5-
#[cfg_attr(not(feature = "sudoedit"), allow(unused_imports))]
65
use crate::sudo::{SudoEditOptions, SudoListOptions, SudoRunOptions, SudoValidateOptions};
76
use crate::sudoers::Sudoers;
87
use crate::system::{audit::sudo_call, Group, Hostname, Process, User};
@@ -36,7 +35,6 @@ pub struct Context {
3635
pub umask: Umask,
3736
pub noninteractive_auth: bool,
3837
// sudoedit
39-
#[cfg_attr(not(feature = "sudoedit"), allow(unused))]
4038
pub files_to_edit: Vec<Option<SudoPath>>,
4139
}
4240

@@ -111,7 +109,6 @@ impl Context {
111109
})
112110
}
113111

114-
#[cfg(feature = "sudoedit")]
115112
pub fn from_edit_opts(sudo_options: SudoEditOptions) -> Result<Context, Error> {
116113
use std::path::Path;
117114
let hostname = Hostname::resolve();

src/sudo/cli/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ use std::{borrow::Cow, mem};
66
use crate::common::{SudoPath, SudoString};
77

88
pub mod help;
9-
#[cfg_attr(not(feature = "sudoedit"), allow(unused))]
109
pub mod help_edit;
1110

1211
#[cfg(test)]
1312
mod tests;
1413

15-
#[cfg_attr(not(feature = "sudoedit"), allow(dead_code))]
1614
pub enum SudoAction {
1715
Edit(SudoEditOptions),
1816
Help(SudoHelpOptions),
@@ -222,7 +220,6 @@ impl TryFrom<SudoOptions> for SudoValidateOptions {
222220
}
223221

224222
// sudo -e [-ABkNnS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ...
225-
#[cfg_attr(not(feature = "sudoedit"), allow(dead_code))]
226223
pub struct SudoEditOptions {
227224
// -B
228225
pub bell: bool,

src/sudo/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::path::PathBuf;
1515

1616
mod cli;
1717
pub(crate) use cli::{SudoEditOptions, SudoListOptions, SudoRunOptions, SudoValidateOptions};
18-
#[cfg(feature = "sudoedit")]
1918
mod edit;
2019

2120
pub(crate) mod diagnostic;
@@ -119,13 +118,7 @@ fn sudo_process() -> Result<(), Error> {
119118
}
120119
}
121120
SudoAction::List(options) => pipeline::run_list(options),
122-
#[cfg(feature = "sudoedit")]
123121
SudoAction::Edit(options) => pipeline::run_edit(options),
124-
#[cfg(not(feature = "sudoedit"))]
125-
SudoAction::Edit(_) => {
126-
eprintln_ignore_io_error!("error: `--edit` flag has not yet been implemented");
127-
std::process::exit(1);
128-
}
129122
},
130123
Err(e) => {
131124
eprintln_ignore_io_error!("{e}\n{}", usage_msg);

src/sudo/pipeline.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use crate::system::{escape_os_str_lossy, Process};
2121
mod list;
2222
pub(super) use list::run_list;
2323

24-
#[cfg(feature = "sudoedit")]
2524
mod edit;
26-
#[cfg(feature = "sudoedit")]
2725
pub(super) use edit::run_edit;
2826

2927
fn read_sudoers() -> Result<Sudoers, Error> {

src/sudoers/policy.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ impl Judgement {
145145
}
146146
}
147147

148-
#[cfg_attr(not(feature = "sudoedit"), allow(unused))]
149148
pub(crate) fn preferred_editor(&self) -> std::path::PathBuf {
150149
super::select_editor(&self.settings, true)
151150
}

src/system/audit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg_attr(not(feature = "sudoedit"), allow(dead_code))]
21
use std::collections::HashSet;
32
use std::ffi::{CStr, CString};
43
use std::fs::{DirBuilder, File, Metadata, OpenOptions};

test-framework/sudo-test/src/docker.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ pub fn build_base_image() {
192192
#[cfg(feature = "apparmor")]
193193
features.push("apparmor");
194194

195-
// TEMPORARY: when sudoedit is mainlined we can remove this
196-
features.push("sudoedit");
197-
198195
features.join(",")
199196
});
200197

util/build-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DATE=$(grep -m1 '^##' "$PROJECT_DIR"/CHANGELOG.md | grep -o '[0-9]\{4\}-[0-9]\{2
1414
# Build binaries
1515
docker build --pull --tag "$BUILDER_IMAGE_TAG" --file "$SCRIPT_DIR/Dockerfile-release" "$SCRIPT_DIR"
1616
docker run --rm --user "$(id -u):$(id -g)" -v "$PROJECT_DIR:/build" -w "/build" "$BUILDER_IMAGE_TAG" cargo clean
17-
docker run --rm --user "$(id -u):$(id -g)" -v "$PROJECT_DIR:/build" -w "/build" "$BUILDER_IMAGE_TAG" cargo build --release --features pam-login,sudoedit,apparmor
17+
docker run --rm --user "$(id -u):$(id -g)" -v "$PROJECT_DIR:/build" -w "/build" "$BUILDER_IMAGE_TAG" cargo build --release --features pam-login,apparmor
1818

1919
# Generate man pages
2020
"$PROJECT_DIR/util/generate-docs.sh"

0 commit comments

Comments
 (0)