[Nagiosplug-checkins] nagiosplug/plugins-root check_dhcp.c, 1.11, 1.12 check_icmp.c, 1.12, 1.13
M. Sean Finney
seanius at users.sourceforge.net
Sun May 27 15:46:34 CEST 2007
Update of /cvsroot/nagiosplug/nagiosplug/plugins-root
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13507/plugins-root
Modified Files:
check_dhcp.c check_icmp.c
Log Message:
added functions to utils_base:
np_check_if_root() - returns nonzero if geteuid()==0
np_warn_if_not_root() - uses the above to print an informative warning
added uses of these functions to check_dhcp and check_icmp.
Index: check_dhcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-root/check_dhcp.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- check_dhcp.c 13 May 2007 12:28:30 -0000 1.11
+++ check_dhcp.c 27 May 2007 13:46:32 -0000 1.12
@@ -250,10 +250,13 @@
int dhcp_socket;
int result = STATE_UNKNOWN;
+ /* this plugin almost certainly needs root permissions. */
+ np_warn_if_not_root();
+
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
-
+
if(process_arguments(argc,argv)!=OK){
usage4 (_("Could not parse arguments"));
}
Index: check_icmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-root/check_icmp.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- check_icmp.c 27 Mar 2007 06:53:57 -0000 1.12
+++ check_icmp.c 27 May 2007 13:46:32 -0000 1.13
@@ -372,6 +372,9 @@
int result;
struct rta_host *host;
+ /* 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;
More information about the Commits
mailing list