From: Daniel Golle Date: Sun, 10 Jun 2018 16:44:36 +0000 (+0200) Subject: fix host build X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=54be4d654308175cd95b16fb38e0260220db242b;p=oweals%2Fucert.git fix host build use execvp in host builds instead of hardcoding /usr/bin/usign path Signed-off-by: Daniel Golle This work was sponsored by WIO (wiowireless.com) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2554ffe..a44ff23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/usign-exec.c b/usign-exec.c index 2ab2cd3..21a24c2 100644 --- a/usign-exec.c +++ b/usign-exec.c @@ -20,7 +20,11 @@ #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;