diff options
| author | Ron Yorston <rmy@pobox.com> | 2023-12-05 07:44:02 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2023-12-05 07:44:02 +0000 |
| commit | 7dff7f37600209353cf4e86d1cca29bacf5f7372 (patch) | |
| tree | fd2d62684e46663ebd435391058dcf8558c6b70d /coreutils | |
| parent | f444dc586b16c104a82d201d3a7caca68affe51b (diff) | |
| parent | 28f41260935852eda6bd8ab1f26347c012ae0a53 (diff) | |
| download | busybox-w32-7dff7f37600209353cf4e86d1cca29bacf5f7372.tar.gz busybox-w32-7dff7f37600209353cf4e86d1cca29bacf5f7372.tar.bz2 busybox-w32-7dff7f37600209353cf4e86d1cca29bacf5f7372.zip | |
Merge branch 'busybox' into mergeFRP-5236-g7dff7f376
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/install.c | 16 | ||||
| -rw-r--r-- | coreutils/printf.c | 10 | ||||
| -rw-r--r-- | coreutils/sleep.c | 19 |
3 files changed, 24 insertions, 21 deletions
diff --git a/coreutils/install.c b/coreutils/install.c index c0f1c538a..00f8be87e 100644 --- a/coreutils/install.c +++ b/coreutils/install.c | |||
| @@ -244,6 +244,15 @@ int install_main(int argc, char **argv) | |||
| 244 | } | 244 | } |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | /* Set the user and group id */ | ||
| 248 | /* (must be before chmod, or else chown may clear suid/gid bits) */ | ||
| 249 | if ((opts & (OPT_OWNER|OPT_GROUP)) | ||
| 250 | && lchown(dest, uid, gid) == -1 | ||
| 251 | ) { | ||
| 252 | bb_perror_msg("can't change %s of %s", "ownership", dest); | ||
| 253 | ret = EXIT_FAILURE; | ||
| 254 | } | ||
| 255 | |||
| 247 | /* Set the file mode (always, not only with -m). | 256 | /* Set the file mode (always, not only with -m). |
| 248 | * GNU coreutils 6.10 is not affected by umask. */ | 257 | * GNU coreutils 6.10 is not affected by umask. */ |
| 249 | if (chmod(dest, mode) == -1) { | 258 | if (chmod(dest, mode) == -1) { |
| @@ -254,13 +263,6 @@ int install_main(int argc, char **argv) | |||
| 254 | if (use_default_selinux_context) | 263 | if (use_default_selinux_context) |
| 255 | setdefaultfilecon(dest); | 264 | setdefaultfilecon(dest); |
| 256 | #endif | 265 | #endif |
| 257 | /* Set the user and group id */ | ||
| 258 | if ((opts & (OPT_OWNER|OPT_GROUP)) | ||
| 259 | && lchown(dest, uid, gid) == -1 | ||
| 260 | ) { | ||
| 261 | bb_perror_msg("can't change %s of %s", "ownership", dest); | ||
| 262 | ret = EXIT_FAILURE; | ||
| 263 | } | ||
| 264 | next: | 266 | next: |
| 265 | if (ENABLE_FEATURE_CLEAN_UP && isdir) | 267 | if (ENABLE_FEATURE_CLEAN_UP && isdir) |
| 266 | free(dest); | 268 | free(dest); |
diff --git a/coreutils/printf.c b/coreutils/printf.c index 1bcc74d3b..379c00cc6 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
| @@ -490,9 +490,9 @@ int printf_main(int argc UNUSED_PARAM, char **argv) | |||
| 490 | /* bash builtin errors out on "printf '-%s-\n' foo", | 490 | /* bash builtin errors out on "printf '-%s-\n' foo", |
| 491 | * coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo". | 491 | * coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo". |
| 492 | * We will mimic coreutils. */ | 492 | * We will mimic coreutils. */ |
| 493 | if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2]) | 493 | argv = skip_dash_dash(argv); |
| 494 | argv++; | 494 | |
| 495 | if (!argv[1]) { | 495 | if (!argv[0]) { |
| 496 | if ((ENABLE_ASH_PRINTF || ENABLE_HUSH_PRINTF) | 496 | if ((ENABLE_ASH_PRINTF || ENABLE_HUSH_PRINTF) |
| 497 | && applet_name[0] != 'p' | 497 | && applet_name[0] != 'p' |
| 498 | ) { | 498 | ) { |
| @@ -502,8 +502,8 @@ int printf_main(int argc UNUSED_PARAM, char **argv) | |||
| 502 | bb_show_usage(); | 502 | bb_show_usage(); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | format = argv[1]; | 505 | format = argv[0]; |
| 506 | argv2 = argv + 2; | 506 | argv2 = argv + 1; |
| 507 | 507 | ||
| 508 | conv_err = 0; | 508 | conv_err = 0; |
| 509 | do { | 509 | do { |
diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 6edff59cc..6fd00f9f1 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c | |||
| @@ -17,14 +17,15 @@ | |||
| 17 | //config: default y | 17 | //config: default y |
| 18 | //config: help | 18 | //config: help |
| 19 | //config: sleep is used to pause for a specified number of seconds. | 19 | //config: sleep is used to pause for a specified number of seconds. |
| 20 | //config: It comes in 3 versions: | 20 | //config: It comes in 2 versions: |
| 21 | //config: - small: takes one integer parameter | 21 | //config: - small: takes one integer parameter |
| 22 | //config: - fancy: takes multiple integer arguments with suffixes: | 22 | //config: - fancy: |
| 23 | //config: sleep 1d 2h 3m 15s | 23 | //config: * takes multiple integer arguments with suffixes: |
| 24 | //config: - fancy with fractional numbers: | 24 | //config: sleep 1d 2h 3m 15s |
| 25 | //config: sleep 2.3s 4.5h sleeps for 16202.3 seconds | 25 | //config: * allows fractional numbers: |
| 26 | //config: Last one is "the most compatible" with coreutils sleep, | 26 | //config: sleep 2.3s 4.5h sleeps for 16202.3 seconds |
| 27 | //config: but it adds around 1k of code. | 27 | //config: fancy is more compatible with coreutils sleep, but it adds around |
| 28 | //config: 1k of code. | ||
| 28 | //config: | 29 | //config: |
| 29 | //config:config FEATURE_FANCY_SLEEP | 30 | //config:config FEATURE_FANCY_SLEEP |
| 30 | //config: bool "Enable multiple arguments and s/m/h/d suffixes" | 31 | //config: bool "Enable multiple arguments and s/m/h/d suffixes" |
| @@ -71,8 +72,8 @@ int sleep_main(int argc UNUSED_PARAM, char **argv) | |||
| 71 | * + we can't use bb_show_usage | 72 | * + we can't use bb_show_usage |
| 72 | * + applet_name can be the name of the shell | 73 | * + applet_name can be the name of the shell |
| 73 | */ | 74 | */ |
| 74 | ++argv; | 75 | argv = skip_dash_dash(argv); |
| 75 | if (!*argv) { | 76 | if (!argv[0]) { |
| 76 | /* Without this, bare "sleep" in ash shows _ash_ --help */ | 77 | /* Without this, bare "sleep" in ash shows _ash_ --help */ |
| 77 | /* (ash can be the "sh" applet as well, so check 2nd char) */ | 78 | /* (ash can be the "sh" applet as well, so check 2nd char) */ |
| 78 | if (ENABLE_ASH_SLEEP && applet_name[1] != 'l') { | 79 | if (ENABLE_ASH_SLEEP && applet_name[1] != 'l') { |
