Skip to content

Commit 09922b8

Browse files
committed
ls: use translate!() macro for SELinux warning messages
1 parent 58a96e8 commit 09922b8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/uu/ls/locales/en-US.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,7 @@ ls-invalid-columns-width = ignoring invalid width in environment variable COLUMN
124124
ls-invalid-ignore-pattern = Invalid pattern for ignore: {$pattern}
125125
ls-invalid-hide-pattern = Invalid pattern for hide: {$pattern}
126126
ls-total = total {$size}
127+
128+
# Security context warnings
129+
ls-warning-failed-to-get-security-context = failed to get security context of: {$path}
130+
ls-warning-getting-security-context = getting security context of: {$path}: {$error}

src/uu/ls/src/ls.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,7 +3389,13 @@ fn get_security_context<'a>(
33893389
match selinux::SecurityContext::of_path(path, must_dereference, false) {
33903390
Err(_r) => {
33913391
// TODO: show the actual reason why it failed
3392-
show_warning!("failed to get security context of: {}", path.quote());
3392+
show_warning!(
3393+
"{}",
3394+
translate!(
3395+
"ls-warning-failed-to-get-security-context",
3396+
"path" => path.quote().to_string()
3397+
)
3398+
);
33933399
return Cow::Borrowed(SUBSTITUTE_STRING);
33943400
}
33953401
Ok(None) => return Cow::Borrowed(SUBSTITUTE_STRING),
@@ -3400,9 +3406,12 @@ fn get_security_context<'a>(
34003406

34013407
let res: String = String::from_utf8(context.to_vec()).unwrap_or_else(|e| {
34023408
show_warning!(
3403-
"getting security context of: {}: {}",
3404-
path.quote(),
3405-
e.to_string()
3409+
"{}",
3410+
translate!(
3411+
"ls-warning-getting-security-context",
3412+
"path" => path.quote().to_string(),
3413+
"error" => e.to_string()
3414+
)
34063415
);
34073416

34083417
String::from_utf8_lossy(context).to_string()

0 commit comments

Comments
 (0)