From 1adc7e5a2a1230825154e671a36639af6006764f Mon Sep 17 00:00:00 2001 From: Graham Mainwaring Date: Sun, 24 Apr 2022 18:19:25 -0400 Subject: [PATCH] Set ping_group_range so ping works --- netns-exec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/netns-exec.c b/netns-exec.c index 8d11fa3..b48223b 100644 --- a/netns-exec.c +++ b/netns-exec.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "namespace.h" @@ -108,6 +109,16 @@ int main(int argc, char *argv[]) return EXIT_OTHER_ERROR; + // allow non-root user to use the ping command + int fd = open("/proc/sys/net/ipv4/ping_group_range", O_WRONLY); + if (fd == -1) { + fprintf(stderr, "Error setting ping_group_range: %s\n", strerror(errno)); + usage(argv0, true); + } + dprintf(fd, "0 2147483647\n"); + close(fd); + + drop_root_privileges();