Skip to content
Snippets Groups Projects

Fix tr hack to not leak

Closed Sjoerd Simons requested to merge wip/sjoerd/dont-leak-boxes into wip/aferraris/default-coreutils
17 files
+ 4586
396
Compare changes
  • Side-by-side
  • Inline
Files
17
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Mon, 7 Jun 2021 18:13:18 +0200
Subject: HACK cp, mv, ls: add dummy missing arguments
Post-installation scripts for `apparmor` and the kernel make use of
the `-Z` flag for `cp` or `mv` in order to set the SELinux context of
copied/moved files. As the current implementations don't support this
flag, the commands error out, causing those packages' installation to
fail. As those are required, building Apertis images using
`rust-coreutils` subsequently fails too.
This commit adds support for the `-Z` flag without implementing the
associated behavior as it isn't strictly needed for building basic
Apertis images.
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: not-needed
Bug: https://github.com/uutils/coreutils/issues/2404
---
src/uu/cp/src/cp.rs | 4 ++++
src/uu/ls/src/ls.rs | 10 ++++++++++
src/uu/mv/src/mv.rs | 11 +++++++++++
3 files changed, 25 insertions(+)
diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs
index 569ee78..1277acc 100644
--- a/src/uu/cp/src/cp.rs
+++ b/src/uu/cp/src/cp.rs
@@ -238,6 +238,7 @@ static OPT_ATTRIBUTES_ONLY: &str = "attributes-only";
static OPT_BACKUP: &str = "backup";
static OPT_CLI_SYMBOLIC_LINKS: &str = "cli-symbolic-links";
static OPT_CONTEXT: &str = "context";
+static OPT_CONTEXT_DEFAULT: &str = "context-default";
static OPT_COPY_CONTENTS: &str = "copy-contents";
static OPT_DEREFERENCE: &str = "dereference";
static OPT_FORCE: &str = "force";
@@ -450,6 +451,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_CONTEXT)
.takes_value(true)
.value_name("CTX")
+ .help("NotImplemented: set the SELinux or SMACK security context to CTX"))
+ .arg(Arg::with_name(OPT_CONTEXT_DEFAULT)
+ .short("Z")
.help("NotImplemented: set SELinux security context of destination file to default type"))
.arg(Arg::with_name(OPT_CLI_SYMBOLIC_LINKS)
.short("H")
diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs
index ece497b..c63a771 100644
--- a/src/uu/ls/src/ls.rs
+++ b/src/uu/ls/src/ls.rs
@@ -138,6 +138,7 @@ pub mod options {
pub static COLOR: &str = "color";
pub static PATHS: &str = "paths";
pub static INDICATOR_STYLE: &str = "indicator-style";
+ pub static CONTEXT: &str = "context";
}
#[derive(PartialEq, Eq)]
@@ -884,6 +885,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
options::INDICATOR_STYLE,
]))
+ // TODO: implement the following args
+ .arg(
+ Arg::with_name(options::CONTEXT)
+ .long(options::CONTEXT)
+ .short("Z")
+ .help("NotImplemented: print any security context of each file.")
+ )
+ // END TODO
+
// Positional arguments
.arg(Arg::with_name(options::PATHS).multiple(true).takes_value(true));
diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs
index b481aee..4bcf19c 100644
--- a/src/uu/mv/src/mv.rs
+++ b/src/uu/mv/src/mv.rs
@@ -62,6 +62,7 @@ static OPT_TARGET_DIRECTORY: &str = "target-directory";
static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory";
static OPT_UPDATE: &str = "update";
static OPT_VERBOSE: &str = "verbose";
+static OPT_CONTEXT: &str = "context";
static ARG_FILES: &str = "files";
@@ -164,6 +165,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.min_values(2)
.required(true)
)
+
+ // TODO: implement the following args
+ .arg(
+ Arg::with_name(OPT_CONTEXT)
+ .short("Z")
+ .long(OPT_CONTEXT)
+ .help("NotImplemented: set SELinux security context of destination file to default type")
+ )
+ // END TODO
+
.get_matches_from(args);
let files: Vec<String> = matches
--
Loading