From 4d980cd6a73e866b63949a76a9106689522e2e21 Mon Sep 17 00:00:00 2001 From: Gustavo Zacarias Date: Wed, 10 Dec 2014 17:14:41 -0300 Subject: util-linux: add security patch for CVE-2014-9114 Fixes CVE-2014-9114 - command injection flaw in blkid. See https://bugzilla.redhat.com/show_bug.cgi?id=1168485 Patch upstream. Signed-off-by: Gustavo Zacarias Signed-off-by: Thomas Petazzoni --- package/util-linux/0001-sscanf-no-ms-as.patch | 175 +++++++++++++++++++++ .../0002-program-invocation-short-name.patch | 11 ++ ...fine-mkostemp-for-older-version-of-uClibc.patch | 50 ++++++ package/util-linux/0004-fix-CVE-2014-9114.patch | 168 ++++++++++++++++++++ .../util-linux-001-sscanf-no-ms-as.patch | 175 --------------------- ...l-linux-002-program-invocation-short-name.patch | 11 -- ...fine-mkostemp-for-older-version-of-uClibc.patch | 50 ------ 7 files changed, 404 insertions(+), 236 deletions(-) create mode 100644 package/util-linux/0001-sscanf-no-ms-as.patch create mode 100644 package/util-linux/0002-program-invocation-short-name.patch create mode 100644 package/util-linux/0003-c.h-define-mkostemp-for-older-version-of-uClibc.patch create mode 100644 package/util-linux/0004-fix-CVE-2014-9114.patch delete mode 100644 package/util-linux/util-linux-001-sscanf-no-ms-as.patch delete mode 100644 package/util-linux/util-linux-002-program-invocation-short-name.patch delete mode 100644 package/util-linux/util-linux-003-c.h-define-mkostemp-for-older-version-of-uClibc.patch (limited to 'package') diff --git a/package/util-linux/0001-sscanf-no-ms-as.patch b/package/util-linux/0001-sscanf-no-ms-as.patch new file mode 100644 index 0000000000..be2b0eb269 --- /dev/null +++ b/package/util-linux/0001-sscanf-no-ms-as.patch @@ -0,0 +1,175 @@ +Fix libmount build under uClibc + +See https://bugs.gentoo.org/show_bug.cgi?id=406303 +http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/util-linux/files/util-linux-2.21.1-no-printf-alloc.patch?revision=1.2 + +[Gustavo: Ported to util-linux-2.25.1] + +Signed-off-by: Gustavo Zacarias + +diff -Nura util-linux-2.25.1.orig/configure.ac util-linux-2.25.1/configure.ac +--- util-linux-2.25.1.orig/configure.ac 2014-09-05 10:44:45.302080174 -0300 ++++ util-linux-2.25.1/configure.ac 2014-09-05 10:45:07.183832640 -0300 +@@ -791,7 +791,6 @@ + UL_BUILD_INIT([libmount]) + UL_REQUIRES_LINUX([libmount]) + UL_REQUIRES_BUILD([libmount], [libblkid]) +-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier]) + AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes]) + AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes]) + +diff -Nura util-linux-2.25.1.orig/lib/colors.c util-linux-2.25.1/lib/colors.c +--- util-linux-2.25.1.orig/lib/colors.c 2014-09-05 10:44:45.301080140 -0300 ++++ util-linux-2.25.1/lib/colors.c 2014-09-05 13:12:00.175205476 -0300 +@@ -16,6 +16,10 @@ + #include "pathnames.h" + #include "strutils.h" + ++#ifndef HAVE_SCANF_MS_MODIFIER ++# define UL_SCNsA "%s" ++#endif ++ + /* + * terminal-colors.d file types + */ +@@ -577,9 +581,19 @@ + if (*p == '\0' || *p == '#') + continue; + ++#ifndef HAVE_SCANF_MS_MODIFIER ++ size_t len = strlen(p) + 1; ++ cn = malloc(len); ++ seq = malloc(len); ++#endif ++ + rc = sscanf(p, UL_SCNsA" " /* name */ + UL_SCNsA, /* color */ ++#ifdef HAVE_SCANF_MS_MODIFIER + &cn, &seq); ++#else ++ cn, seq); ++#endif + if (rc == 2 && cn && seq) + rc = colors_add_scheme(cc, cn, seq); /* set rc=0 on success */ + if (rc) { +diff -Nura util-linux-2.25.1.orig/libmount/src/tab_parse.c util-linux-2.25.1/libmount/src/tab_parse.c +--- util-linux-2.25.1.orig/libmount/src/tab_parse.c 2014-09-05 10:44:45.276079280 -0300 ++++ util-linux-2.25.1/libmount/src/tab_parse.c 2014-09-05 10:51:22.500738967 -0300 +@@ -22,6 +22,10 @@ + #include "pathnames.h" + #include "strutils.h" + ++#ifndef HAVE_SCANF_MS_MODIFIER ++# define UL_SCNsA "%s" ++#endif ++ + static int next_number(char **s, int *num) + { + char *end = NULL; +@@ -52,16 +56,31 @@ + int rc, n = 0, xrc; + char *src = NULL, *fstype = NULL, *optstr = NULL; + ++#ifndef HAVE_SCANF_MS_MODIFIER ++ size_t len = strlen(s) + 1; ++ src = malloc(len); ++ fstype = malloc(len); ++ fs->target = malloc(len); ++ optstr = malloc(len); ++#endif ++ + rc = sscanf(s, UL_SCNsA" " /* (1) source */ + UL_SCNsA" " /* (2) target */ + UL_SCNsA" " /* (3) FS type */ + UL_SCNsA" " /* (4) options */ + "%n", /* byte count */ + ++#ifdef HAVE_SCANF_MS_MODIFIER + &src, + &fs->target, + &fstype, + &optstr, ++#else ++ src, ++ fs->target, ++ fstype, ++ optstr, ++#endif + &n); + xrc = rc; + +@@ -127,6 +146,16 @@ + unsigned int maj, min; + char *fstype = NULL, *src = NULL, *p; + ++#ifndef HAVE_SCANF_MS_MODIFIER ++ size_t len = strlen(s) + 1; ++ fs->root = malloc(len); ++ fs->target = malloc(len); ++ fs->vfs_optstr = malloc(len); ++ fs->fs_optstr = malloc(len); ++ fstype = malloc(len); ++ src = malloc(len); ++#endif ++ + rc = sscanf(s, "%d " /* (1) id */ + "%d " /* (2) parent */ + "%u:%u " /* (3) maj:min */ +@@ -138,9 +167,15 @@ + &fs->id, + &fs->parent, + &maj, &min, ++#ifdef HAVE_SCANF_MS_MODIFIER + &fs->root, + &fs->target, + &fs->vfs_optstr, ++#else ++ fs->root, ++ fs->target, ++ fs->vfs_optstr, ++#endif + &end); + + if (rc >= 7 && end > 0) +@@ -160,9 +195,15 @@ + UL_SCNsA" " /* (9) source */ + UL_SCNsA, /* (10) fs options (fs specific) */ + ++#ifdef HAVE_SCANF_MS_MODIFIER + &fstype, + &src, + &fs->fs_optstr); ++#else ++ fstype, ++ src, ++ fs->fs_optstr); ++#endif + + if (rc >= 10) { + size_t sz; +@@ -281,14 +322,25 @@ + int rc; + char *src = NULL; + ++#ifndef HAVE_SCANF_MS_MODIFIER ++ size_t len = strlen(s) + 1; ++ src = malloc(len); ++ fs->swaptype = malloc(len); ++#endif ++ + rc = sscanf(s, UL_SCNsA" " /* (1) source */ + UL_SCNsA" " /* (2) type */ + "%ju" /* (3) size */ + "%ju" /* (4) used */ + "%d", /* priority */ + ++#ifdef HAVE_SCANF_MS_MODIFIER + &src, + &fs->swaptype, ++#else ++ src, ++ fs->swaptype, ++#endif + &fsz, + &usz, + &fs->priority); diff --git a/package/util-linux/0002-program-invocation-short-name.patch b/package/util-linux/0002-program-invocation-short-name.patch new file mode 100644 index 0000000000..95fea3f13d --- /dev/null +++ b/package/util-linux/0002-program-invocation-short-name.patch @@ -0,0 +1,11 @@ +--- a/configure.ac 2013-09-05 15:31:21.590981268 -0500 ++++ b/configure.ac 2013-09-05 15:31:29.160981049 -0500 +@@ -387,7 +387,7 @@ + + AC_MSG_CHECKING([whether program_invocation_short_name is defined]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +- #include ++ #include + ]], [[ + program_invocation_short_name = "test"; + ]])], [ diff --git a/package/util-linux/0003-c.h-define-mkostemp-for-older-version-of-uClibc.patch b/package/util-linux/0003-c.h-define-mkostemp-for-older-version-of-uClibc.patch new file mode 100644 index 0000000000..0dfe7befba --- /dev/null +++ b/package/util-linux/0003-c.h-define-mkostemp-for-older-version-of-uClibc.patch @@ -0,0 +1,50 @@ +From 42a84250fc78bae3e885ecd1379e713663fe6487 Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Sun, 6 Apr 2014 12:12:41 +0200 +Subject: [PATCH 1/1] c.h: define mkostemp for older version of uClibc + +Signed-off-by: Romain Naour +--- + configure.ac | 2 ++ + include/c.h | 14 ++++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 35a1f26..a9b8d34 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -321,6 +321,8 @@ AC_CHECK_FUNCS([ \ + ]) + AC_FUNC_FSEEKO + ++AC_CHECK_FUNCS([mkostemp]) ++ + AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no]) + AC_CHECK_FUNCS([ioperm iopl], [have_io=yes]) + +diff --git a/include/c.h b/include/c.h +index 4a9bf3d..1b880ed 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -300,4 +300,18 @@ static inline int usleep(useconds_t usec) + # define SEEK_HOLE 4 + #endif + ++/* ++ * mkostemp() may be missing with older version of uClibc ++ */ ++#ifndef HAVE_MKOSTEMP ++static inline int mkostemp(char *template, int flags) ++{ ++ int fd; ++ fd = mkstemp(template); ++ if (flags & O_CLOEXEC && fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++ return fd; ++} ++#endif ++ + #endif /* UTIL_LINUX_C_H */ +-- +1.9.0 + diff --git a/package/util-linux/0004-fix-CVE-2014-9114.patch b/package/util-linux/0004-fix-CVE-2014-9114.patch new file mode 100644 index 0000000000..95cb1c5e33 --- /dev/null +++ b/package/util-linux/0004-fix-CVE-2014-9114.patch @@ -0,0 +1,168 @@ +From 89e90ae7b2826110ea28c1c0eb8e7c56c3907bdc Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 27 Nov 2014 13:39:35 +0100 +Subject: [PATCH] libblkid: care about unsafe chars in cache + +The high-level libblkid API uses /run/blkid/blkid.tab cache to +store probing results. The cache format is + + devname + +and unfortunately the cache code does not escape quotation marks: + + # mkfs.ext4 -L 'AAA"BBB' + + # cat /run/blkid/blkid.tab + ... + /dev/sdb1 + +such string is later incorrectly parsed and blkid(8) returns +nonsenses. And for use-cases like + + # eval $(blkid -o export /dev/sdb1) + +it's also insecure. + +Note that mount, udevd and blkid -p are based on low-level libblkid +API, it bypass the cache and directly read data from the devices. + +The current udevd upstream does not depend on blkid(8) output at all, +it's directly linked with the library and all unsafe chars are encoded by +\x notation. + + # mkfs.ext4 -L 'X"`/tmp/foo` "' /dev/sdb1 + # udevadm info --export-db | grep LABEL + ... + E: ID_FS_LABEL=X__/tmp/foo___ + E: ID_FS_LABEL_ENC=X\x22\x60\x2ftmp\x2ffoo\x60\x20\x22 + +Signed-off-by: Karel Zak +Signed-off-by: Gustavo Zacarias +--- + libblkid/src/read.c | 21 ++++++++++++++++++--- + libblkid/src/save.c | 22 +++++++++++++++++++++- + misc-utils/blkid.8 | 5 ++++- + misc-utils/blkid.c | 4 ++-- + 4 files changed, 45 insertions(+), 7 deletions(-) + +diff --git a/libblkid/src/read.c b/libblkid/src/read.c +index 0e91c9c..81ab0df 100644 +--- a/libblkid/src/read.c ++++ b/libblkid/src/read.c +@@ -252,15 +252,30 @@ static int parse_token(char **name, char **value, char **cp) + *value = skip_over_blank(*value + 1); + + if (**value == '"') { +- end = strchr(*value + 1, '"'); +- if (!end) { ++ char *p = end = *value + 1; ++ ++ /* convert 'foo\"bar' to 'foo"bar' */ ++ while (*p) { ++ if (*p == '\\') { ++ p++; ++ *end = *p; ++ } else { ++ *end = *p; ++ if (*p == '"') ++ break; ++ } ++ p++; ++ end++; ++ } ++ ++ if (*end != '"') { + DBG(READ, ul_debug("unbalanced quotes at: %s", *value)); + *cp = *value; + return -BLKID_ERR_CACHE; + } + (*value)++; + *end = '\0'; +- end++; ++ end = ++p; + } else { + end = skip_over_word(*value); + if (*end) { +diff --git a/libblkid/src/save.c b/libblkid/src/save.c +index 8216f09..5e8bbee 100644 +--- a/libblkid/src/save.c ++++ b/libblkid/src/save.c +@@ -26,6 +26,21 @@ + + #include "blkidP.h" + ++ ++static void save_quoted(const char *data, FILE *file) ++{ ++ const char *p; ++ ++ fputc('"', file); ++ for (p = data; p && *p; p++) { ++ if ((unsigned char) *p == 0x22 || /* " */ ++ (unsigned char) *p == 0x5c) /* \ */ ++ fputc('\\', file); ++ ++ fputc(*p, file); ++ } ++ fputc('"', file); ++} + static int save_dev(blkid_dev dev, FILE *file) + { + struct list_head *p; +@@ -43,9 +58,14 @@ static int save_dev(blkid_dev dev, FILE *file) + + if (dev->bid_pri) + fprintf(file, " PRI=\"%d\"", dev->bid_pri); ++ + list_for_each(p, &dev->bid_tags) { + blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); +- fprintf(file, " %s=\"%s\"", tag->bit_name,tag->bit_val); ++ ++ fputc(' ', file); /* space between tags */ ++ fputs(tag->bit_name, file); /* tag NAME */ ++ fputc('=', file); /* separator between NAME and VALUE */ ++ save_quoted(tag->bit_val, file); /* tag "VALUE" */ + } + fprintf(file, ">%s\n", dev->bid_name); + +diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8 +index 156a14b..c95b833 100644 +--- a/misc-utils/blkid.8 ++++ b/misc-utils/blkid.8 +@@ -200,7 +200,10 @@ partitions. This output format is \fBDEPRECATED\fR. + .TP + .B export + print key=value pairs for easy import into the environment; this output format +-is automatically enabled when I/O Limits (\fB-i\fR option) are requested ++is automatically enabled when I/O Limits (\fB-i\fR option) are requested. ++ ++The non-printing characters are encoded by ^ and M- notation and all ++potentially unsafe characters are escaped. + .RE + .TP + .BI \-O " offset" +diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c +index a6ca660..1bd8646 100644 +--- a/misc-utils/blkid.c ++++ b/misc-utils/blkid.c +@@ -306,7 +306,7 @@ static void print_value(int output, int num, const char *devname, + printf("DEVNAME=%s\n", devname); + fputs(name, stdout); + fputs("=", stdout); +- safe_print(value, valsz, NULL); ++ safe_print(value, valsz, " \\\"'$`<>"); + fputs("\n", stdout); + + } else { +@@ -315,7 +315,7 @@ static void print_value(int output, int num, const char *devname, + fputs(" ", stdout); + fputs(name, stdout); + fputs("=\"", stdout); +- safe_print(value, valsz, "\""); ++ safe_print(value, valsz, "\"\\"); + fputs("\"", stdout); + } + } +-- +2.0.4 + diff --git a/package/util-linux/util-linux-001-sscanf-no-ms-as.patch b/package/util-linux/util-linux-001-sscanf-no-ms-as.patch deleted file mode 100644 index be2b0eb269..0000000000 --- a/package/util-linux/util-linux-001-sscanf-no-ms-as.patch +++ /dev/null @@ -1,175 +0,0 @@ -Fix libmount build under uClibc - -See https://bugs.gentoo.org/show_bug.cgi?id=406303 -http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/util-linux/files/util-linux-2.21.1-no-printf-alloc.patch?revision=1.2 - -[Gustavo: Ported to util-linux-2.25.1] - -Signed-off-by: Gustavo Zacarias - -diff -Nura util-linux-2.25.1.orig/configure.ac util-linux-2.25.1/configure.ac ---- util-linux-2.25.1.orig/configure.ac 2014-09-05 10:44:45.302080174 -0300 -+++ util-linux-2.25.1/configure.ac 2014-09-05 10:45:07.183832640 -0300 -@@ -791,7 +791,6 @@ - UL_BUILD_INIT([libmount]) - UL_REQUIRES_LINUX([libmount]) - UL_REQUIRES_BUILD([libmount], [libblkid]) --UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier]) - AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes]) - AM_CONDITIONAL([BUILD_LIBMOUNT_TESTS], [test "x$build_libmount" = xyes -a "x$enable_static" = xyes]) - -diff -Nura util-linux-2.25.1.orig/lib/colors.c util-linux-2.25.1/lib/colors.c ---- util-linux-2.25.1.orig/lib/colors.c 2014-09-05 10:44:45.301080140 -0300 -+++ util-linux-2.25.1/lib/colors.c 2014-09-05 13:12:00.175205476 -0300 -@@ -16,6 +16,10 @@ - #include "pathnames.h" - #include "strutils.h" - -+#ifndef HAVE_SCANF_MS_MODIFIER -+# define UL_SCNsA "%s" -+#endif -+ - /* - * terminal-colors.d file types - */ -@@ -577,9 +581,19 @@ - if (*p == '\0' || *p == '#') - continue; - -+#ifndef HAVE_SCANF_MS_MODIFIER -+ size_t len = strlen(p) + 1; -+ cn = malloc(len); -+ seq = malloc(len); -+#endif -+ - rc = sscanf(p, UL_SCNsA" " /* name */ - UL_SCNsA, /* color */ -+#ifdef HAVE_SCANF_MS_MODIFIER - &cn, &seq); -+#else -+ cn, seq); -+#endif - if (rc == 2 && cn && seq) - rc = colors_add_scheme(cc, cn, seq); /* set rc=0 on success */ - if (rc) { -diff -Nura util-linux-2.25.1.orig/libmount/src/tab_parse.c util-linux-2.25.1/libmount/src/tab_parse.c ---- util-linux-2.25.1.orig/libmount/src/tab_parse.c 2014-09-05 10:44:45.276079280 -0300 -+++ util-linux-2.25.1/libmount/src/tab_parse.c 2014-09-05 10:51:22.500738967 -0300 -@@ -22,6 +22,10 @@ - #include "pathnames.h" - #include "strutils.h" - -+#ifndef HAVE_SCANF_MS_MODIFIER -+# define UL_SCNsA "%s" -+#endif -+ - static int next_number(char **s, int *num) - { - char *end = NULL; -@@ -52,16 +56,31 @@ - int rc, n = 0, xrc; - char *src = NULL, *fstype = NULL, *optstr = NULL; - -+#ifndef HAVE_SCANF_MS_MODIFIER -+ size_t len = strlen(s) + 1; -+ src = malloc(len); -+ fstype = malloc(len); -+ fs->target = malloc(len); -+ optstr = malloc(len); -+#endif -+ - rc = sscanf(s, UL_SCNsA" " /* (1) source */ - UL_SCNsA" " /* (2) target */ - UL_SCNsA" " /* (3) FS type */ - UL_SCNsA" " /* (4) options */ - "%n", /* byte count */ - -+#ifdef HAVE_SCANF_MS_MODIFIER - &src, - &fs->target, - &fstype, - &optstr, -+#else -+ src, -+ fs->target, -+ fstype, -+ optstr, -+#endif - &n); - xrc = rc; - -@@ -127,6 +146,16 @@ - unsigned int maj, min; - char *fstype = NULL, *src = NULL, *p; - -+#ifndef HAVE_SCANF_MS_MODIFIER -+ size_t len = strlen(s) + 1; -+ fs->root = malloc(len); -+ fs->target = malloc(len); -+ fs->vfs_optstr = malloc(len); -+ fs->fs_optstr = malloc(len); -+ fstype = malloc(len); -+ src = malloc(len); -+#endif -+ - rc = sscanf(s, "%d " /* (1) id */ - "%d " /* (2) parent */ - "%u:%u " /* (3) maj:min */ -@@ -138,9 +167,15 @@ - &fs->id, - &fs->parent, - &maj, &min, -+#ifdef HAVE_SCANF_MS_MODIFIER - &fs->root, - &fs->target, - &fs->vfs_optstr, -+#else -+ fs->root, -+ fs->target, -+ fs->vfs_optstr, -+#endif - &end); - - if (rc >= 7 && end > 0) -@@ -160,9 +195,15 @@ - UL_SCNsA" " /* (9) source */ - UL_SCNsA, /* (10) fs options (fs specific) */ - -+#ifdef HAVE_SCANF_MS_MODIFIER - &fstype, - &src, - &fs->fs_optstr); -+#else -+ fstype, -+ src, -+ fs->fs_optstr); -+#endif - - if (rc >= 10) { - size_t sz; -@@ -281,14 +322,25 @@ - int rc; - char *src = NULL; - -+#ifndef HAVE_SCANF_MS_MODIFIER -+ size_t len = strlen(s) + 1; -+ src = malloc(len); -+ fs->swaptype = malloc(len); -+#endif -+ - rc = sscanf(s, UL_SCNsA" " /* (1) source */ - UL_SCNsA" " /* (2) type */ - "%ju" /* (3) size */ - "%ju" /* (4) used */ - "%d", /* priority */ - -+#ifdef HAVE_SCANF_MS_MODIFIER - &src, - &fs->swaptype, -+#else -+ src, -+ fs->swaptype, -+#endif - &fsz, - &usz, - &fs->priority); diff --git a/package/util-linux/util-linux-002-program-invocation-short-name.patch b/package/util-linux/util-linux-002-program-invocation-short-name.patch deleted file mode 100644 index 95fea3f13d..0000000000 --- a/package/util-linux/util-linux-002-program-invocation-short-name.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/configure.ac 2013-09-05 15:31:21.590981268 -0500 -+++ b/configure.ac 2013-09-05 15:31:29.160981049 -0500 -@@ -387,7 +387,7 @@ - - AC_MSG_CHECKING([whether program_invocation_short_name is defined]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -- #include -+ #include - ]], [[ - program_invocation_short_name = "test"; - ]])], [ diff --git a/package/util-linux/util-linux-003-c.h-define-mkostemp-for-older-version-of-uClibc.patch b/package/util-linux/util-linux-003-c.h-define-mkostemp-for-older-version-of-uClibc.patch deleted file mode 100644 index 0dfe7befba..0000000000 --- a/package/util-linux/util-linux-003-c.h-define-mkostemp-for-older-version-of-uClibc.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 42a84250fc78bae3e885ecd1379e713663fe6487 Mon Sep 17 00:00:00 2001 -From: Romain Naour -Date: Sun, 6 Apr 2014 12:12:41 +0200 -Subject: [PATCH 1/1] c.h: define mkostemp for older version of uClibc - -Signed-off-by: Romain Naour ---- - configure.ac | 2 ++ - include/c.h | 14 ++++++++++++++ - 2 files changed, 16 insertions(+) - -diff --git a/configure.ac b/configure.ac -index 35a1f26..a9b8d34 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -321,6 +321,8 @@ AC_CHECK_FUNCS([ \ - ]) - AC_FUNC_FSEEKO - -+AC_CHECK_FUNCS([mkostemp]) -+ - AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no]) - AC_CHECK_FUNCS([ioperm iopl], [have_io=yes]) - -diff --git a/include/c.h b/include/c.h -index 4a9bf3d..1b880ed 100644 ---- a/include/c.h -+++ b/include/c.h -@@ -300,4 +300,18 @@ static inline int usleep(useconds_t usec) - # define SEEK_HOLE 4 - #endif - -+/* -+ * mkostemp() may be missing with older version of uClibc -+ */ -+#ifndef HAVE_MKOSTEMP -+static inline int mkostemp(char *template, int flags) -+{ -+ int fd; -+ fd = mkstemp(template); -+ if (flags & O_CLOEXEC && fd >= 0) -+ fcntl(fd, F_SETFD, FD_CLOEXEC); -+ return fd; -+} -+#endif -+ - #endif /* UTIL_LINUX_C_H */ --- -1.9.0 - -- cgit v1.2.1