Skip to content

Commit 722d245

Browse files
authored
Merge branch 'main' into patch-3
2 parents 280e74e + 0fbc17c commit 722d245

File tree

33 files changed

+759
-217
lines changed

33 files changed

+759
-217
lines changed

.github/workflows/CICD.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,22 +300,22 @@ jobs:
300300
run: make nextest PROFILE=ci CARGOFLAGS="--hide-progress-bar"
301301
env:
302302
RUST_BACKTRACE: "1"
303-
304-
- name: "`make install PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n`"
303+
- name: "`make install PROG_PREFIX=uu- PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n`"
305304
shell: bash
306305
run: |
307306
set -x
308-
DESTDIR=/tmp/ make PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n install
307+
DESTDIR=/tmp/ make install PROG_PREFIX=uu- PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n
309308
# Check that utils are built with given profile
310309
./target/release-fast/true
311-
# Check that the utils are present
312-
test -f /tmp/usr/local/bin/tty
310+
# Check that the progs have prefix
311+
test -f /tmp/usr/local/bin/uu-tty
312+
test -f /tmp/usr/local/libexec/uu-coreutils/libstdbuf.*
313313
# Check that the manpage is not present
314-
! test -f /tmp/usr/local/share/man/man1/whoami.1
314+
! test -f /tmp/usr/local/share/man/man1/uu-whoami.1
315315
# Check that the completion is not present
316-
! test -f /tmp/usr/local/share/zsh/site-functions/_install
317-
! test -f /tmp/usr/local/share/bash-completion/completions/head.bash
318-
! test -f /tmp/usr/local/share/fish/vendor_completions.d/cat.fish
316+
! test -f /tmp/usr/local/share/zsh/site-functions/_uu-install
317+
! test -f /tmp/usr/local/share/bash-completion/completions/uu-head.bash
318+
! test -f /tmp/usr/local/share/fish/vendor_completions.d/uu-cat.fish
319319
env:
320320
RUST_BACKTRACE: "1"
321321
- name: "`make install`"

.github/workflows/GnuTests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: GnuTests
66
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
77
# spell-checker:ignore (people) Dawid Dziurla * dawidd dtolnay
88
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS
9+
# spell-checker:ignore userns
910

1011
# * note: to run a single test => `REPO/util/run-gnu-test.sh PATH/TO/TEST/SCRIPT`
1112

@@ -116,6 +117,9 @@ jobs:
116117
- name: Run GNU tests
117118
shell: bash
118119
run: |
120+
## Use unshare
121+
sudo sysctl -w kernel.unprivileged_userns_clone=1
122+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
119123
## Run GNU tests
120124
path_GNU='gnu'
121125
path_UUTILS='uutils'

.github/workflows/fuzzing.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ jobs:
7979
matrix:
8080
test-target:
8181
- { name: fuzz_test, should_pass: true }
82-
# https://github.com/uutils/coreutils/issues/5311
83-
- { name: fuzz_date, should_pass: false }
82+
- { name: fuzz_date, should_pass: true }
8483
- { name: fuzz_expr, should_pass: true }
8584
- { name: fuzz_printf, should_pass: true }
8685
- { name: fuzz_echo, should_pass: true }

GNUmakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ CARGO ?= cargo
2727
CARGOFLAGS ?=
2828
RUSTC_ARCH ?= # should be empty except for cross-build, not --target $(shell rustc --print host-tuple)
2929

30+
#prefix prepended to all binaries and library dir
31+
PROG_PREFIX ?=
32+
3033
# Install directories
3134
PREFIX ?= /usr/local
3235
DESTDIR ?=
3336
BINDIR ?= $(PREFIX)/bin
3437
DATAROOTDIR ?= $(PREFIX)/share
35-
LIBSTDBUF_DIR ?= $(PREFIX)/libexec/coreutils
38+
LIBSTDBUF_DIR ?= $(PREFIX)/libexec/$(PROG_PREFIX)coreutils
3639
# Export variable so that it is used during the build
3740
export LIBSTDBUF_DIR
3841

3942
INSTALLDIR_BIN=$(DESTDIR)$(BINDIR)
4043

41-
#prefix to apply to coreutils binary and all tool binaries
42-
PROG_PREFIX ?=
43-
4444
# This won't support any directory with spaces in its name, but you can just
4545
# make a symlink without spaces that points to the directory.
4646
BASEDIR ?= $(shell pwd)

docs/src/extensions.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ Similar to the proc-ps implementation and unlike GNU/Coreutils, `uptime` provide
190190

191191
Just like on macOS, `base32/base64/basenc` provides `-D` to decode data.
192192

193-
## `shred`
194-
195-
The number of random passes is deterministic in both GNU and uutils. However, uutils `shred` computes the number of random passes in a simplified way, specifically `max(3, x / 10)`, which is very close but not identical to the number of random passes that GNU would do. This also satisfies an expectation that reasonable users might have, namely that the number of random passes increases monotonically with the number of passes overall; GNU `shred` violates this assumption.
196-
197193
## `unexpand`
198194

199195
GNU `unexpand` provides `--first-only` to convert only leading sequences of blanks. We support a

fuzz/fuzz_targets/fuzz_date.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,38 @@ use libfuzzer_sys::fuzz_target;
33

44
use std::ffi::OsString;
55
use uu_date::uumain;
6+
use uufuzz::generate_and_run_uumain;
67

78
fuzz_target!(|data: &[u8]| {
89
let delim: u8 = 0; // Null byte
9-
let args = data
10+
let fuzz_args: Vec<OsString> = data
1011
.split(|b| *b == delim)
1112
.filter_map(|e| std::str::from_utf8(e).ok())
12-
.map(OsString::from);
13-
uumain(args);
13+
.map(OsString::from)
14+
.collect();
15+
16+
// Skip test cases that would cause the program to read from stdin
17+
// These would hang the fuzzer waiting for input
18+
for i in 0..fuzz_args.len() {
19+
if let Some(arg) = fuzz_args.get(i) {
20+
let arg_str = arg.to_string_lossy();
21+
// Skip if -f- or --file=- (reads dates from stdin)
22+
if (arg_str == "-f"
23+
&& fuzz_args
24+
.get(i + 1)
25+
.map(|a| a.to_string_lossy() == "-")
26+
.unwrap_or(false))
27+
|| arg_str == "-f-"
28+
|| arg_str == "--file=-"
29+
{
30+
return;
31+
}
32+
}
33+
}
34+
35+
// Add program name as first argument (required for proper argument parsing)
36+
let mut args = vec![OsString::from("date")];
37+
args.extend(fuzz_args);
38+
39+
let _ = generate_and_run_uumain(&args, uumain, None);
1440
});

src/uu/cksum/src/cksum.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
216216
algo_kind: algo,
217217
output_format,
218218
line_ending,
219-
no_names: false,
220219
};
221220

222221
perform_checksum_computation(opts, files)?;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@ date-error-date-overflow = date overflow '{$date}'
104104
date-error-setting-date-not-supported-macos = setting the date is not supported by macOS
105105
date-error-setting-date-not-supported-redox = setting the date is not supported by Redox
106106
date-error-cannot-set-date = cannot set date
107+
date-error-extra-operand = extra operand '{$operand}'

src/uu/date/locales/fr-FR.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ date-error-date-overflow = débordement de date '{$date}'
9999
date-error-setting-date-not-supported-macos = la définition de la date n'est pas prise en charge par macOS
100100
date-error-setting-date-not-supported-redox = la définition de la date n'est pas prise en charge par Redox
101101
date-error-cannot-set-date = impossible de définir la date
102+
date-error-extra-operand = opérande supplémentaire '{$operand}'

src/uu/date/src/date.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ fn parse_military_timezone_with_offset(s: &str) -> Option<i32> {
171171
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
172172
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
173173

174+
// Check for extra operands (multiple positional arguments)
175+
if let Some(formats) = matches.get_many::<String>(OPT_FORMAT) {
176+
let format_args: Vec<&String> = formats.collect();
177+
if format_args.len() > 1 {
178+
return Err(USimpleError::new(
179+
1,
180+
translate!("date-error-extra-operand", "operand" => format_args[1]),
181+
));
182+
}
183+
}
184+
174185
let format = if let Some(form) = matches.get_one::<String>(OPT_FORMAT) {
175186
if !form.starts_with('+') {
176187
return Err(USimpleError::new(
@@ -515,7 +526,7 @@ pub fn uu_app() -> Command {
515526
.help(translate!("date-help-universal"))
516527
.action(ArgAction::SetTrue),
517528
)
518-
.arg(Arg::new(OPT_FORMAT))
529+
.arg(Arg::new(OPT_FORMAT).num_args(0..).trailing_var_arg(true))
519530
}
520531

521532
/// Return the appropriate format string for the given settings.

0 commit comments

Comments
 (0)