fix host build
authorDaniel Golle <daniel@makrotopia.org>
Sun, 10 Jun 2018 16:44:36 +0000 (18:44 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 14 Jun 2018 16:51:22 +0000 (18:51 +0200)
use execvp in host builds instead of hardcoding /usr/bin/usign path

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This work was sponsored by WIO (wiowireless.com)

CMakeLists.txt
usign-exec.c

index 2554ffe..a44ff23 100644 (file)
@@ -7,6 +7,10 @@ SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 
 find_library(json NAMES json-c json)
 
+IF(UCERT_HOST_BUILD)
+ADD_DEFINITIONS(-DUCERT_HOST_BUILD)
+ENDIF()
+
 ADD_EXECUTABLE(ucert ucert.c usign-exec.c)
 IF(UCERT_FULL)
 ADD_DEFINITIONS(-DUCERT_FULL)
index 2ab2cd3..21a24c2 100644 (file)
 
 #include "usign.h"
 
+#ifdef UCERT_HOST_BUILD
+#define USIGN_EXEC "usign"
+#else
 #define USIGN_EXEC "/usr/bin/usign"
+#endif
 
 /*
  * check for revoker deadlink in pubkeydir
@@ -68,7 +72,13 @@ int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bo
                return -1;
 
        case 0:
-               if (execv(usign_argv[0], usign_argv))
+               if (
+#ifdef UCERT_HOST_BUILD
+                       execvp(usign_argv[0], usign_argv)
+#else
+                       execv(usign_argv[0], usign_argv)
+#endif
+                  )
                        return -1;
 
                break;
@@ -131,7 +141,13 @@ static int usign_f(char *fingerprint, const char *pubkeyfile, const char *seckey
                close(fds[0]);
                close(fds[1]);
 
-               if (execv(usign_argv[0], usign_argv))
+               if (
+#ifdef UCERT_HOST_BUILD
+                   execvp(usign_argv[0], usign_argv)
+#else
+                   execv(usign_argv[0], usign_argv)
+#endif
+                  )
                        return -1;
 
                break;
@@ -230,7 +246,13 @@ int usign_v(const char *msgfile, const char *pubkeyfile,
                return -1;
 
        case 0:
-               if (execv(usign_argv[0], usign_argv))
+               if (
+#ifdef UCERT_HOST_BUILD
+                   execvp(usign_argv[0], usign_argv)
+#else
+                   execv(usign_argv[0], usign_argv)
+#endif
+                  )
                        return -1;
 
                break;