sysrepo: bump to latest version
[feed/packages.git] / net / netopeer2 / patches / 004-BUGFIX-for-missing-mkstemps-in-uClibc
1 Index: netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/CMakeLists.txt
2 ===================================================================
3 --- netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459.orig/cli/CMakeLists.txt
4 +++ netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/CMakeLists.txt
5 @@ -69,6 +69,10 @@ endif()
6
7 include(CheckFunctionExists)
8 check_function_exists(eaccess HAVE_EACCESS)
9 +check_function_exists(mkstemps HAVE_MKSTEMPS)
10 +if(HAVE_MKSTEMPS)
11 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MKSTEMPS")
12 +endif(HAVE_MKSTEMPS)
13
14 # install binary
15 install(TARGETS netopeer2-cli DESTINATION ${BIN_INSTALL_DIR})
16 Index: netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/completion.c
17 ===================================================================
18 --- netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459.orig/cli/completion.c
19 +++ netopeer2-0.4.0-d028c1f931819db4b3e3cb1fd2d349a4fd5c0459/cli/completion.c
20 @@ -120,6 +120,7 @@ readinput(const char *instruction, const
21 char* tmpname = NULL, *input = NULL, *old_content = NULL, *ptr, *ptr2;
22
23 /* Create a unique temporary file */
24 +#ifdef HAVE_MKSTEMPS
25 if (asprintf(&tmpname, "/tmp/tmpXXXXXX.xml") == -1) {
26 ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
27 goto fail;
28 @@ -129,6 +130,23 @@ readinput(const char *instruction, const
29 ERROR(__func__, "Failed to create a temporary file (%s).", strerror(errno));
30 goto fail;
31 }
32 +#else
33 + if (asprintf(&tmpname, "/tmp/tmpXXXXXX") == -1) {
34 + ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
35 + goto fail;
36 + }
37 + /* cannot fail */
38 + mktemp(tmpname);
39 + if (asprintf(&tmpname, ".xml") == -1) {
40 + ERROR(__func__, "asprintf() failed (%s).", strerror(errno));
41 + goto fail;
42 + }
43 + tmpfd = open(tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
44 + if (tmpfd == -1) {
45 + ERROR(__func__, "Failed to create a temporary file (%s).", strerror(errno));
46 + goto fail;
47 + }
48 +#endif /* #ifdef HAVE_MKSTEMPS */
49
50 /* Read the old content, if any */
51 if (old_tmp != NULL) {