Imported Upstream version 1.4.10
This commit is contained in:
parent
6dd54dd8e2
commit
cff68b4c0a
203 changed files with 15026 additions and 8063 deletions
|
@ -5,8 +5,8 @@ SUBDIRS = tests
|
|||
noinst_LIBRARIES = libnagiosplug.a
|
||||
|
||||
|
||||
libnagiosplug_a_SOURCES = utils_base.c utils_disk.c
|
||||
EXTRA_DIST = utils_base.h utils_disk.h
|
||||
libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c
|
||||
EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.9.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
|
@ -14,6 +14,8 @@
|
|||
|
||||
@SET_MAKE@
|
||||
|
||||
SOURCES = $(libnagiosplug_a_SOURCES)
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
@ -95,14 +97,15 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
|
|||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
ARFLAGS = cru
|
||||
libnagiosplug_a_AR = $(AR) $(ARFLAGS)
|
||||
libnagiosplug_a_LIBADD =
|
||||
am_libnagiosplug_a_OBJECTS = utils_base.$(OBJEXT) utils_disk.$(OBJEXT)
|
||||
am_libnagiosplug_a_OBJECTS = utils_base.$(OBJEXT) utils_disk.$(OBJEXT) \
|
||||
utils_tcp.$(OBJEXT) utils_cmd.$(OBJEXT)
|
||||
libnagiosplug_a_OBJECTS = $(am_libnagiosplug_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
|
||||
|
@ -261,6 +264,7 @@ PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
|
|||
PATH_TO_UPTIME = @PATH_TO_UPTIME@
|
||||
PATH_TO_WHO = @PATH_TO_WHO@
|
||||
PERL = @PERL@
|
||||
PERLMODS_DIR = @PERLMODS_DIR@
|
||||
PGINCLUDE = @PGINCLUDE@
|
||||
PGLIBS = @PGLIBS@
|
||||
PKG_ARCH = @PKG_ARCH@
|
||||
|
@ -349,8 +353,8 @@ target_alias = @target_alias@
|
|||
with_trusted_path = @with_trusted_path@
|
||||
SUBDIRS = tests
|
||||
noinst_LIBRARIES = libnagiosplug.a
|
||||
libnagiosplug_a_SOURCES = utils_base.c utils_disk.c
|
||||
EXTRA_DIST = utils_base.h utils_disk.h
|
||||
libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c
|
||||
EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h
|
||||
INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
|
||||
all: all-recursive
|
||||
|
||||
|
@ -400,7 +404,9 @@ distclean-compile:
|
|||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils_base.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils_cmd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils_disk.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils_tcp.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
|
|
|
@ -7,9 +7,9 @@ check_PROGRAMS = @EXTRA_TEST@
|
|||
|
||||
INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
|
||||
|
||||
EXTRA_PROGRAMS = test_utils test_disk
|
||||
EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd
|
||||
|
||||
EXTRA_DIST = test_utils.t test_disk.t
|
||||
EXTRA_DIST = test_utils.t test_disk.t test_tcp.t test_cmd.t
|
||||
|
||||
LIBS = @LIBINTL@
|
||||
|
||||
|
@ -23,6 +23,16 @@ test_disk_CFLAGS = -g -I..
|
|||
test_disk_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
|
||||
|
||||
test_tcp_SOURCES = test_tcp.c
|
||||
test_tcp_CFLAGS = -g -I..
|
||||
test_tcp_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_tcp_LDADD = ../utils_tcp.o
|
||||
|
||||
test_cmd_SOURCES = test_cmd.c
|
||||
test_cmd_CFLAGS = -g -I..
|
||||
test_cmd_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_cmd_LDADD = ../utils_cmd.o ../utils_base.o
|
||||
|
||||
test: ${noinst_PROGRAMS}
|
||||
perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.9.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
|
@ -14,6 +14,8 @@
|
|||
|
||||
@SET_MAKE@
|
||||
|
||||
SOURCES = $(test_cmd_SOURCES) $(test_disk_SOURCES) $(test_tcp_SOURCES) $(test_utils_SOURCES)
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
@ -37,7 +39,8 @@ build_triplet = @build@
|
|||
host_triplet = @host@
|
||||
noinst_PROGRAMS = @EXTRA_TEST@
|
||||
check_PROGRAMS = @EXTRA_TEST@
|
||||
EXTRA_PROGRAMS = test_utils$(EXEEXT) test_disk$(EXEEXT)
|
||||
EXTRA_PROGRAMS = test_utils$(EXEEXT) test_disk$(EXEEXT) \
|
||||
test_tcp$(EXEEXT) test_cmd$(EXEEXT)
|
||||
subdir = lib/tests
|
||||
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
|
@ -98,13 +101,19 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
|
|||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
PROGRAMS = $(noinst_PROGRAMS)
|
||||
am_test_cmd_OBJECTS = test_cmd-test_cmd.$(OBJEXT)
|
||||
test_cmd_OBJECTS = $(am_test_cmd_OBJECTS)
|
||||
test_cmd_DEPENDENCIES = ../utils_cmd.o ../utils_base.o
|
||||
am_test_disk_OBJECTS = test_disk-test_disk.$(OBJEXT)
|
||||
test_disk_OBJECTS = $(am_test_disk_OBJECTS)
|
||||
test_disk_DEPENDENCIES = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
|
||||
am_test_tcp_OBJECTS = test_tcp-test_tcp.$(OBJEXT)
|
||||
test_tcp_OBJECTS = $(am_test_tcp_OBJECTS)
|
||||
test_tcp_DEPENDENCIES = ../utils_tcp.o
|
||||
am_test_utils_OBJECTS = test_utils-test_utils.$(OBJEXT)
|
||||
test_utils_OBJECTS = $(am_test_utils_OBJECTS)
|
||||
test_utils_DEPENDENCIES = ../utils_base.o
|
||||
|
@ -119,8 +128,10 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
|
|||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(test_disk_SOURCES) $(test_utils_SOURCES)
|
||||
DIST_SOURCES = $(test_disk_SOURCES) $(test_utils_SOURCES)
|
||||
SOURCES = $(test_cmd_SOURCES) $(test_disk_SOURCES) $(test_tcp_SOURCES) \
|
||||
$(test_utils_SOURCES)
|
||||
DIST_SOURCES = $(test_cmd_SOURCES) $(test_disk_SOURCES) \
|
||||
$(test_tcp_SOURCES) $(test_utils_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
@ -258,6 +269,7 @@ PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
|
|||
PATH_TO_UPTIME = @PATH_TO_UPTIME@
|
||||
PATH_TO_WHO = @PATH_TO_WHO@
|
||||
PERL = @PERL@
|
||||
PERLMODS_DIR = @PERLMODS_DIR@
|
||||
PGINCLUDE = @PGINCLUDE@
|
||||
PGLIBS = @PGLIBS@
|
||||
PKG_ARCH = @PKG_ARCH@
|
||||
|
@ -348,7 +360,7 @@ with_trusted_path = @with_trusted_path@
|
|||
# These two lines support "make check", but we use "make test"
|
||||
TESTS = @EXTRA_TEST@
|
||||
INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
|
||||
EXTRA_DIST = test_utils.t test_disk.t
|
||||
EXTRA_DIST = test_utils.t test_disk.t test_tcp.t test_cmd.t
|
||||
test_utils_SOURCES = test_utils.c
|
||||
test_utils_CFLAGS = -g -I..
|
||||
test_utils_LDFLAGS = -L/usr/local/lib -ltap
|
||||
|
@ -357,6 +369,14 @@ test_disk_SOURCES = test_disk.c
|
|||
test_disk_CFLAGS = -g -I..
|
||||
test_disk_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
|
||||
test_tcp_SOURCES = test_tcp.c
|
||||
test_tcp_CFLAGS = -g -I..
|
||||
test_tcp_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_tcp_LDADD = ../utils_tcp.o
|
||||
test_cmd_SOURCES = test_cmd.c
|
||||
test_cmd_CFLAGS = -g -I..
|
||||
test_cmd_LDFLAGS = -L/usr/local/lib -ltap
|
||||
test_cmd_LDADD = ../utils_cmd.o ../utils_base.o
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -404,9 +424,15 @@ clean-noinstPROGRAMS:
|
|||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
test_cmd$(EXEEXT): $(test_cmd_OBJECTS) $(test_cmd_DEPENDENCIES)
|
||||
@rm -f test_cmd$(EXEEXT)
|
||||
$(LINK) $(test_cmd_LDFLAGS) $(test_cmd_OBJECTS) $(test_cmd_LDADD) $(LIBS)
|
||||
test_disk$(EXEEXT): $(test_disk_OBJECTS) $(test_disk_DEPENDENCIES)
|
||||
@rm -f test_disk$(EXEEXT)
|
||||
$(LINK) $(test_disk_LDFLAGS) $(test_disk_OBJECTS) $(test_disk_LDADD) $(LIBS)
|
||||
test_tcp$(EXEEXT): $(test_tcp_OBJECTS) $(test_tcp_DEPENDENCIES)
|
||||
@rm -f test_tcp$(EXEEXT)
|
||||
$(LINK) $(test_tcp_LDFLAGS) $(test_tcp_OBJECTS) $(test_tcp_LDADD) $(LIBS)
|
||||
test_utils$(EXEEXT): $(test_utils_OBJECTS) $(test_utils_DEPENDENCIES)
|
||||
@rm -f test_utils$(EXEEXT)
|
||||
$(LINK) $(test_utils_LDFLAGS) $(test_utils_OBJECTS) $(test_utils_LDADD) $(LIBS)
|
||||
|
@ -417,7 +443,9 @@ mostlyclean-compile:
|
|||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cmd-test_cmd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_disk-test_disk.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tcp-test_tcp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_utils-test_utils.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
|
@ -441,6 +469,20 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
test_cmd-test_cmd.o: test_cmd.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cmd_CFLAGS) $(CFLAGS) -MT test_cmd-test_cmd.o -MD -MP -MF "$(DEPDIR)/test_cmd-test_cmd.Tpo" -c -o test_cmd-test_cmd.o `test -f 'test_cmd.c' || echo '$(srcdir)/'`test_cmd.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_cmd-test_cmd.Tpo" "$(DEPDIR)/test_cmd-test_cmd.Po"; else rm -f "$(DEPDIR)/test_cmd-test_cmd.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test_cmd.c' object='test_cmd-test_cmd.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cmd_CFLAGS) $(CFLAGS) -c -o test_cmd-test_cmd.o `test -f 'test_cmd.c' || echo '$(srcdir)/'`test_cmd.c
|
||||
|
||||
test_cmd-test_cmd.obj: test_cmd.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cmd_CFLAGS) $(CFLAGS) -MT test_cmd-test_cmd.obj -MD -MP -MF "$(DEPDIR)/test_cmd-test_cmd.Tpo" -c -o test_cmd-test_cmd.obj `if test -f 'test_cmd.c'; then $(CYGPATH_W) 'test_cmd.c'; else $(CYGPATH_W) '$(srcdir)/test_cmd.c'; fi`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_cmd-test_cmd.Tpo" "$(DEPDIR)/test_cmd-test_cmd.Po"; else rm -f "$(DEPDIR)/test_cmd-test_cmd.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test_cmd.c' object='test_cmd-test_cmd.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_cmd_CFLAGS) $(CFLAGS) -c -o test_cmd-test_cmd.obj `if test -f 'test_cmd.c'; then $(CYGPATH_W) 'test_cmd.c'; else $(CYGPATH_W) '$(srcdir)/test_cmd.c'; fi`
|
||||
|
||||
test_disk-test_disk.o: test_disk.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_disk_CFLAGS) $(CFLAGS) -MT test_disk-test_disk.o -MD -MP -MF "$(DEPDIR)/test_disk-test_disk.Tpo" -c -o test_disk-test_disk.o `test -f 'test_disk.c' || echo '$(srcdir)/'`test_disk.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_disk-test_disk.Tpo" "$(DEPDIR)/test_disk-test_disk.Po"; else rm -f "$(DEPDIR)/test_disk-test_disk.Tpo"; exit 1; fi
|
||||
|
@ -455,6 +497,20 @@ test_disk-test_disk.obj: test_disk.c
|
|||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_disk_CFLAGS) $(CFLAGS) -c -o test_disk-test_disk.obj `if test -f 'test_disk.c'; then $(CYGPATH_W) 'test_disk.c'; else $(CYGPATH_W) '$(srcdir)/test_disk.c'; fi`
|
||||
|
||||
test_tcp-test_tcp.o: test_tcp.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tcp_CFLAGS) $(CFLAGS) -MT test_tcp-test_tcp.o -MD -MP -MF "$(DEPDIR)/test_tcp-test_tcp.Tpo" -c -o test_tcp-test_tcp.o `test -f 'test_tcp.c' || echo '$(srcdir)/'`test_tcp.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_tcp-test_tcp.Tpo" "$(DEPDIR)/test_tcp-test_tcp.Po"; else rm -f "$(DEPDIR)/test_tcp-test_tcp.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test_tcp.c' object='test_tcp-test_tcp.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tcp_CFLAGS) $(CFLAGS) -c -o test_tcp-test_tcp.o `test -f 'test_tcp.c' || echo '$(srcdir)/'`test_tcp.c
|
||||
|
||||
test_tcp-test_tcp.obj: test_tcp.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tcp_CFLAGS) $(CFLAGS) -MT test_tcp-test_tcp.obj -MD -MP -MF "$(DEPDIR)/test_tcp-test_tcp.Tpo" -c -o test_tcp-test_tcp.obj `if test -f 'test_tcp.c'; then $(CYGPATH_W) 'test_tcp.c'; else $(CYGPATH_W) '$(srcdir)/test_tcp.c'; fi`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_tcp-test_tcp.Tpo" "$(DEPDIR)/test_tcp-test_tcp.Po"; else rm -f "$(DEPDIR)/test_tcp-test_tcp.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test_tcp.c' object='test_tcp-test_tcp.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_tcp_CFLAGS) $(CFLAGS) -c -o test_tcp-test_tcp.obj `if test -f 'test_tcp.c'; then $(CYGPATH_W) 'test_tcp.c'; else $(CYGPATH_W) '$(srcdir)/test_tcp.c'; fi`
|
||||
|
||||
test_utils-test_utils.o: test_utils.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_utils_CFLAGS) $(CFLAGS) -MT test_utils-test_utils.o -MD -MP -MF "$(DEPDIR)/test_utils-test_utils.Tpo" -c -o test_utils-test_utils.o `test -f 'test_utils.c' || echo '$(srcdir)/'`test_utils.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/test_utils-test_utils.Tpo" "$(DEPDIR)/test_utils-test_utils.Po"; else rm -f "$(DEPDIR)/test_utils-test_utils.Tpo"; exit 1; fi
|
||||
|
|
210
lib/tests/test_cmd.c
Normal file
210
lib/tests/test_cmd.c
Normal file
|
@ -0,0 +1,210 @@
|
|||
/******************************************************************************
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: test_cmd.c 1732 2007-06-03 15:58:22Z psychotrahe $
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "utils_cmd.h"
|
||||
#include "utils_base.h"
|
||||
#include "tap.h"
|
||||
|
||||
#define COMMAND_LINE 1024
|
||||
#define UNSET 65530
|
||||
|
||||
char *
|
||||
get_command (char *const *line)
|
||||
{
|
||||
char *cmd;
|
||||
int i = 0;
|
||||
|
||||
asprintf (&cmd, " %s", line[i++]);
|
||||
while (line[i] != NULL) {
|
||||
asprintf (&cmd, "%s %s", cmd, line[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char **command_line = malloc (sizeof (char *) * COMMAND_LINE);
|
||||
char *command = NULL;
|
||||
char *perl;
|
||||
output chld_out, chld_err;
|
||||
int c;
|
||||
int result = UNSET;
|
||||
|
||||
plan_tests(47);
|
||||
|
||||
diag ("Running plain echo command, set one");
|
||||
|
||||
/* ensure everything is empty before we begin */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
command_line[0] = strdup ("/bin/echo");
|
||||
command_line[1] = strdup ("this");
|
||||
command_line[2] = strdup ("is");
|
||||
command_line[3] = strdup ("test");
|
||||
command_line[4] = strdup ("one");
|
||||
|
||||
command = get_command (command_line);
|
||||
|
||||
result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
|
||||
ok (chld_out.lines == 1,
|
||||
"(array) Check for expected number of stdout lines");
|
||||
ok (chld_err.lines == 0,
|
||||
"(array) Check for expected number of stderr lines");
|
||||
ok (strcmp (chld_out.line[0], "this is test one") == 0,
|
||||
"(array) Check for expected stdout output");
|
||||
ok (result == 0, "(array) Checking exit code");
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
result = cmd_run (command, &chld_out, &chld_err, 0);
|
||||
|
||||
ok (chld_out.lines == 1,
|
||||
"(string) Check for expected number of stdout lines");
|
||||
ok (chld_err.lines == 0,
|
||||
"(string) Check for expected number of stderr lines");
|
||||
ok (strcmp (chld_out.line[0], "this is test one") == 0,
|
||||
"(string) Check for expected stdout output");
|
||||
ok (result == 0, "(string) Checking exit code");
|
||||
|
||||
diag ("Running plain echo command, set two");
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
command_line[0] = strdup ("/bin/echo");
|
||||
command_line[1] = strdup ("this is test two");
|
||||
command_line[2] = NULL;
|
||||
command_line[3] = NULL;
|
||||
command_line[4] = NULL;
|
||||
|
||||
result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
|
||||
ok (chld_out.lines == 1,
|
||||
"(array) Check for expected number of stdout lines");
|
||||
ok (chld_err.lines == 0,
|
||||
"(array) Check for expected number of stderr lines");
|
||||
ok (strcmp (chld_out.line[0], "this is test two") == 0,
|
||||
"(array) Check for expected stdout output");
|
||||
ok (result == 0, "(array) Checking exit code");
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
result = cmd_run (command, &chld_out, &chld_err, 0);
|
||||
|
||||
ok (chld_out.lines == 1,
|
||||
"(string) Check for expected number of stdout lines");
|
||||
ok (chld_err.lines == 0,
|
||||
"(string) Check for expected number of stderr lines");
|
||||
ok (strcmp (chld_out.line[0], "this is test one") == 0,
|
||||
"(string) Check for expected stdout output");
|
||||
ok (result == 0, "(string) Checking exit code");
|
||||
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
/* Pass linefeeds via parameters through - those should be evaluated by echo to give multi line output */
|
||||
command_line[0] = strdup("/bin/echo");
|
||||
command_line[1] = strdup("this is a test via echo\nline two\nit's line 3");
|
||||
command_line[2] = strdup("and (note space between '3' and 'and') $$ will not get evaluated");
|
||||
|
||||
result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
|
||||
ok (chld_out.lines == 3,
|
||||
"(array) Check for expected number of stdout lines");
|
||||
ok (chld_err.lines == 0,
|
||||
"(array) Check for expected number of stderr lines");
|
||||
ok (strcmp (chld_out.line[0], "this is a test via echo") == 0,
|
||||
"(array) Check line 1 for expected stdout output");
|
||||
ok (strcmp (chld_out.line[1], "line two") == 0,
|
||||
"(array) Check line 2 for expected stdout output");
|
||||
ok (strcmp (chld_out.line[2], "it's line 3 and (note space between '3' and 'and') $$ will not get evaluated") == 0,
|
||||
"(array) Check line 3 for expected stdout output");
|
||||
ok (result == 0, "(array) Checking exit code");
|
||||
|
||||
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
ok (chld_out.lines == 0, "(initialised) Checking stdout is reset");
|
||||
ok (chld_err.lines == 0, "(initialised) Checking stderr is reset");
|
||||
ok (result == UNSET, "(initialised) Checking exit code is reset");
|
||||
|
||||
command = (char *)malloc(COMMAND_LINE);
|
||||
strcpy(command, "/bin/echo3456 non-existant command");
|
||||
result = cmd_run (command, &chld_out, &chld_err, 0);
|
||||
|
||||
ok (chld_out.lines == 0,
|
||||
"Non existant command, so no output");
|
||||
ok (chld_err.lines == 0,
|
||||
"No stderr either");
|
||||
ok (result == 3, "Get return code 3 (?) for non-existant command");
|
||||
|
||||
|
||||
/* ensure everything is empty again */
|
||||
memset (&chld_out, 0, sizeof (output));
|
||||
memset (&chld_err, 0, sizeof (output));
|
||||
result = UNSET;
|
||||
|
||||
command = (char *)malloc(COMMAND_LINE);
|
||||
strcpy(command, "/bin/grep pattern non-existant-file");
|
||||
result = cmd_run (command, &chld_out, &chld_err, 0);
|
||||
|
||||
ok (chld_out.lines == 0,
|
||||
"Grep returns no stdout when file is missing...");
|
||||
ok (chld_err.lines == 1,
|
||||
"...but does give an error line");
|
||||
ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message");
|
||||
ok (result == 2, "Get return code 2 from grep");
|
||||
|
||||
|
||||
|
||||
return exit_status ();
|
||||
}
|
6
lib/tests/test_cmd.t
Normal file
6
lib/tests/test_cmd.t
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
use Test::More;
|
||||
if (! -e "./test_cmd") {
|
||||
plan skip_all => "./test_cmd not compiled - please install tap library to test";
|
||||
}
|
||||
exec "./test_cmd";
|
|
@ -14,7 +14,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: test_disk.c,v 1.3 2007/03/30 09:00:05 psychotrahe Exp $
|
||||
$Id: test_disk.c 1786 2007-09-22 17:40:35Z psychotrahe $
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -36,14 +36,15 @@ main (int argc, char **argv)
|
|||
struct name_list *dummy_mountlist = NULL;
|
||||
struct name_list *temp_name;
|
||||
struct parameter_list *paths = NULL;
|
||||
struct parameter_list *p;
|
||||
struct parameter_list *p, *prev, *last;
|
||||
|
||||
struct mount_entry *dummy_mount_list;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry **mtail = &dummy_mount_list;
|
||||
int cflags = REG_NOSUB | REG_EXTENDED;
|
||||
int found = 0, count = 0;
|
||||
|
||||
plan_tests(29);
|
||||
plan_tests(33);
|
||||
|
||||
ok( np_find_name(exclude_filesystem, "/var/log") == FALSE, "/var/log not in list");
|
||||
np_add_name(&exclude_filesystem, "/var/log");
|
||||
|
@ -160,6 +161,46 @@ main (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* test deleting first element in paths */
|
||||
paths = np_del_parameter(paths, NULL);
|
||||
for (p = paths; p; p = p->name_next) {
|
||||
if (! strcmp(p->name, "/home/groups"))
|
||||
found = 1;
|
||||
}
|
||||
ok(found == 0, "first element successfully deleted");
|
||||
found = 0;
|
||||
|
||||
p=paths;
|
||||
while (p) {
|
||||
if (! strcmp(p->name, "/tmp"))
|
||||
p = np_del_parameter(p, prev);
|
||||
else {
|
||||
prev = p;
|
||||
p = p->name_next;
|
||||
}
|
||||
}
|
||||
|
||||
for (p = paths; p; p = p->name_next) {
|
||||
if (! strcmp(p->name, "/tmp"))
|
||||
found = 1;
|
||||
if (p->name_next)
|
||||
prev = p;
|
||||
else
|
||||
last = p;
|
||||
}
|
||||
ok(found == 0, "/tmp element successfully deleted");
|
||||
|
||||
p = np_del_parameter(last, prev);
|
||||
for (p = paths; p; p = p->name_next) {
|
||||
if (! strcmp(p->name, "/home"))
|
||||
found = 1;
|
||||
last = p;
|
||||
count++;
|
||||
}
|
||||
ok(found == 0, "last (/home) element successfully deleted");
|
||||
ok(count == 2, "two elements remaining");
|
||||
|
||||
|
||||
return exit_status();
|
||||
}
|
||||
|
||||
|
|
58
lib/tests/test_tcp.c
Normal file
58
lib/tests/test_tcp.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/******************************************************************************
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: test_tcp.c 1732 2007-06-03 15:58:22Z psychotrahe $
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "utils_tcp.h"
|
||||
#include "tap.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char** server_expect;
|
||||
int server_expect_count = 3;
|
||||
plan_tests(8);
|
||||
|
||||
server_expect = malloc(sizeof(char*) * server_expect_count);
|
||||
|
||||
server_expect[0] = strdup("AA");
|
||||
server_expect[1] = strdup("bb");
|
||||
server_expect[2] = strdup("CC");
|
||||
|
||||
ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
|
||||
"Test matching any string at the beginning (first expect string)");
|
||||
ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == TRUE,
|
||||
"Test matching any string at the beginning (second expect string)");
|
||||
ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
|
||||
"Test with strings not matching at the beginning");
|
||||
ok(np_expect_match("XX CC XX", server_expect, server_expect_count, FALSE, TRUE, FALSE) == FALSE,
|
||||
"Test matching any string");
|
||||
ok(np_expect_match("XX", server_expect, server_expect_count, FALSE, FALSE, FALSE) == FALSE,
|
||||
"Test not matching any string");
|
||||
ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == TRUE,
|
||||
"Test matching all strings");
|
||||
ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
|
||||
"Test not matching all strings");
|
||||
ok(np_expect_match("XX XX", server_expect, server_expect_count, TRUE, FALSE, FALSE) == FALSE,
|
||||
"Test not matching any string (testing all)");
|
||||
|
||||
|
||||
return exit_status();
|
||||
}
|
||||
|
6
lib/tests/test_tcp.t
Executable file
6
lib/tests/test_tcp.t
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
use Test::More;
|
||||
if (! -e "./test_tcp") {
|
||||
plan skip_all => "./test_tcp not compiled - please install tap library to test";
|
||||
}
|
||||
exec "./test_tcp";
|
|
@ -14,7 +14,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: test_utils.c,v 1.2 2006/07/13 23:58:00 tonvoon Exp $
|
||||
$Id: test_utils.c 1452 2006-07-13 23:58:00Z tonvoon $
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
* Copyright (c) 2006 Nagios Plugin Development Team
|
||||
* License: GPL
|
||||
*
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2007/01/27 17:49:08 $
|
||||
* $Revision: 1768 $
|
||||
* $Date: 2007-07-29 13:42:05 +0100 (Sun, 29 Jul 2007) $
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -228,3 +228,18 @@ char *np_escaped_string (const char *string) {
|
|||
data[j] = '\0';
|
||||
return data;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ typedef struct thresholds_struct {
|
|||
range *parse_range_string (char *);
|
||||
int _set_thresholds(thresholds **, char *, char *);
|
||||
void set_thresholds(thresholds **, char *, char *);
|
||||
void print_thresholds(const char *, thresholds *);
|
||||
int check_range(double, range *);
|
||||
int get_status(double, thresholds *);
|
||||
|
||||
|
@ -42,4 +43,11 @@ void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)))
|
|||
#define NP_RANGE_UNPARSEABLE 1
|
||||
#define NP_WARN_WITHIN_CRIT 2
|
||||
|
||||
/* a simple check to see if we're running as root.
|
||||
* returns zero on failure, nonzero on success */
|
||||
int np_check_if_root(void);
|
||||
/* and a helpful wrapper around that. it returns the same status
|
||||
* code from the above function, in case it's helpful for testing */
|
||||
int np_warn_if_not_root(void);
|
||||
|
||||
#endif /* _UTILS_BASE_ */
|
||||
|
|
378
lib/utils_cmd.c
Normal file
378
lib/utils_cmd.c
Normal file
|
@ -0,0 +1,378 @@
|
|||
/****************************************************************************
|
||||
* Nagios run command utilities
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2005 nagios-plugins team
|
||||
*
|
||||
* $Id: utils_cmd.c 1434 2006-06-18 19:36:48Z opensides $
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
* A simple interface to executing programs from other programs, using an
|
||||
* optimized and safe popen()-like implementation. It is considered safe
|
||||
* in that no shell needs to be spawned and the environment passed to the
|
||||
* execve()'d program is essentially empty.
|
||||
*
|
||||
*
|
||||
* The code in this file is a derivative of popen.c which in turn was taken
|
||||
* from "Advanced Programming for the Unix Environment" by W. Richard Stevens.
|
||||
*
|
||||
* Care has been taken to make sure the functions are async-safe. The one
|
||||
* function which isn't is cmd_init() which it doesn't make sense to
|
||||
* call twice anyway, so the api as a whole should be considered async-safe.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define NAGIOSPLUG_API_C 1
|
||||
|
||||
/** includes **/
|
||||
#include "common.h"
|
||||
#include "utils_cmd.h"
|
||||
#include "utils_base.h"
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
/** macros **/
|
||||
#ifndef WEXITSTATUS
|
||||
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
|
||||
#endif
|
||||
|
||||
#ifndef WIFEXITED
|
||||
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
|
||||
#endif
|
||||
|
||||
/* 4.3BSD Reno <signal.h> doesn't define SIG_ERR */
|
||||
#if defined(SIG_IGN) && !defined(SIG_ERR)
|
||||
# define SIG_ERR ((Sigfunc *)-1)
|
||||
#endif
|
||||
|
||||
/* This variable must be global, since there's no way the caller
|
||||
* can forcibly slay a dead or ungainly running program otherwise.
|
||||
* Multithreading apps and plugins can initialize it (via CMD_INIT)
|
||||
* in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
|
||||
* for the first time.
|
||||
*
|
||||
* The check for initialized values is atomic and can
|
||||
* occur in any number of threads simultaneously. */
|
||||
static pid_t *_cmd_pids = NULL;
|
||||
|
||||
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
|
||||
* If that fails and the macro isn't defined, we fall back to an educated
|
||||
* guess. There's no guarantee that our guess is adequate and the program
|
||||
* will die with SIGSEGV if it isn't and the upper boundary is breached. */
|
||||
#ifdef _SC_OPEN_MAX
|
||||
static long maxfd = 0;
|
||||
#elif defined(OPEN_MAX)
|
||||
# define maxfd OPEN_MAX
|
||||
#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
|
||||
# define maxfd 256
|
||||
#endif
|
||||
|
||||
|
||||
/** prototypes **/
|
||||
static int _cmd_open (char *const *, int *, int *)
|
||||
__attribute__ ((__nonnull__ (1, 2, 3)));
|
||||
|
||||
static int _cmd_fetch_output (int, output *, int)
|
||||
__attribute__ ((__nonnull__ (2)));
|
||||
|
||||
static int _cmd_close (int);
|
||||
|
||||
/* prototype imported from utils.h */
|
||||
extern void die (int, const char *, ...)
|
||||
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
|
||||
|
||||
|
||||
/* this function is NOT async-safe. It is exported so multithreaded
|
||||
* plugins (or other apps) can call it prior to running any commands
|
||||
* through this api and thus achieve async-safeness throughout the api */
|
||||
void
|
||||
cmd_init (void)
|
||||
{
|
||||
#ifndef maxfd
|
||||
if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
|
||||
/* possibly log or emit a warning here, since there's no
|
||||
* guarantee that our guess at maxfd will be adequate */
|
||||
maxfd = 256;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!_cmd_pids)
|
||||
_cmd_pids = calloc (maxfd, sizeof (pid_t));
|
||||
}
|
||||
|
||||
|
||||
/* Start running a command, array style */
|
||||
static int
|
||||
_cmd_open (char *const *argv, int *pfd, int *pfderr)
|
||||
{
|
||||
char *env[2];
|
||||
pid_t pid;
|
||||
#ifdef RLIMIT_CORE
|
||||
struct rlimit limit;
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
|
||||
/* if no command was passed, return with no error */
|
||||
if (argv == NULL)
|
||||
return -1;
|
||||
|
||||
if (!_cmd_pids)
|
||||
CMD_INIT;
|
||||
|
||||
env[0] = strdup ("LC_ALL=C");
|
||||
env[1] = '\0';
|
||||
|
||||
if (pipe (pfd) < 0 || pipe (pfderr) < 0 || (pid = fork ()) < 0)
|
||||
return -1; /* errno set by the failing function */
|
||||
|
||||
/* child runs exceve() and _exit. */
|
||||
if (pid == 0) {
|
||||
#ifdef RLIMIT_CORE
|
||||
/* the program we execve shouldn't leave core files */
|
||||
getrlimit (RLIMIT_CORE, &limit);
|
||||
limit.rlim_cur = 0;
|
||||
setrlimit (RLIMIT_CORE, &limit);
|
||||
#endif
|
||||
close (pfd[0]);
|
||||
if (pfd[1] != STDOUT_FILENO) {
|
||||
dup2 (pfd[1], STDOUT_FILENO);
|
||||
close (pfd[1]);
|
||||
}
|
||||
close (pfderr[0]);
|
||||
if (pfderr[1] != STDERR_FILENO) {
|
||||
dup2 (pfderr[1], STDERR_FILENO);
|
||||
close (pfderr[1]);
|
||||
}
|
||||
|
||||
/* close all descriptors in _cmd_pids[]
|
||||
* This is executed in a separate address space (pure child),
|
||||
* so we don't have to worry about async safety */
|
||||
for (i = 0; i < maxfd; i++)
|
||||
if (_cmd_pids[i] > 0)
|
||||
close (i);
|
||||
|
||||
execve (argv[0], argv, env);
|
||||
_exit (STATE_UNKNOWN);
|
||||
}
|
||||
|
||||
/* parent picks up execution here */
|
||||
/* close childs descriptors in our address space */
|
||||
close (pfd[1]);
|
||||
close (pfderr[1]);
|
||||
|
||||
/* tag our file's entry in the pid-list and return it */
|
||||
_cmd_pids[pfd[0]] = pid;
|
||||
|
||||
return pfd[0];
|
||||
}
|
||||
|
||||
static int
|
||||
_cmd_close (int fd)
|
||||
{
|
||||
int status;
|
||||
pid_t pid;
|
||||
|
||||
/* make sure the provided fd was opened */
|
||||
if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0)
|
||||
return -1;
|
||||
|
||||
_cmd_pids[fd] = 0;
|
||||
if (close (fd) == -1)
|
||||
return -1;
|
||||
|
||||
/* EINTR is ok (sort of), everything else is bad */
|
||||
while (waitpid (pid, &status, 0) < 0)
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
|
||||
/* return child's termination status */
|
||||
return (WIFEXITED (status)) ? WEXITSTATUS (status) : -1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_cmd_fetch_output (int fd, output * op, int flags)
|
||||
{
|
||||
size_t len = 0, i = 0, lineno = 0;
|
||||
size_t rsf = 6, ary_size = 0; /* rsf = right shift factor, dec'ed uncond once */
|
||||
char *buf = NULL;
|
||||
int ret;
|
||||
char tmpbuf[4096];
|
||||
|
||||
op->buf = NULL;
|
||||
op->buflen = 0;
|
||||
while ((ret = read (fd, tmpbuf, sizeof (tmpbuf))) > 0) {
|
||||
len = (size_t) ret;
|
||||
op->buf = realloc (op->buf, op->buflen + len + 1);
|
||||
memcpy (op->buf + op->buflen, tmpbuf, len);
|
||||
op->buflen += len;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
printf ("read() returned %d: %s\n", ret, strerror (errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* some plugins may want to keep output unbroken, and some commands
|
||||
* will yield no output, so return here for those */
|
||||
if (flags & CMD_NO_ARRAYS || !op->buf || !op->buflen)
|
||||
return op->buflen;
|
||||
|
||||
/* and some may want both */
|
||||
if (flags & CMD_NO_ASSOC) {
|
||||
buf = malloc (op->buflen);
|
||||
memcpy (buf, op->buf, op->buflen);
|
||||
}
|
||||
else
|
||||
buf = op->buf;
|
||||
|
||||
op->line = NULL;
|
||||
op->lens = NULL;
|
||||
i = 0;
|
||||
while (i < op->buflen) {
|
||||
/* make sure we have enough memory */
|
||||
if (lineno >= ary_size) {
|
||||
/* ary_size must never be zero */
|
||||
do {
|
||||
ary_size = op->buflen >> --rsf;
|
||||
} while (!ary_size);
|
||||
|
||||
op->line = realloc (op->line, ary_size * sizeof (char *));
|
||||
op->lens = realloc (op->lens, ary_size * sizeof (size_t));
|
||||
}
|
||||
|
||||
/* set the pointer to the string */
|
||||
op->line[lineno] = &buf[i];
|
||||
|
||||
/* hop to next newline or end of buffer */
|
||||
while (buf[i] != '\n' && i < op->buflen)
|
||||
i++;
|
||||
buf[i] = '\0';
|
||||
|
||||
/* calculate the string length using pointer difference */
|
||||
op->lens[lineno] = (size_t) & buf[i] - (size_t) op->line[lineno];
|
||||
|
||||
lineno++;
|
||||
i++;
|
||||
}
|
||||
|
||||
return lineno;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
cmd_run (const char *cmdstring, output * out, output * err, int flags)
|
||||
{
|
||||
int fd, pfd_out[2], pfd_err[2];
|
||||
int i = 0, argc;
|
||||
size_t cmdlen;
|
||||
char **argv = NULL;
|
||||
char *cmd = NULL;
|
||||
char *str = NULL;
|
||||
|
||||
if (cmdstring == NULL)
|
||||
return -1;
|
||||
|
||||
/* initialize the structs */
|
||||
if (out)
|
||||
memset (out, 0, sizeof (output));
|
||||
if (err)
|
||||
memset (err, 0, sizeof (output));
|
||||
|
||||
/* make copy of command string so strtok() doesn't silently modify it */
|
||||
/* (the calling program may want to access it later) */
|
||||
cmdlen = strlen (cmdstring);
|
||||
if ((cmd = malloc (cmdlen + 1)) == NULL)
|
||||
return -1;
|
||||
memcpy (cmd, cmdstring, cmdlen);
|
||||
cmd[cmdlen] = '\0';
|
||||
|
||||
/* This is not a shell, so we don't handle "???" */
|
||||
if (strstr (cmdstring, "\"")) return -1;
|
||||
|
||||
/* allow single quotes, but only if non-whitesapce doesn't occur on both sides */
|
||||
if (strstr (cmdstring, " ' ") || strstr (cmdstring, "'''"))
|
||||
return -1;
|
||||
|
||||
/* each arg must be whitespace-separated, so args can be a maximum
|
||||
* of (len / 2) + 1. We add 1 extra to the mix for NULL termination */
|
||||
argc = (cmdlen >> 1) + 2;
|
||||
argv = calloc (sizeof (char *), argc);
|
||||
|
||||
if (argv == NULL) {
|
||||
printf ("%s\n", _("Could not malloc argv array in popen()"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get command arguments (stupidly, but fairly quickly) */
|
||||
while (cmd) {
|
||||
str = cmd;
|
||||
str += strspn (str, " \t\r\n"); /* trim any leading whitespace */
|
||||
|
||||
if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */
|
||||
str++;
|
||||
if (!strstr (str, "'"))
|
||||
return -1; /* balanced? */
|
||||
cmd = 1 + strstr (str, "'");
|
||||
str[strcspn (str, "'")] = 0;
|
||||
}
|
||||
else {
|
||||
if (strpbrk (str, " \t\r\n")) {
|
||||
cmd = 1 + strpbrk (str, " \t\r\n");
|
||||
str[strcspn (str, " \t\r\n")] = 0;
|
||||
}
|
||||
else {
|
||||
cmd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd && strlen (cmd) == strspn (cmd, " \t\r\n"))
|
||||
cmd = NULL;
|
||||
|
||||
argv[i++] = str;
|
||||
}
|
||||
|
||||
return cmd_run_array (argv, out, err, flags);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_run_array (char *const *argv, output * out, output * err, int flags)
|
||||
{
|
||||
int fd, pfd_out[2], pfd_err[2];
|
||||
|
||||
/* initialize the structs */
|
||||
if (out)
|
||||
memset (out, 0, sizeof (output));
|
||||
if (err)
|
||||
memset (err, 0, sizeof (output));
|
||||
|
||||
if ((fd = _cmd_open (argv, pfd_out, pfd_err)) == -1)
|
||||
die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), argv[0]);
|
||||
|
||||
if (out)
|
||||
out->lines = _cmd_fetch_output (pfd_out[0], out, flags);
|
||||
if (err)
|
||||
err->lines = _cmd_fetch_output (pfd_err[0], err, flags);
|
||||
|
||||
return _cmd_close (fd);
|
||||
}
|
34
lib/utils_cmd.h
Normal file
34
lib/utils_cmd.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef _UTILS_CMD_
|
||||
#define _UTILS_CMD_
|
||||
|
||||
/*
|
||||
* Header file for nagios plugins utils_cmd.c
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** types **/
|
||||
struct output
|
||||
{
|
||||
char *buf; /* output buffer */
|
||||
size_t buflen; /* output buffer content length */
|
||||
char **line; /* array of lines (points to buf) */
|
||||
size_t *lens; /* string lengths */
|
||||
size_t lines; /* lines of output */
|
||||
};
|
||||
|
||||
typedef struct output output;
|
||||
|
||||
/** prototypes **/
|
||||
int cmd_run (const char *, output *, output *, int);
|
||||
int cmd_run_array (char *const *, output *, output *, int);
|
||||
|
||||
/* only multi-threaded plugins need to bother with this */
|
||||
void cmd_init (void);
|
||||
#define CMD_INIT cmd_init()
|
||||
|
||||
/* possible flags for cmd_run()'s fourth argument */
|
||||
#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
|
||||
#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
|
||||
|
||||
#endif /* _UTILS_CMD_ */
|
|
@ -4,7 +4,7 @@
|
|||
* License: GPL
|
||||
* Copyright (c) 1999-2006 nagios-plugins team
|
||||
*
|
||||
* Last Modified: $Date: 2007/04/01 11:17:16 $
|
||||
* Last Modified: $Date: 2007-09-22 18:48:33 +0100 (Sat, 22 Sep 2007) $
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: utils_disk.c,v 1.6 2007/04/01 11:17:16 psychotrahe Exp $
|
||||
* $Id: utils_disk.c 1787 2007-09-22 17:48:33Z psychotrahe $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
@ -74,6 +74,26 @@ np_add_parameter(struct parameter_list **list, const char *name)
|
|||
return new_path;
|
||||
}
|
||||
|
||||
/* Delete a given parameter from list and return pointer to next element*/
|
||||
struct parameter_list *
|
||||
np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
|
||||
{
|
||||
struct parameter_list *next;
|
||||
if (item->name_next)
|
||||
next = item->name_next;
|
||||
else
|
||||
next = NULL;
|
||||
|
||||
|
||||
free(item);
|
||||
if (prev)
|
||||
prev->name_next = next;
|
||||
|
||||
return next;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* returns a pointer to the struct found in the list */
|
||||
struct parameter_list *
|
||||
np_find_parameter(struct parameter_list *list, const char *name)
|
||||
|
@ -161,8 +181,9 @@ np_regex_match_mount_entry (struct mount_entry* me, regex_t* re)
|
|||
{
|
||||
if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 ||
|
||||
regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) {
|
||||
return true;
|
||||
return TRUE;
|
||||
} else {
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ int np_find_name (struct name_list *list, const char *name);
|
|||
int np_seen_name (struct name_list *list, const char *name);
|
||||
struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name);
|
||||
struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name);
|
||||
struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev);
|
||||
|
||||
int search_parameter_list (struct parameter_list *list, const char *name);
|
||||
void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact);
|
||||
int np_regex_match_mount_entry (struct mount_entry* me, regex_t* re);
|
||||
|
|
60
lib/utils_tcp.c
Normal file
60
lib/utils_tcp.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/****************************************************************************
|
||||
* Utils for check_tcp
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 1999-2007 nagios-plugins team
|
||||
*
|
||||
* Last Modified: $Date: 2007-09-22 18:48:33 +0100 (Sat, 22 Sep 2007) $
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This file contains utilities for check_tcp. These are tested by libtap
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: utils_tcp.c 1787 2007-09-22 17:48:33Z psychotrahe $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "utils_tcp.h"
|
||||
|
||||
int
|
||||
np_expect_match(char* status, char** server_expect, int expect_count, int all, int exact_match, int verbose)
|
||||
{
|
||||
int match = 0;
|
||||
int i;
|
||||
for (i = 0; i < expect_count; i++) {
|
||||
if (verbose)
|
||||
printf ("looking for [%s] %s [%s]\n", server_expect[i],
|
||||
(exact_match) ? "in beginning of" : "anywhere in",
|
||||
status);
|
||||
|
||||
if ((exact_match && !strncmp(status, server_expect[i], strlen(server_expect[i]))) ||
|
||||
(! exact_match && strstr(status, server_expect[i])))
|
||||
{
|
||||
if(verbose) puts("found it");
|
||||
match += 1;
|
||||
} else
|
||||
if(verbose) puts("couldn't find it");
|
||||
}
|
||||
if ((all == TRUE && match == expect_count) ||
|
||||
(! all && match >= 1)) {
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
4
lib/utils_tcp.h
Normal file
4
lib/utils_tcp.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* Header file for utils_disk */
|
||||
|
||||
int np_expect_match(char* status, char** server_expect, int server_expect_count,
|
||||
int all, int exact_match, int verbose);
|
Loading…
Add table
Add a link
Reference in a new issue