packages/net/netopeer2/patches/004-BUGFIX-for-missing-mkstemps-in-uClibc
Mislav Novakovic 8f2dd7dbb7 sysrepo: update the sysrepo/netopeer2 stack
Patch includes updates to packages:
netopeer2: update to version 0.4.0
sysrepo: update to 0.7.0
libnetconf2: update to 0.9.15
libyang: update to 0.13.46

Signed-off-by: Mislav Novakovic <mislav.novakovic@sartura.hr>
2017-09-18 12:00:38 +02:00

51 lines
2.1 KiB
Text

Index: netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/CMakeLists.txt
===================================================================
--- netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459.orig/cli/CMakeLists.txt
+++ netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/CMakeLists.txt
@@ -69,6 +69,10 @@ endif()
include(CheckFunctionExists)
check_function_exists(eaccess HAVE_EACCESS)
+check_function_exists(mkstemps HAVE_MKSTEMPS)
+if(HAVE_MKSTEMPS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MKSTEMPS")
+endif(HAVE_MKSTEMPS)
# install binary
install(TARGETS netopeer2-cli DESTINATION ${BIN_INSTALL_DIR})
Index: netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/completion.c
===================================================================
--- netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459.orig/cli/completion.c
+++ netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/completion.c
@@ -120,6 +120,7 @@ readinput(const char *instruction, const
char* tmpname = NULL, *input = NULL, *old_content = NULL, *ptr, *ptr2;
/* Create a unique temporary file */
+#ifdef HAVE_MKSTEMPS
if (asprintf(&tmpname, "/tmp/tmpXXXXXX.xml") == -1) {
ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
goto fail;
@@ -129,6 +130,23 @@ readinput(const char *instruction, const
ERROR(__func__, "Failed to create a temporary file (%s).", strerror(errno));
goto fail;
}
+#else
+ if (asprintf(&tmpname, "/tmp/tmpXXXXXX") == -1) {
+ ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
+ goto fail;
+ }
+ /* cannot fail */
+ mktemp(tmpname);
+ if (asprintf(&tmpname, ".xml") == -1) {
+ ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
+ goto fail;
+ }
+ tmpfd = open(tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
+ if (tmpfd == -1) {
+ ERROR(__func__, "Failed to create a temporary file (%s).", strerror(errno));
+ goto fail;
+ }
+#endif /* #ifdef HAVE_MKSTEMPS */
/* Read the old content, if any */
if (old_tmp != NULL) {