You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.1 KiB

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