Code

oping: Drop root privileges as soon as possible.
[liboping.git] / src / oping.c
index 23d998609774c7b0945afa94f06cf2a1903caa94..3201e85dc0f8808268f467d4337ae9a137d7ee64 100644 (file)
@@ -322,6 +322,9 @@ int main (int argc, char **argv)
                }
        }
 
+       /* Drop root privileges if we're setuid-root. */
+       setuid (getuid ());
+
        i = 0;
        for (iter = ping_iterator_get (ping);
                        iter != NULL;
@@ -372,7 +375,8 @@ int main (int argc, char **argv)
 
                if (ping_send (ping) < 0)
                {
-                       fprintf (stderr, "ping_send failed\n");
+                       fprintf (stderr, "ping_send failed: %s\n",
+                                       ping_get_error (ping));
                        return (1);
                }