From 80bbafecfc45683dc4441b0fa9f721fbccbcee5c Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 13 Dec 2017 17:31:55 +0100 Subject: [PATCH] Fix detection of the executable directory on NetBSD --- client/util.h | 2 +- client/whereami.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/util.h b/client/util.h index 8dc56f8..f4ea49d 100644 --- a/client/util.h +++ b/client/util.h @@ -82,7 +82,7 @@ void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length); void xor(unsigned char *dst, unsigned char *src, size_t len); int32_t le24toh(uint8_t data[3]); -uint32_t le32toh (uint8_t *data); +#endif void rol(uint8_t *data, const size_t len); void clean_ascii(unsigned char *buf, size_t len); diff --git a/client/whereami.c b/client/whereami.c index 6e5e85f..8cc49da 100644 --- a/client/whereami.c +++ b/client/whereami.c @@ -559,6 +559,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) defined(__FreeBSD_kernel__) || defined(__NetBSD__) #include +#include #include #include #include @@ -576,7 +577,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) for (;;) { +#ifdef KERN_PROC_ARGV + int mib[4] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; +#else int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; +#endif size_t size = sizeof(buffer1); if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0)