diff options
author | Sami Kerola <kerolasa@iki.fi> | 2018-01-15 20:39:18 +0000 |
---|---|---|
committer | Sami Kerola <kerolasa@iki.fi> | 2018-10-03 20:28:43 +0100 |
commit | 5307071a8fde797e8eee1b75a9c7640e08e8bd6b (patch) | |
tree | 5ca73727dc3200f595c1fad874223c0b4af90372 | |
parent | f9fbe2b46b56a5bdcd1dbc85a40a97b1ee744ec9 (diff) | |
download | iputils-5307071a8fde797e8eee1b75a9c7640e08e8bd6b.tar.gz |
build-sys: use HAVE_LIBCAP to determine libcap code should be compiled
The HAVE_* style is more common in other project, so change CAPABILITIES
definition to match that - that is also used in ninfod/*.c files.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r-- | arping.c | 12 | ||||
-rw-r--r-- | clockdiff.c | 4 | ||||
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | ping.h | 4 | ||||
-rw-r--r-- | ping_common.c | 10 | ||||
-rw-r--r-- | traceroute6.c | 4 |
6 files changed, 19 insertions, 18 deletions
@@ -19,7 +19,7 @@ #include <net/if_arp.h> #include <sys/ioctl.h> #include <sys/param.h> -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP #include <sys/prctl.h> #include <sys/capability.h> #endif @@ -91,7 +91,7 @@ struct timespec start, last; int sent, brd_sent; int received, brd_recv, req_recv; -#ifndef CAPABILITIES +#ifndef HAVE_LIBCAP static uid_t euid; #endif @@ -147,14 +147,14 @@ void set_signal(int signo, void (*handler)(void)) sigaction(signo, &sa, NULL); } -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP static const cap_value_t caps[] = { CAP_NET_RAW, }; static cap_flag_value_t cap_raw = CAP_CLEAR; #endif void limit_capabilities(void) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t cap_p; cap_p = cap_get_proc(); @@ -203,7 +203,7 @@ void limit_capabilities(void) int modify_capability_raw(int on) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t cap_p; if (cap_raw != CAP_SET) @@ -244,7 +244,7 @@ static inline int disable_capability_raw(void) void drop_capabilities(void) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t cap_p = cap_init(); if (!cap_p) { diff --git a/clockdiff.c b/clockdiff.c index fe9ca8d..9a9d23a 100644 --- a/clockdiff.c +++ b/clockdiff.c @@ -48,7 +48,7 @@ #include <arpa/inet.h> #include <errno.h> #include <linux/types.h> -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP #include <sys/capability.h> #endif @@ -569,7 +569,7 @@ void usage(void) } void drop_rights(void) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t caps = cap_init(); if (cap_set_proc(caps)) { perror("clockdiff: cap_set_proc"); diff --git a/meson.build b/meson.build index 15d6768..b45282a 100644 --- a/meson.build +++ b/meson.build @@ -49,7 +49,8 @@ rt_dep = cc.find_library('rt') opt = get_option('USE_CAP') if opt == true cap_dep = cc.find_library('cap') - add_project_arguments('-DCAPABILITIES', language : 'c') + conf.set('HAVE_LIBCAP', 1, + description : 'Defined if libcap exists.') else cap_dep = [] endif @@ -29,7 +29,7 @@ #include <linux/filter.h> #include <resolv.h> -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP #include <sys/prctl.h> #include <sys/capability.h> #endif @@ -272,7 +272,7 @@ static int enable_capability_raw(void); static int disable_capability_raw(void); static int enable_capability_admin(void); static int disable_capability_admin(void); -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP extern int modify_capability(cap_value_t, cap_flag_value_t); static inline int enable_capability_raw(void) { return modify_capability(CAP_NET_RAW, CAP_SET); }; static inline int disable_capability_raw(void) { return modify_capability(CAP_NET_RAW, CAP_CLEAR); }; diff --git a/ping_common.c b/ping_common.c index 9913d35..3839e8c 100644 --- a/ping_common.c +++ b/ping_common.c @@ -95,7 +95,7 @@ static int screen_width = INT_MAX; #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP static cap_value_t cap_raw = CAP_NET_RAW; static cap_value_t cap_admin = CAP_NET_ADMIN; #endif @@ -150,7 +150,7 @@ void usage(void) void limit_capabilities(void) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t cap_cur_p; cap_t cap_p; cap_flag_value_t cap_ok; @@ -204,7 +204,7 @@ void limit_capabilities(void) #endif uid = getuid(); euid = geteuid(); -#ifndef CAPABILITIES +#ifndef HAVE_LIBCAP if (seteuid(uid)) { perror("ping: setuid"); exit(-1); @@ -212,7 +212,7 @@ void limit_capabilities(void) #endif } -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP int modify_capability(cap_value_t cap, cap_flag_value_t on) { cap_t cap_p = cap_get_proc(); @@ -261,7 +261,7 @@ int modify_capability(int on) void drop_capabilities(void) { -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP cap_t cap = cap_init(); if (cap_set_proc(cap) < 0) { perror("ping: cap_set_proc"); diff --git a/traceroute6.c b/traceroute6.c index af51965..cedd09b 100644 --- a/traceroute6.c +++ b/traceroute6.c @@ -239,7 +239,7 @@ #include <netinet/ip6.h> #include <netinet/icmp6.h> #include <linux/types.h> -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP #include <sys/capability.h> #endif @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) perror("traceroute6: setuid"); exit(-1); } -#ifdef CAPABILITIES +#ifdef HAVE_LIBCAP { cap_t caps = cap_init(); if (cap_set_proc(caps)) { |