]> code.ossystems Code Review - openembedded-core.git/commitdiff
busybox: add tmpdir option into mktemp applet
authorAndrej Valek <andrej.valek@siemens.com>
Fri, 25 Jun 2021 06:10:11 +0000 (08:10 +0200)
committerSteve Sakoman <steve@sakoman.com>
Wed, 14 Jul 2021 22:27:38 +0000 (12:27 -1000)
- Make mktemp applet compatible with --tmpdir option in ca-certificate
update script.

Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 3d969e482d29da29828d1510f106f161d2b3d3c0)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-core/busybox/busybox/0001-mktemp-add-tmpdir-option.patch [new file with mode: 0644]
meta/recipes-core/busybox/busybox_1.31.1.bb

diff --git a/meta/recipes-core/busybox/busybox/0001-mktemp-add-tmpdir-option.patch b/meta/recipes-core/busybox/busybox/0001-mktemp-add-tmpdir-option.patch
new file mode 100644 (file)
index 0000000..4a1960d
--- /dev/null
@@ -0,0 +1,81 @@
+From ceb378209f953ea745ed93a8645567196380ce3c Mon Sep 17 00:00:00 2001
+From: Andrej Valek <andrej.valek@siemens.com>
+Date: Thu, 24 Jun 2021 19:13:22 +0200
+Subject: [PATCH] mktemp: add tmpdir option
+
+Make mktemp more compatible with coreutils.
+- add "--tmpdir" option
+- add long variants for "d,q,u" options
+
+Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2021-June/088932.html]
+
+Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
+Signed-off-by: Peter Marko <peter.marko@siemens.com>
+---
+ coreutils/mktemp.c | 26 ++++++++++++++++++--------
+ 1 file changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/coreutils/mktemp.c b/coreutils/mktemp.c
+index 5393320a5..05c6d98c6 100644
+--- a/coreutils/mktemp.c
++++ b/coreutils/mktemp.c
+@@ -39,16 +39,17 @@
+ //kbuild:lib-$(CONFIG_MKTEMP) += mktemp.o
+ //usage:#define mktemp_trivial_usage
+-//usage:       "[-dt] [-p DIR] [TEMPLATE]"
++//usage:       "[-dt] [-p DIR, --tmpdir[=DIR]] [TEMPLATE]"
+ //usage:#define mktemp_full_usage "\n\n"
+ //usage:       "Create a temporary file with name based on TEMPLATE and print its name.\n"
+ //usage:       "TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).\n"
+ //usage:       "Without TEMPLATE, -t tmp.XXXXXX is assumed.\n"
+-//usage:     "\n      -d      Make directory, not file"
+-//usage:     "\n      -q      Fail silently on errors"
+-//usage:     "\n      -t      Prepend base directory name to TEMPLATE"
+-//usage:     "\n      -p DIR  Use DIR as a base directory (implies -t)"
+-//usage:     "\n      -u      Do not create anything; print a name"
++//usage:     "\n      -d                      Make directory, not file"
++//usage:     "\n      -q                      Fail silently on errors"
++//usage:     "\n      -t                      Prepend base directory name to TEMPLATE"
++//usage:     "\n      -p DIR, --tmpdir[=DIR]  Use DIR as a base directory (implies -t)"
++//usage:     "\n                              For --tmpdir is a optional one."
++//usage:     "\n      -u                      Do not create anything; print a name"
+ //usage:     "\n"
+ //usage:     "\nBase directory is: -p DIR, else $TMPDIR, else /tmp"
+ //usage:
+@@ -72,13 +73,22 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
+               OPT_t = 1 << 2,
+               OPT_p = 1 << 3,
+               OPT_u = 1 << 4,
++              OPT_td = 1 << 5,
+       };
+       path = getenv("TMPDIR");
+       if (!path || path[0] == '\0')
+               path = "/tmp";
+-      opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path);
++      opts = getopt32long(argv, "^"
++             "dqtp:u\0"
++             "?1" /* 1 arg max */,
++             "directory\0" No_argument       "d"
++             "quiet\0"     No_argument       "q"
++             "dry-run\0"   No_argument       "u"
++             "tmpdir\0"    Optional_argument "\xff"
++             , &path, &path
++      );
+       chp = argv[optind];
+       if (!chp) {
+@@ -95,7 +105,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
+               goto error;
+       }
+ #endif
+-      if (opts & (OPT_t|OPT_p))
++      if (opts & (OPT_t|OPT_p|OPT_td))
+               chp = concat_path_file(path, chp);
+       if (opts & OPT_u) {
+-- 
+2.11.0
+
index f7808f4d84aae3804efd039d9ac4a78e2e3e8609..d9d5f4f96bb701f144c965e06c90e2837255a924 100644 (file)
@@ -51,6 +51,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://busybox-CVE-2018-1000500.patch \
            file://0001-hwclock-make-glibc-2.31-compatible.patch \
            file://0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch \
+           file://0001-mktemp-add-tmpdir-option.patch \
            "
 SRC_URI_append_libc-musl = " file://musl.cfg "