Skip to content

Commit a381d11

Browse files
authored
install: rename "unprivileged" property (#11283)
to "privileged" to avoid double-negations in the code
1 parent 913654b commit a381d11

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/uu/install/src/install.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub struct Behavior {
6565
preserve_context: bool,
6666
context: Option<String>,
6767
default_context: bool,
68-
unprivileged: bool,
68+
privileged: bool,
6969
}
7070

7171
#[derive(Error, Debug)]
@@ -428,7 +428,7 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
428428

429429
let context = matches.get_one::<String>(OPT_CONTEXT).cloned();
430430
let default_context = matches.get_flag(OPT_DEFAULT_CONTEXT);
431-
let unprivileged = matches.get_flag(OPT_UNPRIVILEGED);
431+
let privileged = !matches.get_flag(OPT_UNPRIVILEGED);
432432

433433
Ok(Behavior {
434434
main_function,
@@ -452,7 +452,7 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
452452
preserve_context: matches.get_flag(OPT_PRESERVE_CONTEXT),
453453
context,
454454
default_context,
455-
unprivileged,
455+
privileged,
456456
})
457457
}
458458

@@ -513,7 +513,7 @@ fn directory(paths: &[OsString], b: &Behavior) -> UResult<()> {
513513
continue;
514514
}
515515

516-
if !b.unprivileged {
516+
if b.privileged {
517517
show_if_err!(chown_optional_user_group(path, b));
518518

519519
// Set SELinux context for directory if needed
@@ -1044,7 +1044,7 @@ fn set_ownership_and_permissions(to: &Path, b: &Behavior) -> UResult<()> {
10441044
return Err(InstallError::ChmodFailed(to.to_path_buf()).into());
10451045
}
10461046

1047-
if !b.unprivileged {
1047+
if b.privileged {
10481048
chown_optional_user_group(to, b)?;
10491049
}
10501050

@@ -1097,7 +1097,7 @@ fn finalize_installed_file(
10971097
}
10981098

10991099
#[cfg(all(feature = "selinux", target_os = "linux"))]
1100-
if !b.unprivileged {
1100+
if b.privileged {
11011101
if b.preserve_context {
11021102
uucore::selinux::preserve_security_context(from, to)
11031103
.map_err(|e| InstallError::SelinuxContextFailed(e.to_string()))?;
@@ -1166,7 +1166,7 @@ fn get_context_for_selinux(b: &Behavior) -> Option<&String> {
11661166

11671167
#[cfg(all(feature = "selinux", target_os = "linux"))]
11681168
fn should_set_selinux_context(b: &Behavior) -> bool {
1169-
!b.unprivileged && (b.context.is_some() || b.default_context)
1169+
b.privileged && (b.context.is_some() || b.default_context)
11701170
}
11711171

11721172
/// Check if a file needs to be copied due to ownership differences when no explicit group is specified.
@@ -1259,7 +1259,7 @@ fn need_copy(from: &Path, to: &Path, b: &Behavior) -> bool {
12591259
return true;
12601260
}
12611261

1262-
if !b.unprivileged {
1262+
if b.privileged {
12631263
#[cfg(all(feature = "selinux", target_os = "linux"))]
12641264
if b.preserve_context && contexts_differ(from, to) {
12651265
return true;

0 commit comments

Comments
 (0)