Skip to content

Commit 26882e1

Browse files
committed
protect names against binary name
1 parent e0f0318 commit 26882e1

88 files changed

Lines changed: 167 additions & 167 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/uu/arch/src/arch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2121
}
2222

2323
pub fn uu_app() -> Command {
24-
Command::new(uucore::util_name())
24+
Command::new("arch")
2525
.version(uucore::crate_version!())
26-
.help_template(uucore::localized_help_template(uucore::util_name()))
26+
.help_template(uucore::localized_help_template("arch"))
2727
.about(translate!("arch-about"))
2828
.after_help(translate!("arch-after-help"))
2929
.override_usage(translate!("arch-usage"))

src/uu/basename/src/basename.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
8080
}
8181

8282
pub fn uu_app() -> Command {
83-
Command::new(uucore::util_name())
83+
Command::new("basename")
8484
.version(uucore::crate_version!())
85-
.help_template(uucore::localized_help_template(uucore::util_name()))
85+
.help_template(uucore::localized_help_template("basename"))
8686
.about(translate!("basename-about"))
8787
.override_usage(format_usage(&translate!("basename-usage")))
8888
.infer_long_args(true)

src/uu/cat/src/cat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
268268
}
269269

270270
pub fn uu_app() -> Command {
271-
Command::new(uucore::util_name())
271+
Command::new("cat")
272272
.version(uucore::crate_version!())
273273
.override_usage(format_usage(&translate!("cat-usage")))
274274
.about(translate!("cat-about"))
275-
.help_template(uucore::localized_help_template(uucore::util_name()))
275+
.help_template(uucore::localized_help_template("cat"))
276276
.infer_long_args(true)
277277
.args_override_self(true)
278278
.arg(
@@ -420,11 +420,11 @@ where
420420
Ok(())
421421
} else {
422422
// each next line is expected to display "cat: …"
423-
let line_joiner = format!("\n{}: ", uucore::util_name());
423+
let line_joiner = "\ncat: ";
424424

425425
Err(uucore::error::USimpleError::new(
426426
error_messages.len() as i32,
427-
error_messages.join(&line_joiner),
427+
error_messages.join(line_joiner),
428428
))
429429
}
430430
}

src/uu/chcon/src/chcon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
156156
}
157157

158158
pub fn uu_app() -> Command {
159-
let cmd = Command::new(uucore::util_name())
159+
let cmd = Command::new("chcon")
160160
.version(uucore::crate_version!())
161161
.about(translate!("chcon-about"))
162162
.override_usage(format_usage(&translate!("chcon-usage")))
@@ -613,7 +613,7 @@ fn process_file(
613613
if options.verbose {
614614
println!(
615615
"{}",
616-
translate!("chcon-verbose-changing-context", "util_name" => uucore::util_name(), "file" => file_full_name.quote())
616+
translate!("chcon-verbose-changing-context", "util_name" => "chcon", "file" => file_full_name.quote())
617617
);
618618
}
619619

src/uu/chgrp/src/chgrp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
9898
}
9999

100100
pub fn uu_app() -> Command {
101-
let cmd = Command::new(uucore::util_name())
101+
let cmd = Command::new("chgrp")
102102
.version(uucore::crate_version!())
103103
.about(translate!("chgrp-about"))
104104
.override_usage(format_usage(&translate!("chgrp-usage")))

src/uu/chmod/src/chmod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
175175
}
176176

177177
pub fn uu_app() -> Command {
178-
Command::new(uucore::util_name())
178+
Command::new("chmod")
179179
.version(uucore::crate_version!())
180180
.about(translate!("chmod-about"))
181181
.override_usage(format_usage(&translate!("chmod-usage")))
182-
.help_template(uucore::localized_help_template(uucore::util_name()))
182+
.help_template(uucore::localized_help_template("chmod"))
183183
.args_override_self(true)
184184
.infer_long_args(true)
185185
.no_binary_name(true)

src/uu/chown/src/chown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
7575
}
7676

7777
pub fn uu_app() -> Command {
78-
Command::new(uucore::util_name())
78+
Command::new("chown")
7979
.version(uucore::crate_version!())
80-
.help_template(uucore::localized_help_template(uucore::util_name()))
80+
.help_template(uucore::localized_help_template("chown"))
8181
.about(translate!("chown-about"))
8282
.override_usage(format_usage(&translate!("chown-usage")))
8383
.infer_long_args(true)

src/uu/chroot/src/chroot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
220220
}
221221

222222
pub fn uu_app() -> Command {
223-
let cmd = Command::new(uucore::util_name())
223+
let cmd = Command::new("chroot")
224224
.version(uucore::crate_version!())
225225
.about(translate!("chroot-about"))
226226
.override_usage(format_usage(&translate!("chroot-usage")))

src/uu/comm/src/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
374374
}
375375

376376
pub fn uu_app() -> Command {
377-
Command::new(uucore::util_name())
377+
Command::new("comm")
378378
.version(uucore::crate_version!())
379-
.help_template(uucore::localized_help_template(uucore::util_name()))
379+
.help_template(uucore::localized_help_template("comm"))
380380
.about(translate!("comm-about"))
381381
.override_usage(format_usage(&translate!("comm-usage")))
382382
.infer_long_args(true)

src/uu/cp/src/cp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ pub fn uu_app() -> Command {
521521
options::ATTRIBUTES_ONLY,
522522
options::COPY_CONTENTS,
523523
];
524-
Command::new(uucore::util_name())
524+
Command::new("cp")
525525
.version(uucore::crate_version!())
526526
.about(translate!("cp-about"))
527527
.help_template(uucore::localized_help_template(uucore::util_name()))
@@ -1404,7 +1404,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
14041404
)
14051405
.unwrap(),
14061406
)
1407-
.with_message(uucore::util_name());
1407+
.with_message("cp");
14081408
pb.tick();
14091409
Some(pb)
14101410
} else {

0 commit comments

Comments
 (0)