From 8272d73e579739cccbfce61f7401cd5f8b9fd0e0 Mon Sep 17 00:00:00 2001 From: Danijel Tasov Date: Sat, 23 Sep 2023 16:18:08 +0200 Subject: remove root check We can perfectly do icmp without root by using capabalities. So, instead of doing unsufficient checks beforehand, we just try and fail if it doesn't work. Signed-off-by: Danijel Tasov diff --git a/lib/utils_base.c b/lib/utils_base.c index 8a03d09..3822bcf 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -300,19 +300,6 @@ char *np_escaped_string (const char *string) { int np_check_if_root(void) { return (geteuid() == 0); } -int np_warn_if_not_root(void) { - int status = np_check_if_root(); - if(!status) { - printf(_("Warning: ")); - printf(_("This plugin must be either run as root or setuid root.\n")); - printf(_("To run as root, you can use a tool like sudo.\n")); - printf(_("To set the setuid permissions, use the command:\n")); - /* XXX could we use something like progname? */ - printf("\tchmod u+s yourpluginfile\n"); - } - return status; -} - /* * Extract the value from key/value pairs, or return NULL. The value returned * can be free()ed. diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 2ad644e..a7fad36 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -417,9 +417,6 @@ main(int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - /* print a helpful error message if geteuid != 0 */ - np_warn_if_not_root(); - /* we only need to be setsuid when we get the sockets, so do * that before pointer magic (esp. on network data) */ icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0; -- cgit v0.10-9-g596f