[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH] conditional removal of -u paramter from mktemp
From: Nicolas Hüppelshäuser <nicolas.hueppelshaeuser () emlix ! com
Date: 2019-03-05 10:55:24
Message-ID: 20190305105524.5122-1-nicolas.hueppelshaeuser () emlix ! com
[Download RAW message or body]
From: Edmund Henniges <eh@emlix.com>
allows disabling UCLIBC_SUSV3_LEGACY in uclibc-ng
Signed-off-by: Edmund Henniges <ehenniges@emlix.com>
---
coreutils/mktemp.c | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/coreutils/mktemp.c b/coreutils/mktemp.c
index 5393320a5..ab12e3596 100644
--- a/coreutils/mktemp.c
+++ b/coreutils/mktemp.c
@@ -34,12 +34,22 @@
//config: help
//config: mktemp is used to create unique temporary files
+//config:config FEATURE_MKTEMPU
+//config: bool "Enable -u option"
+//config: default n
+//config: depends on MKTEMP
+//config: help
+//config: -u do not create anything; merely print a name (unsafe)
+
+
//applet:IF_MKTEMP(APPLET_NOEXEC(mktemp, mktemp, BB_DIR_BIN, BB_SUID_DROP, mktemp))
//kbuild:lib-$(CONFIG_MKTEMP) += mktemp.o
//usage:#define mktemp_trivial_usage
//usage: "[-dt] [-p DIR] [TEMPLATE]"
+//usage:
+//usage:#if ENABLE_FEATURE_MKTEMPU
//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"
@@ -52,6 +62,19 @@
//usage: "\n"
//usage: "\nBase directory is: -p DIR, else $TMPDIR, else /tmp"
//usage:
+//usage:#else
+//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"
+//usage: "\nBase directory is: -p DIR, else $TMPDIR, else /tmp"
+//usage:
+//usage:#endif
//usage:#define mktemp_example_usage
//usage: "$ mktemp /tmp/temp.XXXXXX\n"
//usage: "/tmp/temp.mWiLjM\n"
@@ -71,14 +94,18 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
OPT_q = 1 << 1,
OPT_t = 1 << 2,
OPT_p = 1 << 3,
- OPT_u = 1 << 4,
+ OPT_u = ENABLE_FEATURE_MKTEMPU << 4,
};
path = getenv("TMPDIR");
if (!path || path[0] == '\0')
path = "/tmp";
+#if ENABLE_FEATURE_MKTEMPU
opts = getopt32(argv, "^" "dqtp:u" "\0" "?1"/*1 arg max*/, &path);
+#else
+ opts = getopt32(argv, "^" "dqtp:" "\0" "?1"/*1 arg max*/, &path);
+#endif
chp = argv[optind];
if (!chp) {
@@ -98,13 +125,15 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
if (opts & (OPT_t|OPT_p))
chp = concat_path_file(path, chp);
- if (opts & OPT_u) {
+ if (opts & OPT_d) {
+ if (mkdtemp(chp) == NULL)
+ goto error;
+#if ENABLE_FEATURE_MKTEMPU
+ } else if (opts & OPT_u) {
chp = mktemp(chp);
if (chp[0] == '\0')
goto error;
- } else if (opts & OPT_d) {
- if (mkdtemp(chp) == NULL)
- goto error;
+#endif
} else {
if (mkstemp(chp) < 0)
goto error;
--
2.19.2
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic