diff options
Diffstat (limited to 'rubbos/app/httpd-2.0.64/support')
106 files changed, 16057 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/support/.deps b/rubbos/app/httpd-2.0.64/support/.deps new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.deps diff --git a/rubbos/app/httpd-2.0.64/support/.indent.pro b/rubbos/app/httpd-2.0.64/support/.indent.pro new file mode 100644 index 00000000..a9fbe9f9 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.indent.pro @@ -0,0 +1,54 @@ +-i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 +-TBUFF +-TFILE +-TTRANS +-TUINT4 +-T_trans +-Tallow_options_t +-Tapache_sfio +-Tarray_header +-Tbool_int +-Tbuf_area +-Tbuff_struct +-Tbuffy +-Tcmd_how +-Tcmd_parms +-Tcommand_rec +-Tcommand_struct +-Tconn_rec +-Tcore_dir_config +-Tcore_server_config +-Tdir_maker_func +-Tevent +-Tglobals_s +-Thandler_func +-Thandler_rec +-Tjoblist_s +-Tlisten_rec +-Tmerger_func +-Tmode_t +-Tmodule +-Tmodule_struct +-Tmutex +-Tn_long +-Tother_child_rec +-Toverrides_t +-Tparent_score +-Tpid_t +-Tpiped_log +-Tpool +-Trequest_rec +-Trequire_line +-Trlim_t +-Tscoreboard +-Tsemaphore +-Tserver_addr_rec +-Tserver_rec +-Tserver_rec_chain +-Tshort_score +-Ttable +-Ttable_entry +-Tthread +-Tu_wide_int +-Tvtime_t +-Twide_int diff --git a/rubbos/app/httpd-2.0.64/support/.libs/ab b/rubbos/app/httpd-2.0.64/support/.libs/ab Binary files differnew file mode 100755 index 00000000..e5b37b70 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/ab diff --git a/rubbos/app/httpd-2.0.64/support/.libs/ab.o b/rubbos/app/httpd-2.0.64/support/.libs/ab.o Binary files differnew file mode 100644 index 00000000..446096ca --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/ab.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/checkgid b/rubbos/app/httpd-2.0.64/support/.libs/checkgid Binary files differnew file mode 100755 index 00000000..7c0f5e49 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/checkgid diff --git a/rubbos/app/httpd-2.0.64/support/.libs/checkgid.o b/rubbos/app/httpd-2.0.64/support/.libs/checkgid.o Binary files differnew file mode 100644 index 00000000..9116a3a9 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/checkgid.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htdbm b/rubbos/app/httpd-2.0.64/support/.libs/htdbm Binary files differnew file mode 100755 index 00000000..815389da --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htdbm diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htdbm.o b/rubbos/app/httpd-2.0.64/support/.libs/htdbm.o Binary files differnew file mode 100644 index 00000000..35bf9bd8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htdbm.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htdigest b/rubbos/app/httpd-2.0.64/support/.libs/htdigest Binary files differnew file mode 100755 index 00000000..25b27d18 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htdigest diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htdigest.o b/rubbos/app/httpd-2.0.64/support/.libs/htdigest.o Binary files differnew file mode 100644 index 00000000..e3ec6704 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htdigest.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htpasswd b/rubbos/app/httpd-2.0.64/support/.libs/htpasswd Binary files differnew file mode 100755 index 00000000..48ca8792 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htpasswd diff --git a/rubbos/app/httpd-2.0.64/support/.libs/htpasswd.o b/rubbos/app/httpd-2.0.64/support/.libs/htpasswd.o Binary files differnew file mode 100644 index 00000000..da73e002 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/htpasswd.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm b/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm Binary files differnew file mode 100755 index 00000000..b8a48382 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm diff --git a/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm.o b/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm.o Binary files differnew file mode 100644 index 00000000..1e12f6c8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/httxt2dbm.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/logresolve b/rubbos/app/httpd-2.0.64/support/.libs/logresolve Binary files differnew file mode 100755 index 00000000..e658dc23 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/logresolve diff --git a/rubbos/app/httpd-2.0.64/support/.libs/logresolve.o b/rubbos/app/httpd-2.0.64/support/.libs/logresolve.o Binary files differnew file mode 100644 index 00000000..a948c1d0 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/logresolve.o diff --git a/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs b/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs Binary files differnew file mode 100755 index 00000000..9775a25e --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs diff --git a/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs.o b/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs.o Binary files differnew file mode 100644 index 00000000..7ae2ef96 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/.libs/rotatelogs.o diff --git a/rubbos/app/httpd-2.0.64/support/Makefile b/rubbos/app/httpd-2.0.64/support/Makefile new file mode 100644 index 00000000..b9ccd2bc --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/Makefile @@ -0,0 +1,73 @@ +top_srcdir = /bottlenecks/rubbos/app/httpd-2.0.64 +top_builddir = /bottlenecks/rubbos/app/httpd-2.0.64 +srcdir = /bottlenecks/rubbos/app/httpd-2.0.64/support +builddir = /bottlenecks/rubbos/app/httpd-2.0.64/support +VPATH = /bottlenecks/rubbos/app/httpd-2.0.64/support +DISTCLEAN_TARGETS = apxs apachectl dbmmanage log_server_status \ + logresolve.pl phf_abuse_log.cgi split-logfile envvars-std + +CLEAN_TARGETS = suexec + +PROGRAMS = htpasswd htdigest rotatelogs logresolve ab checkgid htdbm httxt2dbm +TARGETS = $(PROGRAMS) + +PROGRAM_LDADD = $(UTIL_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(EXTRA_LIBS) $(AP_LIBS) +PROGRAM_DEPENDENCIES = + +include $(top_builddir)/build/rules.mk + +install: + @test -d $(DESTDIR)$(bindir) || $(MKINSTALLDIRS) $(DESTDIR)$(bindir) + @test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir) + @test -d $(DESTDIR)$(libexecdir) || $(MKINSTALLDIRS) $(DESTDIR)$(libexecdir) + @cp -p $(top_builddir)/server/httpd.exp $(DESTDIR)$(libexecdir) + @for i in apxs apachectl dbmmanage; do \ + if test -f "$(builddir)/$$i"; then \ + cp -p $$i $(DESTDIR)$(sbindir); \ + chmod 755 $(DESTDIR)$(sbindir)/$$i; \ + fi ; \ + done + @if test -f "$(builddir)/envvars-std"; then \ + cp -p envvars-std $(DESTDIR)$(sbindir); \ + if test ! -f $(DESTDIR)$(sbindir)/envvars; then \ + cp -p envvars-std $(DESTDIR)$(sbindir)/envvars ; \ + fi ; \ + fi + +htpasswd_OBJECTS = htpasswd.lo +htpasswd: $(htpasswd_OBJECTS) + $(LINK) $(htpasswd_LTFLAGS) $(htpasswd_OBJECTS) $(PROGRAM_LDADD) + +htdigest_OBJECTS = htdigest.lo +htdigest: $(htdigest_OBJECTS) + $(LINK) $(htdigest_LTFLAGS) $(htdigest_OBJECTS) $(PROGRAM_LDADD) + +rotatelogs_OBJECTS = rotatelogs.lo +rotatelogs: $(rotatelogs_OBJECTS) + $(LINK) $(rotatelogs_LTFLAGS) $(rotatelogs_OBJECTS) $(PROGRAM_LDADD) + +logresolve_OBJECTS = logresolve.lo +logresolve: $(logresolve_OBJECTS) + $(LINK) $(logresolve_LTFLAGS) $(logresolve_OBJECTS) $(PROGRAM_LDADD) + +htdbm_OBJECTS = htdbm.lo +htdbm: $(htdbm_OBJECTS) + $(LINK) $(htdbm_LTFLAGS) $(htdbm_OBJECTS) $(PROGRAM_LDADD) + +ab_OBJECTS = ab.lo +ab_LDADD = $(PROGRAM_LDADD) $(SSL_LIBS) +ab: $(ab_OBJECTS) + $(LINK) $(ab_LTFLAGS) $(ab_OBJECTS) $(ab_LDADD) + +checkgid_OBJECTS = checkgid.lo +checkgid: $(checkgid_OBJECTS) + $(LINK) $(checkgid_LTFLAGS) $(checkgid_OBJECTS) $(PROGRAM_LDADD) + +suexec_OBJECTS = suexec.lo +suexec: $(suexec_OBJECTS) + $(LINK) $(suexec_OBJECTS) + +httxt2dbm_OBJECTS = httxt2dbm.lo +httxt2dbm: $(httxt2dbm_OBJECTS) + $(LINK) $(httxt2dbm_LTFLAGS) $(httxt2dbm_OBJECTS) $(PROGRAM_LDADD) + diff --git a/rubbos/app/httpd-2.0.64/support/Makefile.in b/rubbos/app/httpd-2.0.64/support/Makefile.in new file mode 100644 index 00000000..696885ba --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/Makefile.in @@ -0,0 +1,68 @@ +DISTCLEAN_TARGETS = apxs apachectl dbmmanage log_server_status \ + logresolve.pl phf_abuse_log.cgi split-logfile envvars-std + +CLEAN_TARGETS = suexec + +PROGRAMS = htpasswd htdigest rotatelogs logresolve ab checkgid htdbm httxt2dbm +TARGETS = $(PROGRAMS) + +PROGRAM_LDADD = $(UTIL_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(EXTRA_LIBS) $(AP_LIBS) +PROGRAM_DEPENDENCIES = + +include $(top_builddir)/build/rules.mk + +install: + @test -d $(DESTDIR)$(bindir) || $(MKINSTALLDIRS) $(DESTDIR)$(bindir) + @test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir) + @test -d $(DESTDIR)$(libexecdir) || $(MKINSTALLDIRS) $(DESTDIR)$(libexecdir) + @cp -p $(top_builddir)/server/httpd.exp $(DESTDIR)$(libexecdir) + @for i in apxs apachectl dbmmanage; do \ + if test -f "$(builddir)/$$i"; then \ + cp -p $$i $(DESTDIR)$(sbindir); \ + chmod 755 $(DESTDIR)$(sbindir)/$$i; \ + fi ; \ + done + @if test -f "$(builddir)/envvars-std"; then \ + cp -p envvars-std $(DESTDIR)$(sbindir); \ + if test ! -f $(DESTDIR)$(sbindir)/envvars; then \ + cp -p envvars-std $(DESTDIR)$(sbindir)/envvars ; \ + fi ; \ + fi + +htpasswd_OBJECTS = htpasswd.lo +htpasswd: $(htpasswd_OBJECTS) + $(LINK) $(htpasswd_LTFLAGS) $(htpasswd_OBJECTS) $(PROGRAM_LDADD) + +htdigest_OBJECTS = htdigest.lo +htdigest: $(htdigest_OBJECTS) + $(LINK) $(htdigest_LTFLAGS) $(htdigest_OBJECTS) $(PROGRAM_LDADD) + +rotatelogs_OBJECTS = rotatelogs.lo +rotatelogs: $(rotatelogs_OBJECTS) + $(LINK) $(rotatelogs_LTFLAGS) $(rotatelogs_OBJECTS) $(PROGRAM_LDADD) + +logresolve_OBJECTS = logresolve.lo +logresolve: $(logresolve_OBJECTS) + $(LINK) $(logresolve_LTFLAGS) $(logresolve_OBJECTS) $(PROGRAM_LDADD) + +htdbm_OBJECTS = htdbm.lo +htdbm: $(htdbm_OBJECTS) + $(LINK) $(htdbm_LTFLAGS) $(htdbm_OBJECTS) $(PROGRAM_LDADD) + +ab_OBJECTS = ab.lo +ab_LDADD = $(PROGRAM_LDADD) $(SSL_LIBS) +ab: $(ab_OBJECTS) + $(LINK) $(ab_LTFLAGS) $(ab_OBJECTS) $(ab_LDADD) + +checkgid_OBJECTS = checkgid.lo +checkgid: $(checkgid_OBJECTS) + $(LINK) $(checkgid_LTFLAGS) $(checkgid_OBJECTS) $(PROGRAM_LDADD) + +suexec_OBJECTS = suexec.lo +suexec: $(suexec_OBJECTS) + $(LINK) $(suexec_OBJECTS) + +httxt2dbm_OBJECTS = httxt2dbm.lo +httxt2dbm: $(httxt2dbm_OBJECTS) + $(LINK) $(httxt2dbm_LTFLAGS) $(httxt2dbm_OBJECTS) $(PROGRAM_LDADD) + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUab b/rubbos/app/httpd-2.0.64/support/NWGNUab new file mode 100644 index 00000000..180a96c3 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUab @@ -0,0 +1,254 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(APR)/misc/netware \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = ab + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Benchmark Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = ab + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +#NLM_SCREEN_NAME = Apache Bench +NLM_SCREEN_NAME = DEFAULT + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/ab.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/ab.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUhtdbm b/rubbos/app/httpd-2.0.64/support/NWGNUhtdbm new file mode 100644 index 00000000..38e60636 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUhtdbm @@ -0,0 +1,252 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(APR)/misc/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = htdbm + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) HT Database Management Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = htdbm + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +NLM_SCREEN_NAME = htdbm Password Management + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/htdbm.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/htdbm.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUhtdigest b/rubbos/app/httpd-2.0.64/support/NWGNUhtdigest new file mode 100644 index 00000000..48a55550 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUhtdigest @@ -0,0 +1,252 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(APR)/misc/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = htdigest + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) HT Digest Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = htdigest + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +NLM_SCREEN_NAME = Digest Password Management + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/htdigest.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/htdigest.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUhtpasswd b/rubbos/app/httpd-2.0.64/support/NWGNUhtpasswd new file mode 100644 index 00000000..b866ec2b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUhtpasswd @@ -0,0 +1,252 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(APR)/misc/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = htpasswd + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) HT Password Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = htpasswd + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +NLM_SCREEN_NAME = htpasswd Password Management + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 8192 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/htpasswd.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/htpasswd.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUlogres b/rubbos/app/httpd-2.0.64/support/NWGNUlogres new file mode 100644 index 00000000..f82eee32 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUlogres @@ -0,0 +1,254 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APRUTIL)/include \ + $(APR)/misc/netware \ + $(AP_WORK)/include \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = logres + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Logresolve Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = logres + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +NLM_SCREEN_NAME = Log Resolve + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 65536 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/logres.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/logresolve.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + @ws2nlm.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUmakefile b/rubbos/app/httpd-2.0.64/support/NWGNUmakefile new file mode 100644 index 00000000..327cd4d8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUmakefile @@ -0,0 +1,249 @@ +# +# Declare the sub-directories to be built here +# + +SUBDIRS = \ + $(EOLIST) + +# +# Get the 'head' of the build environment. This includes default targets and +# paths to tools +# + +include $(AP_WORK)\build\NWGNUhead.inc + +# +# build this level's files + +# +# Make sure all needed macro's are defined +# + +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/ab.nlm \ + $(OBJDIR)/htpasswd.nlm \ + $(OBJDIR)/htdigest.nlm \ + $(OBJDIR)/htdbm.nlm \ + $(OBJDIR)/logres.nlm \ + $(OBJDIR)/rotlogs.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + copy $(OBJDIR)\*.nlm $(INSTALL)\Apache2\bin\*.* + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/NWGNUrotlogs b/rubbos/app/httpd-2.0.64/support/NWGNUrotlogs new file mode 100644 index 00000000..cdd6461e --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/NWGNUrotlogs @@ -0,0 +1,251 @@ +# +# Make sure all needed macro's are defined +# + +# +# Get the 'head' of the build environment if necessary. This includes default +# targets and paths to tools +# + +ifndef EnvironmentDefined +include $(AP_WORK)\build\NWGNUhead.inc +endif + +# +# These directories will be at the beginning of the include list, followed by +# INCDIRS +# +XINCDIRS += \ + $(APR)/include \ + $(APR)/misc/netware \ + $(NWOS) \ + $(EOLIST) + +# +# These flags will come after CFLAGS +# +XCFLAGS += \ + $(EOLIST) + +# +# These defines will come after DEFINES +# +XDEFINES += \ + $(EOLIST) + +# +# These flags will be added to the link.opt file +# +XLFLAGS += \ + $(EOLIST) + +# +# These values will be appended to the correct variables based on the value of +# RELEASE +# +ifeq "$(RELEASE)" "debug" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "noopt" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +ifeq "$(RELEASE)" "release" +XINCDIRS += \ + $(EOLIST) + +XCFLAGS += \ + $(EOLIST) + +XDEFINES += \ + $(EOLIST) + +XLFLAGS += \ + $(EOLIST) +endif + +# +# These are used by the link target if an NLM is being generated +# This is used by the link 'name' directive to name the nlm. If left blank +# TARGET_nlm (see below) will be used. +# +NLM_NAME = rotlogs + +# +# This is used by the link '-desc ' directive. +# If left blank, NLM_NAME will be used. +# +NLM_DESCRIPTION = Apache $(VERSION_STR) Log Rotation Utility for NetWare + +# +# This is used by the '-threadname' directive. If left blank, +# NLM_NAME Thread will be used. +# +NLM_THREAD_NAME = rotlogs + +# +# This is used by the '-screenname' directive. If left blank, +# 'Apache for NetWare' Thread will be used. +# +NLM_SCREEN_NAME = DEFAULT + +# +# If this is specified, it will override VERSION value in +# $(AP_WORK)\build\NWGNUenvironment.inc +# +NLM_VERSION = + +# +# If this is specified, it will override the default of 64K +# +NLM_STACK_SIZE = 98304 + + +# +# If this is specified it will be used by the link '-entry' directive +# +NLM_ENTRY_SYM = _LibCPrelude + +# +# If this is specified it will be used by the link '-exit' directive +# +NLM_EXIT_SYM = _LibCPostlude + +# +# If this is specified it will be used by the link '-check' directive +# +NLM_CHECK_SYM = + +# +# If these are specified it will be used by the link '-flags' directive +# +NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION, MULTIPLE + +# +# If this is specified it will be linked in with the XDCData option in the def +# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled +# by setting APACHE_UNIPROC in the environment +# +XDCDATA = + +# +# If there is an NLM target, put it here +# +TARGET_nlm = \ + $(OBJDIR)/rotlogs.nlm \ + $(EOLIST) + +# +# If there is an LIB target, put it here +# +TARGET_lib = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the NLM target above. +# Paths must all use the '/' character +# +FILES_nlm_objs = \ + $(OBJDIR)/rotatelogs.o \ + $(EOLIST) + +# +# These are the LIB files needed to create the NLM target above. +# These will be added as a library command in the link.opt file. +# +FILES_nlm_libs = \ + libcpre.o \ + $(EOLIST) + +# +# These are the modules that the above NLM target depends on to load. +# These will be added as a module command in the link.opt file. +# +FILES_nlm_modules = \ + aprlib \ + libc \ + $(EOLIST) + +# +# If the nlm has a msg file, put it's path here +# +FILE_nlm_msg = + +# +# If the nlm has a hlp file put it's path here +# +FILE_nlm_hlp = + +# +# If this is specified, it will override $(NWOS)\copyright.txt. +# +FILE_nlm_copyright = + +# +# Any additional imports go here +# +FILES_nlm_Ximports = \ + @$(APR)/aprlib.imp \ + @libc.imp \ + $(EOLIST) + +# +# Any symbols exported to here +# +FILES_nlm_exports = \ + $(EOLIST) + +# +# These are the OBJ files needed to create the LIB target above. +# Paths must all use the '/' character +# +FILES_lib_objs = \ + $(EOLIST) + +# +# implement targets and dependancies (leave this section alone) +# + +libs :: $(OBJDIR) $(TARGET_lib) + +nlms :: libs $(TARGET_nlm) + +# +# Updated this target to create necessary directories and copy files to the +# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) +# +install :: nlms FORCE + +# +# Any specialized rules here +# + +# +# Include the 'tail' makefile that has targets that depend on variables defined +# in this makefile +# + +include $(AP_WORK)\build\NWGNUtail.inc + + diff --git a/rubbos/app/httpd-2.0.64/support/README b/rubbos/app/httpd-2.0.64/support/README new file mode 100644 index 00000000..80e9cafd --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/README @@ -0,0 +1,62 @@ +Support files: + +ab + ABuse your server with this benchmarker. Rudimentary + command line testing tool. + +apachectl + Apache run-time Control script. To facilitate the + administrator and/or your rc.d scripts to control the + functioning of the Apache httpd daemon. + +apxs + APache eXtenSion tool. Eases building and installing + DSO style modules. + +dbmmanage + Create and update user authentication files in the faster + DBM format used by mod_auth_db. + +htdigest + Create and update user authentication files used in + DIGEST authentification. See mod_auth_digest. + +htpasswd + Create and update user authentication files used in + BASIC authentification. I.e. the htpasswd files. + See mod_auth. + +httpd.8 + General apache man page. + +log_server_status + This script is designed to be run at a frequent interval by something + like cron. It connects to the server and downloads the status + information. It reformats the information to a single line and logs + it to a file. + +logresolve + resolve hostnames for IP-adresses in Apache logfiles + +phf_abuse_log.cgi + This script can be used to detect people trying to abuse an ancient + and long plugged security hole which existed in a CGI script distributed + with Apache 1.0.3 and earlier versions. + +rotatelogs + rotate Apache logs without having to kill the server. + +split-logfile + This script will take a combined virtual hosts access + log file and break its contents into separate files. + +suexec + Switch User For Exec. Used internally by apache, + see the document `Apache suEXEC Support' + under http://www.apache.org/docs/suexec.html . + +SHA1 + This directory includes some utilities to allow Apache 1.3.6 to + recognize passwords in SHA1 format, as used by Netscape web + servers. It is not installed by default. + diff --git a/rubbos/app/httpd-2.0.64/support/SHA1/README.sha1 b/rubbos/app/httpd-2.0.64/support/SHA1/README.sha1 new file mode 100644 index 00000000..3998e1fd --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/SHA1/README.sha1 @@ -0,0 +1,34 @@ +This directory includes some utilities to allow Apache 1.3.6 to +recognize passwords in SHA1 format, as used by Netscape web servers. + +From Netscape's admin interface, export the password database to an +ldif file and then use convert.pl in this distribution to generate +apache style password files. + +Note: SHA1 support is useful for migration purposes, but is less + secure than Apache's password format, since Apache's (MD5) + password format uses a random eight character salt to generate + one of many possible hashes for the same password. Netscape + uses plain SHA1 without a salt, so the same password + will always generate the same hash, making it easier + to break since the search space is smaller. + +This code was contributed by Clinton Wong <clintdw@netcom.com>. + +README.sha1 + this file + +convert-sha1.pl + takes an ldif dump from Netscape's web server on + standard in, outputs apache htpasswd format on standard out. + + Usage: convert.pl < ldif > passwords + +htpasswd-sha1.pl + perl script to generate entries in apache htpasswd format. + + Usage: htpasswd-sha1.pl some_user some_password + +ldif-sha1.example + sample ldif dump with one sha1 password and one crypt password. + diff --git a/rubbos/app/httpd-2.0.64/support/SHA1/convert-sha1.pl b/rubbos/app/httpd-2.0.64/support/SHA1/convert-sha1.pl new file mode 100644 index 00000000..35228022 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/SHA1/convert-sha1.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w +use strict; + +# This is public domain code. Do whatever you want with it. +# It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif +# patch distribution as sample code for converting accounts from +# ldif format (as used by Netscape web servers) to Apache password format. + +my $uid=''; +my $passwd=''; + +while (my $line = <>) { + chomp $line; + if ( $line =~ /uid:\s*(.+)/) { $uid = $1 } + if ( $line =~ /userpassword:\s*(\{\w+\}.+)/) { + $passwd = $1; + $passwd =~ s/^\{crypt\}//i; # Apache stores crypt without a magic string + } + + if (length($line)==0) { + + if (length $uid and length $passwd) { + print $uid, ':', $passwd, "\n"; + } # output if we have something to print + + $uid = ''; + $passwd = ''; + + } # if newline +} # while something to read + +# handle last entry if there isn't a newline before EOF + if (length $uid and length $passwd) { + print $uid, ':', $passwd, "\n"; +} + diff --git a/rubbos/app/httpd-2.0.64/support/SHA1/htpasswd-sha1.pl b/rubbos/app/httpd-2.0.64/support/SHA1/htpasswd-sha1.pl new file mode 100644 index 00000000..ad624d11 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/SHA1/htpasswd-sha1.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl -w +use strict; +# +# Utility which takes a username and password +# on the command line and generates a username +# sha1-encrytped password on the stdout. +# +# Typical useage: +# ./htpasswd-sha1.pl dirkx MySecret >> sha1-passwd +# +# This is public domain code. Do whatever you want with it. +# It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif +# patch distribution as sample code for generating entries for +# Apache password files using SHA1. + +use MIME::Base64; # http://www.cpan.org/modules/by-module/MIME/ +use Digest::SHA1; # http://www.cpan.org/modules/by-module/MD5/ + +if ($#ARGV!=1) { die "Usage $0: user password\n" } + +print $ARGV[0], ':{SHA}', encode_base64( Digest::SHA1::sha1($ARGV[1]) ); + diff --git a/rubbos/app/httpd-2.0.64/support/SHA1/ldif-sha1.example b/rubbos/app/httpd-2.0.64/support/SHA1/ldif-sha1.example new file mode 100644 index 00000000..b8fe917e --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/SHA1/ldif-sha1.example @@ -0,0 +1,19 @@ +dn: cn=someuser +cn: someuser +sn: someuser +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +uid: someuser +userpassword: {SHA}GvF+c3IdvgxAARuC7Uuxp9vjzik= + +dn: cn=anotheruser +cn: anotheruser +sn: anotheruser +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +uid: anotheruser +userpassword: {crypt}eFnp.4sz5XnH6 diff --git a/rubbos/app/httpd-2.0.64/support/ab b/rubbos/app/httpd-2.0.64/support/ab new file mode 100755 index 00000000..a5757c29 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/ab @@ -0,0 +1,131 @@ +#! /bin/bash + +# ab - temporary wrapper script for .libs/ab +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The ab program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/ab.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'ab' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/ab.c b/rubbos/app/httpd-2.0.64/support/ab.c new file mode 100644 index 00000000..9f6edfd0 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/ab.c @@ -0,0 +1,2195 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + ** This program is based on ZeusBench V1.0 written by Adam Twiss + ** which is Copyright (c) 1996 by Zeus Technology Ltd. http://www.zeustech.net/ + ** + ** This software is provided "as is" and any express or implied waranties, + ** including but not limited to, the implied warranties of merchantability and + ** fitness for a particular purpose are disclaimed. In no event shall + ** Zeus Technology Ltd. be liable for any direct, indirect, incidental, special, + ** exemplary, or consequential damaged (including, but not limited to, + ** procurement of substitute good or services; loss of use, data, or profits; + ** or business interruption) however caused and on theory of liability. Whether + ** in contract, strict liability or tort (including negligence or otherwise) + ** arising in any way out of the use of this software, even if advised of the + ** possibility of such damage. + ** + */ + +/* + ** HISTORY: + ** - Originally written by Adam Twiss <adam@zeus.co.uk>, March 1996 + ** with input from Mike Belshe <mbelshe@netscape.com> and + ** Michael Campanella <campanella@stevms.enet.dec.com> + ** - Enhanced by Dean Gaudet <dgaudet@apache.org>, November 1997 + ** - Cleaned up by Ralf S. Engelschall <rse@apache.org>, March 1998 + ** - POST and verbosity by Kurt Sussman <kls@merlot.com>, August 1998 + ** - HTML table output added by David N. Welton <davidw@prosa.it>, January 1999 + ** - Added Cookie, Arbitrary header and auth support. <dirkx@webweaving.org>, April 1999 + ** Version 1.3d + ** - Increased version number - as some of the socket/error handling has + ** fundamentally changed - and will give fundamentally different results + ** in situations where a server is dropping requests. Therefore you can + ** no longer compare results of AB as easily. Hence the inc of the version. + ** They should be closer to the truth though. Sander & <dirkx@covalent.net>, End 2000. + ** - Fixed proxy functionality, added median/mean statistics, added gnuplot + ** output option, added _experimental/rudimentary_ SSL support. Added + ** confidence guestimators and warnings. Sander & <dirkx@covalent.net>, End 2000 + ** - Fixed serious int overflow issues which would cause realistic (longer + ** than a few minutes) run's to have wrong (but believable) results. Added + ** trapping of connection errors which influenced measurements. + ** Contributed by Sander Temme, Early 2001 + ** Version 1.3e + ** - Changed timeout behavour during write to work whilst the sockets + ** are filling up and apr_write() does writes a few - but not all. + ** This will potentially change results. <dirkx@webweaving.org>, April 2001 + ** Version 2.0.36-dev + ** Improvements to concurrent processing: + ** - Enabled non-blocking connect()s. + ** - Prevent blocking calls to apr_recv() (thereby allowing AB to + ** manage its entire set of socket descriptors). + ** - Any error returned from apr_recv() that is not EAGAIN or EOF + ** is now treated as fatal. + ** Contributed by Aaron Bannert, April 24, 2002 + ** + ** Version 2.0.36-2 + ** Internalized the version string - this string is part + ** of the Agent: header and the result output. + ** + ** Version 2.0.37-dev + ** Adopted SSL code by Madhu Mathihalli <madhusudan_mathihalli@hp.com> + ** [PATCH] ab with SSL support Posted Wed, 15 Aug 2001 20:55:06 GMT + ** Introduces four 'if (int == value)' tests per non-ssl request. + ** + ** Version 2.0.40-dev + ** Switched to the new abstract pollset API, allowing ab to + ** take advantage of future apr_pollset_t scalability improvements. + ** Contributed by Brian Pane, August 31, 2002 + **/ + +/* Note: this version string should start with \d+[\d\.]* and be a valid + * string for an HTTP Agent: header when prefixed with 'ApacheBench/'. + * It should reflect the version of AB - and not that of the apache server + * it happens to accompany. And it should be updated or changed whenever + * the results are no longer fundamentally comparable to the results of + * a previous version of ab. Either due to a change in the logic of + * ab - or to due to a change in the distribution it is compiled with + * (such as an APR change in for example blocking). + */ +#define AP_AB_BASEREVISION "2.0.41-dev" + +/* + * BUGS: + * + * - uses strcpy/etc. + * - has various other poor buffer attacks related to the lazy parsing of + * response headers from the server + * - doesn't implement much of HTTP/1.x, only accepts certain forms of + * responses + * - (performance problem) heavy use of strstr shows up top in profile + * only an issue for loopback usage + */ + +/* -------------------------------------------------------------------- */ + +#if 'A' != 0x41 +/* Hmmm... This source code isn't being compiled in ASCII. + * In order for data that flows over the network to make + * sense, we need to translate to/from ASCII. + */ +#define NOT_ASCII +#endif + +/* affects include files on Solaris */ +#define BSD_COMP + +#include "apr.h" +#include "apr_signal.h" +#include "apr_strings.h" +#include "apr_network_io.h" +#include "apr_file_io.h" +#include "apr_time.h" +#include "apr_getopt.h" +#include "apr_general.h" +#include "apr_lib.h" +#include "apr_portable.h" +#include "ap_release.h" +#include "apr_poll.h" + +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#include "apr_base64.h" +#ifdef NOT_ASCII +#include "apr_xlate.h" +#endif +#if APR_HAVE_STDIO_H +#include <stdio.h> +#endif +#if APR_HAVE_STDLIB_H +#include <stdlib.h> + +#ifdef USE_SSL +#if ((!(RSAREF)) && (!(SYSSSL))) +/* Libraries on most systems.. */ +#include <openssl/rsa.h> +#include <openssl/crypto.h> +#include <openssl/x509.h> +#include <openssl/pem.h> +#include <openssl/err.h> +#include <openssl/ssl.h> +#include <openssl/rand.h> +#else +/* Libraries for RSAref and SYSSSL */ +#include <rsa.h> +#include <crypto.h> +#include <x509.h> +#include <pem.h> +#include <err.h> +#include <ssl.h> +#include <rand.h> +#endif +#endif + +#include <math.h> +#endif +#if APR_HAVE_CTYPE_H +#include <ctype.h> +#endif + +/* ------------------- DEFINITIONS -------------------------- */ + +#ifndef LLONG_MAX +#define AB_MAX APR_INT64_C(0x7fffffffffffffff) +#else +#define AB_MAX LLONG_MAX +#endif + +/* maximum number of requests on a time limited test */ +#define MAX_REQUESTS 50000 + +/* good old state hostname */ +#define STATE_UNCONNECTED 0 +#define STATE_CONNECTING 1 /* TCP connect initiated, but we don't + * know if it worked yet + */ +#define STATE_CONNECTED 2 /* we know TCP connect completed */ +#define STATE_READ 3 + +#define CBUFFSIZE (2048) + +struct connection { + apr_pool_t *ctx; + apr_socket_t *aprsock; + int state; + apr_size_t read; /* amount of bytes read */ + apr_size_t bread; /* amount of body read */ + apr_size_t rwrite, rwrote; /* keep pointers in what we write - across + * EAGAINs */ + apr_size_t length; /* Content-Length value used for keep-alive */ + char cbuff[CBUFFSIZE]; /* a buffer to store server response header */ + int cbx; /* offset in cbuffer */ + int keepalive; /* non-zero if a keep-alive request */ + int gotheader; /* non-zero if we have the entire header in + * cbuff */ + apr_time_t start, /* Start of connection */ + connect, /* Connected, start writing */ + endwrite, /* Request written */ + beginread, /* First byte of input */ + done; /* Connection closed */ + + int socknum; +#ifdef USE_SSL + SSL *ssl; +#endif +}; + +struct data { +#ifdef USE_SSL + /* XXXX insert SSL timings */ +#endif + int read; /* number of bytes read */ + apr_time_t starttime; /* start time of connection in seconds since + * Jan. 1, 1970 */ + apr_interval_time_t waittime; /* Between writing request and reading + * response */ + apr_interval_time_t ctime; /* time in ms to connect */ + apr_interval_time_t time; /* time in ms for connection */ +}; + +#define ap_min(a,b) ((a)<(b))?(a):(b) +#define ap_max(a,b) ((a)>(b))?(a):(b) +#define MAX_CONCURRENCY 20000 + +/* --------------------- GLOBALS ---------------------------- */ + +int verbosity = 0; /* no verbosity by default */ +int posting = 0; /* GET by default */ +int requests = 1; /* Number of requests to make */ +int heartbeatres = 100; /* How often do we say we're alive */ +int concurrency = 1; /* Number of multiple requests to make */ +int percentile = 1; /* Show percentile served */ +int confidence = 1; /* Show confidence estimator and warnings */ +int tlimit = 0; /* time limit in secs */ +int keepalive = 0; /* try and do keepalive connections */ +char servername[1024]; /* name that server reports */ +char *hostname; /* host name from URL */ +char *host_field; /* value of "Host:" header field */ +char *path; /* path name */ +char postfile[1024]; /* name of file containing post data */ +char *postdata; /* *buffer containing data from postfile */ +apr_size_t postlen = 0; /* length of data to be POSTed */ +char content_type[1024]; /* content type to put in POST header */ +char *cookie, /* optional cookie line */ + *auth, /* optional (basic/uuencoded) auhentication */ + *hdrs; /* optional arbitrary headers */ +apr_port_t port; /* port number */ +char proxyhost[1024]; /* proxy host name */ +int proxyport = 0; /* proxy port */ +char *connecthost; +apr_port_t connectport; +char *gnuplot; /* GNUplot file */ +char *csvperc; /* CSV Percentile file */ +char url[1024]; +char * fullurl, * colonhost; +int isproxy = 0; +apr_interval_time_t aprtimeout = apr_time_from_sec(30); /* timeout value */ + /* + * XXX - this is now a per read/write transact type of value + */ + +int use_html = 0; /* use html in the report */ +const char *tablestring; +const char *trstring; +const char *tdstring; + +apr_size_t doclen = 0; /* the length the document should be */ +long started = 0; /* number of requests started, so no excess */ +long totalread = 0; /* total number of bytes read */ +long totalbread = 0; /* totoal amount of entity body read */ +long totalposted = 0; /* total number of bytes posted, inc. headers */ +long done = 0; /* number of requests we have done */ +long doneka = 0; /* number of keep alive connections done */ +long good = 0, bad = 0; /* number of good and bad requests */ +long epipe = 0; /* number of broken pipe writes */ + +#ifdef USE_SSL +int ssl = 0; +SSL_CTX *ctx; +BIO *bio_out,*bio_err; +static void write_request(struct connection * c); +#endif + +/* store error cases */ +int err_length = 0, err_conn = 0, err_except = 0; +int err_response = 0; + +apr_time_t start, endtime; + +/* global request (and its length) */ +char _request[512]; +char *request = _request; +apr_size_t reqlen; + +/* one global throw-away buffer to read stuff into */ +char buffer[8192]; + +/* interesting percentiles */ +int percs[] = {50, 66, 75, 80, 90, 95, 98, 99, 100}; + +struct connection *con; /* connection array */ +struct data *stats; /* date for each request */ +apr_pool_t *cntxt; + +apr_pollset_t *readbits; + +apr_sockaddr_t *destsa; + +#ifdef NOT_ASCII +apr_xlate_t *from_ascii, *to_ascii; +#endif + +static void close_connection(struct connection * c); +/* --------------------------------------------------------- */ + +/* simple little function to write an error string and exit */ + +static void err(char *s) +{ + fprintf(stderr, "%s\n", s); + if (done) + printf("Total of %ld requests completed\n" , done); + exit(1); +} + +/* simple little function to write an APR error string and exit */ + +static void apr_err(char *s, apr_status_t rv) +{ + char buf[120]; + + fprintf(stderr, + "%s: %s (%d)\n", + s, apr_strerror(rv, buf, sizeof buf), rv); + if (done) + printf("Total of %ld requests completed\n" , done); + exit(rv); +} + +#if defined(USE_SSL) && USE_THREADS +/* + * To ensure thread-safetyness in OpenSSL - work in progress + */ + +static apr_thread_mutex_t **lock_cs; +static int lock_num_locks; + +static void ssl_util_thr_lock(int mode, int type, + const char *file, int line) +{ + if (type < lock_num_locks) { + if (mode & CRYPTO_LOCK) { + apr_thread_mutex_lock(lock_cs[type]); + } + else { + apr_thread_mutex_unlock(lock_cs[type]); + } + } +} + +static unsigned long ssl_util_thr_id(void) +{ + /* OpenSSL needs this to return an unsigned long. On OS/390, the pthread + * id is a structure twice that big. Use the TCB pointer instead as a + * unique unsigned long. + */ +#ifdef __MVS__ + struct PSA { + char unmapped[540]; + unsigned long PSATOLD; + } *psaptr = 0; + + return psaptr->PSATOLD; +#else + return (unsigned long) apr_os_thread_current(); +#endif +} + +static apr_status_t ssl_util_thread_cleanup(void *data) +{ + CRYPTO_set_locking_callback(NULL); + + /* Let the registered mutex cleanups do their own thing + */ + return APR_SUCCESS; +} + +void ssl_util_thread_setup(apr_pool_t *p) +{ + int i; + + lock_num_locks = CRYPTO_num_locks(); + lock_cs = apr_palloc(p, lock_num_locks * sizeof(*lock_cs)); + + for (i = 0; i < lock_num_locks; i++) { + apr_thread_mutex_create(&(lock_cs[i]), APR_THREAD_MUTEX_DEFAULT, p); + } + + CRYPTO_set_id_callback(ssl_util_thr_id); + + CRYPTO_set_locking_callback(ssl_util_thr_lock); + + apr_pool_cleanup_register(p, NULL, ssl_util_thread_cleanup, + apr_pool_cleanup_null); +} +#endif + +/* --------------------------------------------------------- */ +/* write out request to a connection - assumes we can write + * (small) request out in one go into our new socket buffer + * + */ +#ifdef USE_SSL +long ssl_print_cb(BIO *bio,int cmd,const char *argp,int argi,long argl,long ret) +{ + BIO *out; + + out=(BIO *)BIO_get_callback_arg(bio); + if (out == NULL) return(ret); + + if (cmd == (BIO_CB_READ|BIO_CB_RETURN)) + { + BIO_printf(out,"read from %08X [%08lX] (%d bytes => %ld (0x%X))\n", + bio,argp,argi,ret,ret); + BIO_dump(out,(char *)argp,(int)ret); + return(ret); + } + else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN)) + { + BIO_printf(out,"write to %08X [%08lX] (%d bytes => %ld (0x%X))\n", + bio,argp,argi,ret,ret); + BIO_dump(out,(char *)argp,(int)ret); + } + return(ret); +} + +#ifndef RAND_MAX +#include <limits.h> +#define RAND_MAX INT_MAX +#endif + +static int ssl_rand_choosenum(int l, int h) +{ + int i; + char buf[50]; + + srand((unsigned int)time(NULL)); + apr_snprintf(buf, sizeof(buf), "%.0f", + (((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l))); + i = atoi(buf)+1; + if (i < l) i = l; + if (i > h) i = h; + return i; +} + +void ssl_rand_seed() +{ + int nDone = 0; + int n, l; + time_t t; + pid_t pid; + unsigned char stackdata[256]; + + /* + * seed in the current time (usually just 4 bytes) + */ + t = time(NULL); + l = sizeof(time_t); + RAND_seed((unsigned char *)&t, l); + nDone += l; + + /* + * seed in the current process id (usually just 4 bytes) + */ + pid = getpid(); + l = sizeof(pid_t); + RAND_seed((unsigned char *)&pid, l); + nDone += l; + + /* + * seed in some current state of the run-time stack (128 bytes) + */ + n = ssl_rand_choosenum(0, sizeof(stackdata)-128-1); + RAND_seed(stackdata+n, 128); + nDone += 128; +} + +int ssl_print_connection_info(bio,ssl) +BIO *bio; +SSL *ssl; +{ + SSL_CIPHER *c; + int alg_bits,bits; + + c=SSL_get_current_cipher(ssl); + BIO_printf(bio,"Cipher Suite Protocol :%s\n", SSL_CIPHER_get_version(c)); + BIO_printf(bio,"Cipher Suite Name :%s\n",SSL_CIPHER_get_name(c)); + + bits=SSL_CIPHER_get_bits(c,&alg_bits); + BIO_printf(bio,"Cipher Suite Cipher Bits:%d (%d)\n",bits,alg_bits); + + return(1); +} + +int ssl_print_cert_info(bio,x509cert) +BIO *bio; +X509 *x509cert; +{ + X509_NAME *dn; + char buf[64]; + + BIO_printf(bio,"Certificate version: %d\n",X509_get_version(x509cert)+1); + + BIO_printf(bio,"Valid from: "); + ASN1_UTCTIME_print(bio, X509_get_notBefore(x509cert)); + BIO_printf(bio,"\n"); + + BIO_printf(bio,"Valid to : "); + ASN1_UTCTIME_print(bio, X509_get_notAfter(x509cert)); + BIO_printf(bio,"\n"); + + BIO_printf(bio,"Public key is %d bits\n", + EVP_PKEY_bits(X509_get_pubkey(x509cert))); + + dn=X509_get_issuer_name(x509cert); + X509_NAME_oneline(dn, buf, BUFSIZ); + BIO_printf(bio,"The issuer name is %s\n", buf); + + dn=X509_get_subject_name(x509cert); + X509_NAME_oneline(dn, buf, BUFSIZ); + BIO_printf(bio,"The subject name is %s\n", buf); + + /* dump the extension list too */ + BIO_printf(bio,"Extension Count: %d\n",X509_get_ext_count(x509cert)); + + return(1); +} + +void ssl_start_connect(struct connection * c) +{ + BIO *bio; + X509 *x509cert; +#ifdef RSAREF + STACK *sk; +#else + STACK_OF(X509) *sk; +#endif + int i, count, hdone = 0; + char ssl_hostname[80]; + + /* XXX - Verify if it's okay - TBD */ + if (requests < concurrency) + requests = concurrency; + + if (!(started < requests)) + return; + + c->read = 0; + c->bread = 0; + c->keepalive = 0; + c->cbx = 0; + c->gotheader = 0; + c->rwrite = 0; + if (c->ctx) + apr_pool_destroy(c->ctx); + apr_pool_create(&c->ctx, cntxt); + + if ((c->ssl=SSL_new(ctx)) == NULL) + { + BIO_printf(bio_err,"SSL_new failed\n"); + exit(1); + } + + ssl_rand_seed(); + + c->start = apr_time_now(); + memset(ssl_hostname, 0, 80); + sprintf(ssl_hostname, "%s:%d", hostname, port); + + if ((bio = BIO_new_connect(ssl_hostname)) == NULL) + { + BIO_printf(bio_err,"BIO_new_connect failed\n"); + exit(1); + } + SSL_set_bio(c->ssl,bio,bio); + SSL_set_connect_state(c->ssl); + + if (verbosity >= 4) + { + BIO_set_callback(bio,ssl_print_cb); + BIO_set_callback_arg(bio,(void*)bio_err); + } + + while (!hdone) + { + i = SSL_do_handshake(c->ssl); + + switch (SSL_get_error(c->ssl,i)) + { + case SSL_ERROR_NONE: + hdone=1; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + BIO_printf(bio_err,"SSL connection failed\n"); + err_conn++; + c->state = STATE_UNCONNECTED; + if (bad++ > 10) { + SSL_free (c->ssl); + BIO_printf(bio_err,"\nTest aborted after 10 failures\n\n"); + exit (1); + } + break; + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_CONNECT: + BIO_printf(bio_err, "Waiting .. sleep(1)\n"); + apr_sleep(apr_time_from_sec(1)); + c->state = STATE_CONNECTED; + c->rwrite = 0; + break; + case SSL_ERROR_ZERO_RETURN: + BIO_printf(bio_err,"socket closed\n"); + break; + } + } + + if (verbosity >= 2) + { + BIO_printf(bio_err, "\n"); + sk = SSL_get_peer_cert_chain(c->ssl); +#ifdef RSAREF + if ((count = sk_num(sk)) > 0) +#else + if ((count = sk_X509_num(sk)) > 0) +#endif + { + for (i=1; i<count; i++) + { +#ifdef RSAREF + x509cert = (X509 *)sk_value(sk,i); +#else + x509cert = (X509 *)sk_X509_value(sk,i); +#endif + ssl_print_cert_info(bio_out,x509cert); + X509_free(x509cert); + } + } + + x509cert = SSL_get_peer_certificate(c->ssl); + if (x509cert == NULL) + BIO_printf(bio_out, "Anon DH\n"); + else + { + BIO_printf(bio_out, "Peer certificate\n"); + ssl_print_cert_info(bio_out,x509cert); + X509_free(x509cert); + } + + ssl_print_connection_info(bio_err,c->ssl); + SSL_SESSION_print(bio_err,SSL_get_session(c->ssl)); + } + + /* connected first time */ + started++; + write_request(c); +} +#endif /* USE_SSL */ + +static void write_request(struct connection * c) +{ + do { + apr_time_t tnow = apr_time_now(); + apr_size_t l = c->rwrite; + apr_status_t e; + + /* + * First time round ? + */ + if (c->rwrite == 0) { +#ifdef USE_SSL + if (ssl != 1) +#endif + apr_socket_timeout_set(c->aprsock, 0); + c->connect = tnow; + c->rwrite = reqlen; + c->rwrote = 0; + if (posting) + c->rwrite += postlen; + } + else if (tnow > c->connect + aprtimeout) { + printf("Send request timed out!\n"); + close_connection(c); + return; + } + +#ifdef USE_SSL + if (ssl == 1) { + apr_size_t e_ssl; + e_ssl = SSL_write(c->ssl,request + c->rwrote, l); + if (e_ssl != l) + { + printf("SSL write failed - closing connection\n"); + close_connection (c); + return; + } + l = e_ssl; + } + else +#endif + e = apr_send(c->aprsock, request + c->rwrote, &l); + + /* + * Bail early on the most common case + */ + if (l == c->rwrite) + break; + +#ifdef USE_SSL + if (ssl != 1) +#endif + if (e != APR_SUCCESS) { + /* + * Let's hope this traps EWOULDBLOCK too ! + */ + if (!APR_STATUS_IS_EAGAIN(e)) { + epipe++; + printf("Send request failed!\n"); + close_connection(c); + } + return; + } + c->rwrote += l; + c->rwrite -= l; + } while (1); + + totalposted += c->rwrite; + c->state = STATE_READ; + c->endwrite = apr_time_now(); +#ifdef USE_SSL + if (ssl != 1) +#endif + { + apr_pollfd_t new_pollfd; + new_pollfd.desc_type = APR_POLL_SOCKET; + new_pollfd.reqevents = APR_POLLIN; + new_pollfd.desc.s = c->aprsock; + new_pollfd.client_data = c; + apr_pollset_add(readbits, &new_pollfd); + } +} + +/* --------------------------------------------------------- */ + +/* calculate and output results */ + +static int compradre(struct data * a, struct data * b) +{ + if ((a->ctime) < (b->ctime)) + return -1; + if ((a->ctime) > (b->ctime)) + return +1; + return 0; +} + +static int comprando(struct data * a, struct data * b) +{ + if ((a->time) < (b->time)) + return -1; + if ((a->time) > (b->time)) + return +1; + return 0; +} + +static int compri(struct data * a, struct data * b) +{ + apr_interval_time_t p = a->time - a->ctime; + apr_interval_time_t q = b->time - b->ctime; + if (p < q) + return -1; + if (p > q) + return +1; + return 0; +} + +static int compwait(struct data * a, struct data * b) +{ + if ((a->waittime) < (b->waittime)) + return -1; + if ((a->waittime) > (b->waittime)) + return 1; + return 0; +} + +static void output_results(void) +{ + apr_interval_time_t timetakenusec; + float timetaken; + + endtime = apr_time_now(); + timetakenusec = endtime - start; + timetaken = ((float)apr_time_sec(timetakenusec)) + + ((float)apr_time_usec(timetakenusec)) / 1000000.0F; + + printf("\n\n"); + printf("Server Software: %s\n", servername); + printf("Server Hostname: %s\n", hostname); + printf("Server Port: %hd\n", port); + printf("\n"); + printf("Document Path: %s\n", path); + printf("Document Length: %" APR_SIZE_T_FMT " bytes\n", doclen); + printf("\n"); + printf("Concurrency Level: %d\n", concurrency); + printf("Time taken for tests: %ld.%03ld seconds\n", + (long) apr_time_sec(timetakenusec), + (long) apr_time_usec(timetakenusec)); + printf("Complete requests: %ld\n", done); + printf("Failed requests: %ld\n", bad); + if (bad) + printf(" (Connect: %d, Length: %d, Exceptions: %d)\n", + err_conn, err_length, err_except); + printf("Write errors: %ld\n", epipe); + if (err_response) + printf("Non-2xx responses: %d\n", err_response); + if (keepalive) + printf("Keep-Alive requests: %ld\n", doneka); + printf("Total transferred: %ld bytes\n", totalread); + if (posting > 0) + printf("Total POSTed: %ld\n", totalposted); + printf("HTML transferred: %ld bytes\n", totalbread); + + /* avoid divide by zero */ + if (timetaken) { + printf("Requests per second: %.2f [#/sec] (mean)\n", + (float) (done / timetaken)); + printf("Time per request: %.3f [ms] (mean)\n", + (float) (1000 * concurrency * timetaken / done)); + printf("Time per request: %.3f [ms] (mean, across all concurrent requests)\n", + (float) (1000 * timetaken / done)); + printf("Transfer rate: %.2f [Kbytes/sec] received\n", + (float) (totalread / 1024 / timetaken)); + if (posting > 0) { + printf(" %.2f kb/s sent\n", + (float) (totalposted / timetaken / 1024)); + printf(" %.2f kb/s total\n", + (float) ((totalread + totalposted) / timetaken / 1024)); + } + } + + if (requests) { + /* work out connection times */ + long i; + apr_time_t totalcon = 0, total = 0, totald = 0, totalwait = 0; + apr_time_t meancon, meantot, meand, meanwait; + apr_interval_time_t mincon = AB_MAX, mintot = AB_MAX, mind = AB_MAX, + minwait = AB_MAX; + apr_interval_time_t maxcon = 0, maxtot = 0, maxd = 0, maxwait = 0; + apr_interval_time_t mediancon = 0, mediantot = 0, mediand = 0, medianwait = 0; + double sdtot = 0, sdcon = 0, sdd = 0, sdwait = 0; + + for (i = 0; i < requests; i++) { + struct data s = stats[i]; + mincon = ap_min(mincon, s.ctime); + mintot = ap_min(mintot, s.time); + mind = ap_min(mind, s.time - s.ctime); + minwait = ap_min(minwait, s.waittime); + + maxcon = ap_max(maxcon, s.ctime); + maxtot = ap_max(maxtot, s.time); + maxd = ap_max(maxd, s.time - s.ctime); + maxwait = ap_max(maxwait, s.waittime); + + totalcon += s.ctime; + total += s.time; + totald += s.time - s.ctime; + totalwait += s.waittime; + } + meancon = totalcon / requests; + meantot = total / requests; + meand = totald / requests; + meanwait = totalwait / requests; + + /* calculating the sample variance: the sum of the squared deviations, divided by n-1 */ + for (i = 0; i < requests; i++) { + struct data s = stats[i]; + double a; + a = ((double)s.time - meantot); + sdtot += a * a; + a = ((double)s.ctime - meancon); + sdcon += a * a; + a = ((double)s.time - (double)s.ctime - meand); + sdd += a * a; + a = ((double)s.waittime - meanwait); + sdwait += a * a; + } + + sdtot = (requests > 1) ? sqrt(sdtot / (requests - 1)) : 0; + sdcon = (requests > 1) ? sqrt(sdcon / (requests - 1)) : 0; + sdd = (requests > 1) ? sqrt(sdd / (requests - 1)) : 0; + sdwait = (requests > 1) ? sqrt(sdwait / (requests - 1)) : 0; + + if (gnuplot) { + FILE *out = fopen(gnuplot, "w"); + long i; + apr_time_t sttime; + char tmstring[1024];/* XXXX */ + if (!out) { + perror("Cannot open gnuplot output file"); + exit(1); + } + fprintf(out, "starttime\tseconds\tctime\tdtime\tttime\twait\n"); + for (i = 0; i < requests; i++) { + apr_time_t diff = stats[i].time - stats[i].ctime; + + sttime = stats[i].starttime; + (void) apr_ctime(tmstring, sttime); + fprintf(out, "%s\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\n", + tmstring, + sttime, + stats[i].ctime, + diff, + stats[i].time, + stats[i].waittime); + } + fclose(out); + } + /* + * XXX: what is better; this hideous cast of the compradre function; or + * the four warnings during compile ? dirkx just does not know and + * hates both/ + */ + qsort(stats, requests, sizeof(struct data), + (int (*) (const void *, const void *)) compradre); + if ((requests > 1) && (requests % 2)) + mediancon = (stats[requests / 2].ctime + stats[requests / 2 + 1].ctime) / 2; + else + mediancon = stats[requests / 2].ctime; + + qsort(stats, requests, sizeof(struct data), + (int (*) (const void *, const void *)) compri); + if ((requests > 1) && (requests % 2)) + mediand = (stats[requests / 2].time + stats[requests / 2 + 1].time \ + -stats[requests / 2].ctime - stats[requests / 2 + 1].ctime) / 2; + else + mediand = stats[requests / 2].time - stats[requests / 2].ctime; + + qsort(stats, requests, sizeof(struct data), + (int (*) (const void *, const void *)) compwait); + if ((requests > 1) && (requests % 2)) + medianwait = (stats[requests / 2].waittime + stats[requests / 2 + 1].waittime) / 2; + else + medianwait = stats[requests / 2].waittime; + + qsort(stats, requests, sizeof(struct data), + (int (*) (const void *, const void *)) comprando); + if ((requests > 1) && (requests % 2)) + mediantot = (stats[requests / 2].time + stats[requests / 2 + 1].time) / 2; + else + mediantot = stats[requests / 2].time; + + printf("\nConnection Times (ms)\n"); + + if (confidence) { +#define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %4d %5.1f %6" APR_TIME_T_FMT " %7" APR_TIME_T_FMT "\n" + printf(" min mean[+/-sd] median max\n"); + printf("Connect: " CONF_FMT_STRING, + mincon, (int) (meancon + 0.5), sdcon, mediancon, maxcon); + printf("Processing: " CONF_FMT_STRING, + mind, (int) (meand + 0.5), sdd, mediand, maxd); + printf("Waiting: " CONF_FMT_STRING, + minwait, (int) (meanwait + 0.5), sdwait, medianwait, maxwait); + printf("Total: " CONF_FMT_STRING, + mintot, (int) (meantot + 0.5), sdtot, mediantot, maxtot); +#undef CONF_FMT_STRING + +#define SANE(what,mean,median,sd) \ + { \ + double d = (double)mean - median; \ + if (d < 0) d = -d; \ + if (d > 2 * sd ) \ + printf("ERROR: The median and mean for " what " are more than twice the standard\n" \ + " deviation apart. These results are NOT reliable.\n"); \ + else if (d > sd ) \ + printf("WARNING: The median and mean for " what " are not within a normal deviation\n" \ + " These results are probably not that reliable.\n"); \ + } + SANE("the initial connection time", meancon, mediancon, sdcon); + SANE("the processing time", meand, mediand, sdd); + SANE("the waiting time", meanwait, medianwait, sdwait); + SANE("the total time", meantot, mediantot, sdtot); + } + else { + printf(" min avg max\n"); +#define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n" + printf("Connect: " CONF_FMT_STRING, + mincon, meancon, maxcon); + printf("Processing: " CONF_FMT_STRING, + mintot - mincon, meantot - meancon, maxtot - maxcon); + printf("Total: " CONF_FMT_STRING, + mintot, meantot, maxtot); +#undef CONF_FMT_STRING + } + + + /* Sorted on total connect times */ + if (percentile && (requests > 1)) { + printf("\nPercentage of the requests served within a certain time (ms)\n"); + for (i = 0; i < sizeof(percs) / sizeof(int); i++) + if (percs[i] <= 0) + printf(" 0%% <0> (never)\n"); + else if (percs[i] >= 100) + printf(" 100%% %5" APR_TIME_T_FMT " (longest request)\n", + stats[requests - 1].time); + else + printf(" %d%% %5" APR_TIME_T_FMT "\n", percs[i], + stats[(int) (requests * percs[i] / 100)].time); + } + if (csvperc) { + FILE *out = fopen(csvperc, "w"); + int i; + if (!out) { + perror("Cannot open CSV output file"); + exit(1); + } + fprintf(out, "" "Percentage served" "," "Time in ms" "\n"); + for (i = 0; i < 100; i++) { + apr_time_t t; + if (i == 0) + t = stats[0].time; + else if (i == 100) + t = stats[requests - 1].time; + else + t = stats[(int) (0.5 + requests * i / 100.0)].time; + fprintf(out, "%d,%e\n", i, (double)t); + } + fclose(out); + } + + } +} + +/* --------------------------------------------------------- */ + +/* calculate and output results in HTML */ + +static void output_html_results(void) +{ + long timetaken; + + endtime = apr_time_now(); + timetaken = (long)((endtime - start) / 1000); + + printf("\n\n<table %s>\n", tablestring); + printf("<tr %s><th colspan=2 %s>Server Software:</th>" + "<td colspan=2 %s>%s</td></tr>\n", + trstring, tdstring, tdstring, servername); + printf("<tr %s><th colspan=2 %s>Server Hostname:</th>" + "<td colspan=2 %s>%s</td></tr>\n", + trstring, tdstring, tdstring, hostname); + printf("<tr %s><th colspan=2 %s>Server Port:</th>" + "<td colspan=2 %s>%hd</td></tr>\n", + trstring, tdstring, tdstring, port); + printf("<tr %s><th colspan=2 %s>Document Path:</th>" + "<td colspan=2 %s>%s</td></tr>\n", + trstring, tdstring, tdstring, path); + printf("<tr %s><th colspan=2 %s>Document Length:</th>" + "<td colspan=2 %s>%" APR_SIZE_T_FMT " bytes</td></tr>\n", + trstring, tdstring, tdstring, doclen); + printf("<tr %s><th colspan=2 %s>Concurrency Level:</th>" + "<td colspan=2 %s>%d</td></tr>\n", + trstring, tdstring, tdstring, concurrency); + printf("<tr %s><th colspan=2 %s>Time taken for tests:</th>" + "<td colspan=2 %s>%" APR_INT64_T_FMT ".%03ld seconds</td></tr>\n", + trstring, tdstring, tdstring, apr_time_sec(timetaken), + (long)apr_time_usec(timetaken)); + printf("<tr %s><th colspan=2 %s>Complete requests:</th>" + "<td colspan=2 %s>%ld</td></tr>\n", + trstring, tdstring, tdstring, done); + printf("<tr %s><th colspan=2 %s>Failed requests:</th>" + "<td colspan=2 %s>%ld</td></tr>\n", + trstring, tdstring, tdstring, bad); + if (bad) + printf("<tr %s><td colspan=4 %s > (Connect: %d, Length: %d, Exceptions: %d)</td></tr>\n", + trstring, tdstring, err_conn, err_length, err_except); + if (err_response) + printf("<tr %s><th colspan=2 %s>Non-2xx responses:</th>" + "<td colspan=2 %s>%d</td></tr>\n", + trstring, tdstring, tdstring, err_response); + if (keepalive) + printf("<tr %s><th colspan=2 %s>Keep-Alive requests:</th>" + "<td colspan=2 %s>%ld</td></tr>\n", + trstring, tdstring, tdstring, doneka); + printf("<tr %s><th colspan=2 %s>Total transferred:</th>" + "<td colspan=2 %s>%ld bytes</td></tr>\n", + trstring, tdstring, tdstring, totalread); + if (posting > 0) + printf("<tr %s><th colspan=2 %s>Total POSTed:</th>" + "<td colspan=2 %s>%ld</td></tr>\n", + trstring, tdstring, tdstring, totalposted); + printf("<tr %s><th colspan=2 %s>HTML transferred:</th>" + "<td colspan=2 %s>%ld bytes</td></tr>\n", + trstring, tdstring, tdstring, totalbread); + + /* avoid divide by zero */ + if (timetaken) { + printf("<tr %s><th colspan=2 %s>Requests per second:</th>" + "<td colspan=2 %s>%.2f</td></tr>\n", + trstring, tdstring, tdstring, 1000 * (float) (done) / timetaken); + printf("<tr %s><th colspan=2 %s>Transfer rate:</th>" + "<td colspan=2 %s>%.2f kb/s received</td></tr>\n", + trstring, tdstring, tdstring, (float) (totalread) / timetaken); + if (posting > 0) { + printf("<tr %s><td colspan=2 %s> </td>" + "<td colspan=2 %s>%.2f kb/s sent</td></tr>\n", + trstring, tdstring, tdstring, + (float) (totalposted) / timetaken); + printf("<tr %s><td colspan=2 %s> </td>" + "<td colspan=2 %s>%.2f kb/s total</td></tr>\n", + trstring, tdstring, tdstring, + (float) (totalread + totalposted) / timetaken); + } + } { + /* work out connection times */ + long i; + apr_interval_time_t totalcon = 0, total = 0; + apr_interval_time_t mincon = AB_MAX, mintot = AB_MAX; + apr_interval_time_t maxcon = 0, maxtot = 0; + + for (i = 0; i < requests; i++) { + struct data s = stats[i]; + mincon = ap_min(mincon, s.ctime); + mintot = ap_min(mintot, s.time); + maxcon = ap_max(maxcon, s.ctime); + maxtot = ap_max(maxtot, s.time); + totalcon += s.ctime; + total += s.time; + } + + if (requests > 0) { /* avoid division by zero (if 0 requests) */ + printf("<tr %s><th %s colspan=4>Connnection Times (ms)</th></tr>\n", + trstring, tdstring); + printf("<tr %s><th %s> </th> <th %s>min</th> <th %s>avg</th> <th %s>max</th></tr>\n", + trstring, tdstring, tdstring, tdstring, tdstring); + printf("<tr %s><th %s>Connect:</th>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n", + trstring, tdstring, tdstring, mincon, tdstring, totalcon / requests, tdstring, maxcon); + printf("<tr %s><th %s>Processing:</th>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n", + trstring, tdstring, tdstring, mintot - mincon, tdstring, + (total / requests) - (totalcon / requests), tdstring, maxtot - maxcon); + printf("<tr %s><th %s>Total:</th>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td>" + "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n", + trstring, tdstring, tdstring, mintot, tdstring, total / requests, tdstring, maxtot); + } + printf("</table>\n"); + } +} + +/* --------------------------------------------------------- */ + +/* start asnchronous non-blocking connection */ + +static void start_connect(struct connection * c) +{ + apr_status_t rv; + +#ifdef USE_SSL + if (ssl == 1) { + ssl_start_connect(c); + return; + } +#endif + + if (!(started < requests)) + return; + + c->read = 0; + c->bread = 0; + c->keepalive = 0; + c->cbx = 0; + c->gotheader = 0; + c->rwrite = 0; + if (c->ctx) + apr_pool_destroy(c->ctx); + apr_pool_create(&c->ctx, cntxt); + + if ((rv = apr_socket_create(&c->aprsock, destsa->family, + SOCK_STREAM, c->ctx)) != APR_SUCCESS) { + apr_err("socket", rv); + } + if ((rv = apr_socket_opt_set(c->aprsock, APR_SO_NONBLOCK, 1)) + != APR_SUCCESS) { + apr_err("socket nonblock", rv); + } + c->start = apr_time_now(); + if ((rv = apr_connect(c->aprsock, destsa)) != APR_SUCCESS) { + if (APR_STATUS_IS_EINPROGRESS(rv)) { + apr_pollfd_t new_pollfd; + c->state = STATE_CONNECTING; + c->rwrite = 0; + new_pollfd.desc_type = APR_POLL_SOCKET; + new_pollfd.reqevents = APR_POLLOUT; + new_pollfd.desc.s = c->aprsock; + new_pollfd.client_data = c; + apr_pollset_add(readbits, &new_pollfd); + return; + } + else { + apr_pollfd_t remove_pollfd; + remove_pollfd.desc_type = APR_POLL_SOCKET; + remove_pollfd.desc.s = c->aprsock; + apr_pollset_remove(readbits, &remove_pollfd); + apr_socket_close(c->aprsock); + err_conn++; + if (bad++ > 10) { + fprintf(stderr, + "\nTest aborted after 10 failures\n\n"); + apr_err("apr_connect()", rv); + } + c->state = STATE_UNCONNECTED; + start_connect(c); + return; + } + } + + /* connected first time */ + c->state = STATE_CONNECTED; + started++; + write_request(c); +} + +/* --------------------------------------------------------- */ + +/* close down connection and save stats */ + +static void close_connection(struct connection * c) +{ + if (c->read == 0 && c->keepalive) { + /* + * server has legitimately shut down an idle keep alive request + */ + if (good) + good--; /* connection never happened */ + } + else { + if (good == 1) { + /* first time here */ + doclen = c->bread; + } + else if (c->bread != doclen) { + bad++; + err_length++; + } + /* save out time */ + if (done < requests) { + struct data s; + if ((done) && heartbeatres && !(done % heartbeatres)) { + fprintf(stderr, "Completed %ld requests\n", done); + fflush(stderr); + } + c->done = apr_time_now(); + s.read = c->read; + s.starttime = c->start; + s.ctime = (c->connect - c->start) / 1000; + s.time = (c->done - c->start) / 1000; + s.waittime = (c->beginread - c->endwrite) / 1000; + stats[done++] = s; + } + } + +#ifdef USE_SSL + if (ssl == 1) { + SSL_shutdown(c->ssl); + SSL_free(c->ssl); + } + else +#endif + { + apr_pollfd_t remove_pollfd; + remove_pollfd.desc_type = APR_POLL_SOCKET; + remove_pollfd.desc.s = c->aprsock; + apr_pollset_remove(readbits, &remove_pollfd); + apr_socket_close(c->aprsock); + } + c->state = STATE_UNCONNECTED; + + /* connect again */ + start_connect(c); + return; +} + +/* --------------------------------------------------------- */ + +/* read data from connection */ + +static void read_connection(struct connection * c) +{ + apr_size_t r; + apr_status_t status; + char *part; + char respcode[4]; /* 3 digits and null */ + + r = sizeof(buffer); +#ifdef USE_SSL + if (ssl == 1) + { + status = SSL_read (c->ssl, buffer, r); + if (status <= 0) { + good++; c->read = 0; + if (status < 0) printf("SSL read failed - closing connection\n"); + close_connection(c); + return; + } + r = status; + } + else { +#endif + status = apr_recv(c->aprsock, buffer, &r); + if (APR_STATUS_IS_EAGAIN(status)) + return; + else if (r == 0 && APR_STATUS_IS_EOF(status)) { + good++; + close_connection(c); + return; + } + /* catch legitimate fatal apr_recv errors */ + else if (status != APR_SUCCESS) { + err_except++; /* XXX: is this the right error counter? */ + /* XXX: Should errors here be fatal, or should we allow a + * certain number of them before completely failing? -aaron */ + apr_err("apr_recv", status); + } +#ifdef USE_SSL + } +#endif + + totalread += r; + if (c->read == 0) { + c->beginread = apr_time_now(); + } + c->read += r; + + + if (!c->gotheader) { + char *s; + int l = 4; + apr_size_t space = CBUFFSIZE - c->cbx - 1; /* -1 allows for \0 term */ + int tocopy = (space < r) ? space : r; +#ifdef NOT_ASCII + apr_size_t inbytes_left = space, outbytes_left = space; + + status = apr_xlate_conv_buffer(from_ascii, buffer, &inbytes_left, + c->cbuff + c->cbx, &outbytes_left); + if (status || inbytes_left || outbytes_left) { + fprintf(stderr, "only simple translation is supported (%d/%u/%u)\n", + status, inbytes_left, outbytes_left); + exit(1); + } +#else + memcpy(c->cbuff + c->cbx, buffer, space); +#endif /* NOT_ASCII */ + c->cbx += tocopy; + space -= tocopy; + c->cbuff[c->cbx] = 0; /* terminate for benefit of strstr */ + if (verbosity >= 2) { + printf("LOG: header received:\n%s\n", c->cbuff); + } + s = strstr(c->cbuff, "\r\n\r\n"); + /* + * this next line is so that we talk to NCSA 1.5 which blatantly + * breaks the http specifaction + */ + if (!s) { + s = strstr(c->cbuff, "\n\n"); + l = 2; + } + + if (!s) { + /* read rest next time */ + if (space) { + return; + } + else { + /* header is in invalid or too big - close connection */ + apr_pollfd_t remove_pollfd; + remove_pollfd.desc_type = APR_POLL_SOCKET; + remove_pollfd.desc.s = c->aprsock; + apr_pollset_remove(readbits, &remove_pollfd); + apr_socket_close(c->aprsock); + err_response++; + if (bad++ > 10) { + err("\nTest aborted after 10 failures\n\n"); + } + start_connect(c); + } + } + else { + /* have full header */ + if (!good) { + /* + * this is first time, extract some interesting info + */ + char *p, *q; + p = strstr(c->cbuff, "Server:"); + q = servername; + if (p) { + p += 8; + while (*p > 32) + *q++ = *p++; + } + *q = 0; + } + /* + * XXX: this parsing isn't even remotely HTTP compliant... but in + * the interest of speed it doesn't totally have to be, it just + * needs to be extended to handle whatever servers folks want to + * test against. -djg + */ + + /* check response code */ + part = strstr(c->cbuff, "HTTP"); /* really HTTP/1.x_ */ + if (part && strlen(part) > strlen("HTTP/1.x_")) { + strncpy(respcode, (part + strlen("HTTP/1.x_")), 3); + respcode[3] = '\0'; + } + else { + strcpy(respcode, "500"); + } + + if (respcode[0] != '2') { + err_response++; + if (verbosity >= 2) + printf("WARNING: Response code not 2xx (%s)\n", respcode); + } + else if (verbosity >= 3) { + printf("LOG: Response code = %s\n", respcode); + } + c->gotheader = 1; + *s = 0; /* terminate at end of header */ + if (keepalive && + (strstr(c->cbuff, "Keep-Alive") + || strstr(c->cbuff, "keep-alive"))) { /* for benefit of MSIIS */ + char *cl; + cl = strstr(c->cbuff, "Content-Length:"); + /* handle NCSA, which sends Content-length: */ + if (!cl) + cl = strstr(c->cbuff, "Content-length:"); + if (cl) { + c->keepalive = 1; + c->length = atoi(cl + 16); + } + } + c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy; + totalbread += c->bread; + } + } + else { + /* outside header, everything we have read is entity body */ + c->bread += r; + totalbread += r; + } + + if (c->keepalive && (c->bread >= c->length)) { + /* finished a keep-alive connection */ + good++; + /* save out time */ + if (good == 1) { + /* first time here */ + doclen = c->bread; + } + else if (c->bread != doclen) { + bad++; + err_length++; + } + if (done < requests) { + struct data s; + doneka++; + if (done && heartbeatres && !(done % heartbeatres)) { + fprintf(stderr, "Completed %ld requests\n", done); + fflush(stderr); + } + c->done = apr_time_now(); + s.read = c->read; + s.starttime = c->start; + s.ctime = (c->connect - c->start) / 1000; + s.waittime = (c->beginread - c->endwrite) / 1000; + s.time = (c->done - c->start) / 1000; + stats[done++] = s; + } + c->keepalive = 0; + c->length = 0; + c->gotheader = 0; + c->cbx = 0; + c->read = c->bread = 0; + c->start = c->connect = apr_time_now(); /* zero connect time with keep-alive */ + write_request(c); + } +} + +/* --------------------------------------------------------- */ + +/* run the tests */ + +static void test(void) +{ + apr_time_t now; + apr_int16_t rv; + long i; + apr_status_t status; +#ifdef NOT_ASCII + apr_size_t inbytes_left, outbytes_left; +#endif + + if (isproxy) { + connecthost = apr_pstrdup(cntxt, proxyhost); + connectport = proxyport; + } + else { + connecthost = apr_pstrdup(cntxt, hostname); + connectport = port; + } + + if (!use_html) { + printf("Benchmarking %s ", hostname); + if (isproxy) + printf("[through %s:%d] ", proxyhost, proxyport); + printf("(be patient)%s", + (heartbeatres ? "\n" : "...")); + fflush(stdout); + } + + now = apr_time_now(); + + con = calloc(concurrency * sizeof(struct connection), 1); + + stats = calloc(requests * sizeof(struct data), 1); + + if ((status = apr_pollset_create(&readbits, concurrency, cntxt, 0)) != APR_SUCCESS) { + apr_err("apr_pollset_create failed", status); + } + + /* setup request */ + if (posting <= 0) { + sprintf(request, "%s %s HTTP/1.0\r\n" + "User-Agent: ApacheBench/%s\r\n" + "%s" "%s" "%s" + "Host: %s%s\r\n" + "Accept: */*\r\n" + "%s" "\r\n", + (posting == 0) ? "GET" : "HEAD", + (isproxy) ? fullurl : path, + AP_AB_BASEREVISION, + keepalive ? "Connection: Keep-Alive\r\n" : "", + cookie, auth, host_field, colonhost, hdrs); + } + else { + sprintf(request, "POST %s HTTP/1.0\r\n" + "User-Agent: ApacheBench/%s\r\n" + "%s" "%s" "%s" + "Host: %s%s\r\n" + "Accept: */*\r\n" + "Content-length: %" APR_SIZE_T_FMT "\r\n" + "Content-type: %s\r\n" + "%s" + "\r\n", + (isproxy) ? fullurl : path, + AP_AB_BASEREVISION, + keepalive ? "Connection: Keep-Alive\r\n" : "", + cookie, auth, + host_field, colonhost, postlen, + (content_type[0]) ? content_type : "text/plain", hdrs); + } + + if (verbosity >= 2) + printf("INFO: POST header == \n---\n%s\n---\n", request); + + reqlen = strlen(request); + + /* + * Combine headers and (optional) post file into one contineous buffer + */ + if (posting == 1) { + char *buff = malloc(postlen + reqlen + 1); + if (!buff) { + fprintf(stderr, "error creating request buffer: out of memory\n"); + return; + } + strcpy(buff, request); + strcpy(buff + reqlen, postdata); + request = buff; + } + +#ifdef NOT_ASCII + inbytes_left = outbytes_left = reqlen; + status = apr_xlate_conv_buffer(to_ascii, request, &inbytes_left, + request, &outbytes_left); + if (status || inbytes_left || outbytes_left) { + fprintf(stderr, "only simple translation is supported (%d/%u/%u)\n", + status, inbytes_left, outbytes_left); + exit(1); + } +#endif /* NOT_ASCII */ + + /* This only needs to be done once */ +#ifdef USE_SSL + if (ssl != 1) +#endif + if ((rv = apr_sockaddr_info_get(&destsa, connecthost, APR_UNSPEC, connectport, 0, cntxt)) + != APR_SUCCESS) { + char buf[120]; + apr_snprintf(buf, sizeof(buf), + "apr_sockaddr_info_get() for %s", connecthost); + apr_err(buf, rv); + } + + /* ok - lets start */ + start = apr_time_now(); + + /* initialise lots of requests */ + for (i = 0; i < concurrency; i++) { + con[i].socknum = i; + start_connect(&con[i]); + } + + while (done < requests) { + apr_int32_t n; + apr_int32_t timed; + const apr_pollfd_t *pollresults; + + /* check for time limit expiry */ + now = apr_time_now(); + timed = (apr_int32_t)apr_time_sec(now - start); + if (tlimit && timed >= tlimit) { + requests = done; /* so stats are correct */ + break; /* no need to do another round */ + } + + n = concurrency; +#ifdef USE_SSL + if (ssl == 1) + status = APR_SUCCESS; + else +#endif + status = apr_pollset_poll(readbits, aprtimeout, &n, &pollresults); + if (status != APR_SUCCESS) + apr_err("apr_poll", status); + + if (!n) { + err("\nServer timed out\n\n"); + } + + for (i = 0; i < n; i++) { + const apr_pollfd_t *next_fd = &(pollresults[i]); + struct connection *c = next_fd->client_data; + + /* + * If the connection isn't connected how can we check it? + */ + if (c->state == STATE_UNCONNECTED) + continue; + +#ifdef USE_SSL + if (ssl == 1) + rv = APR_POLLIN; + else +#endif + rv = next_fd->rtnevents; + + /* + * Notes: APR_POLLHUP is set after FIN is received on some + * systems, so treat that like APR_POLLIN so that we try to read + * again. + * + * Some systems return APR_POLLERR with APR_POLLHUP. We need to + * call read_connection() for APR_POLLHUP, so check for + * APR_POLLHUP first so that a closed connection isn't treated + * like an I/O error. If it is, we never figure out that the + * connection is done and we loop here endlessly calling + * apr_poll(). + */ + if ((rv & APR_POLLIN) || (rv & APR_POLLPRI) || (rv & APR_POLLHUP)) + read_connection(c); + if ((rv & APR_POLLERR) || (rv & APR_POLLNVAL)) { + bad++; + err_except++; + start_connect(c); + continue; + } + if (rv & APR_POLLOUT) { + if (c->state == STATE_CONNECTING) { + apr_pollfd_t remove_pollfd; + rv = apr_connect(c->aprsock, destsa); + remove_pollfd.desc_type = APR_POLL_SOCKET; + remove_pollfd.desc.s = c->aprsock; + apr_pollset_remove(readbits, &remove_pollfd); + if (rv != APR_SUCCESS) { + apr_socket_close(c->aprsock); + err_conn++; + if (bad++ > 10) { + fprintf(stderr, + "\nTest aborted after 10 failures\n\n"); + apr_err("apr_connect()", rv); + } + c->state = STATE_UNCONNECTED; + start_connect(c); + continue; + } + else { + c->state = STATE_CONNECTED; + write_request(c); + } + } + else { + write_request(c); + } + } + + /* + * When using a select based poll every time we check the bits + * are reset. In 1.3's ab we copied the FD_SET's each time + * through, but here we're going to check the state and if the + * connection is in STATE_READ or STATE_CONNECTING we'll add the + * socket back in as APR_POLLIN. + */ +#ifdef USE_SSL + if (ssl != 1) +#endif + if (c->state == STATE_READ) { + apr_pollfd_t new_pollfd; + new_pollfd.desc_type = APR_POLL_SOCKET; + new_pollfd.reqevents = APR_POLLIN; + new_pollfd.desc.s = c->aprsock; + new_pollfd.client_data = c; + apr_pollset_add(readbits, &new_pollfd); + } + } + } + + if (heartbeatres) + fprintf(stderr, "Finished %ld requests\n", done); + else + printf("..done\n"); + + if (use_html) + output_html_results(); + else + output_results(); +} + +/* ------------------------------------------------------- */ + +/* display copyright information */ +static void copyright(void) +{ + if (!use_html) { + printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1.121.2.12 $> apache-2.0"); + printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); + printf("Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/\n"); + printf("\n"); + } + else { + printf("<p>\n"); + printf(" This is ApacheBench, Version %s <i><%s></i> apache-2.0<br>\n", AP_AB_BASEREVISION, "$Revision: 1.121.2.12 $"); + printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n"); + printf(" Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/<br>\n"); + printf("</p>\n<p>\n"); + } +} + +/* display usage information */ +static void usage(const char *progname) +{ + fprintf(stderr, "Usage: %s [options] [http" +#ifdef USE_SSL + "[s]" +#endif + "://]hostname[:port]/path\n", progname); + fprintf(stderr, "Options are:\n"); + fprintf(stderr, " -n requests Number of requests to perform\n"); + fprintf(stderr, " -c concurrency Number of multiple requests to make\n"); + fprintf(stderr, " -t timelimit Seconds to max. wait for responses\n"); + fprintf(stderr, " -p postfile File containing data to POST\n"); + fprintf(stderr, " -T content-type Content-type header for POSTing\n"); + fprintf(stderr, " -v verbosity How much troubleshooting info to print\n"); + fprintf(stderr, " -w Print out results in HTML tables\n"); + fprintf(stderr, " -i Use HEAD instead of GET\n"); + fprintf(stderr, " -x attributes String to insert as table attributes\n"); + fprintf(stderr, " -y attributes String to insert as tr attributes\n"); + fprintf(stderr, " -z attributes String to insert as td or th attributes\n"); + fprintf(stderr, " -C attribute Add cookie, eg. 'Apache=1234. (repeatable)\n"); + fprintf(stderr, " -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'\n"); + fprintf(stderr, " Inserted after all normal header lines. (repeatable)\n"); + fprintf(stderr, " -A attribute Add Basic WWW Authentication, the attributes\n"); + fprintf(stderr, " are a colon separated username and password.\n"); + fprintf(stderr, " -P attribute Add Basic Proxy Authentication, the attributes\n"); + fprintf(stderr, " are a colon separated username and password.\n"); + fprintf(stderr, " -X proxy:port Proxyserver and port number to use\n"); + fprintf(stderr, " -V Print version number and exit\n"); + fprintf(stderr, " -k Use HTTP KeepAlive feature\n"); + fprintf(stderr, " -d Do not show percentiles served table.\n"); + fprintf(stderr, " -S Do not show confidence estimators and warnings.\n"); + fprintf(stderr, " -g filename Output collected data to gnuplot format file.\n"); + fprintf(stderr, " -e filename Output CSV file with percentages served\n"); +#ifdef USE_SSL + fprintf(stderr, " -s Use httpS instead of HTTP (SSL)\n"); +#endif + fprintf(stderr, " -h Display usage information (this message)\n"); + exit(EINVAL); +} + +/* ------------------------------------------------------- */ + +/* split URL into parts */ + +static int parse_url(char *url) +{ + char *cp; + char *h; + char *scope_id; + apr_status_t rv; + + /* Save a copy for the proxy */ + fullurl = apr_pstrdup(cntxt, url); + + if (strlen(url) > 7 && strncmp(url, "http://", 7) == 0) { + url += 7; +#ifdef USE_SSL + ssl = 0; +#endif + } + else +#ifdef USE_SSL + if (strlen(url) > 8 && strncmp(url, "https://", 8) == 0) { + url += 8; + ssl = 1; + } +#else + if (strlen(url) > 8 && strncmp(url, "https://", 8) == 0) { + fprintf(stderr, "SSL not compiled in; no https support\n"); + exit(1); + } +#endif + + if ((cp = strchr(url, '/')) == NULL) + return 1; + h = apr_palloc(cntxt, cp - url + 1); + memcpy(h, url, cp - url); + h[cp - url] = '\0'; + rv = apr_parse_addr_port(&hostname, &scope_id, &port, h, cntxt); + if (rv != APR_SUCCESS || !hostname || scope_id) { + return 1; + } + path = apr_pstrdup(cntxt, cp); + *cp = '\0'; + if (*url == '[') { /* IPv6 numeric address string */ + host_field = apr_psprintf(cntxt, "[%s]", hostname); + } + else { + host_field = hostname; + } + + if (port == 0) { /* no port specified */ +#ifdef USE_SSL + if (ssl == 1) + port = 443; + else +#endif + port = 80; + } + + if (( +#ifdef USE_SSL + (ssl == 1) && (port != 443)) || (( ssl == 0 ) && +#endif + (port != 80))) + { + colonhost = apr_psprintf(cntxt,":%d",port); + } else + colonhost = ""; + return 0; +} + +/* ------------------------------------------------------- */ + +/* read data to POST from file, save contents and length */ + +static int open_postfile(const char *pfile) +{ + apr_file_t *postfd = NULL; + apr_finfo_t finfo; + apr_fileperms_t mode = APR_OS_DEFAULT; + apr_size_t length; + apr_status_t rv; + char errmsg[120]; + + rv = apr_file_open(&postfd, pfile, APR_READ, mode, cntxt); + if (rv != APR_SUCCESS) { + printf("Invalid postfile name (%s): %s\n", pfile, + apr_strerror(rv, errmsg, sizeof errmsg)); + return rv; + } + + apr_file_info_get(&finfo, APR_FINFO_NORM, postfd); + postlen = (apr_size_t)finfo.size; + postdata = (char *) malloc(postlen); + if (!postdata) { + printf("Can\'t alloc postfile buffer\n"); + return APR_ENOMEM; + } + length = postlen; + rv = apr_file_read(postfd, postdata, &length); + if (rv != APR_SUCCESS) { + printf("error reading postfile: %s\n", + apr_strerror(rv, errmsg, sizeof errmsg)); + return rv; + } + if (length != postlen) { + printf("error reading postfile: read only %" + APR_SIZE_T_FMT " bytes", + length); + return APR_EINVAL; + } + apr_file_close(postfd); + return 0; +} + +/* ------------------------------------------------------- */ + +/* sort out command-line args and call test */ +int main(int argc, const char * const argv[]) +{ + int r, l; + char tmp[1024]; + apr_status_t status; + apr_getopt_t *opt; + const char *optarg; + char c; + + /* table defaults */ + tablestring = ""; + trstring = ""; + tdstring = "bgcolor=white"; + cookie = ""; + auth = ""; + proxyhost[0] = '\0'; + hdrs = ""; + + apr_app_initialize(&argc, &argv, NULL); + atexit(apr_terminate); + apr_pool_create(&cntxt, NULL); + +#ifdef NOT_ASCII + status = apr_xlate_open(&to_ascii, "ISO8859-1", APR_DEFAULT_CHARSET, cntxt); + if (status) { + fprintf(stderr, "apr_xlate_open(to ASCII)->%d\n", status); + exit(1); + } + status = apr_xlate_open(&from_ascii, APR_DEFAULT_CHARSET, "ISO8859-1", cntxt); + if (status) { + fprintf(stderr, "apr_xlate_open(from ASCII)->%d\n", status); + exit(1); + } + status = apr_base64init_ebcdic(to_ascii, from_ascii); + if (status) { + fprintf(stderr, "apr_base64init_ebcdic()->%d\n", status); + exit(1); + } +#endif + + apr_getopt_init(&opt, cntxt, argc, argv); + while ((status = apr_getopt(opt, "n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:g:X:de:Sq" +#ifdef USE_SSL + "s" +#endif + ,&c, &optarg)) == APR_SUCCESS) { + switch (c) { + case 's': +#ifdef USE_SSL + ssl = 1; + break; +#else + fprintf(stderr, "SSL not compiled in; no https support\n"); + exit(1); +#endif + case 'n': + requests = atoi(optarg); + if (!requests) { + err("Invalid number of requests\n"); + } + break; + case 'k': + keepalive = 1; + break; + case 'q': + heartbeatres = 0; + break; + case 'c': + concurrency = atoi(optarg); + break; + case 'i': + if (posting == 1) + err("Cannot mix POST and HEAD\n"); + posting = -1; + break; + case 'g': + gnuplot = strdup(optarg); + break; + case 'd': + percentile = 0; + break; + case 'e': + csvperc = strdup(optarg); + break; + case 'S': + confidence = 0; + break; + case 'p': + if (posting != 0) + err("Cannot mix POST and HEAD\n"); + + if (0 == (r = open_postfile(optarg))) { + posting = 1; + } + else if (postdata) { + exit(r); + } + break; + case 'v': + verbosity = atoi(optarg); + break; + case 't': + tlimit = atoi(optarg); + requests = MAX_REQUESTS; /* need to size data array on + * something */ + break; + case 'T': + strcpy(content_type, optarg); + break; + case 'C': + cookie = apr_pstrcat(cntxt, "Cookie: ", optarg, "\r\n", NULL); + break; + case 'A': + /* + * assume username passwd already to be in colon separated form. + * Ready to be uu-encoded. + */ + while (apr_isspace(*optarg)) + optarg++; + if (apr_base64_encode_len(strlen(optarg)) > sizeof(tmp)) { + err("Authentication credentials too long\n"); + } + l = apr_base64_encode(tmp, optarg, strlen(optarg)); + tmp[l] = '\0'; + + auth = apr_pstrcat(cntxt, auth, "Authorization: Basic ", tmp, + "\r\n", NULL); + break; + case 'P': + /* + * assume username passwd already to be in colon separated form. + */ + while (apr_isspace(*optarg)) + optarg++; + if (apr_base64_encode_len(strlen(optarg)) > sizeof(tmp)) { + err("Proxy credentials too long\n"); + } + l = apr_base64_encode(tmp, optarg, strlen(optarg)); + tmp[l] = '\0'; + + auth = apr_pstrcat(cntxt, auth, "Proxy-Authorization: Basic ", + tmp, "\r\n", NULL); + break; + case 'H': + hdrs = apr_pstrcat(cntxt, hdrs, optarg, "\r\n", NULL); + break; + case 'w': + use_html = 1; + break; + /* + * if any of the following three are used, turn on html output + * automatically + */ + case 'x': + use_html = 1; + tablestring = optarg; + break; + case 'X': + { + char *p; + /* + * assume proxy-name[:port] + */ + if ((p = strchr(optarg, ':'))) { + *p = '\0'; + p++; + proxyport = atoi(p); + } + strcpy(proxyhost, optarg); + isproxy = 1; + } + break; + case 'y': + use_html = 1; + trstring = optarg; + break; + case 'z': + use_html = 1; + tdstring = optarg; + break; + case 'h': + usage(argv[0]); + break; + case 'V': + copyright(); + return 0; + } + } + + if (opt->ind != argc - 1) { + fprintf(stderr, "%s: wrong number of arguments\n", argv[0]); + usage(argv[0]); + } + + if (parse_url(apr_pstrdup(cntxt, opt->argv[opt->ind++]))) { + fprintf(stderr, "%s: invalid URL\n", argv[0]); + usage(argv[0]); + } + + if ((concurrency < 0) || (concurrency > MAX_CONCURRENCY)) { + fprintf(stderr, "%s: Invalid Concurrency [Range 0..%d]\n", + argv[0], MAX_CONCURRENCY); + usage(argv[0]); + } + + if ((heartbeatres) && (requests > 150)) { + heartbeatres = requests / 10; /* Print line every 10% of requests */ + if (heartbeatres < 100) + heartbeatres = 100; /* but never more often than once every 100 + * connections. */ + } + else + heartbeatres = 0; + +#ifdef USE_SSL +#ifdef RSAREF + R_malloc_init(); +#else + CRYPTO_malloc_init(); +#endif + SSL_load_error_strings(); + SSL_library_init(); + bio_out=BIO_new_fp(stdout,BIO_NOCLOSE); + bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); + + /* TODO: Allow force SSLv2_client_method() (TLSv1?) */ + if (!(ctx = SSL_CTX_new(SSLv23_client_method()))) { + fprintf(stderr, "Could not init SSL CTX"); + ERR_print_errors_fp(stderr); + exit(1); + } + SSL_CTX_set_options(ctx, SSL_OP_ALL); +#ifdef USE_THREADS + ssl_util_thread_setup(cntxt); +#endif +#endif +#ifdef SIGPIPE + apr_signal(SIGPIPE, SIG_IGN); /* Ignore writes to connections that + * have been closed at the other end. */ +#endif + copyright(); + test(); + apr_pool_destroy(cntxt); + + return 0; +} diff --git a/rubbos/app/httpd-2.0.64/support/ab.dsp b/rubbos/app/httpd-2.0.64/support/ab.dsp new file mode 100644 index 00000000..c3866ba3 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/ab.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="ab" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=ab - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ab.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ab.mak" CFG="ab - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ab - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "ab - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ab - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /I "../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/ab_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "ab - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /I "../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/ab_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "ab - Win32 Release" +# Name "ab - Win32 Debug" +# Begin Source File + +SOURCE=.\ab.c +# End Source File +# Begin Source File + +SOURCE=.\ab.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "ab - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\ab.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk ab.exe "ApacheBench Utility" ../include/ap_release.h > .\ab.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "ab - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\ab.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk ab.exe "ApacheBench Utility" ../include/ap_release.h > .\ab.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/ab.lo b/rubbos/app/httpd-2.0.64/support/ab.lo new file mode 100644 index 00000000..a7d38649 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/ab.lo @@ -0,0 +1,12 @@ +# ab.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/ab.o' + +# Name of the non-PIC object. +non_pic_object='ab.o' + diff --git a/rubbos/app/httpd-2.0.64/support/ab.o b/rubbos/app/httpd-2.0.64/support/ab.o Binary files differnew file mode 100644 index 00000000..446096ca --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/ab.o diff --git a/rubbos/app/httpd-2.0.64/support/abs.dsp b/rubbos/app/httpd-2.0.64/support/abs.dsp new file mode 100644 index 00000000..f44242d8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/abs.dsp @@ -0,0 +1,134 @@ +# Microsoft Developer Studio Project File - Name="abs" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=abs - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "abs.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "abs.mak" CFG="abs - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "abs - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "abs - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "abs - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "SSL" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /I "../include" /I "../srclib/openssl/inc32/openssl" /I "../srclib/openssl/inc32" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "USE_SSL" /D "WIN32_LEAN_AND_MEAN" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /Fd"Release/abs_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib wsock32.lib ws2_32.lib shell32.lib ssleay32.lib libeay32.lib /nologo /subsystem:console /libpath:"../srclib/openssl/out32dll" +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib ssleay32.lib libeay32.lib /nologo /subsystem:console /debug /libpath:"../srclib/openssl/out32dll" /opt:ref + +!ELSEIF "$(CFG)" == "abs - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "SSL" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /I "../include" /I "../srclib/openssl/inc32/openssl" /I "../srclib/openssl/inc32" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "USE_SSL" /D "WIN32_LEAN_AND_MEAN" /D "NO_IDEA" /D "NO_RC5" /D "NO_MDC2" /D "OPENSSL_NO_IDEA" /D "OPENSSL_NO_RC5" /D "OPENSSL_NO_MDC2" /Fd"Debug/abs_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib ssleay32.lib libeay32.lib /nologo /subsystem:console /incremental:no /debug /libpath:"../srclib/openssl/out32dll" +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib ssleay32.lib libeay32.lib /nologo /subsystem:console /incremental:no /debug /libpath:"../srclib/openssl/out32dll" + +!ENDIF + +# Begin Target + +# Name "abs - Win32 Release" +# Name "abs - Win32 Debug" +# Begin Source File + +SOURCE=.\ab.c + +!IF "$(CFG)" == "abs - Win32 Release" + +# ADD CPP /Fo"Release/abs.obj" + +!ELSEIF "$(CFG)" == "abs - Win32 Debug" + +# ADD CPP /Fo"Debug/abs.obj" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\abs.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "abs - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\abs.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk ab.exe "ApacheBench/SSL Utility" ../include/ap_release.h > .\abs.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "abs - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\abs.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk ab.exe "ApacheBench/SSL Utility" ../include/ap_release.h > .\abs.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/apachectl b/rubbos/app/httpd-2.0.64/support/apachectl new file mode 100644 index 00000000..5eb2fe95 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/apachectl @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# Apache control script designed to allow an easy command line interface +# to controlling Apache. Written by Marc Slemko, 1997/08/23 +# +# The exit codes returned are: +# XXX this doc is no longer correct now that the interesting +# XXX functions are handled by httpd +# 0 - operation completed successfully +# 1 - +# 2 - usage error +# 3 - httpd could not be started +# 4 - httpd could not be stopped +# 5 - httpd could not be started during a restart +# 6 - httpd could not be restarted during a restart +# 7 - httpd could not be restarted during a graceful restart +# 8 - configuration syntax error +# +# When multiple arguments are given, only the error from the _last_ +# one is reported. Run "apachectl help" for usage info +# +ARGV="$@" +# +# |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| +# -------------------- -------------------- +# +# the path to your httpd binary, including options if necessary +HTTPD='/bottlenecks/rubbos/app/apache2/bin/httpd' +# +# pick up any necessary environment variables +if test -f /bottlenecks/rubbos/app/apache2/bin/envvars; then + . /bottlenecks/rubbos/app/apache2/bin/envvars +fi +# +# a command that outputs a formatted text version of the HTML at the +# url given on the command line. Designed for lynx, however other +# programs may work. +LYNX="lynx -dump" +# +# the URL to your server's mod_status status page. If you do not +# have one, then status and fullstatus will not work. +STATUSURL="http://localhost:80/server-status" +# +# Set this variable to a command that increases the maximum +# number of file descriptors allowed per child process. This is +# critical for configurations that use many file descriptors, +# such as mass vhosting, or a multithreaded server. +ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`" +# -------------------- -------------------- +# |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| + +# Set the maximum number of file descriptors allowed per child process. +if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then + $ULIMIT_MAX_FILES +fi + +ERROR=0 +if [ "x$ARGV" = "x" ] ; then + ARGV="-h" +fi + +case $ARGV in +start|stop|restart|graceful) + $HTTPD -k $ARGV + ERROR=$? + ;; +startssl|sslstart|start-SSL) + $HTTPD -k start -DSSL + ERROR=$? + ;; +configtest) + $HTTPD -t + ERROR=$? + ;; +status) + $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' + ;; +fullstatus) + $LYNX $STATUSURL + ;; +*) + $HTTPD $ARGV + ERROR=$? +esac + +exit $ERROR + diff --git a/rubbos/app/httpd-2.0.64/support/apachectl.in b/rubbos/app/httpd-2.0.64/support/apachectl.in new file mode 100644 index 00000000..58732d07 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/apachectl.in @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# Apache control script designed to allow an easy command line interface +# to controlling Apache. Written by Marc Slemko, 1997/08/23 +# +# The exit codes returned are: +# XXX this doc is no longer correct now that the interesting +# XXX functions are handled by httpd +# 0 - operation completed successfully +# 1 - +# 2 - usage error +# 3 - httpd could not be started +# 4 - httpd could not be stopped +# 5 - httpd could not be started during a restart +# 6 - httpd could not be restarted during a restart +# 7 - httpd could not be restarted during a graceful restart +# 8 - configuration syntax error +# +# When multiple arguments are given, only the error from the _last_ +# one is reported. Run "apachectl help" for usage info +# +ARGV="$@" +# +# |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| +# -------------------- -------------------- +# +# the path to your httpd binary, including options if necessary +HTTPD='@exp_sbindir@/@progname@' +# +# pick up any necessary environment variables +if test -f @exp_sbindir@/envvars; then + . @exp_sbindir@/envvars +fi +# +# a command that outputs a formatted text version of the HTML at the +# url given on the command line. Designed for lynx, however other +# programs may work. +LYNX="lynx -dump" +# +# the URL to your server's mod_status status page. If you do not +# have one, then status and fullstatus will not work. +STATUSURL="http://localhost:@PORT@/server-status" +# +# Set this variable to a command that increases the maximum +# number of file descriptors allowed per child process. This is +# critical for configurations that use many file descriptors, +# such as mass vhosting, or a multithreaded server. +ULIMIT_MAX_FILES="@APACHECTL_ULIMIT@" +# -------------------- -------------------- +# |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| + +# Set the maximum number of file descriptors allowed per child process. +if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then + $ULIMIT_MAX_FILES +fi + +ERROR=0 +if [ "x$ARGV" = "x" ] ; then + ARGV="-h" +fi + +case $ARGV in +start|stop|restart|graceful) + $HTTPD -k $ARGV + ERROR=$? + ;; +startssl|sslstart|start-SSL) + $HTTPD -k start -DSSL + ERROR=$? + ;; +configtest) + $HTTPD -t + ERROR=$? + ;; +status) + $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' + ;; +fullstatus) + $LYNX $STATUSURL + ;; +*) + $HTTPD $ARGV + ERROR=$? +esac + +exit $ERROR + diff --git a/rubbos/app/httpd-2.0.64/support/apxs b/rubbos/app/httpd-2.0.64/support/apxs new file mode 100644 index 00000000..4b3b702d --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/apxs @@ -0,0 +1,778 @@ +#!/usr/bin/perl -w +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 5.003; +use strict; +package apxs; + +## +## Configuration +## + +my %config_vars = (); + +my $installbuilddir = "/bottlenecks/rubbos/app/apache2/build"; +get_config_vars("$installbuilddir/config_vars.mk",\%config_vars); + +# read the configuration variables once + +my $prefix = get_vars("prefix"); +my $CFG_PREFIX = $prefix; +my $exec_prefix = get_vars("exec_prefix"); +my $datadir = get_vars("datadir"); +my $localstatedir = get_vars("localstatedir"); +my $CFG_TARGET = get_vars("progname"); +my $CFG_SYSCONFDIR = get_vars("sysconfdir"); +my $CFG_CFLAGS = join ' ', map { get_vars($_) } + qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS); +my $includedir = get_vars("includedir"); +my $CFG_INCLUDEDIR = eval qq("$includedir"); +my $CFG_CC = get_vars("CC"); +my $libexecdir = get_vars("libexecdir"); +my $CFG_LIBEXECDIR = eval qq("$libexecdir"); +my $sbindir = get_vars("sbindir"); +my $CFG_SBINDIR = eval qq("$sbindir"); +my $ltflags = $ENV{'LTFLAGS'}; +$ltflags or $ltflags = "--silent"; + +my %internal_vars = map {$_ => 1} + qw(TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB + PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR); + +## +## parse argument line +## + +# defaults for parameters +my $opt_n = ''; +my $opt_g = ''; +my $opt_c = 0; +my $opt_o = ''; +my @opt_D = (); +my @opt_I = (); +my @opt_L = (); +my @opt_l = (); +my @opt_W = (); +my @opt_S = (); +my $opt_e = 0; +my $opt_i = 0; +my $opt_a = 0; +my $opt_A = 0; +my $opt_q = 0; +my $opt_h = 0; +my $opt_p = 0; + +# this subroutine is derived from Perl's getopts.pl with the enhancement of +# the "+" metacharacter at the format string to allow a list to be built by +# subsequent occurrences of the same option. +sub Getopts { + my ($argumentative, @ARGV) = @_; + my $errs = 0; + local $_; + local $[ = 0; + + my @args = split / */, $argumentative; + while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { + my ($first, $rest) = ($1,$2); + if ($_ =~ m|^--$|) { + shift @ARGV; + last; + } + my $pos = index($argumentative,$first); + if ($pos >= $[) { + if ($pos < $#args && $args[$pos+1] eq ':') { + shift @ARGV; + if ($rest eq '') { + unless (@ARGV) { + error("Incomplete option: $first (needs an argument)"); + $errs++; + } + $rest = shift(@ARGV); + } + eval "\$opt_$first = \$rest;"; + } + elsif ($pos < $#args && $args[$pos+1] eq '+') { + shift @ARGV; + if ($rest eq '') { + unless (@ARGV) { + error("Incomplete option: $first (needs an argument)"); + $errs++; + } + $rest = shift(@ARGV); + } + eval "push(\@opt_$first, \$rest);"; + } + else { + eval "\$opt_$first = 1"; + if ($rest eq '') { + shift(@ARGV); + } + else { + $ARGV[0] = "-$rest"; + } + } + } + else { + error("Unknown option: $first"); + $errs++; + if ($rest ne '') { + $ARGV[0] = "-$rest"; + } + else { + shift(@ARGV); + } + } + } + return ($errs == 0, @ARGV); +} + +sub usage { + print STDERR "Usage: apxs -g [-S <var>=<val>] -n <modname>\n"; + print STDERR " apxs -q [-S <var>=<val>] <query> ...\n"; + print STDERR " apxs -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n"; + print STDERR " [-I <incdir>] [-L <libdir>] [-l <libname>] [-Wc,<flags>]\n"; + print STDERR " [-Wl,<flags>] [-p] <files> ...\n"; + print STDERR " apxs -i [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n"; + print STDERR " apxs -e [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n"; + exit(1); +} + +# option handling +my $rc; +($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaAp", @ARGV); +&usage if ($rc == 0); +&usage if ($#ARGV == -1 and not $opt_g); +&usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and not $opt_c and not $opt_e); + +# argument handling +my @args = @ARGV; +my $name = 'unknown'; +$name = $opt_n if ($opt_n ne ''); + +if (@opt_S) { + my ($opt_S); + foreach $opt_S (@opt_S) { + if ($opt_S =~ m/^([^=]+)=(.*)$/) { + my ($var) = $1; + my ($val) = $2; + my $oldval = eval "\$CFG_$var"; + + unless ($var and $oldval) { + print STDERR "apxs:Error: no config variable $var\n"; + &usage; + } + + eval "\$CFG_${var}=\"${val}\""; + } else { + print STDERR "apxs:Error: malformatted -S option\n"; + &usage; + } + } +} + +## +## Initial shared object support check +## +my $httpd = get_vars("sbindir") . "/" . get_vars("progname"); +$httpd = eval qq("$httpd"); +$httpd = eval qq("$httpd"); +my $envvars = get_vars("sbindir") . "/envvars"; +$envvars = eval qq("$envvars"); +$envvars = eval qq("$envvars"); + +#allow apxs to be run from the source tree, before installation +if ($0 =~ m:support/apxs$:) { + ($httpd = $0) =~ s:support/apxs$::; +} + +unless (-x "$httpd") { + error("$httpd not found or not executable"); + exit 1; +} + +unless (grep /mod_so/, `. $envvars && $httpd -l`) { + error("Sorry, no shared object support for Apache"); + error("available under your platform. Make sure"); + error("the Apache module mod_so is compiled into"); + error("your server binary `$httpd'."); + exit 1; +} + +sub get_config_vars{ + my ($file, $rh_config) = @_; + + open IN, $file or die "cannot open $file: $!"; + while (<IN>){ + if (/^\s*(.*?)\s*=\s*(.*)$/){ + $rh_config->{$1} = $2; + } + } + close IN; +} + +sub get_vars { + my $result = ''; + my $ok = 0; + my $arg; + foreach $arg (@_) { + if (exists $config_vars{$arg} or exists $config_vars{lc $arg}) { + my $val = exists $config_vars{$arg} + ? $config_vars{$arg} + : $config_vars{lc $arg}; + $val =~ s/[()]//g; + $result .= eval "qq($val)" if defined $val; + $result .= ";;"; + $ok = 1; + } + if (not $ok) { + if (exists $internal_vars{$arg} or exists $internal_vars{lc $arg}) { + my $val = exists $internal_vars{$arg} ? $arg : lc $arg; + $val = eval "\$CFG_$val"; + $result .= eval "qq($val)" if defined $val; + $result .= ";;"; + $ok = 1; + } + if (not $ok) { + error("Invalid query string `$arg'"); + exit(1); + } + } + } + $result =~ s|;;$||; + $result =~ s|:| |; + return $result; +} + +## +## Operation +## + +# helper function for executing a list of +# system command with return code checks +sub execute_cmds { + my (@cmds) = @_; + my ($cmd, $rc); + + foreach $cmd (@cmds) { + notice($cmd); + $rc = system $cmd; + if ($rc) { + error(sprintf "Command failed with rc=%d\n", $rc << 8); + exit 1 ; + } + } +} + +if ($opt_g) { + ## + ## SAMPLE MODULE SOURCE GENERATION + ## + + if (-d $name) { + error("Directory `$name' already exists. Remove first"); + exit(1); + } + + my $data = join('', <DATA>); + $data =~ s|%NAME%|$name|sg; + $data =~ s|%TARGET%|$CFG_TARGET|sg; + $data =~ s|%PREFIX%|$prefix|sg; + $data =~ s|%INSTALLBUILDDIR%|$installbuilddir|sg; + + my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s); + + notice("Creating [DIR] $name"); + system("mkdir $name"); + notice("Creating [FILE] $name/Makefile"); + open(FP, ">${name}/Makefile") || die; + print FP $mkf; + close(FP); + notice("Creating [FILE] $name/modules.mk"); + open(FP, ">${name}/modules.mk") || die; + print FP $mods; + close(FP); + notice("Creating [FILE] $name/mod_$name.c"); + open(FP, ">${name}/mod_${name}.c") || die; + print FP $src; + close(FP); + notice("Creating [FILE] $name/.deps"); + system("touch ${name}/.deps"); + + exit(0); +} + + +if ($opt_q) { + ## + ## QUERY INFORMATION + ## + my $result = get_vars(@args); + print "$result\n"; +} + +my $apr_bindir = get_vars("APR_BINDIR"); + +if (! -x "$apr_bindir/apr-config") { + error("$apr_bindir/apr-config not found!"); + exit(1); +} + +my $apu_bindir = get_vars("APU_BINDIR"); + +if (! -x "$apu_bindir/apu-config") { + error("$apu_bindir/apu-config not found!"); + exit(1); +} + +my $libtool = `$apr_bindir/apr-config --installbuilddir`; +chomp($libtool); +$libtool = "$libtool/libtool"; + +my $apr_includedir = `$apr_bindir/apr-config --includes`; +chomp($apr_includedir); +my $apu_includedir = `$apu_bindir/apu-config --includes`; +chomp($apu_includedir); + +if ($opt_c) { + ## + ## SHARED OBJECT COMPILATION + ## + + # split files into sources and objects + my @srcs = (); + my @objs = (); + my $f; + foreach $f (@args) { + if ($f =~ m|\.c$|) { + push(@srcs, $f); + } + else { + push(@objs, $f); + } + } + + # determine output file + my $dso_file; + if ($opt_o eq '') { + if ($#srcs > -1) { + $dso_file = $srcs[0]; + $dso_file =~ s|\.[^.]+$|.la|; + } + elsif ($#objs > -1) { + $dso_file = $objs[0]; + $dso_file =~ s|\.[^.]+$|.la|; + } + else { + $dso_file = "mod_unknown.la"; + } + } + else { + $dso_file = $opt_o; + $dso_file =~ s|\.[^.]+$|.la|; + } + + # create compilation commands + my @cmds = (); + my $opt = ''; + my ($opt_Wc, $opt_I, $opt_D); + foreach $opt_Wc (@opt_W) { + $opt .= "$1 " if ($opt_Wc =~ m|^\s*c,(.*)$|); + } + foreach $opt_I (@opt_I) { + $opt .= "-I$opt_I "; + } + foreach $opt_D (@opt_D) { + $opt .= "-D$opt_D "; + } + my $cflags = "$CFG_CFLAGS"; + my $s; + my $mod; + foreach $s (@srcs) { + my $slo = $s; + $slo =~ s|\.c$|.slo|; + my $lo = $s; + $lo =~ s|\.c$|.lo|; + my $la = $s; + $la =~ s|\.c$|.la|; + my $o = $s; + $o =~ s|\.c$|.o|; + push(@cmds, "$libtool $ltflags --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $apr_includedir $apu_includedir $opt -c -o $lo $s && touch $slo"); + unshift(@objs, $lo); + } + + # create link command + my $o; + my $lo; + foreach $o (@objs) { + $lo .= " $o"; + } + my ($opt_Wl, $opt_L, $opt_l); + $opt = ''; + foreach $opt_Wl (@opt_W) { + $opt .= "$1 " if ($opt_Wl =~ m|^\s*l,(.*)$|); + } + foreach $opt_L (@opt_L) { + $opt .= " -L$opt_L"; + } + foreach $opt_l (@opt_l) { + $opt .= " -l$opt_l"; + } + + if ($opt_p == 1) { + + my $apr_libs=`$apr_bindir/apr-config --ldflags --link-libtool --libs`; + chomp($apr_libs); + my $apu_libs=`$apu_bindir/apu-config --ldflags --link-libtool --libs`; + chomp($apu_libs); + + $opt .= " ".$apu_libs." ".$apr_libs; + } + else { + my $apr_ldflags=`$apr_bindir/apr-config --ldflags`; + chomp($apr_ldflags); + $opt .= " -rpath $CFG_LIBEXECDIR -module -avoid-version $apr_ldflags"; + } + + push(@cmds, "$libtool $ltflags --mode=link $CFG_CC -o $dso_file $opt $lo"); + + # execute the commands + &execute_cmds(@cmds); + + # allow one-step compilation and installation + if ($opt_i or $opt_e) { + @args = ( $dso_file ); + } +} + +if ($opt_i or $opt_e) { + ## + ## SHARED OBJECT INSTALLATION + ## + + # determine installation commands + # and corresponding LoadModule/AddModule directives + my @lmd = (); + my @amd = (); + my @cmds = (); + my $f; + foreach $f (@args) { + if ($f !~ m#(\.so$|\.la$)#) { + error("file $f is not a shared object"); + exit(1); + } + my $t = $f; + $t =~ s|^.+/([^/]+)$|$1|; + $t =~ s|\.la$|\.so|; + if ($opt_i) { + push(@cmds, "$installbuilddir/instdso.sh SH_LIBTOOL='" . + "$libtool' $f $CFG_LIBEXECDIR"); + push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t"); + } + + # determine module symbolname and filename + my $filename = ''; + if ($name eq 'unknown') { + $name = ''; + my $base = $f; + $base =~ s|\.[^.]+$||; + if (-f "$base.c") { + open(FP, "<$base.c"); + my $content = join('', <FP>); + close(FP); + if ($content =~ m|.*module\s+(?:AP_MODULE_DECLARE_DATA\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) { + $name = "$1"; + $filename = "$base.c"; + $filename =~ s|^[^/]+/||; + } + } + if ($name eq '') { + if ($base =~ m|.*mod_([a-zA-Z0-9_]+)\..+|) { + $name = "$1"; + $filename = $base; + $filename =~ s|^[^/]+/||; + } + } + if ($name eq '') { + error("Sorry, cannot determine bootstrap symbol name"); + error("Please specify one with option `-n'"); + exit(1); + } + } + if ($filename eq '') { + $filename = "mod_${name}.c"; + } + my $dir = $CFG_LIBEXECDIR; + $dir =~ s|^$CFG_PREFIX/?||; + $dir =~ s|(.)$|$1/|; + $t =~ s|\.la$|.so|; + push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t")); + push(@amd, sprintf("AddModule %s", $filename)); + } + + # execute the commands + &execute_cmds(@cmds); + + # activate module via LoadModule/AddModule directive + if ($opt_a or $opt_A) { + if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") { + error("Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found"); + exit(1); + } + + open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die; + my $content = join('', <FP>); + close(FP); + + if ($content !~ m|\n#?\s*LoadModule\s+|) { + error("Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file."); + error("At least one `LoadModule' directive already has to exist."); + exit(1); + } + + my $lmd; + my $c = ''; + $c = '#' if ($opt_A); + foreach $lmd (@lmd) { + my $what = $opt_A ? "preparing" : "activating"; + my $lmd_re = $lmd; + $lmd_re =~ s/\s+/\\s+/g; + + if ($content !~ m|\n#?\s*$lmd_re|) { + # check for open <containers>, so that the new LoadModule + # directive always appears *outside* of an <container>. + + my $before = ($content =~ m|^(.*\n)#?\s*LoadModule\s+[^\n]+\n|s)[0]; + + # the '()=' trick forces list context and the scalar + # assignment counts the number of list members (aka number + # of matches) then + my $cntopen = () = ($before =~ m|^\s*<[^/].*$|mg); + my $cntclose = () = ($before =~ m|^\s*</.*$|mg); + + if ($cntopen == $cntclose) { + # fine. Last LoadModule is contextless. + $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|s; + } + elsif ($cntopen < $cntclose) { + error('Configuration file is not valid. There are sections' + . ' closed before opened.'); + exit(1); + } + else { + # put our cmd after the section containing the last + # LoadModule. + my $found = + $content =~ s!\A ( # string and capture start + (?:(?: + ^\s* # start of conf line with a + (?:[^<]|<[^/]) # directive which does not + # start with '</' + + .*(?:$)\n # rest of the line. + # the '$' is in parentheses + # to avoid misinterpreting + # the string "$\" as + # perl variable. + + )* # catch as much as possible + # of such lines. (including + # zero) + + ^\s*</.*(?:$)\n? # after the above, we + # expect a config line with + # a closing container (</) + + ) {$cntopen} # the whole pattern (bunch + # of lines that end up with + # a closing directive) must + # be repeated $cntopen + # times. That's it. + # Simple, eh? ;-) + + ) # capture end + !$1$c$lmd\n!mx; + + unless ($found) { + error('Configuration file is not valid. There are ' + . 'sections opened and not closed.'); + exit(1); + } + } + } else { + # replace already existing LoadModule line + $content =~ s|^(.*\n)#?\s*$lmd_re[^\n]*\n|$1$c$lmd\n|s; + } + $lmd =~ m|LoadModule\s+(.+?)_module.*|; + notice("[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]"); + } + my $amd; + foreach $amd (@amd) { + if ($content !~ m|\n#?\s*$amd|) { + $content =~ s|^(.*\n#?\s*AddModule\s+[^\n]+\n)|$1$c$amd\n|sg; + } else { + $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|sg; + } + } + if (@lmd or @amd) { + if (open(FP, ">$CFG_SYSCONFDIR/$CFG_TARGET.conf.new")) { + print FP $content; + close(FP); + system("cp $CFG_SYSCONFDIR/$CFG_TARGET.conf $CFG_SYSCONFDIR/$CFG_TARGET.conf.bak && " . + "cp $CFG_SYSCONFDIR/$CFG_TARGET.conf.new $CFG_SYSCONFDIR/$CFG_TARGET.conf && " . + "rm $CFG_SYSCONFDIR/$CFG_TARGET.conf.new"); + } else { + notice("unable to open configuration file"); + } + } + } +} + +sub error{ + print STDERR "apxs:Error: $_[0].\n"; +} + +sub notice{ + print STDERR "$_[0]\n"; +} + +##EOF## +__DATA__ +## +## Makefile -- Build procedure for sample %NAME% Apache module +## Autogenerated via ``apxs -n %NAME% -g''. +## + +builddir=. +top_srcdir=%PREFIX% +top_builddir=%PREFIX% +include %INSTALLBUILDDIR%/special.mk + +# the used tools +APXS=apxs +APACHECTL=apachectl + +# additional defines, includes and libraries +#DEFS=-Dmy_define=my_value +#INCLUDES=-Imy/include/dir +#LIBS=-Lmy/lib/dir -lmylib + +# the default target +all: local-shared-build + +# install the shared object file into Apache +install: install-modules + +# cleanup +clean: + -rm -f mod_%NAME%.o mod_%NAME%.lo mod_%NAME%.slo mod_%NAME%.la + +# simple test +test: reload + lynx -mime_header http://localhost/%NAME% + +# install and activate shared object by reloading Apache to +# force a reload of the shared object file +reload: install restart + +# the general Apache start/restart/stop +# procedures +start: + $(APACHECTL) start +restart: + $(APACHECTL) restart +stop: + $(APACHECTL) stop + +-=#=- +mod_%NAME%.la: mod_%NAME%.slo + $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_%NAME%.lo +DISTCLEAN_TARGETS = modules.mk +shared = mod_%NAME%.la +-=#=- +/* +** mod_%NAME%.c -- Apache sample %NAME% module +** [Autogenerated via ``apxs -n %NAME% -g''] +** +** To play with this sample module first compile it into a +** DSO file and install it into Apache's modules directory +** by running: +** +** $ apxs -c -i mod_%NAME%.c +** +** Then activate it in Apache's %TARGET%.conf file for instance +** for the URL /%NAME% in as follows: +** +** # %TARGET%.conf +** LoadModule %NAME%_module modules/mod_%NAME%.so +** <Location /%NAME%> +** SetHandler %NAME% +** </Location> +** +** Then after restarting Apache via +** +** $ apachectl restart +** +** you immediately can request the URL /%NAME% and watch for the +** output of this module. This can be achieved for instance via: +** +** $ lynx -mime_header http://localhost/%NAME% +** +** The output should be similar to the following one: +** +** HTTP/1.1 200 OK +** Date: Tue, 31 Mar 1998 14:42:22 GMT +** Server: Apache/1.3.4 (Unix) +** Connection: close +** Content-Type: text/html +** +** The sample page from mod_%NAME%.c +*/ + +#include "httpd.h" +#include "http_config.h" +#include "http_protocol.h" +#include "ap_config.h" + +/* The sample content handler */ +static int %NAME%_handler(request_rec *r) +{ + if (strcmp(r->handler, "%NAME%")) { + return DECLINED; + } + r->content_type = "text/html"; + + if (!r->header_only) + ap_rputs("The sample page from mod_%NAME%.c\n", r); + return OK; +} + +static void %NAME%_register_hooks(apr_pool_t *p) +{ + ap_hook_handler(%NAME%_handler, NULL, NULL, APR_HOOK_MIDDLE); +} + +/* Dispatch list for API hooks */ +module AP_MODULE_DECLARE_DATA %NAME%_module = { + STANDARD20_MODULE_STUFF, + NULL, /* create per-dir config structures */ + NULL, /* merge per-dir config structures */ + NULL, /* create per-server config structures */ + NULL, /* merge per-server config structures */ + NULL, /* table of config file commands */ + %NAME%_register_hooks /* register hooks */ +}; + diff --git a/rubbos/app/httpd-2.0.64/support/apxs.in b/rubbos/app/httpd-2.0.64/support/apxs.in new file mode 100644 index 00000000..135544cc --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/apxs.in @@ -0,0 +1,778 @@ +#!@perlbin@ -w +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 5.003; +use strict; +package apxs; + +## +## Configuration +## + +my %config_vars = (); + +my $installbuilddir = "@exp_installbuilddir@"; +get_config_vars("$installbuilddir/config_vars.mk",\%config_vars); + +# read the configuration variables once + +my $prefix = get_vars("prefix"); +my $CFG_PREFIX = $prefix; +my $exec_prefix = get_vars("exec_prefix"); +my $datadir = get_vars("datadir"); +my $localstatedir = get_vars("localstatedir"); +my $CFG_TARGET = get_vars("progname"); +my $CFG_SYSCONFDIR = get_vars("sysconfdir"); +my $CFG_CFLAGS = join ' ', map { get_vars($_) } + qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS); +my $includedir = get_vars("includedir"); +my $CFG_INCLUDEDIR = eval qq("$includedir"); +my $CFG_CC = get_vars("CC"); +my $libexecdir = get_vars("libexecdir"); +my $CFG_LIBEXECDIR = eval qq("$libexecdir"); +my $sbindir = get_vars("sbindir"); +my $CFG_SBINDIR = eval qq("$sbindir"); +my $ltflags = $ENV{'LTFLAGS'}; +$ltflags or $ltflags = "--silent"; + +my %internal_vars = map {$_ => 1} + qw(TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB + PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR); + +## +## parse argument line +## + +# defaults for parameters +my $opt_n = ''; +my $opt_g = ''; +my $opt_c = 0; +my $opt_o = ''; +my @opt_D = (); +my @opt_I = (); +my @opt_L = (); +my @opt_l = (); +my @opt_W = (); +my @opt_S = (); +my $opt_e = 0; +my $opt_i = 0; +my $opt_a = 0; +my $opt_A = 0; +my $opt_q = 0; +my $opt_h = 0; +my $opt_p = 0; + +# this subroutine is derived from Perl's getopts.pl with the enhancement of +# the "+" metacharacter at the format string to allow a list to be built by +# subsequent occurrences of the same option. +sub Getopts { + my ($argumentative, @ARGV) = @_; + my $errs = 0; + local $_; + local $[ = 0; + + my @args = split / */, $argumentative; + while (@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { + my ($first, $rest) = ($1,$2); + if ($_ =~ m|^--$|) { + shift @ARGV; + last; + } + my $pos = index($argumentative,$first); + if ($pos >= $[) { + if ($pos < $#args && $args[$pos+1] eq ':') { + shift @ARGV; + if ($rest eq '') { + unless (@ARGV) { + error("Incomplete option: $first (needs an argument)"); + $errs++; + } + $rest = shift(@ARGV); + } + eval "\$opt_$first = \$rest;"; + } + elsif ($pos < $#args && $args[$pos+1] eq '+') { + shift @ARGV; + if ($rest eq '') { + unless (@ARGV) { + error("Incomplete option: $first (needs an argument)"); + $errs++; + } + $rest = shift(@ARGV); + } + eval "push(\@opt_$first, \$rest);"; + } + else { + eval "\$opt_$first = 1"; + if ($rest eq '') { + shift(@ARGV); + } + else { + $ARGV[0] = "-$rest"; + } + } + } + else { + error("Unknown option: $first"); + $errs++; + if ($rest ne '') { + $ARGV[0] = "-$rest"; + } + else { + shift(@ARGV); + } + } + } + return ($errs == 0, @ARGV); +} + +sub usage { + print STDERR "Usage: apxs -g [-S <var>=<val>] -n <modname>\n"; + print STDERR " apxs -q [-S <var>=<val>] <query> ...\n"; + print STDERR " apxs -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n"; + print STDERR " [-I <incdir>] [-L <libdir>] [-l <libname>] [-Wc,<flags>]\n"; + print STDERR " [-Wl,<flags>] [-p] <files> ...\n"; + print STDERR " apxs -i [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n"; + print STDERR " apxs -e [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n"; + exit(1); +} + +# option handling +my $rc; +($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaAp", @ARGV); +&usage if ($rc == 0); +&usage if ($#ARGV == -1 and not $opt_g); +&usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and not $opt_c and not $opt_e); + +# argument handling +my @args = @ARGV; +my $name = 'unknown'; +$name = $opt_n if ($opt_n ne ''); + +if (@opt_S) { + my ($opt_S); + foreach $opt_S (@opt_S) { + if ($opt_S =~ m/^([^=]+)=(.*)$/) { + my ($var) = $1; + my ($val) = $2; + my $oldval = eval "\$CFG_$var"; + + unless ($var and $oldval) { + print STDERR "apxs:Error: no config variable $var\n"; + &usage; + } + + eval "\$CFG_${var}=\"${val}\""; + } else { + print STDERR "apxs:Error: malformatted -S option\n"; + &usage; + } + } +} + +## +## Initial shared object support check +## +my $httpd = get_vars("sbindir") . "/" . get_vars("progname"); +$httpd = eval qq("$httpd"); +$httpd = eval qq("$httpd"); +my $envvars = get_vars("sbindir") . "/envvars"; +$envvars = eval qq("$envvars"); +$envvars = eval qq("$envvars"); + +#allow apxs to be run from the source tree, before installation +if ($0 =~ m:support/apxs$:) { + ($httpd = $0) =~ s:support/apxs$::; +} + +unless (-x "$httpd") { + error("$httpd not found or not executable"); + exit 1; +} + +unless (grep /mod_so/, `. $envvars && $httpd -l`) { + error("Sorry, no shared object support for Apache"); + error("available under your platform. Make sure"); + error("the Apache module mod_so is compiled into"); + error("your server binary `$httpd'."); + exit 1; +} + +sub get_config_vars{ + my ($file, $rh_config) = @_; + + open IN, $file or die "cannot open $file: $!"; + while (<IN>){ + if (/^\s*(.*?)\s*=\s*(.*)$/){ + $rh_config->{$1} = $2; + } + } + close IN; +} + +sub get_vars { + my $result = ''; + my $ok = 0; + my $arg; + foreach $arg (@_) { + if (exists $config_vars{$arg} or exists $config_vars{lc $arg}) { + my $val = exists $config_vars{$arg} + ? $config_vars{$arg} + : $config_vars{lc $arg}; + $val =~ s/[()]//g; + $result .= eval "qq($val)" if defined $val; + $result .= ";;"; + $ok = 1; + } + if (not $ok) { + if (exists $internal_vars{$arg} or exists $internal_vars{lc $arg}) { + my $val = exists $internal_vars{$arg} ? $arg : lc $arg; + $val = eval "\$CFG_$val"; + $result .= eval "qq($val)" if defined $val; + $result .= ";;"; + $ok = 1; + } + if (not $ok) { + error("Invalid query string `$arg'"); + exit(1); + } + } + } + $result =~ s|;;$||; + $result =~ s|:| |; + return $result; +} + +## +## Operation +## + +# helper function for executing a list of +# system command with return code checks +sub execute_cmds { + my (@cmds) = @_; + my ($cmd, $rc); + + foreach $cmd (@cmds) { + notice($cmd); + $rc = system $cmd; + if ($rc) { + error(sprintf "Command failed with rc=%d\n", $rc << 8); + exit 1 ; + } + } +} + +if ($opt_g) { + ## + ## SAMPLE MODULE SOURCE GENERATION + ## + + if (-d $name) { + error("Directory `$name' already exists. Remove first"); + exit(1); + } + + my $data = join('', <DATA>); + $data =~ s|%NAME%|$name|sg; + $data =~ s|%TARGET%|$CFG_TARGET|sg; + $data =~ s|%PREFIX%|$prefix|sg; + $data =~ s|%INSTALLBUILDDIR%|$installbuilddir|sg; + + my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s); + + notice("Creating [DIR] $name"); + system("mkdir $name"); + notice("Creating [FILE] $name/Makefile"); + open(FP, ">${name}/Makefile") || die; + print FP $mkf; + close(FP); + notice("Creating [FILE] $name/modules.mk"); + open(FP, ">${name}/modules.mk") || die; + print FP $mods; + close(FP); + notice("Creating [FILE] $name/mod_$name.c"); + open(FP, ">${name}/mod_${name}.c") || die; + print FP $src; + close(FP); + notice("Creating [FILE] $name/.deps"); + system("touch ${name}/.deps"); + + exit(0); +} + + +if ($opt_q) { + ## + ## QUERY INFORMATION + ## + my $result = get_vars(@args); + print "$result\n"; +} + +my $apr_bindir = get_vars("APR_BINDIR"); + +if (! -x "$apr_bindir/apr-config") { + error("$apr_bindir/apr-config not found!"); + exit(1); +} + +my $apu_bindir = get_vars("APU_BINDIR"); + +if (! -x "$apu_bindir/apu-config") { + error("$apu_bindir/apu-config not found!"); + exit(1); +} + +my $libtool = `$apr_bindir/apr-config --installbuilddir`; +chomp($libtool); +$libtool = "$libtool/libtool"; + +my $apr_includedir = `$apr_bindir/apr-config --includes`; +chomp($apr_includedir); +my $apu_includedir = `$apu_bindir/apu-config --includes`; +chomp($apu_includedir); + +if ($opt_c) { + ## + ## SHARED OBJECT COMPILATION + ## + + # split files into sources and objects + my @srcs = (); + my @objs = (); + my $f; + foreach $f (@args) { + if ($f =~ m|\.c$|) { + push(@srcs, $f); + } + else { + push(@objs, $f); + } + } + + # determine output file + my $dso_file; + if ($opt_o eq '') { + if ($#srcs > -1) { + $dso_file = $srcs[0]; + $dso_file =~ s|\.[^.]+$|.la|; + } + elsif ($#objs > -1) { + $dso_file = $objs[0]; + $dso_file =~ s|\.[^.]+$|.la|; + } + else { + $dso_file = "mod_unknown.la"; + } + } + else { + $dso_file = $opt_o; + $dso_file =~ s|\.[^.]+$|.la|; + } + + # create compilation commands + my @cmds = (); + my $opt = ''; + my ($opt_Wc, $opt_I, $opt_D); + foreach $opt_Wc (@opt_W) { + $opt .= "$1 " if ($opt_Wc =~ m|^\s*c,(.*)$|); + } + foreach $opt_I (@opt_I) { + $opt .= "-I$opt_I "; + } + foreach $opt_D (@opt_D) { + $opt .= "-D$opt_D "; + } + my $cflags = "$CFG_CFLAGS"; + my $s; + my $mod; + foreach $s (@srcs) { + my $slo = $s; + $slo =~ s|\.c$|.slo|; + my $lo = $s; + $lo =~ s|\.c$|.lo|; + my $la = $s; + $la =~ s|\.c$|.la|; + my $o = $s; + $o =~ s|\.c$|.o|; + push(@cmds, "$libtool $ltflags --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $apr_includedir $apu_includedir $opt -c -o $lo $s && touch $slo"); + unshift(@objs, $lo); + } + + # create link command + my $o; + my $lo; + foreach $o (@objs) { + $lo .= " $o"; + } + my ($opt_Wl, $opt_L, $opt_l); + $opt = ''; + foreach $opt_Wl (@opt_W) { + $opt .= "$1 " if ($opt_Wl =~ m|^\s*l,(.*)$|); + } + foreach $opt_L (@opt_L) { + $opt .= " -L$opt_L"; + } + foreach $opt_l (@opt_l) { + $opt .= " -l$opt_l"; + } + + if ($opt_p == 1) { + + my $apr_libs=`$apr_bindir/apr-config --ldflags --link-libtool --libs`; + chomp($apr_libs); + my $apu_libs=`$apu_bindir/apu-config --ldflags --link-libtool --libs`; + chomp($apu_libs); + + $opt .= " ".$apu_libs." ".$apr_libs; + } + else { + my $apr_ldflags=`$apr_bindir/apr-config --ldflags`; + chomp($apr_ldflags); + $opt .= " -rpath $CFG_LIBEXECDIR -module -avoid-version $apr_ldflags"; + } + + push(@cmds, "$libtool $ltflags --mode=link $CFG_CC -o $dso_file $opt $lo"); + + # execute the commands + &execute_cmds(@cmds); + + # allow one-step compilation and installation + if ($opt_i or $opt_e) { + @args = ( $dso_file ); + } +} + +if ($opt_i or $opt_e) { + ## + ## SHARED OBJECT INSTALLATION + ## + + # determine installation commands + # and corresponding LoadModule/AddModule directives + my @lmd = (); + my @amd = (); + my @cmds = (); + my $f; + foreach $f (@args) { + if ($f !~ m#(\.so$|\.la$)#) { + error("file $f is not a shared object"); + exit(1); + } + my $t = $f; + $t =~ s|^.+/([^/]+)$|$1|; + $t =~ s|\.la$|\.so|; + if ($opt_i) { + push(@cmds, "$installbuilddir/instdso.sh SH_LIBTOOL='" . + "$libtool' $f $CFG_LIBEXECDIR"); + push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t"); + } + + # determine module symbolname and filename + my $filename = ''; + if ($name eq 'unknown') { + $name = ''; + my $base = $f; + $base =~ s|\.[^.]+$||; + if (-f "$base.c") { + open(FP, "<$base.c"); + my $content = join('', <FP>); + close(FP); + if ($content =~ m|.*module\s+(?:AP_MODULE_DECLARE_DATA\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) { + $name = "$1"; + $filename = "$base.c"; + $filename =~ s|^[^/]+/||; + } + } + if ($name eq '') { + if ($base =~ m|.*mod_([a-zA-Z0-9_]+)\..+|) { + $name = "$1"; + $filename = $base; + $filename =~ s|^[^/]+/||; + } + } + if ($name eq '') { + error("Sorry, cannot determine bootstrap symbol name"); + error("Please specify one with option `-n'"); + exit(1); + } + } + if ($filename eq '') { + $filename = "mod_${name}.c"; + } + my $dir = $CFG_LIBEXECDIR; + $dir =~ s|^$CFG_PREFIX/?||; + $dir =~ s|(.)$|$1/|; + $t =~ s|\.la$|.so|; + push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t")); + push(@amd, sprintf("AddModule %s", $filename)); + } + + # execute the commands + &execute_cmds(@cmds); + + # activate module via LoadModule/AddModule directive + if ($opt_a or $opt_A) { + if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") { + error("Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found"); + exit(1); + } + + open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die; + my $content = join('', <FP>); + close(FP); + + if ($content !~ m|\n#?\s*LoadModule\s+|) { + error("Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file."); + error("At least one `LoadModule' directive already has to exist."); + exit(1); + } + + my $lmd; + my $c = ''; + $c = '#' if ($opt_A); + foreach $lmd (@lmd) { + my $what = $opt_A ? "preparing" : "activating"; + my $lmd_re = $lmd; + $lmd_re =~ s/\s+/\\s+/g; + + if ($content !~ m|\n#?\s*$lmd_re|) { + # check for open <containers>, so that the new LoadModule + # directive always appears *outside* of an <container>. + + my $before = ($content =~ m|^(.*\n)#?\s*LoadModule\s+[^\n]+\n|s)[0]; + + # the '()=' trick forces list context and the scalar + # assignment counts the number of list members (aka number + # of matches) then + my $cntopen = () = ($before =~ m|^\s*<[^/].*$|mg); + my $cntclose = () = ($before =~ m|^\s*</.*$|mg); + + if ($cntopen == $cntclose) { + # fine. Last LoadModule is contextless. + $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|s; + } + elsif ($cntopen < $cntclose) { + error('Configuration file is not valid. There are sections' + . ' closed before opened.'); + exit(1); + } + else { + # put our cmd after the section containing the last + # LoadModule. + my $found = + $content =~ s!\A ( # string and capture start + (?:(?: + ^\s* # start of conf line with a + (?:[^<]|<[^/]) # directive which does not + # start with '</' + + .*(?:$)\n # rest of the line. + # the '$' is in parentheses + # to avoid misinterpreting + # the string "$\" as + # perl variable. + + )* # catch as much as possible + # of such lines. (including + # zero) + + ^\s*</.*(?:$)\n? # after the above, we + # expect a config line with + # a closing container (</) + + ) {$cntopen} # the whole pattern (bunch + # of lines that end up with + # a closing directive) must + # be repeated $cntopen + # times. That's it. + # Simple, eh? ;-) + + ) # capture end + !$1$c$lmd\n!mx; + + unless ($found) { + error('Configuration file is not valid. There are ' + . 'sections opened and not closed.'); + exit(1); + } + } + } else { + # replace already existing LoadModule line + $content =~ s|^(.*\n)#?\s*$lmd_re[^\n]*\n|$1$c$lmd\n|s; + } + $lmd =~ m|LoadModule\s+(.+?)_module.*|; + notice("[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]"); + } + my $amd; + foreach $amd (@amd) { + if ($content !~ m|\n#?\s*$amd|) { + $content =~ s|^(.*\n#?\s*AddModule\s+[^\n]+\n)|$1$c$amd\n|sg; + } else { + $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|sg; + } + } + if (@lmd or @amd) { + if (open(FP, ">$CFG_SYSCONFDIR/$CFG_TARGET.conf.new")) { + print FP $content; + close(FP); + system("cp $CFG_SYSCONFDIR/$CFG_TARGET.conf $CFG_SYSCONFDIR/$CFG_TARGET.conf.bak && " . + "cp $CFG_SYSCONFDIR/$CFG_TARGET.conf.new $CFG_SYSCONFDIR/$CFG_TARGET.conf && " . + "rm $CFG_SYSCONFDIR/$CFG_TARGET.conf.new"); + } else { + notice("unable to open configuration file"); + } + } + } +} + +sub error{ + print STDERR "apxs:Error: $_[0].\n"; +} + +sub notice{ + print STDERR "$_[0]\n"; +} + +##EOF## +__DATA__ +## +## Makefile -- Build procedure for sample %NAME% Apache module +## Autogenerated via ``apxs -n %NAME% -g''. +## + +builddir=. +top_srcdir=%PREFIX% +top_builddir=%PREFIX% +include %INSTALLBUILDDIR%/special.mk + +# the used tools +APXS=apxs +APACHECTL=apachectl + +# additional defines, includes and libraries +#DEFS=-Dmy_define=my_value +#INCLUDES=-Imy/include/dir +#LIBS=-Lmy/lib/dir -lmylib + +# the default target +all: local-shared-build + +# install the shared object file into Apache +install: install-modules + +# cleanup +clean: + -rm -f mod_%NAME%.o mod_%NAME%.lo mod_%NAME%.slo mod_%NAME%.la + +# simple test +test: reload + lynx -mime_header http://localhost/%NAME% + +# install and activate shared object by reloading Apache to +# force a reload of the shared object file +reload: install restart + +# the general Apache start/restart/stop +# procedures +start: + $(APACHECTL) start +restart: + $(APACHECTL) restart +stop: + $(APACHECTL) stop + +-=#=- +mod_%NAME%.la: mod_%NAME%.slo + $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_%NAME%.lo +DISTCLEAN_TARGETS = modules.mk +shared = mod_%NAME%.la +-=#=- +/* +** mod_%NAME%.c -- Apache sample %NAME% module +** [Autogenerated via ``apxs -n %NAME% -g''] +** +** To play with this sample module first compile it into a +** DSO file and install it into Apache's modules directory +** by running: +** +** $ apxs -c -i mod_%NAME%.c +** +** Then activate it in Apache's %TARGET%.conf file for instance +** for the URL /%NAME% in as follows: +** +** # %TARGET%.conf +** LoadModule %NAME%_module modules/mod_%NAME%.so +** <Location /%NAME%> +** SetHandler %NAME% +** </Location> +** +** Then after restarting Apache via +** +** $ apachectl restart +** +** you immediately can request the URL /%NAME% and watch for the +** output of this module. This can be achieved for instance via: +** +** $ lynx -mime_header http://localhost/%NAME% +** +** The output should be similar to the following one: +** +** HTTP/1.1 200 OK +** Date: Tue, 31 Mar 1998 14:42:22 GMT +** Server: Apache/1.3.4 (Unix) +** Connection: close +** Content-Type: text/html +** +** The sample page from mod_%NAME%.c +*/ + +#include "httpd.h" +#include "http_config.h" +#include "http_protocol.h" +#include "ap_config.h" + +/* The sample content handler */ +static int %NAME%_handler(request_rec *r) +{ + if (strcmp(r->handler, "%NAME%")) { + return DECLINED; + } + r->content_type = "text/html"; + + if (!r->header_only) + ap_rputs("The sample page from mod_%NAME%.c\n", r); + return OK; +} + +static void %NAME%_register_hooks(apr_pool_t *p) +{ + ap_hook_handler(%NAME%_handler, NULL, NULL, APR_HOOK_MIDDLE); +} + +/* Dispatch list for API hooks */ +module AP_MODULE_DECLARE_DATA %NAME%_module = { + STANDARD20_MODULE_STUFF, + NULL, /* create per-dir config structures */ + NULL, /* merge per-dir config structures */ + NULL, /* create per-server config structures */ + NULL, /* merge per-server config structures */ + NULL, /* table of config file commands */ + %NAME%_register_hooks /* register hooks */ +}; + diff --git a/rubbos/app/httpd-2.0.64/support/check_forensic b/rubbos/app/httpd-2.0.64/support/check_forensic new file mode 100755 index 00000000..3c8123fc --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/check_forensic @@ -0,0 +1,51 @@ +#!/bin/sh + +# check_forensic <forensic log file> + +# check the forensic log for requests that did not complete +# output the request log for each one + +F=$1 + +temp_create_method=file +if test -f `which mktemp`; then + temp_create_method=mktemp +elif test -f `which tempfile`; then + temp_create_method=tempfile +fi + +create_temp() +{ + prefix=$1 + case "$temp_create_method" in + file) + name="/tmp/$1.$$" + ;; + mktemp) + name=`mktemp -t $1.XXXXXX` + ;; + tempfile) + name=`tempfile --prefix=$1` + ;; + *) + echo "$0: Cannot create temporary file" + exit 1 + ;; + esac +} + +create_temp fcall +all=$name +create_temp fcin +in=$name +create_temp fcout +out=$name +trap "rm -f -- \"$all\" \"$in\" \"$out\";" 0 1 2 3 13 15 + +cut -f 1 -d '|' $F > $all +grep + < $all | cut -c2- | sort > $in +grep -- - < $all | cut -c2- | sort > $out + +# use -i instead of -I for GNU xargs +join -v 1 $in $out | xargs -I xx egrep "^\\+xx" $F +exit 0 diff --git a/rubbos/app/httpd-2.0.64/support/checkgid b/rubbos/app/httpd-2.0.64/support/checkgid new file mode 100755 index 00000000..ff663d36 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/checkgid @@ -0,0 +1,131 @@ +#! /bin/bash + +# checkgid - temporary wrapper script for .libs/checkgid +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The checkgid program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/checkgid.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'checkgid' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/checkgid.c b/rubbos/app/httpd-2.0.64/support/checkgid.c new file mode 100644 index 00000000..2a918b29 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/checkgid.c @@ -0,0 +1,110 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Given one or more group identifers on the command line (e.g., + * "httpd" or "#-1"), figure out whether they'll be valid for + * the server to use at run-time. + * + * If a groupname isn't found, or we can't setgid() to it, return + * -1. If all groups are valid, return 0. + * + * This may need to be run as the superuser for the setgid() to + * succeed; running it as any other user may result in a false + * negative. + */ + +#include "ap_config.h" +#if APR_HAVE_STDIO_H +#include <stdio.h> +#endif +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if APR_HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#if HAVE_GRP_H +#include <grp.h> +#endif +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif + +int main(int argc, char *argv[]) +{ + int i; + int result; + gid_t gid; + struct group *grent; + struct group fake_grent; + + /* + * Assume success. :-) + */ + result = 0; + for (i = 1; i < argc; ++i) { + char *arg; + arg = argv[i]; + + /* + * If it's from a 'Group #-1' statement, get the numeric value + * and skip the group lookup stuff. + */ + if (*arg == '#') { + gid = atoi(&arg[1]); + fake_grent.gr_gid = gid; + grent = &fake_grent; + } + else { + grent = getgrnam(arg); + } + + /* + * A NULL return means no such group was found, so we're done + * with this one. + */ + if (grent == NULL) { + fprintf(stderr, "%s: group '%s' not found\n", argv[0], arg); + result = -1; + } + else { + int check; + + /* + * See if we can switch to the numeric GID we have. If so, + * all well and good; if not, well.. + */ + gid = grent->gr_gid; + check = setgid(gid); + if (check != 0) { + fprintf(stderr, "%s: invalid group '%s'\n", argv[0], arg); + perror(argv[0]); + result = -1; + } + } + } + /* + * Worst-case return value. + */ + return result; +} +/* + * Local Variables: + * mode: C + * c-file-style: "bsd" + * End: + */ diff --git a/rubbos/app/httpd-2.0.64/support/checkgid.lo b/rubbos/app/httpd-2.0.64/support/checkgid.lo new file mode 100644 index 00000000..547929ac --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/checkgid.lo @@ -0,0 +1,12 @@ +# checkgid.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/checkgid.o' + +# Name of the non-PIC object. +non_pic_object='checkgid.o' + diff --git a/rubbos/app/httpd-2.0.64/support/checkgid.o b/rubbos/app/httpd-2.0.64/support/checkgid.o Binary files differnew file mode 100644 index 00000000..9116a3a9 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/checkgid.o diff --git a/rubbos/app/httpd-2.0.64/support/config.m4 b/rubbos/app/httpd-2.0.64/support/config.m4 new file mode 100644 index 00000000..8169a1ec --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/config.m4 @@ -0,0 +1,104 @@ +htpasswd_LTFLAGS="" +htdigest_LTFLAGS="" +rotatelogs_LTFLAGS="" +logresolve_LTFLAGS="" +htdbm_LTFLAGS="" +ab_LTFLAGS="" +checkgid_LTFLAGS="" + +AC_ARG_ENABLE(static-support,APACHE_HELP_STRING(--enable-static-support,Build a statically linked version the support binaries),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(htpasswd_LTFLAGS, [-static]) + APR_ADDTO(htdigest_LTFLAGS, [-static]) + APR_ADDTO(rotatelogs_LTFLAGS, [-static]) + APR_ADDTO(logresolve_LTFLAGS, [-static]) + APR_ADDTO(htdbm_LTFLAGS, [-static]) + APR_ADDTO(ab_LTFLAGS, [-static]) + APR_ADDTO(checkgid_LTFLAGS, [-static]) +fi +]) + +AC_ARG_ENABLE(static-htpasswd,APACHE_HELP_STRING(--enable-static-htpasswd,Build a statically linked version of htpasswd),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(htpasswd_LTFLAGS, [-static]) +else + APR_REMOVEFROM(htpasswd_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(htpasswd_LTFLAGS) + +AC_ARG_ENABLE(static-htdigest,APACHE_HELP_STRING(--enable-static-htdigest,Build a statically linked version of htdigest),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(htdigest_LTFLAGS, [-static]) +else + APR_REMOVEFROM(htdigest_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(htdigest_LTFLAGS) + +AC_ARG_ENABLE(static-rotatelogs,APACHE_HELP_STRING(--enable-static-rotatelogs,Build a statically linked version of rotatelogs),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(rotatelogs_LTFLAGS, [-static]) +else + APR_REMOVEFROM(rotatelogs_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(rotatelogs_LTFLAGS) + +AC_ARG_ENABLE(static-logresolve,APACHE_HELP_STRING(--enable-static-logresolve,Build a statically linked version of logresolve),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(logresolve_LTFLAGS, [-static]) +else + APR_REMOVEFROM(logresolve_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(logresolve_LTFLAGS) + +AC_ARG_ENABLE(static-htdbm,APACHE_HELP_STRING(--enable-static-htdbm,Build a statically linked version of htdbm),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(htdbm_LTFLAGS, [-static]) +else + APR_REMOVEFROM(htdbm_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(htdbm_LTFLAGS) + +AC_ARG_ENABLE(static-ab,APACHE_HELP_STRING(--enable-static-ab,Build a statically linked version of ab),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(ab_LTFLAGS, [-static]) +else + APR_REMOVEFROM(ab_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(ab_LTFLAGS) + +AC_ARG_ENABLE(static-checkgid,APACHE_HELP_STRING(--enable-static-checkgid,Build a statically linked version of checkgid),[ +if test "$enableval" = "yes" ; then + APR_ADDTO(checkgid_LTFLAGS, [-static]) +else + APR_REMOVEFROM(checkgid_LTFLAGS, [-static]) +fi +]) +APACHE_SUBST(checkgid_LTFLAGS) + +case $host in + *aix*) + # this works in any locale, unlike the default command below, which + # fails in a non-English locale if the hard limit is unlimited + # since the display of the limit will translate "unlimited", but + # ulimit only accepts English "unlimited" on input + APACHECTL_ULIMIT="ulimit -S -n unlimited" + ;; + *alpha*-dec-osf*) + # Tru64: -H is for setting, not retrieving + APACHECTL_ULIMIT="ulimit -S -n \`ulimit -h -n\`" + ;; + *) + if TMP_ULIMIT=`ulimit -H -n` && ulimit -S -n $TMP_ULIMIT ; then + APACHECTL_ULIMIT="ulimit -S -n \`ulimit -H -n\`" + else + APACHECTL_ULIMIT="" + fi + ;; +esac +APACHE_SUBST(APACHECTL_ULIMIT) diff --git a/rubbos/app/httpd-2.0.64/support/dbmmanage b/rubbos/app/httpd-2.0.64/support/dbmmanage new file mode 100644 index 00000000..436e824f --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/dbmmanage @@ -0,0 +1,312 @@ +#!/usr/bin/perl +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#for more functionality see the HTTPD::UserAdmin module: +# http://www.perl.com/CPAN/modules/by-module/HTTPD/HTTPD-Tools-x.xx.tar.gz +# +# usage: dbmmanage <DBMfile> <command> <user> <password> <groups> <comment> + +package dbmmanage; +# -ldb -lndbm -lgdbm -lsdbm +BEGIN { @AnyDBM_File::ISA = qw(DB_File NDBM_File GDBM_File SDBM_File) } +use strict; +use Fcntl; +use AnyDBM_File (); + +sub usage { + my $cmds = join "|", sort keys %dbmc::; + die <<SYNTAX; +Usage: dbmmanage [enc] dbname command [username [pw [group[,group] [comment]]]] + + where enc is -d for crypt encryption (default except on Win32, Netware) + -m for MD5 encryption (default on Win32, Netware) + -s for SHA1 encryption + -p for plaintext + + command is one of: $cmds + + pw of . for update command retains the old password + pw of - (or blank) for update command prompts for the password + + groups or comment of . (or blank) for update command retains old values + groups or comment of - for update command clears the existing value + groups or comment of - for add and adduser commands is the empty value +SYNTAX +} + +sub need_sha1_crypt { + if (!eval ('require "Digest/SHA1.pm";')) { + print STDERR <<SHAERR; +dbmmanage SHA1 passwords require the interface or the module Digest::SHA1 +available from CPAN: + + http://www.cpan.org/modules/by-module/Digest/Digest-MD5-2.12.tar.gz + +Please install Digest::SHA1 and try again, or use a different crypt option: + +SHAERR + usage(); + } +} + +sub need_md5_crypt { + if (!eval ('require "Crypt/PasswdMD5.pm";')) { + print STDERR <<MD5ERR; +dbmmanage MD5 passwords require the module Crypt::PasswdMD5 available from CPAN + + http://www.cpan.org/modules/by-module/Crypt/Crypt-PasswdMD5-1.1.tar.gz + +Please install Crypt::PasswdMD5 and try again, or use a different crypt option: + +MD5ERR + usage(); + } +} + +# if your osname is in $newstyle_salt, then use new style salt (starts with '_' and contains +# four bytes of iteration count and four bytes of salt). Otherwise, just use +# the traditional two-byte salt. +# see the man page on your system to decide if you have a newer crypt() lib. +# I believe that 4.4BSD derived systems do (at least BSD/OS 2.0 does). +# The new style crypt() allows up to 20 characters of the password to be +# significant rather than only 8. +# +my $newstyle_salt_platforms = join '|', qw{bsdos}; #others? +my $newstyle_salt = $^O =~ /(?:$newstyle_salt_platforms)/; + +# Some platforms just can't crypt() for Apache +# +my $crypt_not_supported_platforms = join '|', qw{MSWin32 NetWare}; #others? +my $crypt_not_supported = $^O =~ /(?:$crypt_not_supported_platforms)/; + +my $crypt_method = "crypt"; + +if ($crypt_not_supported) { + $crypt_method = "md5"; +} + +# Some platforms won't jump through our favorite hoops +# +my $not_unix_platforms = join '|', qw{MSWin32 NetWare}; #others? +my $not_unix = $^O =~ /(?:$not_unix_platforms)/; + +if ($crypt_not_supported) { + $crypt_method = "md5"; +} + +if (@ARGV[0] eq "-d") { + shift @ARGV; + if ($crypt_not_supported) { + print STDERR + "Warning: Apache/$^O does not support crypt()ed passwords!\n\n"; + } + $crypt_method = "crypt"; +} + +if (@ARGV[0] eq "-m") { + shift @ARGV; + $crypt_method = "md5"; +} + +if (@ARGV[0] eq "-p") { + shift @ARGV; + if (!$crypt_not_supported) { + print STDERR + "Warning: Apache/$^O does not support plaintext passwords!\n\n"; + } + $crypt_method = "plain"; +} + +if (@ARGV[0] eq "-s") { + shift @ARGV; + need_sha1_crypt(); + $crypt_method = "sha1"; +} + +if ($crypt_method eq "md5") { + need_md5_crypt(); +} + +my($file,$command,$key,$crypted_pwd,$groups,$comment) = @ARGV; + +usage() unless $file and $command and defined &{$dbmc::{$command}}; + +# remove extension if any +my $chop = join '|', qw{db.? pag dir}; +$file =~ s/\.($chop)$//; + +my $is_update = $command eq "update"; +my %DB = (); +my @range = (); +my($mode, $flags) = $command =~ + /^(?:view|check)$/ ? (0644, O_RDONLY) : (0644, O_RDWR|O_CREAT); + +tie (%DB, "AnyDBM_File", $file, $flags, $mode) || die "Can't tie $file: $!"; +dbmc->$command(); +untie %DB; + + +my $x; +sub genseed { + my $psf; + if ($not_unix) { + srand (time ^ $$ or time ^ ($$ + ($$ << 15))); + } + else { + for (qw(-xlwwa -le)) { + `ps $_ 2>/dev/null`; + $psf = $_, last unless $?; + } + srand (time ^ $$ ^ unpack("%L*", `ps $psf | gzip -f`)); + } + @range = (qw(. /), '0'..'9','a'..'z','A'..'Z'); + $x = int scalar @range; +} + +sub randchar { + join '', map $range[rand $x], 1..shift||1; +} + +sub saltpw_crypt { + genseed() unless @range; + return $newstyle_salt ? + join '', "_", randchar, "a..", randchar(4) : + randchar(2); +} + +sub cryptpw_crypt { + my ($pw, $salt) = @_; + $salt = saltpw_crypt unless $salt; + crypt $pw, $salt; +} + +sub saltpw_md5 { + genseed() unless @range; + randchar(8); +} + +sub cryptpw_md5 { + my($pw, $salt) = @_; + $salt = saltpw_md5 unless $salt; + Crypt::PasswdMD5::apache_md5_crypt($pw, $salt); +} + +sub cryptpw_sha1 { + my($pw, $salt) = @_; + '{SHA}' . Digest::SHA1::sha1_base64($pw) . "="; +} + +sub cryptpw { + if ($crypt_method eq "md5") { + return cryptpw_md5(@_); + } elsif ($crypt_method eq "sha1") { + return cryptpw_sha1(@_); + } elsif ($crypt_method eq "crypt") { + return cryptpw_crypt(@_); + } + @_[0]; # otherwise return plaintext +} + +sub getpass { + my $prompt = shift || "Enter password:"; + + unless($not_unix) { + open STDIN, "/dev/tty" or warn "couldn't open /dev/tty $!\n"; + system "stty -echo;"; + } + + my($c,$pwd); + print STDERR $prompt; + while (($c = getc(STDIN)) ne '' and $c ne "\n" and $c ne "\r") { + $pwd .= $c; + } + + system "stty echo" unless $not_unix; + print STDERR "\n"; + die "Can't use empty password!\n" unless length $pwd; + return $pwd; +} + +sub dbmc::update { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + $crypted_pwd = (split /:/, $DB{$key}, 3)[0] if $crypted_pwd eq '.'; + $groups = (split /:/, $DB{$key}, 3)[1] if !$groups || $groups eq '.'; + $comment = (split /:/, $DB{$key}, 3)[2] if !$comment || $comment eq '.'; + if (!$crypted_pwd || $crypted_pwd eq '-') { + dbmc->adduser; + } + else { + dbmc->add; + } +} + +sub dbmc::add { + die "Can't use empty password!\n" unless $crypted_pwd; + unless($is_update) { + die "Sorry, user `$key' already exists!\n" if $DB{$key}; + } + $groups = '' if $groups eq '-'; + $comment = '' if $comment eq '-'; + $groups .= ":" . $comment if $comment; + $crypted_pwd .= ":" . $groups if $groups; + $DB{$key} = $crypted_pwd; + my $action = $is_update ? "updated" : "added"; + print "User $key $action with password encrypted to $DB{$key} using $crypt_method\n"; +} + +sub dbmc::adduser { + my $value = getpass "New password:"; + die "They don't match, sorry.\n" unless getpass("Re-type new password:") eq $value; + $crypted_pwd = cryptpw $value; + dbmc->add; +} + +sub dbmc::delete { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + delete $DB{$key}, print "`$key' deleted\n"; +} + +sub dbmc::view { + print $key ? "$key:$DB{$key}\n" : map { "$_:$DB{$_}\n" if $DB{$_} } keys %DB; +} + +sub dbmc::check { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + my $chkpass = (split /:/, $DB{$key}, 3)[0]; + my $testpass = getpass(); + if (substr($chkpass, 0, 6) eq '$apr1$') { + need_md5_crypt; + $crypt_method = "md5"; + } elsif (substr($chkpass, 0, 5) eq '{SHA}') { + need_sha1_crypt; + $crypt_method = "sha1"; + } elsif (length($chkpass) == 13 && $chkpass ne $testpass) { + $crypt_method = "crypt"; + } else { + $crypt_method = "plain"; + } + print $crypt_method . (cryptpw($testpass, $chkpass) eq $chkpass + ? " password ok\n" : " password mismatch\n"); +} + +sub dbmc::import { + while(defined($_ = <STDIN>) and chomp) { + ($key,$crypted_pwd,$groups,$comment) = split /:/, $_, 4; + dbmc->add; + } +} + diff --git a/rubbos/app/httpd-2.0.64/support/dbmmanage.in b/rubbos/app/httpd-2.0.64/support/dbmmanage.in new file mode 100644 index 00000000..df78f503 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/dbmmanage.in @@ -0,0 +1,312 @@ +#!@perlbin@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#for more functionality see the HTTPD::UserAdmin module: +# http://www.perl.com/CPAN/modules/by-module/HTTPD/HTTPD-Tools-x.xx.tar.gz +# +# usage: dbmmanage <DBMfile> <command> <user> <password> <groups> <comment> + +package dbmmanage; +# -ldb -lndbm -lgdbm -lsdbm +BEGIN { @AnyDBM_File::ISA = qw(DB_File NDBM_File GDBM_File SDBM_File) } +use strict; +use Fcntl; +use AnyDBM_File (); + +sub usage { + my $cmds = join "|", sort keys %dbmc::; + die <<SYNTAX; +Usage: dbmmanage [enc] dbname command [username [pw [group[,group] [comment]]]] + + where enc is -d for crypt encryption (default except on Win32, Netware) + -m for MD5 encryption (default on Win32, Netware) + -s for SHA1 encryption + -p for plaintext + + command is one of: $cmds + + pw of . for update command retains the old password + pw of - (or blank) for update command prompts for the password + + groups or comment of . (or blank) for update command retains old values + groups or comment of - for update command clears the existing value + groups or comment of - for add and adduser commands is the empty value +SYNTAX +} + +sub need_sha1_crypt { + if (!eval ('require "Digest/SHA1.pm";')) { + print STDERR <<SHAERR; +dbmmanage SHA1 passwords require the interface or the module Digest::SHA1 +available from CPAN: + + http://www.cpan.org/modules/by-module/Digest/Digest-MD5-2.12.tar.gz + +Please install Digest::SHA1 and try again, or use a different crypt option: + +SHAERR + usage(); + } +} + +sub need_md5_crypt { + if (!eval ('require "Crypt/PasswdMD5.pm";')) { + print STDERR <<MD5ERR; +dbmmanage MD5 passwords require the module Crypt::PasswdMD5 available from CPAN + + http://www.cpan.org/modules/by-module/Crypt/Crypt-PasswdMD5-1.1.tar.gz + +Please install Crypt::PasswdMD5 and try again, or use a different crypt option: + +MD5ERR + usage(); + } +} + +# if your osname is in $newstyle_salt, then use new style salt (starts with '_' and contains +# four bytes of iteration count and four bytes of salt). Otherwise, just use +# the traditional two-byte salt. +# see the man page on your system to decide if you have a newer crypt() lib. +# I believe that 4.4BSD derived systems do (at least BSD/OS 2.0 does). +# The new style crypt() allows up to 20 characters of the password to be +# significant rather than only 8. +# +my $newstyle_salt_platforms = join '|', qw{bsdos}; #others? +my $newstyle_salt = $^O =~ /(?:$newstyle_salt_platforms)/; + +# Some platforms just can't crypt() for Apache +# +my $crypt_not_supported_platforms = join '|', qw{MSWin32 NetWare}; #others? +my $crypt_not_supported = $^O =~ /(?:$crypt_not_supported_platforms)/; + +my $crypt_method = "crypt"; + +if ($crypt_not_supported) { + $crypt_method = "md5"; +} + +# Some platforms won't jump through our favorite hoops +# +my $not_unix_platforms = join '|', qw{MSWin32 NetWare}; #others? +my $not_unix = $^O =~ /(?:$not_unix_platforms)/; + +if ($crypt_not_supported) { + $crypt_method = "md5"; +} + +if (@ARGV[0] eq "-d") { + shift @ARGV; + if ($crypt_not_supported) { + print STDERR + "Warning: Apache/$^O does not support crypt()ed passwords!\n\n"; + } + $crypt_method = "crypt"; +} + +if (@ARGV[0] eq "-m") { + shift @ARGV; + $crypt_method = "md5"; +} + +if (@ARGV[0] eq "-p") { + shift @ARGV; + if (!$crypt_not_supported) { + print STDERR + "Warning: Apache/$^O does not support plaintext passwords!\n\n"; + } + $crypt_method = "plain"; +} + +if (@ARGV[0] eq "-s") { + shift @ARGV; + need_sha1_crypt(); + $crypt_method = "sha1"; +} + +if ($crypt_method eq "md5") { + need_md5_crypt(); +} + +my($file,$command,$key,$crypted_pwd,$groups,$comment) = @ARGV; + +usage() unless $file and $command and defined &{$dbmc::{$command}}; + +# remove extension if any +my $chop = join '|', qw{db.? pag dir}; +$file =~ s/\.($chop)$//; + +my $is_update = $command eq "update"; +my %DB = (); +my @range = (); +my($mode, $flags) = $command =~ + /^(?:view|check)$/ ? (0644, O_RDONLY) : (0644, O_RDWR|O_CREAT); + +tie (%DB, "AnyDBM_File", $file, $flags, $mode) || die "Can't tie $file: $!"; +dbmc->$command(); +untie %DB; + + +my $x; +sub genseed { + my $psf; + if ($not_unix) { + srand (time ^ $$ or time ^ ($$ + ($$ << 15))); + } + else { + for (qw(-xlwwa -le)) { + `ps $_ 2>/dev/null`; + $psf = $_, last unless $?; + } + srand (time ^ $$ ^ unpack("%L*", `ps $psf | gzip -f`)); + } + @range = (qw(. /), '0'..'9','a'..'z','A'..'Z'); + $x = int scalar @range; +} + +sub randchar { + join '', map $range[rand $x], 1..shift||1; +} + +sub saltpw_crypt { + genseed() unless @range; + return $newstyle_salt ? + join '', "_", randchar, "a..", randchar(4) : + randchar(2); +} + +sub cryptpw_crypt { + my ($pw, $salt) = @_; + $salt = saltpw_crypt unless $salt; + crypt $pw, $salt; +} + +sub saltpw_md5 { + genseed() unless @range; + randchar(8); +} + +sub cryptpw_md5 { + my($pw, $salt) = @_; + $salt = saltpw_md5 unless $salt; + Crypt::PasswdMD5::apache_md5_crypt($pw, $salt); +} + +sub cryptpw_sha1 { + my($pw, $salt) = @_; + '{SHA}' . Digest::SHA1::sha1_base64($pw) . "="; +} + +sub cryptpw { + if ($crypt_method eq "md5") { + return cryptpw_md5(@_); + } elsif ($crypt_method eq "sha1") { + return cryptpw_sha1(@_); + } elsif ($crypt_method eq "crypt") { + return cryptpw_crypt(@_); + } + @_[0]; # otherwise return plaintext +} + +sub getpass { + my $prompt = shift || "Enter password:"; + + unless($not_unix) { + open STDIN, "/dev/tty" or warn "couldn't open /dev/tty $!\n"; + system "stty -echo;"; + } + + my($c,$pwd); + print STDERR $prompt; + while (($c = getc(STDIN)) ne '' and $c ne "\n" and $c ne "\r") { + $pwd .= $c; + } + + system "stty echo" unless $not_unix; + print STDERR "\n"; + die "Can't use empty password!\n" unless length $pwd; + return $pwd; +} + +sub dbmc::update { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + $crypted_pwd = (split /:/, $DB{$key}, 3)[0] if $crypted_pwd eq '.'; + $groups = (split /:/, $DB{$key}, 3)[1] if !$groups || $groups eq '.'; + $comment = (split /:/, $DB{$key}, 3)[2] if !$comment || $comment eq '.'; + if (!$crypted_pwd || $crypted_pwd eq '-') { + dbmc->adduser; + } + else { + dbmc->add; + } +} + +sub dbmc::add { + die "Can't use empty password!\n" unless $crypted_pwd; + unless($is_update) { + die "Sorry, user `$key' already exists!\n" if $DB{$key}; + } + $groups = '' if $groups eq '-'; + $comment = '' if $comment eq '-'; + $groups .= ":" . $comment if $comment; + $crypted_pwd .= ":" . $groups if $groups; + $DB{$key} = $crypted_pwd; + my $action = $is_update ? "updated" : "added"; + print "User $key $action with password encrypted to $DB{$key} using $crypt_method\n"; +} + +sub dbmc::adduser { + my $value = getpass "New password:"; + die "They don't match, sorry.\n" unless getpass("Re-type new password:") eq $value; + $crypted_pwd = cryptpw $value; + dbmc->add; +} + +sub dbmc::delete { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + delete $DB{$key}, print "`$key' deleted\n"; +} + +sub dbmc::view { + print $key ? "$key:$DB{$key}\n" : map { "$_:$DB{$_}\n" if $DB{$_} } keys %DB; +} + +sub dbmc::check { + die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; + my $chkpass = (split /:/, $DB{$key}, 3)[0]; + my $testpass = getpass(); + if (substr($chkpass, 0, 6) eq '$apr1$') { + need_md5_crypt; + $crypt_method = "md5"; + } elsif (substr($chkpass, 0, 5) eq '{SHA}') { + need_sha1_crypt; + $crypt_method = "sha1"; + } elsif (length($chkpass) == 13 && $chkpass ne $testpass) { + $crypt_method = "crypt"; + } else { + $crypt_method = "plain"; + } + print $crypt_method . (cryptpw($testpass, $chkpass) eq $chkpass + ? " password ok\n" : " password mismatch\n"); +} + +sub dbmc::import { + while(defined($_ = <STDIN>) and chomp) { + ($key,$crypted_pwd,$groups,$comment) = split /:/, $_, 4; + dbmc->add; + } +} + diff --git a/rubbos/app/httpd-2.0.64/support/envvars-std b/rubbos/app/httpd-2.0.64/support/envvars-std new file mode 100644 index 00000000..771c6c59 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/envvars-std @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# envvars-std - default environment variables for apachectl +# +# This file is generated from envvars-std.in +# +LD_LIBRARY_PATH="/bottlenecks/rubbos/app/apache2/lib:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH +# + diff --git a/rubbos/app/httpd-2.0.64/support/envvars-std.in b/rubbos/app/httpd-2.0.64/support/envvars-std.in new file mode 100644 index 00000000..cf50c5c7 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/envvars-std.in @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# envvars-std - default environment variables for apachectl +# +# This file is generated from envvars-std.in +# +@SHLIBPATH_VAR@="@exp_libdir@:$@SHLIBPATH_VAR@" +export @SHLIBPATH_VAR@ +# +@OS_SPECIFIC_VARS@ diff --git a/rubbos/app/httpd-2.0.64/support/htdbm b/rubbos/app/httpd-2.0.64/support/htdbm new file mode 100755 index 00000000..63c9fce2 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdbm @@ -0,0 +1,131 @@ +#! /bin/bash + +# htdbm - temporary wrapper script for .libs/htdbm +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The htdbm program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/htdbm.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'htdbm' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/htdbm.c b/rubbos/app/httpd-2.0.64/support/htdbm.c new file mode 100644 index 00000000..db1d1378 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdbm.c @@ -0,0 +1,585 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * htdbm.c: simple program for manipulating DBM + * password databases for the Apache HTTP server + * + * Contributed by Mladen Turk <mturk@mappingsoft.com> + * 12 Oct 2001 + */ + +#include "apr.h" +#include "apr_lib.h" +#include "apr_strings.h" +#include "apr_file_io.h" +#include "apr_file_info.h" +#include "apr_pools.h" +#include "apr_signal.h" +#include "apr_md5.h" +#include "apr_sha1.h" +#include "apr_dbm.h" + +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if APR_HAVE_STRING_H +#include <string.h> +#endif +#if APR_HAVE_STRINGS_H +#include <strings.h> +#endif +#include <time.h> + +#if APR_CHARSET_EBCDIC +#include "apr_xlate.h" +#endif /*APR_CHARSET_EBCDIC*/ + +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif +#if APR_HAVE_CRYPT_H +#include <crypt.h> +#endif + + +#if !APR_CHARSET_EBCDIC +#define LF 10 +#define CR 13 +#else /*APR_CHARSET_EBCDIC*/ +#define LF '\n' +#define CR '\r' +#endif /*APR_CHARSET_EBCDIC*/ + +#define MAX_STRING_LEN 256 +#define ALG_PLAIN 0 +#define ALG_APMD5 1 +#define ALG_APSHA 2 + +#if APR_HAVE_CRYPT_H +#define ALG_CRYPT 3 +#endif + + +#define ERR_FILEPERM 1 +#define ERR_SYNTAX 2 +#define ERR_PWMISMATCH 3 +#define ERR_INTERRUPTED 4 +#define ERR_OVERFLOW 5 +#define ERR_BADUSER 6 +#define ERR_EMPTY 7 + + +typedef struct htdbm_t htdbm_t; + +struct htdbm_t { + apr_dbm_t *dbm; + apr_pool_t *pool; +#if APR_CHARSET_EBCDIC + apr_xlate_t *to_ascii; +#endif + char *filename; + char *username; + char *userpass; + char *comment; + char *type; + int create; + int rdonly; + int alg; +}; + + +#define HTDBM_MAKE 0 +#define HTDBM_DELETE 1 +#define HTDBM_VERIFY 2 +#define HTDBM_LIST 3 +#define HTDBM_NOFILE 4 +#define HTDBM_STDIN 5 + +static void terminate(void) +{ + apr_terminate(); +#ifdef NETWARE + pressanykey(); +#endif +} + +static void htdbm_terminate(htdbm_t *htdbm) +{ + if (htdbm->dbm) + apr_dbm_close(htdbm->dbm); + htdbm->dbm = NULL; +} + +static htdbm_t *h; + +static void htdbm_interrupted(void) +{ + htdbm_terminate(h); + fprintf(stderr, "htdbm Interrupted !\n"); + exit(ERR_INTERRUPTED); +} + +static apr_status_t htdbm_init(apr_pool_t **pool, htdbm_t **hdbm) +{ + +#if APR_CHARSET_EBCDIC + apr_status_t rv; +#endif + + apr_pool_create( pool, NULL); + apr_signal(SIGINT, (void (*)(int)) htdbm_interrupted); + + (*hdbm) = (htdbm_t *)apr_pcalloc(*pool, sizeof(htdbm_t)); + (*hdbm)->pool = *pool; + +#if APR_CHARSET_EBCDIC + rv = apr_xlate_open(&((*hdbm)->to_ascii), "ISO8859-1", APR_DEFAULT_CHARSET, (*hdbm)->pool); + if (rv) { + fprintf(stderr, "apr_xlate_open(to ASCII)->%d\n", rv); + return APR_EGENERAL; + } + rv = apr_SHA1InitEBCDIC((*hdbm)->to_ascii); + if (rv) { + fprintf(stderr, "apr_SHA1InitEBCDIC()->%d\n", rv); + return APR_EGENERAL; + } + rv = apr_MD5InitEBCDIC((*hdbm)->to_ascii); + if (rv) { + fprintf(stderr, "apr_MD5InitEBCDIC()->%d\n", rv); + return APR_EGENERAL; + } +#endif /*APR_CHARSET_EBCDIC*/ + + /* Set MD5 as default */ + (*hdbm)->alg = ALG_APMD5; + (*hdbm)->type = "default"; + return APR_SUCCESS; +} + +static apr_status_t htdbm_open(htdbm_t *htdbm) +{ + if (htdbm->create) + return apr_dbm_open_ex(&htdbm->dbm, htdbm->type, htdbm->filename, APR_DBM_RWCREATE, + APR_OS_DEFAULT, htdbm->pool); + else + return apr_dbm_open_ex(&htdbm->dbm, htdbm->type, htdbm->filename, + htdbm->rdonly ? APR_DBM_READONLY : APR_DBM_READWRITE, + APR_OS_DEFAULT, htdbm->pool); +} + +static apr_status_t htdbm_save(htdbm_t *htdbm, int *changed) +{ + apr_datum_t key, val; + + if (!htdbm->username) + return APR_SUCCESS; + + key.dptr = htdbm->username; + key.dsize = strlen(htdbm->username); + if (apr_dbm_exists(htdbm->dbm, key)) + *changed = 1; + + val.dsize = strlen(htdbm->userpass); + if (!htdbm->comment) + val.dptr = htdbm->userpass; + else { + val.dptr = apr_pstrcat(htdbm->pool, htdbm->userpass, ":", + htdbm->comment, NULL); + val.dsize += (strlen(htdbm->comment) + 1); + } + return apr_dbm_store(htdbm->dbm, key, val); +} + +static apr_status_t htdbm_del(htdbm_t *htdbm) +{ + apr_datum_t key; + + key.dptr = htdbm->username; + key.dsize = strlen(htdbm->username); + if (!apr_dbm_exists(htdbm->dbm, key)) + return APR_ENOENT; + + return apr_dbm_delete(htdbm->dbm, key); +} + +static apr_status_t htdbm_verify(htdbm_t *htdbm) +{ + apr_datum_t key, val; + char pwd[MAX_STRING_LEN] = {0}; + char *rec, *cmnt; + + key.dptr = htdbm->username; + key.dsize = strlen(htdbm->username); + if (!apr_dbm_exists(htdbm->dbm, key)) + return APR_ENOENT; + if (apr_dbm_fetch(htdbm->dbm, key, &val) != APR_SUCCESS) + return APR_ENOENT; + rec = apr_pstrndup(htdbm->pool, val.dptr, val.dsize); + cmnt = strchr(rec, ';'); + if (cmnt) + strncpy(pwd, rec, cmnt - rec); + else + strcpy(pwd, rec); + return apr_password_validate(htdbm->userpass, pwd); +} + +static apr_status_t htdbm_list(htdbm_t *htdbm) +{ + apr_status_t rv; + apr_datum_t key, val; + char *rec, *cmnt; + char kb[MAX_STRING_LEN]; + int i = 0; + + rv = apr_dbm_firstkey(htdbm->dbm, &key); + if (rv != APR_SUCCESS) { + fprintf(stderr, "Empty database -- %s\n", htdbm->filename); + return APR_ENOENT; + } + rec = apr_pcalloc(htdbm->pool, HUGE_STRING_LEN); + + fprintf(stderr, "Dumping records from database -- %s\n", htdbm->filename); + fprintf(stderr, " %-32sComment\n", "Username"); + while (key.dptr != NULL) { + rv = apr_dbm_fetch(htdbm->dbm, key, &val); + if (rv != APR_SUCCESS) { + fprintf(stderr, "Failed getting data from %s\n", htdbm->filename); + return APR_EGENERAL; + } + strncpy(kb, key.dptr, key.dsize); + kb[key.dsize] = '\0'; + fprintf(stderr, " %-32s", kb); + strncpy(rec, val.dptr, val.dsize); + rec[val.dsize] = '\0'; + cmnt = strchr(rec, ':'); + if (cmnt) + fprintf(stderr, cmnt + 1); + fprintf(stderr, "\n"); + rv = apr_dbm_nextkey(htdbm->dbm, &key); + if (rv != APR_SUCCESS) + fprintf(stderr, "Failed getting NextKey\n"); + ++i; + } + + fprintf(stderr, "Total #records : %d\n", i); + return APR_SUCCESS; +} + +static void to64(char *s, unsigned long v, int n) +{ + static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } +} + +static apr_status_t htdbm_make(htdbm_t *htdbm) +{ + char cpw[MAX_STRING_LEN]; + char salt[9]; + + switch (htdbm->alg) { + case ALG_APSHA: + /* XXX cpw >= 28 + strlen(sha1) chars - fixed len SHA */ + apr_sha1_base64(htdbm->userpass,strlen(htdbm->userpass),cpw); + break; + + case ALG_APMD5: + (void) srand((int) time((time_t *) NULL)); + to64(&salt[0], rand(), 8); + salt[8] = '\0'; + apr_md5_encode((const char *)htdbm->userpass, (const char *)salt, + cpw, sizeof(cpw)); + break; + case ALG_PLAIN: + /* XXX this len limitation is not in sync with any HTTPd len. */ + apr_cpystrn(cpw,htdbm->userpass,sizeof(cpw)); + break; +#if APR_HAVE_CRYPT_H + case ALG_CRYPT: + (void) srand((int) time((time_t *) NULL)); + to64(&salt[0], rand(), 8); + salt[8] = '\0'; + apr_cpystrn(cpw, (char *)crypt(htdbm->userpass, salt), sizeof(cpw) - 1); + fprintf(stderr, "CRYPT is now deprecated, use MD5 instead!\n"); +#endif + default: + break; + } + htdbm->userpass = apr_pstrdup(htdbm->pool, cpw); + return APR_SUCCESS; +} + +static apr_status_t htdbm_valid_username(htdbm_t *htdbm) +{ + if (!htdbm->username || (strlen(htdbm->username) > 64) || (strlen(htdbm->username) < 1)) { + fprintf(stderr, "Invalid username length\n"); + return APR_EINVAL; + } + if (strchr(htdbm->username, ':')) { + fprintf(stderr, "Username contains invalid characters\n"); + return APR_EINVAL; + } + return APR_SUCCESS; +} + +static void htdbm_usage(void) +{ + +#if APR_HAVE_CRYPT_H +#define CRYPT_OPTION "d" +#else +#define CRYPT_OPTION "" +#endif + fprintf(stderr, "htdbm -- program for manipulating DBM password databases.\n\n"); + fprintf(stderr, "Usage: htdbm [-cm"CRYPT_OPTION"pstvx] [-TDBTYPE] database username\n"); + fprintf(stderr, " -b[cm"CRYPT_OPTION"ptsv] [-TDBTYPE] database username password\n"); + fprintf(stderr, " -n[m"CRYPT_OPTION"pst] username\n"); + fprintf(stderr, " -nb[m"CRYPT_OPTION"pst] username password\n"); + fprintf(stderr, " -v[m"CRYPT_OPTION"ps] [-TDBTYPE] database username\n"); + fprintf(stderr, " -vb[m"CRYPT_OPTION"ps] [-TDBTYPE] database username password\n"); + fprintf(stderr, " -x[m"CRYPT_OPTION"ps] [-TDBTYPE] database username\n"); + fprintf(stderr, " -l [-TDBTYPE] database\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -b Use the password from the command line rather " + "than prompting for it.\n"); + fprintf(stderr, " -c Create a new database.\n"); + fprintf(stderr, " -n Don't update database; display results on stdout.\n"); + fprintf(stderr, " -m Force MD5 encryption of the password (default).\n"); +#if APR_HAVE_CRYPT_H + fprintf(stderr, " -d Force CRYPT encryption of the password (now deprecated).\n"); +#endif + fprintf(stderr, " -p Do not encrypt the password (plaintext).\n"); + fprintf(stderr, " -s Force SHA encryption of the password.\n"); + fprintf(stderr, " -T DBM Type (SDBM|GDBM|DB|default).\n"); + fprintf(stderr, " -l Display usernames from database on stdout.\n"); + fprintf(stderr, " -t The last param is username comment.\n"); + fprintf(stderr, " -v Verify the username/password.\n"); + fprintf(stderr, " -x Remove the username record from database.\n"); + exit(ERR_SYNTAX); + +} + + +int main(int argc, const char * const argv[]) +{ + apr_pool_t *pool; + apr_status_t rv; + apr_size_t l; + char pwi[MAX_STRING_LEN]; + char pwc[MAX_STRING_LEN]; + char errbuf[MAX_STRING_LEN]; + const char *arg; + int need_file = 1; + int need_user = 1; + int need_pwd = 1; + int need_cmnt = 0; + int pwd_supplied = 0; + int changed; + int cmd = HTDBM_MAKE; + int i; + int args_left = 2; + + apr_app_initialize(&argc, &argv, NULL); + atexit(terminate); + + if ((rv = htdbm_init(&pool, &h)) != APR_SUCCESS) { + fprintf(stderr, "Unable to initialize htdbm terminating!\n"); + apr_strerror(rv, errbuf, sizeof(errbuf)); + exit(1); + } + /* + * Preliminary check to make sure they provided at least + * three arguments, we'll do better argument checking as + * we parse the command line. + */ + if (argc < 3) + htdbm_usage(); + /* + * Go through the argument list and pick out any options. They + * have to precede any other arguments. + */ + for (i = 1; i < argc; i++) { + arg = argv[i]; + if (*arg != '-') + break; + + while (*++arg != '\0') { + switch (*arg) { + case 'b': + pwd_supplied = 1; + need_pwd = 0; + args_left++; + break; + case 'c': + h->create = 1; + break; + case 'n': + need_file = 0; + cmd = HTDBM_NOFILE; + args_left--; + break; + case 'l': + need_pwd = 0; + need_user = 0; + cmd = HTDBM_LIST; + h->rdonly = 1; + args_left--; + break; + case 't': + need_cmnt = 1; + args_left++; + break; + case 'T': + h->type = apr_pstrdup(h->pool, ++arg); + while (*arg != '\0') + ++arg; + --arg; /* so incrementing this in the loop with find a null */ + break; + case 'v': + h->rdonly = 1; + cmd = HTDBM_VERIFY; + break; + case 'x': + need_pwd = 0; + cmd = HTDBM_DELETE; + break; + case 'm': + h->alg = ALG_APMD5; + break; + case 'p': + h->alg = ALG_PLAIN; + break; + case 's': + h->alg = ALG_APSHA; + break; +#if APR_HAVE_CRYPT_H + case 'd': + h->alg = ALG_CRYPT; + break; +#endif + default: + htdbm_usage(); + break; + } + } + } + /* + * Make sure we still have exactly the right number of arguments left + * (the filename, the username, and possibly the password if -b was + * specified). + */ + if ((argc - i) != args_left) + htdbm_usage(); + + if (!need_file) + i--; + else { + h->filename = apr_pstrdup(h->pool, argv[i]); + if ((rv = htdbm_open(h)) != APR_SUCCESS) { + fprintf(stderr, "Error opening database %s\n", argv[i]); + apr_strerror(rv, errbuf, sizeof(errbuf)); + fprintf(stderr,"%s\n",errbuf); + exit(ERR_FILEPERM); + } + } + if (need_user) { + h->username = apr_pstrdup(pool, argv[i+1]); + if (htdbm_valid_username(h) != APR_SUCCESS) + exit(ERR_BADUSER); + } + if (pwd_supplied) + h->userpass = apr_pstrdup(pool, argv[i+2]); + + if (need_pwd) { + l = sizeof(pwc); + if (apr_password_get("Enter password : ", pwi, &l) != APR_SUCCESS) { + fprintf(stderr, "Password too long\n"); + exit(ERR_OVERFLOW); + } + l = sizeof(pwc); + if (apr_password_get("Re-type password : ", pwc, &l) != APR_SUCCESS) { + fprintf(stderr, "Password too long\n"); + exit(ERR_OVERFLOW); + } + if (strcmp(pwi, pwc) != 0) { + fprintf(stderr, "Password verification error\n"); + exit(ERR_PWMISMATCH); + } + + h->userpass = apr_pstrdup(pool, pwi); + } + if (need_cmnt && pwd_supplied) + h->comment = apr_pstrdup(pool, argv[i+3]); + else if (need_cmnt) + h->comment = apr_pstrdup(pool, argv[i+2]); + + switch (cmd) { + case HTDBM_VERIFY: + if ((rv = htdbm_verify(h)) != APR_SUCCESS) { + if(rv == APR_ENOENT) { + fprintf(stderr, "The user '%s' could not be found in database\n", h->username); + exit(ERR_BADUSER); + } + else { + fprintf(stderr, "Password mismatch for user '%s'\n", h->username); + exit(ERR_PWMISMATCH); + } + } + else + fprintf(stderr, "Password validated for user '%s'\n", h->username); + break; + case HTDBM_DELETE: + if (htdbm_del(h) != APR_SUCCESS) { + fprintf(stderr, "Cannot find user '%s' in database\n", h->username); + exit(ERR_BADUSER); + } + h->username = NULL; + changed = 1; + break; + case HTDBM_LIST: + htdbm_list(h); + break; + default: + htdbm_make(h); + break; + + } + if (need_file && !h->rdonly) { + if ((rv = htdbm_save(h, &changed)) != APR_SUCCESS) { + apr_strerror(rv, errbuf, sizeof(errbuf)); + exit(ERR_FILEPERM); + } + fprintf(stdout, "Database %s %s.\n", h->filename, + h->create ? "created" : (changed ? "modified" : "updated")); + } + if (cmd == HTDBM_NOFILE) { + if (!need_cmnt) { + fprintf(stderr, "%s:%s\n", h->username, h->userpass); + } + else { + fprintf(stderr, "%s:%s:%s\n", h->username, h->userpass, + h->comment); + } + } + htdbm_terminate(h); + + return 0; /* Suppress compiler warning. */ +} diff --git a/rubbos/app/httpd-2.0.64/support/htdbm.dsp b/rubbos/app/httpd-2.0.64/support/htdbm.dsp new file mode 100644 index 00000000..c00c2c84 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdbm.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="htdbm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=htdbm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "htdbm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "htdbm.mak" CFG="htdbm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "htdbm - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "htdbm - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "htdbm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/htdbm_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "htdbm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/htdbm_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "htdbm - Win32 Release" +# Name "htdbm - Win32 Debug" +# Begin Source File + +SOURCE=.\htdbm.c +# End Source File +# Begin Source File + +SOURCE=.\htdbm.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "htdbm - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htdbm.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htdbm.exe "htdbm Utility" ../include/ap_release.h > .\htdbm.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "htdbm - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htdbm.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htdbm.exe "htdbm Utility" ../include/ap_release.h > .\htdbm.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/htdbm.lo b/rubbos/app/httpd-2.0.64/support/htdbm.lo new file mode 100644 index 00000000..1397a739 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdbm.lo @@ -0,0 +1,12 @@ +# htdbm.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/htdbm.o' + +# Name of the non-PIC object. +non_pic_object='htdbm.o' + diff --git a/rubbos/app/httpd-2.0.64/support/htdbm.o b/rubbos/app/httpd-2.0.64/support/htdbm.o Binary files differnew file mode 100644 index 00000000..35bf9bd8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdbm.o diff --git a/rubbos/app/httpd-2.0.64/support/htdigest b/rubbos/app/httpd-2.0.64/support/htdigest new file mode 100755 index 00000000..61c78dd4 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdigest @@ -0,0 +1,131 @@ +#! /bin/bash + +# htdigest - temporary wrapper script for .libs/htdigest +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The htdigest program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/htdigest.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'htdigest' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/htdigest.c b/rubbos/app/httpd-2.0.64/support/htdigest.c new file mode 100644 index 00000000..55699ad1 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdigest.c @@ -0,0 +1,291 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/****************************************************************************** + ****************************************************************************** + * NOTE! This program is not safe as a setuid executable! Do not make it + * setuid! + ****************************************************************************** + *****************************************************************************/ +/* + * htdigest.c: simple program for manipulating digest passwd file for Apache + * + * by Alexei Kosut, based on htpasswd.c, by Rob McCool + */ + +#include "apr.h" +#include "apr_file_io.h" +#include "apr_md5.h" +#include "apr_lib.h" /* for apr_getpass() */ +#include "apr_general.h" +#include "apr_signal.h" +#include "apr_strings.h" /* for apr_pstrdup() */ + +#define APR_WANT_STDIO +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#if APR_HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#ifdef WIN32 +#include <conio.h> +#endif + + +#if APR_CHARSET_EBCDIC +#define LF '\n' +#define CR '\r' +#else +#define LF 10 +#define CR 13 +#endif /* APR_CHARSET_EBCDIC */ + +#define MAX_STRING_LEN 256 + +apr_file_t *tfp = NULL; +apr_file_t *errfile; +apr_pool_t *cntxt; +#if APR_CHARSET_EBCDIC +apr_xlate_t *to_ascii; +#endif + +static void cleanup_tempfile_and_exit(int rc) +{ + if (tfp) { + apr_file_close(tfp); + } + exit(rc); +} + +static void getword(char *word, char *line, char stop) +{ + int x = 0, y; + + for (x = 0; ((line[x]) && (line[x] != stop)); x++) + word[x] = line[x]; + + word[x] = '\0'; + if (line[x]) + ++x; + y = 0; + + while ((line[y++] = line[x++])); +} + +static int get_line(char *s, int n, apr_file_t *f) +{ + register int i = 0; + char ch; + apr_status_t rv = APR_EINVAL; + + while (i < (n - 1) && + ((rv = apr_file_getc(&ch, f)) == APR_SUCCESS) && (ch != '\n')) { + s[i++] = ch; + } + if (ch == '\n') + s[i++] = ch; + s[i] = '\0'; + + if (rv != APR_SUCCESS) + return 1; + + return 0; +} + +static void putline(apr_file_t *f, char *l) +{ + int x; + + for (x = 0; l[x]; x++) + apr_file_putc(l[x], f); +} + + +static void add_password(const char *user, const char *realm, apr_file_t *f) +{ + char *pw; + apr_md5_ctx_t context; + unsigned char digest[16]; + char string[MAX_STRING_LEN]; + char pwin[MAX_STRING_LEN]; + char pwv[MAX_STRING_LEN]; + unsigned int i; + apr_size_t len = sizeof(pwin); + + if (apr_password_get("New password: ", pwin, &len) != APR_SUCCESS) { + apr_file_printf(errfile, "password too long"); + cleanup_tempfile_and_exit(5); + } + len = sizeof(pwin); + apr_password_get("Re-type new password: ", pwv, &len); + if (strcmp(pwin, pwv) != 0) { + apr_file_printf(errfile, "They don't match, sorry.\n"); + cleanup_tempfile_and_exit(1); + } + pw = pwin; + apr_file_printf(f, "%s:%s:", user, realm); + + /* Do MD5 stuff */ + sprintf(string, "%s:%s:%s", user, realm, pw); + + apr_md5_init(&context); +#if APR_CHARSET_EBCDIC + apr_md5_set_xlate(&context, to_ascii); +#endif + apr_md5_update(&context, (unsigned char *) string, strlen(string)); + apr_md5_final(digest, &context); + + for (i = 0; i < 16; i++) + apr_file_printf(f, "%02x", digest[i]); + + apr_file_printf(f, "\n"); +} + +static void usage(void) +{ + apr_file_printf(errfile, "Usage: htdigest [-c] passwordfile realm username\n"); + apr_file_printf(errfile, "The -c flag creates a new file.\n"); + exit(1); +} + +static void interrupted(void) +{ + apr_file_printf(errfile, "Interrupted.\n"); + cleanup_tempfile_and_exit(1); +} + +static void terminate(void) +{ + apr_terminate(); +#ifdef NETWARE + pressanykey(); +#endif +} + +int main(int argc, const char * const argv[]) +{ + apr_file_t *f; + apr_status_t rv; + char tn[] = "htdigest.tmp.XXXXXX"; + char *dirname; + char user[MAX_STRING_LEN]; + char realm[MAX_STRING_LEN]; + char line[MAX_STRING_LEN]; + char l[MAX_STRING_LEN]; + char w[MAX_STRING_LEN]; + char x[MAX_STRING_LEN]; + int found; + + apr_app_initialize(&argc, &argv, NULL); + atexit(terminate); + apr_pool_create(&cntxt, NULL); + apr_file_open_stderr(&errfile, cntxt); + +#if APR_CHARSET_EBCDIC + rv = apr_xlate_open(&to_ascii, "ISO8859-1", APR_DEFAULT_CHARSET, cntxt); + if (rv) { + apr_file_printf(errfile, "apr_xlate_open(): %s (%d)\n", + apr_strerror(rv, line, sizeof(line)), rv); + exit(1); + } +#endif + + apr_signal(SIGINT, (void (*)(int)) interrupted); + if (argc == 5) { + if (strcmp(argv[1], "-c")) + usage(); + rv = apr_file_open(&f, argv[2], APR_WRITE | APR_CREATE, + APR_OS_DEFAULT, cntxt); + if (rv != APR_SUCCESS) { + char errmsg[120]; + + apr_file_printf(errfile, "Could not open passwd file %s for writing: %s\n", + argv[2], + apr_strerror(rv, errmsg, sizeof errmsg)); + exit(1); + } + apr_file_printf(errfile, "Adding password for %s in realm %s.\n", + argv[4], argv[3]); + add_password(argv[4], argv[3], f); + apr_file_close(f); + exit(0); + } + else if (argc != 4) + usage(); + + if (apr_temp_dir_get((const char**)&dirname, cntxt) != APR_SUCCESS) { + apr_file_printf(errfile, "%s: could not determine temp dir\n", + argv[0]); + exit(1); + } + dirname = apr_psprintf(cntxt, "%s/%s", dirname, tn); + + if (apr_file_mktemp(&tfp, dirname, 0, cntxt) != APR_SUCCESS) { + apr_file_printf(errfile, "Could not open temp file %s.\n", dirname); + exit(1); + } + + if (apr_file_open(&f, argv[1], APR_READ, APR_OS_DEFAULT, cntxt) != APR_SUCCESS) { + apr_file_printf(errfile, + "Could not open passwd file %s for reading.\n", argv[1]); + apr_file_printf(errfile, "Use -c option to create new one.\n"); + cleanup_tempfile_and_exit(1); + } + apr_cpystrn(user, argv[3], sizeof(user)); + apr_cpystrn(realm, argv[2], sizeof(realm)); + + found = 0; + while (!(get_line(line, MAX_STRING_LEN, f))) { + if (found || (line[0] == '#') || (!line[0])) { + putline(tfp, line); + continue; + } + strcpy(l, line); + getword(w, l, ':'); + getword(x, l, ':'); + if (strcmp(user, w) || strcmp(realm, x)) { + putline(tfp, line); + continue; + } + else { + apr_file_printf(errfile, "Changing password for user %s in realm %s\n", + user, realm); + add_password(user, realm, tfp); + found = 1; + } + } + if (!found) { + apr_file_printf(errfile, "Adding user %s in realm %s\n", user, realm); + add_password(user, realm, tfp); + } + apr_file_close(f); + + /* The temporary file has all the data, just copy it to the new location. + */ + if (apr_file_copy(dirname, argv[1], APR_FILE_SOURCE_PERMS, cntxt) != + APR_SUCCESS) { + apr_file_printf(errfile, "%s: unable to update file %s\n", + argv[0], argv[1]); + } + apr_file_close(tfp); + + return 0; +} diff --git a/rubbos/app/httpd-2.0.64/support/htdigest.dsp b/rubbos/app/httpd-2.0.64/support/htdigest.dsp new file mode 100644 index 00000000..94bc802c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdigest.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="htdigest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=htdigest - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "htdigest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "htdigest.mak" CFG="htdigest - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "htdigest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "htdigest - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "htdigest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/htdigest_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "htdigest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/htdigest_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "htdigest - Win32 Release" +# Name "htdigest - Win32 Debug" +# Begin Source File + +SOURCE=.\htdigest.c +# End Source File +# Begin Source File + +SOURCE=.\htdigest.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "htdigest - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htdigest.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htdigest.exe "htdigest Utility" ../include/ap_release.h > .\htdigest.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "htdigest - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htdigest.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htdigest.exe "htdigest Utility" ../include/ap_release.h > .\htdigest.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/htdigest.lo b/rubbos/app/httpd-2.0.64/support/htdigest.lo new file mode 100644 index 00000000..845a48ff --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdigest.lo @@ -0,0 +1,12 @@ +# htdigest.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/htdigest.o' + +# Name of the non-PIC object. +non_pic_object='htdigest.o' + diff --git a/rubbos/app/httpd-2.0.64/support/htdigest.o b/rubbos/app/httpd-2.0.64/support/htdigest.o Binary files differnew file mode 100644 index 00000000..e3ec6704 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htdigest.o diff --git a/rubbos/app/httpd-2.0.64/support/htpasswd b/rubbos/app/httpd-2.0.64/support/htpasswd new file mode 100755 index 00000000..b572d20c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htpasswd @@ -0,0 +1,131 @@ +#! /bin/bash + +# htpasswd - temporary wrapper script for .libs/htpasswd +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The htpasswd program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/htpasswd.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'htpasswd' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/htpasswd.c b/rubbos/app/httpd-2.0.64/support/htpasswd.c new file mode 100644 index 00000000..b76f530b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htpasswd.c @@ -0,0 +1,610 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/****************************************************************************** + ****************************************************************************** + * NOTE! This program is not safe as a setuid executable! Do not make it + * setuid! + ****************************************************************************** + *****************************************************************************/ +/* + * htpasswd.c: simple program for manipulating password file for + * the Apache HTTP server + * + * Originally by Rob McCool + * + * Exit values: + * 0: Success + * 1: Failure; file access/permission problem + * 2: Failure; command line syntax problem (usage message issued) + * 3: Failure; password verification failure + * 4: Failure; operation interrupted (such as with CTRL/C) + * 5: Failure; buffer would overflow (username, filename, or computed + * record too long) + * 6: Failure; username contains illegal or reserved characters + * 7: Failure; file is not a valid htpasswd file + */ + +#include "apr.h" +#include "apr_lib.h" +#include "apr_strings.h" +#include "apr_errno.h" +#include "apr_file_io.h" +#include "apr_general.h" +#include "apr_signal.h" + +#if APR_HAVE_STDIO_H +#include <stdio.h> +#endif + +#include "apr_md5.h" +#include "apr_sha1.h" +#include <time.h> + +#if APR_HAVE_CRYPT_H +#include <crypt.h> +#endif +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if APR_HAVE_STRING_H +#include <string.h> +#endif +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef WIN32 +#include <conio.h> +#define unlink _unlink +#endif + +#if !APR_CHARSET_EBCDIC +#define LF 10 +#define CR 13 +#else /*APR_CHARSET_EBCDIC*/ +#define LF '\n' +#define CR '\r' +#endif /*APR_CHARSET_EBCDIC*/ + +#define MAX_STRING_LEN 256 +#define ALG_PLAIN 0 +#define ALG_CRYPT 1 +#define ALG_APMD5 2 +#define ALG_APSHA 3 + +#define ERR_FILEPERM 1 +#define ERR_SYNTAX 2 +#define ERR_PWMISMATCH 3 +#define ERR_INTERRUPTED 4 +#define ERR_OVERFLOW 5 +#define ERR_BADUSER 6 +#define ERR_INVALID 7 + +#define APHTP_NEWFILE 1 +#define APHTP_NOFILE 2 +#define APHTP_NONINTERACTIVE 4 +#define APHTP_DELUSER 8 + +apr_file_t *errfile; +apr_file_t *ftemp = NULL; + +static void to64(char *s, unsigned long v, int n) +{ + static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } +} + +static void putline(apr_file_t *f, const char *l) +{ + apr_file_puts(l, f); +} + +/* + * Make a password record from the given information. A zero return + * indicates success; failure means that the output buffer contains an + * error message instead. + */ +static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd, + int alg) +{ + char *pw; + char cpw[120]; + char pwin[MAX_STRING_LEN]; + char pwv[MAX_STRING_LEN]; + char salt[9]; + apr_size_t bufsize; + + if (passwd != NULL) { + pw = passwd; + } + else { + bufsize = sizeof(pwin); + if (apr_password_get("New password: ", pwin, &bufsize) != 0) { + apr_snprintf(record, (rlen - 1), "password too long (>%" + APR_SIZE_T_FMT ")", sizeof(pwin) - 1); + return ERR_OVERFLOW; + } + bufsize = sizeof(pwv); + apr_password_get("Re-type new password: ", pwv, &bufsize); + if (strcmp(pwin, pwv) != 0) { + apr_cpystrn(record, "password verification error", (rlen - 1)); + return ERR_PWMISMATCH; + } + pw = pwin; + memset(pwv, '\0', sizeof(pwin)); + } + switch (alg) { + + case ALG_APSHA: + /* XXX cpw >= 28 + strlen(sha1) chars - fixed len SHA */ + apr_sha1_base64(pw,strlen(pw),cpw); + break; + + case ALG_APMD5: + (void) srand((int) time((time_t *) NULL)); + to64(&salt[0], rand(), 8); + salt[8] = '\0'; + + apr_md5_encode((const char *)pw, (const char *)salt, + cpw, sizeof(cpw)); + break; + + case ALG_PLAIN: + /* XXX this len limitation is not in sync with any HTTPd len. */ + apr_cpystrn(cpw,pw,sizeof(cpw)); + break; + +#if !(defined(WIN32) || defined(NETWARE)) + case ALG_CRYPT: + default: + (void) srand((int) time((time_t *) NULL)); + to64(&salt[0], rand(), 8); + salt[8] = '\0'; + + apr_cpystrn(cpw, (char *)crypt(pw, salt), sizeof(cpw) - 1); + break; +#endif + } + memset(pw, '\0', strlen(pw)); + + /* + * Check to see if the buffer is large enough to hold the username, + * hash, and delimiters. + */ + if ((strlen(user) + 1 + strlen(cpw)) > (rlen - 1)) { + apr_cpystrn(record, "resultant record too long", (rlen - 1)); + return ERR_OVERFLOW; + } + strcpy(record, user); + strcat(record, ":"); + strcat(record, cpw); + strcat(record, "\n"); + return 0; +} + +static void usage(void) +{ + apr_file_printf(errfile, "Usage:\n"); + apr_file_printf(errfile, "\thtpasswd [-cmdpsD] passwordfile username\n"); + apr_file_printf(errfile, "\thtpasswd -b[cmdpsD] passwordfile username " + "password\n\n"); + apr_file_printf(errfile, "\thtpasswd -n[mdps] username\n"); + apr_file_printf(errfile, "\thtpasswd -nb[mdps] username password\n"); + apr_file_printf(errfile, " -c Create a new file.\n"); + apr_file_printf(errfile, " -n Don't update file; display results on " + "stdout.\n"); + apr_file_printf(errfile, " -m Force MD5 encryption of the password" +#if defined(WIN32) || defined(TPF) || defined(NETWARE) + " (default)" +#endif + ".\n"); + apr_file_printf(errfile, " -d Force CRYPT encryption of the password" +#if (!(defined(WIN32) || defined(TPF) || defined(NETWARE))) + " (default)" +#endif + ".\n"); + apr_file_printf(errfile, " -p Do not encrypt the password (plaintext).\n"); + apr_file_printf(errfile, " -s Force SHA encryption of the password.\n"); + apr_file_printf(errfile, " -b Use the password from the command line " + "rather than prompting for it.\n"); + apr_file_printf(errfile, " -D Delete the specified user.\n"); + apr_file_printf(errfile, + "On Windows, NetWare and TPF systems the '-m' flag is used by " + "default.\n"); + apr_file_printf(errfile, + "On all other systems, the '-p' flag will probably not work.\n"); + exit(ERR_SYNTAX); +} + +/* + * Check to see if the specified file can be opened for the given + * access. + */ +static int accessible(apr_pool_t *pool, char *fname, int mode) +{ + apr_file_t *f = NULL; + + if (apr_file_open(&f, fname, mode, APR_OS_DEFAULT, pool) != APR_SUCCESS) { + return 0; + } + apr_file_close(f); + return 1; +} + +/* + * Return true if the named file exists, regardless of permissions. + */ +static int exists(char *fname, apr_pool_t *pool) +{ + apr_finfo_t sbuf; + apr_status_t check; + + check = apr_stat(&sbuf, fname, APR_FINFO_TYPE, pool); + return ((check || sbuf.filetype != APR_REG) ? 0 : 1); +} + +static void terminate(void) +{ + apr_terminate(); +#ifdef NETWARE + pressanykey(); +#endif +} + +static void check_args(apr_pool_t *pool, int argc, const char *const argv[], + int *alg, int *mask, char **user, char **pwfilename, + char **password) +{ + const char *arg; + int args_left = 2; + int i; + + /* + * Preliminary check to make sure they provided at least + * three arguments, we'll do better argument checking as + * we parse the command line. + */ + if (argc < 3) { + usage(); + } + + /* + * Go through the argument list and pick out any options. They + * have to precede any other arguments. + */ + for (i = 1; i < argc; i++) { + arg = argv[i]; + if (*arg != '-') { + break; + } + while (*++arg != '\0') { + if (*arg == 'c') { + *mask |= APHTP_NEWFILE; + } + else if (*arg == 'n') { + *mask |= APHTP_NOFILE; + args_left--; + } + else if (*arg == 'm') { + *alg = ALG_APMD5; + } + else if (*arg == 's') { + *alg = ALG_APSHA; + } + else if (*arg == 'p') { + *alg = ALG_PLAIN; + } + else if (*arg == 'd') { + *alg = ALG_CRYPT; + } + else if (*arg == 'b') { + *mask |= APHTP_NONINTERACTIVE; + args_left++; + } + else if (*arg == 'D') { + *mask |= APHTP_DELUSER; + } + else { + usage(); + } + } + } + + if ((*mask & APHTP_NEWFILE) && (*mask & APHTP_NOFILE)) { + apr_file_printf(errfile, "%s: -c and -n options conflict\n", argv[0]); + exit(ERR_SYNTAX); + } + if ((*mask & APHTP_NEWFILE) && (*mask & APHTP_DELUSER)) { + apr_file_printf(errfile, "%s: -c and -D options conflict\n", argv[0]); + exit(ERR_SYNTAX); + } + if ((*mask & APHTP_NOFILE) && (*mask & APHTP_DELUSER)) { + apr_file_printf(errfile, "%s: -n and -D options conflict\n", argv[0]); + exit(ERR_SYNTAX); + } + /* + * Make sure we still have exactly the right number of arguments left + * (the filename, the username, and possibly the password if -b was + * specified). + */ + if ((argc - i) != args_left) { + usage(); + } + + if (*mask & APHTP_NOFILE) { + i--; + } + else { + if (strlen(argv[i]) > (APR_PATH_MAX - 1)) { + apr_file_printf(errfile, "%s: filename too long\n", argv[0]); + exit(ERR_OVERFLOW); + } + *pwfilename = apr_pstrdup(pool, argv[i]); + if (strlen(argv[i + 1]) > (MAX_STRING_LEN - 1)) { + apr_file_printf(errfile, "%s: username too long (> %d)\n", + argv[0], MAX_STRING_LEN - 1); + exit(ERR_OVERFLOW); + } + } + *user = apr_pstrdup(pool, argv[i + 1]); + if ((arg = strchr(*user, ':')) != NULL) { + apr_file_printf(errfile, "%s: username contains illegal " + "character '%c'\n", argv[0], *arg); + exit(ERR_BADUSER); + } + if (*mask & APHTP_NONINTERACTIVE) { + if (strlen(argv[i + 2]) > (MAX_STRING_LEN - 1)) { + apr_file_printf(errfile, "%s: password too long (> %d)\n", + argv[0], MAX_STRING_LEN); + exit(ERR_OVERFLOW); + } + *password = apr_pstrdup(pool, argv[i + 2]); + } +} + +/* + * Let's do it. We end up doing a lot of file opening and closing, + * but what do we care? This application isn't run constantly. + */ +int main(int argc, const char * const argv[]) +{ + apr_file_t *fpw = NULL; + char record[MAX_STRING_LEN]; + char line[MAX_STRING_LEN]; + char *password = NULL; + char *pwfilename = NULL; + char *user = NULL; + char tn[] = "htpasswd.tmp.XXXXXX"; + char *dirname; + char *scratch, cp[MAX_STRING_LEN]; + int found = 0; + int i; + int alg = ALG_CRYPT; + int mask = 0; + apr_pool_t *pool; + int existing_file = 0; +#if APR_CHARSET_EBCDIC + apr_status_t rv; + apr_xlate_t *to_ascii; +#endif + + apr_app_initialize(&argc, &argv, NULL); + atexit(terminate); + apr_pool_create(&pool, NULL); + apr_file_open_stderr(&errfile, pool); + +#if APR_CHARSET_EBCDIC + rv = apr_xlate_open(&to_ascii, "ISO8859-1", APR_DEFAULT_CHARSET, pool); + if (rv) { + apr_file_printf(errfile, "apr_xlate_open(to ASCII)->%d\n", rv); + exit(1); + } + rv = apr_SHA1InitEBCDIC(to_ascii); + if (rv) { + apr_file_printf(errfile, "apr_SHA1InitEBCDIC()->%d\n", rv); + exit(1); + } + rv = apr_MD5InitEBCDIC(to_ascii); + if (rv) { + apr_file_printf(errfile, "apr_MD5InitEBCDIC()->%d\n", rv); + exit(1); + } +#endif /*APR_CHARSET_EBCDIC*/ + + check_args(pool, argc, argv, &alg, &mask, &user, &pwfilename, &password); + + +#if defined(WIN32) || defined(NETWARE) + if (alg == ALG_CRYPT) { + alg = ALG_APMD5; + apr_file_printf(errfile, "Automatically using MD5 format.\n"); + } +#endif + +#if (!(defined(WIN32) || defined(TPF) || defined(NETWARE))) + if (alg == ALG_PLAIN) { + apr_file_printf(errfile,"Warning: storing passwords as plain text " + "might just not work on this platform.\n"); + } +#endif + + /* + * Only do the file checks if we're supposed to frob it. + */ + if (!(mask & APHTP_NOFILE)) { + existing_file = exists(pwfilename, pool); + if (existing_file) { + /* + * Check that this existing file is readable and writable. + */ + if (!accessible(pool, pwfilename, APR_READ | APR_APPEND)) { + apr_file_printf(errfile, "%s: cannot open file %s for " + "read/write access\n", argv[0], pwfilename); + exit(ERR_FILEPERM); + } + } + else { + /* + * Error out if -c was omitted for this non-existant file. + */ + if (!(mask & APHTP_NEWFILE)) { + apr_file_printf(errfile, + "%s: cannot modify file %s; use '-c' to create it\n", + argv[0], pwfilename); + exit(ERR_FILEPERM); + } + /* + * As it doesn't exist yet, verify that we can create it. + */ + if (!accessible(pool, pwfilename, APR_CREATE | APR_WRITE)) { + apr_file_printf(errfile, "%s: cannot create file %s\n", + argv[0], pwfilename); + exit(ERR_FILEPERM); + } + } + } + + /* + * All the file access checks (if any) have been made. Time to go to work; + * try to create the record for the username in question. If that + * fails, there's no need to waste any time on file manipulations. + * Any error message text is returned in the record buffer, since + * the mkrecord() routine doesn't have access to argv[]. + */ + if (!(mask & APHTP_DELUSER)) { + i = mkrecord(user, record, sizeof(record) - 1, + password, alg); + if (i != 0) { + apr_file_printf(errfile, "%s: %s\n", argv[0], record); + exit(i); + } + if (mask & APHTP_NOFILE) { + printf("%s\n", record); + exit(0); + } + } + + /* + * We can access the files the right way, and we have a record + * to add or update. Let's do it.. + */ + if (apr_temp_dir_get((const char**)&dirname, pool) != APR_SUCCESS) { + apr_file_printf(errfile, "%s: could not determine temp dir\n", + argv[0]); + exit(ERR_FILEPERM); + } + dirname = apr_psprintf(pool, "%s/%s", dirname, tn); + + if (apr_file_mktemp(&ftemp, dirname, 0, pool) != APR_SUCCESS) { + apr_file_printf(errfile, "%s: unable to create temporary file %s\n", + argv[0], dirname); + exit(ERR_FILEPERM); + } + + /* + * If we're not creating a new file, copy records from the existing + * one to the temporary file until we find the specified user. + */ + if (existing_file && !(mask & APHTP_NEWFILE)) { + if (apr_file_open(&fpw, pwfilename, APR_READ | APR_BUFFERED, + APR_OS_DEFAULT, pool) != APR_SUCCESS) { + apr_file_printf(errfile, "%s: unable to read file %s\n", + argv[0], pwfilename); + exit(ERR_FILEPERM); + } + while (apr_file_gets(line, sizeof(line), fpw) == APR_SUCCESS) { + char *colon; + + strcpy(cp, line); + scratch = cp; + while (apr_isspace(*scratch)) { + ++scratch; + } + + if (!*scratch || (*scratch == '#')) { + putline(ftemp, line); + continue; + } + /* + * See if this is our user. + */ + colon = strchr(scratch, ':'); + if (colon != NULL) { + *colon = '\0'; + } + else { + /* + * If we've not got a colon on the line, this could well + * not be a valid htpasswd file. + * We should bail at this point. + */ + apr_file_printf(errfile, "\n%s: The file %s does not appear " + "to be a valid htpasswd file.\n", + argv[0], pwfilename); + apr_file_close(fpw); + exit(ERR_INVALID); + } + if (strcmp(user, scratch) != 0) { + putline(ftemp, line); + continue; + } + else { + if (!(mask & APHTP_DELUSER)) { + /* We found the user we were looking for. + * Add him to the file. + */ + apr_file_printf(errfile, "Updating "); + putline(ftemp, record); + found++; + } + else { + /* We found the user we were looking for. + * Delete them from the file. + */ + apr_file_printf(errfile, "Deleting "); + found++; + } + } + } + apr_file_close(fpw); + } + if (!found && !(mask & APHTP_DELUSER)) { + apr_file_printf(errfile, "Adding "); + putline(ftemp, record); + } + else if (!found && (mask & APHTP_DELUSER)) { + apr_file_printf(errfile, "User %s not found\n", user); + exit(0); + } + apr_file_printf(errfile, "password for user %s\n", user); + + /* The temporary file has all the data, just copy it to the new location. + */ + if (apr_file_copy(dirname, pwfilename, APR_FILE_SOURCE_PERMS, pool) != + APR_SUCCESS) { + apr_file_printf(errfile, "%s: unable to update file %s\n", + argv[0], pwfilename); + exit(ERR_FILEPERM); + } + apr_file_close(ftemp); + return 0; +} diff --git a/rubbos/app/httpd-2.0.64/support/htpasswd.dsp b/rubbos/app/httpd-2.0.64/support/htpasswd.dsp new file mode 100644 index 00000000..15bbbdb2 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htpasswd.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="htpasswd" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=htpasswd - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "htpasswd.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "htpasswd.mak" CFG="htpasswd - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "htpasswd - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "htpasswd - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "htpasswd - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/htpasswd_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "htpasswd - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/htpasswd_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "htpasswd - Win32 Release" +# Name "htpasswd - Win32 Debug" +# Begin Source File + +SOURCE=.\htpasswd.c +# End Source File +# Begin Source File + +SOURCE=.\htpasswd.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "htpasswd - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htpasswd.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htpasswd.exe "htpasswd Utility" ../include/ap_release.h > .\htpasswd.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "htpasswd - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\htpasswd.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk htpasswd.exe "htpasswd Utility" ../include/ap_release.h > .\htpasswd.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/htpasswd.lo b/rubbos/app/httpd-2.0.64/support/htpasswd.lo new file mode 100644 index 00000000..7c0845ea --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htpasswd.lo @@ -0,0 +1,12 @@ +# htpasswd.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/htpasswd.o' + +# Name of the non-PIC object. +non_pic_object='htpasswd.o' + diff --git a/rubbos/app/httpd-2.0.64/support/htpasswd.o b/rubbos/app/httpd-2.0.64/support/htpasswd.o Binary files differnew file mode 100644 index 00000000..da73e002 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/htpasswd.o diff --git a/rubbos/app/httpd-2.0.64/support/httxt2dbm b/rubbos/app/httpd-2.0.64/support/httxt2dbm new file mode 100755 index 00000000..61ed535c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/httxt2dbm @@ -0,0 +1,131 @@ +#! /bin/bash + +# httxt2dbm - temporary wrapper script for .libs/httxt2dbm +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The httxt2dbm program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/httxt2dbm.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'httxt2dbm' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/httxt2dbm.c b/rubbos/app/httpd-2.0.64/support/httxt2dbm.c new file mode 100644 index 00000000..ea61b39c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/httxt2dbm.c @@ -0,0 +1,336 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * httxt2dbm.c: simple program for converting RewriteMap text files to DBM + * Rewrite databases for the Apache HTTP server + * + */ + +#include "apr.h" +#include "apr_lib.h" +#include "apr_strings.h" +#include "apr_file_io.h" +#include "apr_file_info.h" +#include "apr_pools.h" +#include "apr_getopt.h" +#include "apu.h" +#include "apr_dbm.h" + +#if APR_HAVE_STDLIB_H +#include <stdlib.h> /* for atexit() */ +#endif + +static const char *input; +static const char *output; +static const char *format; +static const char *shortname; +static apr_file_t *errfile; +static char errbuf[120]; +static int verbose; + +/* From mod_rewrite.c */ +#ifndef REWRITE_MAX_TXT_MAP_LINE +#define REWRITE_MAX_TXT_MAP_LINE 1024 +#endif + +#define NL APR_EOL_STR + +#define AVAIL "available" +#define UNAVAIL "unavailable" + +static void usage(void) +{ + const char *have_sdbm; + const char *have_gdbm; + const char *have_ndbm; + const char *have_db; + +#if APU_HAVE_SDBM + have_sdbm = AVAIL; +#else + have_sdbm = UNAVAIL; +#endif +#if APU_HAVE_GDBM + have_gdbm = AVAIL; +#else + have_gdbm = UNAVAIL; +#endif +#if APU_HAVE_NDBM + have_ndbm = AVAIL; +#else + have_ndbm = UNAVAIL; +#endif +#if APU_HAVE_DB + have_db = AVAIL; +#else + have_db = UNAVAIL; +#endif + + apr_file_printf(errfile, + "%s -- Program to Create DBM Files for use by RewriteMap" NL + "Usage: %s [-v] [-f format] -i SOURCE_TXT -o OUTPUT_DBM" NL + NL + "Options: " NL + " -v More verbose output"NL + NL + " -i Source Text File. If '-', use stdin."NL + NL + " -o Output DBM."NL + NL + " -f DBM Format. If not specified, will use the APR Default." NL + " GDBM for GDBM files (%s)" NL + " SDBM for SDBM files (%s)" NL + " DB for berkeley DB files (%s)" NL + " NDBM for NDBM files (%s)" NL + " default for the default DBM type" NL + NL, + shortname, + shortname, + have_gdbm, + have_sdbm, + have_db, + have_ndbm); +} + + +static apr_status_t to_dbm(apr_dbm_t *dbm, apr_file_t *fp, apr_pool_t *pool) +{ + apr_status_t rv = APR_SUCCESS; + char line[REWRITE_MAX_TXT_MAP_LINE + 1]; /* +1 for \0 */ + apr_datum_t dbmkey; + apr_datum_t dbmval; + apr_pool_t* p; + + apr_pool_create(&p, pool); + + while (apr_file_gets(line, sizeof(line), fp) == APR_SUCCESS) { + char *c, *value; + + if (*line == '#' || apr_isspace(*line)) { + continue; + } + + c = line; + + while (*c && !apr_isspace(*c)) { + ++c; + } + + if (!*c) { + /* no value. solid line of data. */ + continue; + } + + dbmkey.dptr = apr_pstrmemdup(p, line, c - line); + dbmkey.dsize = (c - line); + + while (*c && apr_isspace(*c)) { + ++c; + } + + if (!*c) { + apr_pool_clear(p); + continue; + } + + value = c; + + while (*c && !apr_isspace(*c)) { + ++c; + } + + dbmval.dptr = apr_pstrmemdup(p, value, c - value); + dbmval.dsize = (c - line); + + if (verbose) { + apr_file_printf(errfile, " '%s' -> '%s'"NL, + dbmkey.dptr, dbmval.dptr); + } + + rv = apr_dbm_store(dbm, dbmkey, dbmval); + + apr_pool_clear(p); + + if (rv != APR_SUCCESS) { + break; + } + } + + return rv; +} + +int main(int argc, const char *const argv[]) +{ + apr_pool_t *pool; + apr_status_t rv = APR_SUCCESS; + apr_getopt_t *opt; + const char *optarg; + char ch; + apr_file_t *infile; + apr_dbm_t *outdbm; + + apr_initialize(); + atexit(apr_terminate); + + verbose = 0; + format = NULL; + input = NULL; + output = NULL; + + apr_pool_create(&pool, NULL); + + if (argc) { + shortname = apr_filepath_name_get(argv[0]); + } + else { + shortname = "httxt2dbm"; + } + + apr_file_open_stderr(&errfile, pool); + rv = apr_getopt_init(&opt, pool, argc, argv); + + if (rv != APR_SUCCESS) { + apr_file_printf(errfile, "Error: apr_getopt_init failed."NL NL); + return 1; + } + + if (argc <= 1) { + usage(); + return 1; + } + + while ((rv = apr_getopt(opt, "vf::i::o::", &ch, &optarg)) == APR_SUCCESS) { + switch (ch) { + case 'v': + if (verbose) { + apr_file_printf(errfile, "Error: -v can only be passed once" NL NL); + usage(); + return 1; + } + verbose = 1; + break; + case 'f': + if (format) { + apr_file_printf(errfile, "Error: -f can only be passed once" NL NL); + usage(); + return 1; + } + format = apr_pstrdup(pool, optarg); + break; + case 'i': + if (input) { + apr_file_printf(errfile, "Error: -i can only be passed once" NL NL); + usage(); + return 1; + } + input = apr_pstrdup(pool, optarg); + break; + case 'o': + if (output) { + apr_file_printf(errfile, "Error: -o can only be passed once" NL NL); + usage(); + return 1; + } + output = apr_pstrdup(pool, optarg); + break; + } + } + + if (rv != APR_EOF) { + apr_file_printf(errfile, "Error: Parsing Arguments Failed" NL NL); + usage(); + return 1; + } + + if (!input) { + apr_file_printf(errfile, "Error: No input file specified." NL NL); + usage(); + return 1; + } + + if (!output) { + apr_file_printf(errfile, "Error: No output DBM specified." NL NL); + usage(); + return 1; + } + + if (!format) { + format = "default"; + } + + if (verbose) { + apr_file_printf(errfile, "DBM Format: %s"NL, format); + } + + if (!strcmp(input, "-")) { + rv = apr_file_open_stdin(&infile, pool); + } + else { + rv = apr_file_open(&infile, input, APR_READ|APR_BUFFERED, + APR_OS_DEFAULT, pool); + } + + if (rv != APR_SUCCESS) { + apr_file_printf(errfile, + "Error: Cannot open input file '%s': (%d) %s" NL NL, + input, rv, apr_strerror(rv, errbuf, sizeof(errbuf))); + return 1; + } + + if (verbose) { + apr_file_printf(errfile, "Input File: %s"NL, input); + } + + rv = apr_dbm_open_ex(&outdbm, format, output, APR_DBM_RWCREATE, + APR_OS_DEFAULT, pool); + + if (APR_STATUS_IS_ENOTIMPL(rv)) { + apr_file_printf(errfile, + "Error: The requested DBM Format '%s' is not available." NL NL, + format); + return 1; + } + + if (rv != APR_SUCCESS) { + apr_file_printf(errfile, + "Error: Cannot open output DBM '%s': (%d) %s" NL NL, + output, rv, apr_strerror(rv, errbuf, sizeof(errbuf))); + return 1; + } + + if (verbose) { + apr_file_printf(errfile, "DBM File: %s"NL, output); + } + + rv = to_dbm(outdbm, infile, pool); + + if (rv != APR_SUCCESS) { + apr_file_printf(errfile, + "Error: Converting to DBM: (%d) %s" NL NL, + rv, apr_strerror(rv, errbuf, sizeof(errbuf))); + return 1; + } + + apr_dbm_close(outdbm); + + if (verbose) { + apr_file_printf(errfile, "Conversion Complete." NL); + } + + return 0; +} + diff --git a/rubbos/app/httpd-2.0.64/support/httxt2dbm.dsp b/rubbos/app/httpd-2.0.64/support/httxt2dbm.dsp new file mode 100644 index 00000000..53b78309 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/httxt2dbm.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="httxt2dbm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=httxt2dbm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "httxt2dbm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "httxt2dbm.mak" CFG="httxt2dbm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "httxt2dbm - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "httxt2dbm - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "httxt2dbm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/httxt2dbm_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "httxt2dbm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/httxt2dbm_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "httxt2dbm - Win32 Release" +# Name "httxt2dbm - Win32 Debug" +# Begin Source File + +SOURCE=.\httxt2dbm.c +# End Source File +# Begin Source File + +SOURCE=.\httxt2dbm.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "httxt2dbm - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\httxt2dbm.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk httxt2dbm.exe "httxt2dbm Utility" ../include/ap_release.h > .\httxt2dbm.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "httxt2dbm - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\httxt2dbm.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk httxt2dbm.exe "httxt2dbm Utility" ../include/ap_release.h > .\httxt2dbm.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/httxt2dbm.lo b/rubbos/app/httpd-2.0.64/support/httxt2dbm.lo new file mode 100644 index 00000000..7b4f8e07 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/httxt2dbm.lo @@ -0,0 +1,12 @@ +# httxt2dbm.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/httxt2dbm.o' + +# Name of the non-PIC object. +non_pic_object='httxt2dbm.o' + diff --git a/rubbos/app/httpd-2.0.64/support/httxt2dbm.o b/rubbos/app/httpd-2.0.64/support/httxt2dbm.o Binary files differnew file mode 100644 index 00000000..1e12f6c8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/httxt2dbm.o diff --git a/rubbos/app/httpd-2.0.64/support/list_hooks.pl b/rubbos/app/httpd-2.0.64/support/list_hooks.pl new file mode 100755 index 00000000..cb863db7 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/list_hooks.pl @@ -0,0 +1,101 @@ +#!/usr/bin/perl -w +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +use strict; + +use Carp; + +my $path=shift || '.'; + +findInDir($path); + +foreach my $hook (sort keys %::Hooks) { + my $h=$::Hooks{$hook}; + for my $x (qw(declared implemented type args)) { + print "$hook datum '$x' missing\n" if !exists $h->{$x}; + } + print "$hook\n"; + print " declared in $h->{declared}\n" if defined $h->{declared}; + print " implemented in $h->{implemented}\n" if defined $h->{implemented}; + print " type is $h->{type}\n" if defined $h->{type}; + print " $h->{ret} $hook($h->{args})\n" if defined $h->{args}; + print "\n"; +} + +sub findInDir { + my $path=shift; + + local(*D); + opendir(D,$path) || croak "Can't open $path: $!"; + while(my $f=readdir D) { + next if $f=~/^\./; + my $file="$path/$f"; + + if(-d $file) { + findInDir($file); + next; + } + next if $file !~ /\.[ch]$/; + + scanFile($file); + } + closedir D; +} + +sub scanFile { + my $file=shift; + +# print "scanning $file\n"; + + open(F,$file) || croak "Can't open $file: $!"; + while(<F>) { + next if /\#define/; + next if /\@deffunc/; + if(/AP_DECLARE_HOOK\((.*)\)/) { + my $def=$1; + my($ret,$name,$args)=$def=~/([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*\((.*)\)/; + croak "Don't understand $def in $file" if !defined $args; +# print "found $ret $name($args) in $file\n"; + + croak "$name declared twice! ($_)" + if exists $::Hooks{$name}->{declared}; + $::Hooks{$name}->{declared}=$file; + $::Hooks{$name}->{ret}=$ret; + $::Hooks{$name}->{args}=$args; + } elsif(/AP_DECLARE_HOOK\((\s*[^,\s]+)\s*,\s*([^,\s]+)/) { +# really we should swallow subsequent lines to get the arguments... + my $name=$2; + my $ret=$1; + croak "$name declared twice! ($_)" + if exists $::Hooks{$name}->{declared}; + $::Hooks{$name}->{declared}=$file; + $::Hooks{$name}->{ret}=$ret; + $::Hooks{$name}->{args}='???'; + } + if(/AP_IMPLEMENT_HOOK_()(VOID)\(([^,\s]+)/ + || /AP_IMPLEMENT(_OPTIONAL|)_HOOK_(.*?)\([^,]+?\s*,\s*([^,\s]+)/) { + my($type,$name)=($1 ? "OPTIONAL $2" : $2,$3); + +# print "found $name $type in $file\n"; + + croak "$name implemented twice ($::Hooks{$name}->{implemented} and $file) ($_)" + if exists $::Hooks{$name}->{implemented}; + $::Hooks{$name}->{implemented}=$file; + $::Hooks{$name}->{type}=$type; + } + } +} diff --git a/rubbos/app/httpd-2.0.64/support/log_server_status b/rubbos/app/httpd-2.0.64/support/log_server_status new file mode 100644 index 00000000..e8320f64 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/log_server_status @@ -0,0 +1,78 @@ +#!/usr/bin/perl +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# Log Server Status +# Mark J Cox, UK Web Ltd 1996, mark@ukweb.com +# +# This script is designed to be run at a frequent interval by something +# like cron. It connects to the server and downloads the status +# information. It reformats the information to a single line and logs +# it to a file. Make sure the directory $wherelog is writable by the +# user who runs this script. +# +require 'sys/socket.ph'; + +$wherelog = "/var/log/graph/"; # Logs will be like "/var/log/graph/19960312" +$server = "localhost"; # Name of server, could be "www.foo.com" +$port = "80"; # Port on server +$request = "/status/?auto"; # Request to send + +sub tcp_connect +{ + local($host,$port) =@_; + $sockaddr='S n a4 x8'; + chop($hostname=`hostname`); + $port=(getservbyname($port, 'tcp'))[2] unless $port =~ /^\d+$/; + $me=pack($sockaddr,&AF_INET,0,(gethostbyname($hostname))[4]); + $them=pack($sockaddr,&AF_INET,$port,(gethostbyname($host))[4]); + socket(S,&PF_INET,&SOCK_STREAM,(getprotobyname('tcp'))[2]) || + die "socket: $!"; + bind(S,$me) || return "bind: $!"; + connect(S,$them) || return "connect: $!"; + select(S); + $| = 1; + select(stdout); + return ""; +} + +### Main + +{ + $year=`date +%y`; + chomp($year); + $year += ($year < 70) ? 2000 : 1900; + $date = $year . `date +%m%d:%H%M%S`; + chomp($date); + ($day,$time)=split(/:/,$date); + $res=&tcp_connect($server,$port); + open(OUT,">>$wherelog$day"); + if ($res) { + print OUT "$time:-1:-1:-1:-1:$res\n"; + exit 1; + } + print S "GET $request\n"; + while (<S>) { + $requests=$1 if ( m|^BusyServers:\ (\S+)|); + $idle=$1 if ( m|^IdleServers:\ (\S+)|); + $number=$1 if ( m|sses:\ (\S+)|); + $cpu=$1 if (m|^CPULoad:\ (\S+)|); + } + print OUT "$time:$requests:$idle:$number:$cpu\n"; +} + + diff --git a/rubbos/app/httpd-2.0.64/support/log_server_status.in b/rubbos/app/httpd-2.0.64/support/log_server_status.in new file mode 100644 index 00000000..2268df29 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/log_server_status.in @@ -0,0 +1,78 @@ +#!@perlbin@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# Log Server Status +# Mark J Cox, UK Web Ltd 1996, mark@ukweb.com +# +# This script is designed to be run at a frequent interval by something +# like cron. It connects to the server and downloads the status +# information. It reformats the information to a single line and logs +# it to a file. Make sure the directory $wherelog is writable by the +# user who runs this script. +# +require 'sys/socket.ph'; + +$wherelog = "/var/log/graph/"; # Logs will be like "/var/log/graph/19960312" +$server = "localhost"; # Name of server, could be "www.foo.com" +$port = "80"; # Port on server +$request = "/status/?auto"; # Request to send + +sub tcp_connect +{ + local($host,$port) =@_; + $sockaddr='S n a4 x8'; + chop($hostname=`hostname`); + $port=(getservbyname($port, 'tcp'))[2] unless $port =~ /^\d+$/; + $me=pack($sockaddr,&AF_INET,0,(gethostbyname($hostname))[4]); + $them=pack($sockaddr,&AF_INET,$port,(gethostbyname($host))[4]); + socket(S,&PF_INET,&SOCK_STREAM,(getprotobyname('tcp'))[2]) || + die "socket: $!"; + bind(S,$me) || return "bind: $!"; + connect(S,$them) || return "connect: $!"; + select(S); + $| = 1; + select(stdout); + return ""; +} + +### Main + +{ + $year=`date +%y`; + chomp($year); + $year += ($year < 70) ? 2000 : 1900; + $date = $year . `date +%m%d:%H%M%S`; + chomp($date); + ($day,$time)=split(/:/,$date); + $res=&tcp_connect($server,$port); + open(OUT,">>$wherelog$day"); + if ($res) { + print OUT "$time:-1:-1:-1:-1:$res\n"; + exit 1; + } + print S "GET $request\n"; + while (<S>) { + $requests=$1 if ( m|^BusyServers:\ (\S+)|); + $idle=$1 if ( m|^IdleServers:\ (\S+)|); + $number=$1 if ( m|sses:\ (\S+)|); + $cpu=$1 if (m|^CPULoad:\ (\S+)|); + } + print OUT "$time:$requests:$idle:$number:$cpu\n"; +} + + diff --git a/rubbos/app/httpd-2.0.64/support/logresolve b/rubbos/app/httpd-2.0.64/support/logresolve new file mode 100755 index 00000000..5f4eaa20 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve @@ -0,0 +1,131 @@ +#! /bin/bash + +# logresolve - temporary wrapper script for .libs/logresolve +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The logresolve program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/logresolve.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'logresolve' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.c b/rubbos/app/httpd-2.0.64/support/logresolve.c new file mode 100644 index 00000000..c606039b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.c @@ -0,0 +1,400 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * logresolve 1.1 + * + * Tom Rathborne - tomr@uunet.ca - http://www.uunet.ca/~tomr/ + * UUNET Canada, April 16, 1995 + * + * Rewritten by David Robinson. (drtr ast.cam.ac.uk) + * + * Usage: logresolve [-s filename] [-c] < access_log > new_log + * + * Arguments: + * -s filename name of a file to record statistics + * -c check the DNS for a matching A record for the host. + * + * Notes: + * + * To generate meaningful statistics from an HTTPD log file, it's good + * to have the domain name of each machine that accessed your site, but + * doing this on the fly can slow HTTPD down. + * + * Compiling NCSA HTTPD with the -DMINIMAL_DNS flag turns IP#->hostname + * resolution off. Before running your stats program, just run your log + * file through this program (logresolve) and all of your IP numbers will + * be resolved into hostnames (where possible). + * + * logresolve takes an HTTPD access log (in the COMMON log file format, + * or any other format that has the IP number/domain name as the first + * field for that matter), and outputs the same file with all of the + * domain names looked up. Where no domain name can be found, the IP + * number is left in. + * + * To minimize impact on your nameserver, logresolve has its very own + * internal hash-table cache. This means that each IP number will only + * be looked up the first time it is found in the log file. + * + * The -c option causes logresolve to apply the same check as httpd + * compiled with -DMAXIMUM_DNS; after finding the hostname from the IP + * address, it looks up the IP addresses for the hostname and checks + * that one of these matches the original address. + */ + +#include "apr_lib.h" +#if APR_HAVE_STDIO_H +#include <stdio.h> +#endif +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if APR_HAVE_CTYPE_H +#include <ctype.h> +#endif +#if APR_HAVE_NETDB_H +#include <netdb.h> +#endif +#if APR_HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#if APR_HAVE_STRING_H +#include <string.h> +#endif +#if APR_HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#if APR_HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif + +static void cgethost(struct in_addr ipnum, char *string, int check); +static int get_line(char *s, int n); +static void stats(FILE *output); + +#ifdef BEOS +#define NO_ADDRESS NO_DATA +#endif + + +/* maximum line length */ +#ifndef MAXLINE +#define MAXLINE 1024 +#endif + +/* maximum length of a domain name */ +#ifndef MAXDNAME +#define MAXDNAME 256 +#endif + +/* number of buckets in cache hash apr_table_t */ +#define BUCKETS 256 + +#if !APR_HAVE_STRDUP +char *strdup (const char *str) +{ + char *dup; + + if (!(dup = (char *) malloc(strlen(str) + 1))) + return NULL; + dup = strcpy(dup, str); + + return dup; +} +#endif + +/* + * struct nsrec - record of nameservice for cache linked list + * + * ipnum - IP number hostname - hostname noname - nonzero if IP number has no + * hostname, i.e. hostname=IP number + */ + +struct nsrec { + struct in_addr ipnum; + char *hostname; + int noname; + struct nsrec *next; +} *nscache[BUCKETS]; + +/* + * statistics - obvious + */ + +#ifndef h_errno +#ifdef __CYGWIN__ +extern __declspec(dllimport) int h_errno; +#else +extern int h_errno; /* some machines don't have this in their headers */ +#endif +#endif + +/* largest value for h_errno */ + +#define MAX_ERR (NO_ADDRESS) +#define UNKNOWN_ERR (MAX_ERR+1) +#define NO_REVERSE (MAX_ERR+2) + +static int cachehits = 0; +static int cachesize = 0; +static int entries = 0; +static int resolves = 0; +static int withname = 0; +static int errors[MAX_ERR + 3]; + +/* + * cgethost - gets hostname by IP address, caching, and adding unresolvable + * IP numbers with their IP number as hostname, setting noname flag + */ + +static void cgethost (struct in_addr ipnum, char *string, int check) +{ + struct nsrec **current, *new; + struct hostent *hostdata; + char *name; + + current = &nscache[((ipnum.s_addr + (ipnum.s_addr >> 8) + + (ipnum.s_addr >> 16) + (ipnum.s_addr >> 24)) % BUCKETS)]; + + while (*current != NULL && ipnum.s_addr != (*current)->ipnum.s_addr) + current = &(*current)->next; + + if (*current == NULL) { + cachesize++; + new = (struct nsrec *) malloc(sizeof(struct nsrec)); + if (new == NULL) { + perror("malloc"); + fprintf(stderr, "Insufficient memory\n"); + exit(1); + } + *current = new; + new->next = NULL; + + new->ipnum = ipnum; + + hostdata = gethostbyaddr((const char *) &ipnum, sizeof(struct in_addr), + AF_INET); + if (hostdata == NULL) { + if (h_errno > MAX_ERR) + errors[UNKNOWN_ERR]++; + else + errors[h_errno]++; + new->noname = h_errno; + name = strdup(inet_ntoa(ipnum)); + } + else { + new->noname = 0; + name = strdup(hostdata->h_name); + if (check) { + if (name == NULL) { + perror("strdup"); + fprintf(stderr, "Insufficient memory\n"); + exit(1); + } + hostdata = gethostbyname(name); + if (hostdata != NULL) { + char **hptr; + + for (hptr = hostdata->h_addr_list; *hptr != NULL; hptr++) + if (((struct in_addr *) (*hptr))->s_addr == ipnum.s_addr) + break; + if (*hptr == NULL) + hostdata = NULL; + } + if (hostdata == NULL) { + fprintf(stderr, "Bad host: %s != %s\n", name, + inet_ntoa(ipnum)); + new->noname = NO_REVERSE; + free(name); + name = strdup(inet_ntoa(ipnum)); + errors[NO_REVERSE]++; + } + } + } + new->hostname = name; + if (new->hostname == NULL) { + perror("strdup"); + fprintf(stderr, "Insufficient memory\n"); + exit(1); + } + } + else + cachehits++; + + /* size of string == MAXDNAME +1 */ + strncpy(string, (*current)->hostname, MAXDNAME); + string[MAXDNAME] = '\0'; +} + +/* + * prints various statistics to output + */ + +static void stats (FILE *output) +{ + int i; + char *ipstring; + struct nsrec *current; + char *errstring[MAX_ERR + 3]; + + for (i = 0; i < MAX_ERR + 3; i++) + errstring[i] = "Unknown error"; + errstring[HOST_NOT_FOUND] = "Host not found"; + errstring[TRY_AGAIN] = "Try again"; + errstring[NO_RECOVERY] = "Non recoverable error"; + errstring[NO_DATA] = "No data record"; + errstring[NO_ADDRESS] = "No address"; + errstring[NO_REVERSE] = "No reverse entry"; + + fprintf(output, "logresolve Statistics:\n"); + + fprintf(output, "Entries: %d\n", entries); + fprintf(output, " With name : %d\n", withname); + fprintf(output, " Resolves : %d\n", resolves); + if (errors[HOST_NOT_FOUND]) + fprintf(output, " - Not found : %d\n", errors[HOST_NOT_FOUND]); + if (errors[TRY_AGAIN]) + fprintf(output, " - Try again : %d\n", errors[TRY_AGAIN]); + if (errors[NO_DATA]) + fprintf(output, " - No data : %d\n", errors[NO_DATA]); + if (errors[NO_ADDRESS]) + fprintf(output, " - No address: %d\n", errors[NO_ADDRESS]); + if (errors[NO_REVERSE]) + fprintf(output, " - No reverse: %d\n", errors[NO_REVERSE]); + fprintf(output, "Cache hits : %d\n", cachehits); + fprintf(output, "Cache size : %d\n", cachesize); + fprintf(output, "Cache buckets : IP number * hostname\n"); + + for (i = 0; i < BUCKETS; i++) + for (current = nscache[i]; current != NULL; current = current->next) { + ipstring = inet_ntoa(current->ipnum); + if (current->noname == 0) + fprintf(output, " %3d %15s - %s\n", i, ipstring, + current->hostname); + else { + if (current->noname > MAX_ERR + 2) + fprintf(output, " %3d %15s : Unknown error\n", i, + ipstring); + else + fprintf(output, " %3d %15s : %s\n", i, ipstring, + errstring[current->noname]); + } + } +} + + +/* + * gets a line from stdin + */ + +static int get_line (char *s, int n) +{ + char *cp; + + if (!fgets(s, n, stdin)) + return (0); + cp = strchr(s, '\n'); + if (cp) + *cp = '\0'; + return (1); +} + +int main (int argc, char *argv[]) +{ + struct in_addr ipnum; + char *bar, hoststring[MAXDNAME + 1], line[MAXLINE], *statfile; + int i, check; + +#if defined(WIN32) || defined(NETWARE) + /* If we apr'ify this code, apr_pool_create/apr_pool_destroy + * should perform the WSAStartup/WSACleanup for us. + */ + WSADATA wsaData; + WSAStartup(MAKEWORD(2, 0), &wsaData); +#endif + + check = 0; + statfile = NULL; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-c") == 0) + check = 1; + else if (strcmp(argv[i], "-s") == 0) { + if (i == argc - 1) { + fprintf(stderr, "logresolve: missing filename to -s\n"); + exit(1); + } + i++; + statfile = argv[i]; + } + else { + fprintf(stderr, "Usage: logresolve [-s statfile] [-c] < input > output\n"); + exit(0); + } + } + + for (i = 0; i < BUCKETS; i++) + nscache[i] = NULL; + for (i = 0; i < MAX_ERR + 2; i++) + errors[i] = 0; + + while (get_line(line, MAXLINE)) { + if (line[0] == '\0') + continue; + entries++; + if (!apr_isdigit(line[0])) { /* short cut */ + puts(line); + withname++; + continue; + } + bar = strchr(line, ' '); + if (bar != NULL) + *bar = '\0'; + ipnum.s_addr = inet_addr(line); + if (ipnum.s_addr == 0xffffffffu) { + if (bar != NULL) + *bar = ' '; + puts(line); + withname++; + continue; + } + + resolves++; + + cgethost(ipnum, hoststring, check); + if (bar != NULL) + printf("%s %s\n", hoststring, bar + 1); + else + puts(hoststring); + } + +#if defined(WIN32) || defined(NETWARE) + WSACleanup(); +#endif + + if (statfile != NULL) { + FILE *fp; + fp = fopen(statfile, "w"); + if (fp == NULL) { + fprintf(stderr, "logresolve: could not open statistics file '%s'\n" + ,statfile); + exit(1); + } + stats(fp); + fclose(fp); + } + + return (0); +} diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.dsp b/rubbos/app/httpd-2.0.64/support/logresolve.dsp new file mode 100644 index 00000000..d1fbcb6a --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="logresolve" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=logresolve - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "logresolve.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "logresolve.mak" CFG="logresolve - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "logresolve - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "logresolve - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "logresolve - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/logresolve_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "logresolve - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/logresolve_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "logresolve - Win32 Release" +# Name "logresolve - Win32 Debug" +# Begin Source File + +SOURCE=.\logresolve.c +# End Source File +# Begin Source File + +SOURCE=.\logresolve.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "logresolve - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\logresolve.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk logresolve.exe "logresolve Utility" ../include/ap_release.h > .\logresolve.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "logresolve - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\logresolve.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk logresolve.exe "logresolve Utility" ../include/ap_release.h > .\logresolve.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.lo b/rubbos/app/httpd-2.0.64/support/logresolve.lo new file mode 100644 index 00000000..20028ace --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.lo @@ -0,0 +1,12 @@ +# logresolve.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/logresolve.o' + +# Name of the non-PIC object. +non_pic_object='logresolve.o' + diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.o b/rubbos/app/httpd-2.0.64/support/logresolve.o Binary files differnew file mode 100644 index 00000000..a948c1d0 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.o diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.pl b/rubbos/app/httpd-2.0.64/support/logresolve.pl new file mode 100644 index 00000000..bd517b20 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.pl @@ -0,0 +1,225 @@ +#!/usr/bin/perl +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# logresolve.pl +# +# v 1.2 by robh @ imdb.com +# +# usage: logresolve.pl <infile >outfile +# +# input = Apache/NCSA/.. logfile with IP numbers at start of lines +# output = same logfile with IP addresses resolved to hostnames where +# name lookups succeeded. +# +# this differs from the C based 'logresolve' in that this script +# spawns a number ($CHILDREN) of subprocesses to resolve addresses +# concurrently and sets a short timeout ($TIMEOUT) for each lookup in +# order to keep things moving quickly. +# +# the parent process handles caching of IP->hostnames using a Perl hash +# it also avoids sending the same IP to multiple child processes to be +# resolved multiple times concurrently. +# +# Depending on the settings of $CHILDREN and $TIMEOUT you should see +# significant reductions in the overall time taken to resolve your +# logfiles. With $CHILDREN=40 and $TIMEOUT=5 I've seen 200,000 - 300,000 +# logfile lines processed per hour compared to ~45,000 per hour +# with 'logresolve'. +# +# I haven't yet seen any noticable reduction in the percentage of IPs +# that fail to get resolved. Your mileage will no doubt vary. 5s is long +# enough to wait IMO. +# +# Known to work with FreeBSD 2.2 +# Known to have problems with Solaris +# +# 980417 - use 'sockaddr_un' for bind/connect to make the script work +# with linux. Fix from Luuk de Boer <luuk_de_boer@pi.net> + +require 5.004; + +$|=1; + +use FileHandle; +use Socket; + +use strict; +no strict 'refs'; + +use vars qw($PROTOCOL); +$PROTOCOL = 0; + +my $CHILDREN = 40; +my $TIMEOUT = 5; + +my $filename; +my %hash = (); +my $parent = $$; + +my @children = (); +for (my $child = 1; $child <=$CHILDREN; $child++) { + my $f = fork(); + if (!$f) { + $filename = "./.socket.$parent.$child"; + if (-e $filename) { unlink($filename) || warn "$filename .. $!\n";} + &child($child); + exit(0); + } + push(@children, $f); +} + +&parent; +&cleanup; + +## remove all temporary files before shutting down +sub cleanup { + # die kiddies, die + kill(15, @children); + for (my $child = 1; $child <=$CHILDREN; $child++) { + if (-e "./.socket.$parent.$child") { + unlink("./.socket.$parent.$child") + || warn ".socket.$parent.$child $!"; + } + } +} + +sub parent { + # Trap some possible signals to trigger temp file cleanup + $SIG{'KILL'} = $SIG{'INT'} = $SIG{'PIPE'} = \&cleanup; + + my %CHILDSOCK; + my $filename; + + ## fork child processes. Each child will create a socket connection + ## to this parent and use an unique temp filename to do so. + for (my $child = 1; $child <=$CHILDREN; $child++) { + $CHILDSOCK{$child}= FileHandle->new; + + if (!socket($CHILDSOCK{$child}, AF_UNIX, SOCK_STREAM, $PROTOCOL)) { + warn "parent socket to child failed $!"; + } + $filename = "./.socket.$parent.$child"; + my $response; + do { + $response = connect($CHILDSOCK{$child}, sockaddr_un($filename)); + if ($response != 1) { + sleep(1); + } + } while ($response != 1); + $CHILDSOCK{$child}->autoflush; + } + ## All child processes should now be ready or at worst warming up + + my (@buffer, $child, $ip, $rest, $hostname, $response); + ## read the logfile lines from STDIN + while(<STDIN>) { + @buffer = (); # empty the logfile line buffer array. + $child = 1; # children are numbered 1..N, start with #1 + + # while we have a child to talk to and data to give it.. + do { + push(@buffer, $_); # buffer the line + ($ip, $rest) = split(/ /, $_, 2); # separate IP form rest + + unless ($hash{$ip}) { # resolve if unseen IP + $CHILDSOCK{$child}->print("$ip\n"); # pass IP to next child + $hash{$ip} = $ip; # don't look it up again. + $child++; + } + } while (($child < ($CHILDREN-1)) and ($_ = <STDIN>)); + + ## now poll each child for a response + while (--$child > 0) { + $response = $CHILDSOCK{$child}->getline; + chomp($response); + # child sends us back both the IP and HOSTNAME, no need for us + # to remember what child received any given IP, and no worries + # what order we talk to the children + ($ip, $hostname) = split(/\|/, $response, 2); + $hash{$ip} = $hostname; + } + + # resolve all the logfiles lines held in the log buffer array.. + for (my $line = 0; $line <=$#buffer; $line++) { + # get next buffered line + ($ip, $rest) = split(/ /, $buffer[$line], 2); + # separate IP from rest and replace with cached hostname + printf STDOUT ("%s %s", $hash{$ip}, $rest); + } + } +} + +######################################## + +sub child { + # arg = numeric ID - how the parent refers to me + my $me = shift; + + # add trap for alarm signals. + $SIG{'ALRM'} = sub { die "alarmed"; }; + + # create a socket to communicate with parent + socket(INBOUND, AF_UNIX, SOCK_STREAM, $PROTOCOL) + || die "Error with Socket: !$\n"; + $filename = "./.socket.$parent.$me"; + bind(INBOUND, sockaddr_un($filename)) + || die "Error Binding $filename: $!\n"; + listen(INBOUND, 5) || die "Error Listening: $!\n"; + + my ($ip, $send_back); + my $talk = FileHandle->new; + + # accept a connection from the parent process. We only ever have + # have one connection where we exchange 1 line of info with the + # parent.. 1 line in (IP address), 1 line out (IP + hostname). + accept($talk, INBOUND) || die "Error Accepting: $!\n"; + # disable I/O buffering just in case + $talk->autoflush; + # while the parent keeps sending data, we keep responding.. + while(($ip = $talk->getline)) { + chomp($ip); + # resolve the IP if time permits and send back what we found.. + $send_back = sprintf("%s|%s", $ip, &nslookup($ip)); + $talk->print($send_back."\n"); + } +} + +# perform a time restricted hostname lookup. +sub nslookup { + # get the IP as an arg + my $ip = shift; + my $hostname = undef; + + # do the hostname lookup inside an eval. The eval will use the + # already configured SIGnal handler and drop out of the {} block + # regardless of whether the alarm occured or not. + eval { + alarm($TIMEOUT); + $hostname = gethostbyaddr(gethostbyname($ip), AF_INET); + alarm(0); + }; + if ($@ =~ /alarm/) { + # useful for debugging perhaps.. + # print "alarming, isn't it? ($ip)"; + } + + # return the hostname or the IP address itself if there is no hostname + $hostname ne "" ? $hostname : $ip; +} + + diff --git a/rubbos/app/httpd-2.0.64/support/logresolve.pl.in b/rubbos/app/httpd-2.0.64/support/logresolve.pl.in new file mode 100644 index 00000000..879d2972 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/logresolve.pl.in @@ -0,0 +1,225 @@ +#!@perlbin@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# logresolve.pl +# +# v 1.2 by robh @ imdb.com +# +# usage: logresolve.pl <infile >outfile +# +# input = Apache/NCSA/.. logfile with IP numbers at start of lines +# output = same logfile with IP addresses resolved to hostnames where +# name lookups succeeded. +# +# this differs from the C based 'logresolve' in that this script +# spawns a number ($CHILDREN) of subprocesses to resolve addresses +# concurrently and sets a short timeout ($TIMEOUT) for each lookup in +# order to keep things moving quickly. +# +# the parent process handles caching of IP->hostnames using a Perl hash +# it also avoids sending the same IP to multiple child processes to be +# resolved multiple times concurrently. +# +# Depending on the settings of $CHILDREN and $TIMEOUT you should see +# significant reductions in the overall time taken to resolve your +# logfiles. With $CHILDREN=40 and $TIMEOUT=5 I've seen 200,000 - 300,000 +# logfile lines processed per hour compared to ~45,000 per hour +# with 'logresolve'. +# +# I haven't yet seen any noticable reduction in the percentage of IPs +# that fail to get resolved. Your mileage will no doubt vary. 5s is long +# enough to wait IMO. +# +# Known to work with FreeBSD 2.2 +# Known to have problems with Solaris +# +# 980417 - use 'sockaddr_un' for bind/connect to make the script work +# with linux. Fix from Luuk de Boer <luuk_de_boer@pi.net> + +require 5.004; + +$|=1; + +use FileHandle; +use Socket; + +use strict; +no strict 'refs'; + +use vars qw($PROTOCOL); +$PROTOCOL = 0; + +my $CHILDREN = 40; +my $TIMEOUT = 5; + +my $filename; +my %hash = (); +my $parent = $$; + +my @children = (); +for (my $child = 1; $child <=$CHILDREN; $child++) { + my $f = fork(); + if (!$f) { + $filename = "./.socket.$parent.$child"; + if (-e $filename) { unlink($filename) || warn "$filename .. $!\n";} + &child($child); + exit(0); + } + push(@children, $f); +} + +&parent; +&cleanup; + +## remove all temporary files before shutting down +sub cleanup { + # die kiddies, die + kill(15, @children); + for (my $child = 1; $child <=$CHILDREN; $child++) { + if (-e "./.socket.$parent.$child") { + unlink("./.socket.$parent.$child") + || warn ".socket.$parent.$child $!"; + } + } +} + +sub parent { + # Trap some possible signals to trigger temp file cleanup + $SIG{'KILL'} = $SIG{'INT'} = $SIG{'PIPE'} = \&cleanup; + + my %CHILDSOCK; + my $filename; + + ## fork child processes. Each child will create a socket connection + ## to this parent and use an unique temp filename to do so. + for (my $child = 1; $child <=$CHILDREN; $child++) { + $CHILDSOCK{$child}= FileHandle->new; + + if (!socket($CHILDSOCK{$child}, AF_UNIX, SOCK_STREAM, $PROTOCOL)) { + warn "parent socket to child failed $!"; + } + $filename = "./.socket.$parent.$child"; + my $response; + do { + $response = connect($CHILDSOCK{$child}, sockaddr_un($filename)); + if ($response != 1) { + sleep(1); + } + } while ($response != 1); + $CHILDSOCK{$child}->autoflush; + } + ## All child processes should now be ready or at worst warming up + + my (@buffer, $child, $ip, $rest, $hostname, $response); + ## read the logfile lines from STDIN + while(<STDIN>) { + @buffer = (); # empty the logfile line buffer array. + $child = 1; # children are numbered 1..N, start with #1 + + # while we have a child to talk to and data to give it.. + do { + push(@buffer, $_); # buffer the line + ($ip, $rest) = split(/ /, $_, 2); # separate IP form rest + + unless ($hash{$ip}) { # resolve if unseen IP + $CHILDSOCK{$child}->print("$ip\n"); # pass IP to next child + $hash{$ip} = $ip; # don't look it up again. + $child++; + } + } while (($child < ($CHILDREN-1)) and ($_ = <STDIN>)); + + ## now poll each child for a response + while (--$child > 0) { + $response = $CHILDSOCK{$child}->getline; + chomp($response); + # child sends us back both the IP and HOSTNAME, no need for us + # to remember what child received any given IP, and no worries + # what order we talk to the children + ($ip, $hostname) = split(/\|/, $response, 2); + $hash{$ip} = $hostname; + } + + # resolve all the logfiles lines held in the log buffer array.. + for (my $line = 0; $line <=$#buffer; $line++) { + # get next buffered line + ($ip, $rest) = split(/ /, $buffer[$line], 2); + # separate IP from rest and replace with cached hostname + printf STDOUT ("%s %s", $hash{$ip}, $rest); + } + } +} + +######################################## + +sub child { + # arg = numeric ID - how the parent refers to me + my $me = shift; + + # add trap for alarm signals. + $SIG{'ALRM'} = sub { die "alarmed"; }; + + # create a socket to communicate with parent + socket(INBOUND, AF_UNIX, SOCK_STREAM, $PROTOCOL) + || die "Error with Socket: !$\n"; + $filename = "./.socket.$parent.$me"; + bind(INBOUND, sockaddr_un($filename)) + || die "Error Binding $filename: $!\n"; + listen(INBOUND, 5) || die "Error Listening: $!\n"; + + my ($ip, $send_back); + my $talk = FileHandle->new; + + # accept a connection from the parent process. We only ever have + # have one connection where we exchange 1 line of info with the + # parent.. 1 line in (IP address), 1 line out (IP + hostname). + accept($talk, INBOUND) || die "Error Accepting: $!\n"; + # disable I/O buffering just in case + $talk->autoflush; + # while the parent keeps sending data, we keep responding.. + while(($ip = $talk->getline)) { + chomp($ip); + # resolve the IP if time permits and send back what we found.. + $send_back = sprintf("%s|%s", $ip, &nslookup($ip)); + $talk->print($send_back."\n"); + } +} + +# perform a time restricted hostname lookup. +sub nslookup { + # get the IP as an arg + my $ip = shift; + my $hostname = undef; + + # do the hostname lookup inside an eval. The eval will use the + # already configured SIGnal handler and drop out of the {} block + # regardless of whether the alarm occured or not. + eval { + alarm($TIMEOUT); + $hostname = gethostbyaddr(gethostbyname($ip), AF_INET); + alarm(0); + }; + if ($@ =~ /alarm/) { + # useful for debugging perhaps.. + # print "alarming, isn't it? ($ip)"; + } + + # return the hostname or the IP address itself if there is no hostname + $hostname ne "" ? $hostname : $ip; +} + + diff --git a/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi b/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi new file mode 100644 index 00000000..57e03332 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# This script is used to detect people trying to abuse the security hole which +# existed in A CGI script direstributed with Apache 1.0.3 and earlier versions. +# You can redirect them to here using the "<Location /cgi-bin/phf*>" suggestion +# in httpd.conf. +# +# The format logged to is +# "[date] remote_addr remote_host [date] referrer user_agent". + +$LOG = "/var/log/phf_log"; + +require "ctime.pl"; +$when = &ctime(time); +$when =~ s/\n//go; +$ENV{HTTP_USER_AGENT} .= " via $ENV{HTTP_VIA}" if($ENV{HTTP_VIA}); + +open(LOG, ">>$LOG") || die "boo hoo, phf_log $!"; +print LOG "[$when] $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST} $ENV{$HTTP_REFERER} $ENV{HTTP_USER_AGENT}\n"; +close(LOG); + +print "Content-type: text/html\r\n\r\n<BLINK>Smile, you're on Candid Camera.</BLINK>\n"; diff --git a/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi.in b/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi.in new file mode 100644 index 00000000..39900bf5 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/phf_abuse_log.cgi.in @@ -0,0 +1,38 @@ +#!@perlbin@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# This script is used to detect people trying to abuse the security hole which +# existed in A CGI script direstributed with Apache 1.0.3 and earlier versions. +# You can redirect them to here using the "<Location /cgi-bin/phf*>" suggestion +# in httpd.conf. +# +# The format logged to is +# "[date] remote_addr remote_host [date] referrer user_agent". + +$LOG = "/var/log/phf_log"; + +require "ctime.pl"; +$when = &ctime(time); +$when =~ s/\n//go; +$ENV{HTTP_USER_AGENT} .= " via $ENV{HTTP_VIA}" if($ENV{HTTP_VIA}); + +open(LOG, ">>$LOG") || die "boo hoo, phf_log $!"; +print LOG "[$when] $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST} $ENV{$HTTP_REFERER} $ENV{HTTP_USER_AGENT}\n"; +close(LOG); + +print "Content-type: text/html\r\n\r\n<BLINK>Smile, you're on Candid Camera.</BLINK>\n"; diff --git a/rubbos/app/httpd-2.0.64/support/rotatelogs b/rubbos/app/httpd-2.0.64/support/rotatelogs new file mode 100755 index 00000000..f2d38d2b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/rotatelogs @@ -0,0 +1,131 @@ +#! /bin/bash + +# rotatelogs - temporary wrapper script for .libs/rotatelogs +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# The rotatelogs program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /bottlenecks/rubbos/app/httpd-2.0.64/support; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\"; export PATH; gcc -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/include -I/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib -I. -I/bottlenecks/rubbos/app/httpd-2.0.64/os/unix -I/bottlenecks/rubbos/app/httpd-2.0.64/server/mpm/worker -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/http -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/filters -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/proxy -I/bottlenecks/rubbos/app/httpd-2.0.64/include -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/generators -I/bottlenecks/rubbos/app/httpd-2.0.64/modules/dav/main -o \$progdir/\$file .libs/rotatelogs.o -Wl,--export-dynamic -L/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/lib /bottlenecks/rubbos/app/httpd-2.0.64/srclib/pcre/.libs/libpcre.a /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs/libaprutil-0.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs/libexpat.so /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs/libapr-0.so -lrt -lm -lcrypt -lnsl -lpthread -ldl -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/.libs -Wl,--rpath -Wl,/bottlenecks/rubbos/app/apache2/lib ) " + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/libaprutil-0.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr-util/xml/expat/libexpat.la /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/libapr-0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/bash "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'rotatelogs' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $echo "$0: cannot exec $program $*" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: \`$progdir/$program' does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/rubbos/app/httpd-2.0.64/support/rotatelogs.c b/rubbos/app/httpd-2.0.64/support/rotatelogs.c new file mode 100644 index 00000000..e7b3a0c5 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/rotatelogs.c @@ -0,0 +1,262 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Simple program to rotate Apache logs without having to kill the server. + * + * Contributed by Ben Laurie <ben@algroup.co.uk> + * + * 12 Mar 1996 + * + * Ported to APR by Mladen Turk <mturk@mappingsoft.com> + * + * 23 Sep 2001 + * + * -l option added 2004-06-11 + * + * -l causes the use of local time rather than GMT as the base for the + * interval. NB: Using -l in an environment which changes the GMT offset + * (such as for BST or DST) can lead to unpredictable results! + * + */ + + +#include "apr.h" +#include "apr_lib.h" +#include "apr_strings.h" +#include "apr_errno.h" +#include "apr_file_io.h" +#include "apr_file_info.h" +#include "apr_general.h" +#include "apr_time.h" + +#if APR_HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if APR_HAVE_STRING_H +#include <string.h> +#endif +#if APR_HAVE_STRINGS_H +#include <strings.h> +#endif + +#define BUFSIZE 65536 +#define ERRMSGSZ 82 + +#ifndef MAX_PATH +#define MAX_PATH 1024 +#endif + +int main (int argc, const char * const argv[]) +{ + char buf[BUFSIZE], buf2[MAX_PATH], errbuf[ERRMSGSZ]; + int tLogEnd = 0, tRotation = 0, utc_offset = 0; + unsigned int sRotation = 0; + int nMessCount = 0; + apr_size_t nRead, nWrite; + int use_strftime = 0; + int use_localtime = 0; + int now = 0; + const char *szLogRoot; + apr_file_t *f_stdin, *nLogFD = NULL, *nLogFDprev = NULL; + apr_pool_t *pool; + char *ptr = NULL; + int argBase = 0; + int argFile = 1; + int argIntv = 2; + int argOffset = 3; + + apr_app_initialize(&argc, &argv, NULL); + atexit(apr_terminate); + + apr_pool_create(&pool, NULL); + if ((argc > 2) && (strcmp(argv[1], "-l") == 0)) { + argBase++; + argFile += argBase; + argIntv += argBase; + argOffset += argBase; + use_localtime = 1; + } + if (argc < (argBase + 3) || argc > (argBase + 4)) { + fprintf(stderr, + "Usage: %s [-l] <logfile> <rotation time in seconds> " + "[offset minutes from UTC] or <rotation size in megabytes>\n\n", + argv[0]); +#ifdef OS2 + fprintf(stderr, + "Add this:\n\nTransferLog \"|%s.exe /some/where 86400\"\n\n", + argv[0]); +#else + fprintf(stderr, + "Add this:\n\nTransferLog \"|%s /some/where 86400\"\n\n", + argv[0]); + fprintf(stderr, + "or \n\nTransferLog \"|%s /some/where 5M\"\n\n", argv[0]); +#endif + fprintf(stderr, + "to httpd.conf. The generated name will be /some/where.nnnn " + "where nnnn is the\nsystem time at which the log nominally " + "starts (N.B. if using a rotation time,\nthe time will always " + "be a multiple of the rotation time, so you can synchronize\n" + "cron scripts with it). At the end of each rotation time or " + "when the file size\nis reached a new log is started.\n"); + exit(1); + } + + szLogRoot = argv[argFile]; + + ptr = strchr(argv[argIntv], 'M'); + if (ptr) { + if (*(ptr+1) == '\0') { + sRotation = atoi(argv[argIntv]) * 1048576; + } + if (sRotation == 0) { + fprintf(stderr, "Invalid rotation size parameter\n"); + exit(1); + } + } + else { + if (argc >= (argBase + 4)) { + utc_offset = atoi(argv[argOffset]) * 60; + } + tRotation = atoi(argv[argIntv]); + if (tRotation <= 0) { + fprintf(stderr, "Rotation time must be > 0\n"); + exit(6); + } + } + + use_strftime = (strchr(szLogRoot, '%') != NULL); + if (apr_file_open_stdin(&f_stdin, pool) != APR_SUCCESS) { + fprintf(stderr, "Unable to open stdin\n"); + exit(1); + } + + for (;;) { + nRead = sizeof(buf); + if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) { + exit(3); + } + if (tRotation) { + /* + * Check for our UTC offset every time through the loop, since + * it might change if there's a switch between standard and + * daylight savings time. + */ + if (use_localtime) { + apr_time_exp_t lt; + apr_time_exp_lt(<, apr_time_now()); + utc_offset = lt.tm_gmtoff; + } + now = (int)(apr_time_now() / APR_USEC_PER_SEC) + utc_offset; + if (nLogFD != NULL && now >= tLogEnd) { + nLogFDprev = nLogFD; + nLogFD = NULL; + } + } + else if (sRotation) { + apr_finfo_t finfo; + apr_off_t current_size = -1; + + if ((nLogFD != NULL) && + (apr_file_info_get(&finfo, APR_FINFO_SIZE, nLogFD) == APR_SUCCESS)) { + current_size = finfo.size; + } + + if (current_size > sRotation) { + nLogFDprev = nLogFD; + nLogFD = NULL; + } + } + else { + fprintf(stderr, "No rotation time or size specified\n"); + exit(2); + } + + if (nLogFD == NULL) { + int tLogStart; + + if (tRotation) { + tLogStart = (now / tRotation) * tRotation; + } + else { + tLogStart = (int)apr_time_sec(apr_time_now()); + } + + if (use_strftime) { + apr_time_t tNow = apr_time_from_sec(tLogStart); + apr_time_exp_t e; + apr_size_t rs; + + apr_time_exp_gmt(&e, tNow); + apr_strftime(buf2, &rs, sizeof(buf2), szLogRoot, &e); + } + else { + sprintf(buf2, "%s.%010d", szLogRoot, tLogStart); + } + tLogEnd = tLogStart + tRotation; + apr_file_open(&nLogFD, buf2, + APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE, + APR_OS_DEFAULT, pool); + if (nLogFD == NULL) { + /* Uh-oh. Failed to open the new log file. Try to clear + * the previous log file, note the lost log entries, + * and keep on truckin'. */ + if (nLogFDprev == NULL) { + fprintf(stderr, "1 Previous file handle doesn't exists %s\n", buf2); + exit(2); + } + else { + nLogFD = nLogFDprev; + sprintf(errbuf, + "Resetting log file due to error opening " + "new log file. %10d messages lost.\n", + nMessCount); + nWrite = strlen(errbuf); + apr_file_trunc(nLogFD, 0); + if (apr_file_write(nLogFD, errbuf, &nWrite) != APR_SUCCESS) { + fprintf(stderr, "Error writing to the file %s\n", buf2); + exit(2); + } + } + } + else if (nLogFDprev) { + apr_file_close(nLogFDprev); + } + nMessCount = 0; + } + nWrite = nRead; + apr_file_write(nLogFD, buf, &nWrite); + if (nWrite != nRead) { + nMessCount++; + sprintf(errbuf, + "Error writing to log file. " + "%10d messages lost.\n", + nMessCount); + nWrite = strlen(errbuf); + apr_file_trunc(nLogFD, 0); + if (apr_file_write(nLogFD, errbuf, &nWrite) != APR_SUCCESS) { + fprintf(stderr, "Error writing to the file %s\n", buf2); + exit(2); + } + } + else { + nMessCount++; + } + } + /* Of course we never, but prevent compiler warnings */ + return 0; +} diff --git a/rubbos/app/httpd-2.0.64/support/rotatelogs.dsp b/rubbos/app/httpd-2.0.64/support/rotatelogs.dsp new file mode 100644 index 00000000..7b351121 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/rotatelogs.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="rotatelogs" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=rotatelogs - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "rotatelogs.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "rotatelogs.mak" CFG="rotatelogs - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "rotatelogs - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "rotatelogs - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "rotatelogs - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/rotatelogs_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "rotatelogs - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/rotatelogs_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib advapi32.lib wsock32.lib ws2_32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "rotatelogs - Win32 Release" +# Name "rotatelogs - Win32 Debug" +# Begin Source File + +SOURCE=.\rotatelogs.c +# End Source File +# Begin Source File + +SOURCE=.\rotatelogs.rc +# End Source File +# Begin Source File + +SOURCE=..\build\win32\win32ver.awk + +!IF "$(CFG)" == "rotatelogs - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\rotatelogs.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk rotatelogs.exe "rotatelogs Utility" ../include/ap_release.h > .\rotatelogs.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "rotatelogs - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\build\win32\win32ver.awk + +".\rotatelogs.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../build/win32/win32ver.awk rotatelogs.exe "rotatelogs Utility" ../include/ap_release.h > .\rotatelogs.rc + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/rotatelogs.lo b/rubbos/app/httpd-2.0.64/support/rotatelogs.lo new file mode 100644 index 00000000..de1f5ca6 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/rotatelogs.lo @@ -0,0 +1,12 @@ +# rotatelogs.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/rotatelogs.o' + +# Name of the non-PIC object. +non_pic_object='rotatelogs.o' + diff --git a/rubbos/app/httpd-2.0.64/support/rotatelogs.o b/rubbos/app/httpd-2.0.64/support/rotatelogs.o Binary files differnew file mode 100644 index 00000000..7ae2ef96 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/rotatelogs.o diff --git a/rubbos/app/httpd-2.0.64/support/split-logfile b/rubbos/app/httpd-2.0.64/support/split-logfile new file mode 100644 index 00000000..e67f1df4 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/split-logfile @@ -0,0 +1,67 @@ +#!/usr/bin/perl +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# This script will take a combined Web server access +# log file and break its contents into separate files. +# It assumes that the first field of each line is the +# virtual host identity (put there by "%v"), and that +# the logfiles should be named that+".log" in the current +# directory. +# +# The combined log file is read from stdin. Records read +# will be appended to any existing log files. +# +%is_open = (); + +while ($log_line = <STDIN>) { + # + # Get the first token from the log record; it's the + # identity of the virtual host to which the record + # applies. + # + ($vhost) = split (/\s/, $log_line); + # + # Normalize the virtual host name to all lowercase. + # If it's blank, the request was handled by the default + # server, so supply a default name. This shouldn't + # happen, but caution rocks. + # + $vhost = lc ($vhost) or "access"; + # + # if the vhost contains a "/" or "\", it is illegal so just use + # the default log to avoid any security issues due if it is interprted + # as a directory separator. + if ($vhost =~ m#[/\\]#) { $vhost = "access" } + # + # If the log file for this virtual host isn't opened + # yet, do it now. + # + if (! $is_open{$vhost}) { + open $vhost, ">>${vhost}.log" + or die ("Can't open ${vhost}.log"); + $is_open{$vhost} = 1; + } + # + # Strip off the first token (which may be null in the + # case of the default server), and write the edited + # record to the current log file. + # + $log_line =~ s/^\S*\s+//; + printf $vhost "%s", $log_line; +} +exit 0; diff --git a/rubbos/app/httpd-2.0.64/support/split-logfile.in b/rubbos/app/httpd-2.0.64/support/split-logfile.in new file mode 100644 index 00000000..061162e8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/split-logfile.in @@ -0,0 +1,67 @@ +#!@perlbin@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# This script will take a combined Web server access +# log file and break its contents into separate files. +# It assumes that the first field of each line is the +# virtual host identity (put there by "%v"), and that +# the logfiles should be named that+".log" in the current +# directory. +# +# The combined log file is read from stdin. Records read +# will be appended to any existing log files. +# +%is_open = (); + +while ($log_line = <STDIN>) { + # + # Get the first token from the log record; it's the + # identity of the virtual host to which the record + # applies. + # + ($vhost) = split (/\s/, $log_line); + # + # Normalize the virtual host name to all lowercase. + # If it's blank, the request was handled by the default + # server, so supply a default name. This shouldn't + # happen, but caution rocks. + # + $vhost = lc ($vhost) or "access"; + # + # if the vhost contains a "/" or "\", it is illegal so just use + # the default log to avoid any security issues due if it is interprted + # as a directory separator. + if ($vhost =~ m#[/\\]#) { $vhost = "access" } + # + # If the log file for this virtual host isn't opened + # yet, do it now. + # + if (! $is_open{$vhost}) { + open $vhost, ">>${vhost}.log" + or die ("Can't open ${vhost}.log"); + $is_open{$vhost} = 1; + } + # + # Strip off the first token (which may be null in the + # case of the default server), and write the edited + # record to the current log file. + # + $log_line =~ s/^\S*\s+//; + printf $vhost "%s", $log_line; +} +exit 0; diff --git a/rubbos/app/httpd-2.0.64/support/suexec.c b/rubbos/app/httpd-2.0.64/support/suexec.c new file mode 100644 index 00000000..06e55c4d --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/suexec.c @@ -0,0 +1,619 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * suexec.c -- "Wrapper" support program for suEXEC behaviour for Apache + * + *********************************************************************** + * + * NOTE! : DO NOT edit this code!!! Unless you know what you are doing, + * editing this code might open up your system in unexpected + * ways to would-be crackers. Every precaution has been taken + * to make this code as safe as possible; alter it at your own + * risk. + * + *********************************************************************** + * + * + */ + +#include "apr.h" +#include "ap_config.h" +#include "suexec.h" + +#include <sys/param.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <string.h> +#include <time.h> +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> + +#ifdef HAVE_PWD_H +#include <pwd.h> +#endif + +#ifdef HAVE_GRP_H +#include <grp.h> +#endif + +/* + *********************************************************************** + * There is no initgroups() in QNX, so I believe this is safe :-) + * Use cc -osuexec -3 -O -mf -DQNX suexec.c to compile. + * + * May 17, 1997. + * Igor N. Kovalenko -- infoh@mail.wplus.net + *********************************************************************** + */ + +#if defined(NEED_INITGROUPS) +int initgroups(const char *name, gid_t basegid) +{ + /* QNX and MPE do not appear to support supplementary groups. */ + return 0; +} +#endif + +#if defined(SUNOS4) +extern char *sys_errlist[]; +#define strerror(x) sys_errlist[(x)] +#endif + +#if defined(PATH_MAX) +#define AP_MAXPATH PATH_MAX +#elif defined(MAXPATHLEN) +#define AP_MAXPATH MAXPATHLEN +#else +#define AP_MAXPATH 8192 +#endif + +#define AP_ENVBUF 256 + +extern char **environ; +static FILE *log = NULL; + +char *safe_env_lst[] = +{ + /* variable name starts with */ + "HTTP_", + "SSL_", + + /* variable name is */ + "AUTH_TYPE=", + "CONTENT_LENGTH=", + "CONTENT_TYPE=", + "DATE_GMT=", + "DATE_LOCAL=", + "DOCUMENT_NAME=", + "DOCUMENT_PATH_INFO=", + "DOCUMENT_ROOT=", + "DOCUMENT_URI=", + "FILEPATH_INFO=", + "GATEWAY_INTERFACE=", + "HTTPS=", + "LAST_MODIFIED=", + "PATH_INFO=", + "PATH_TRANSLATED=", + "QUERY_STRING=", + "QUERY_STRING_UNESCAPED=", + "REMOTE_ADDR=", + "REMOTE_HOST=", + "REMOTE_IDENT=", + "REMOTE_PORT=", + "REMOTE_USER=", + "REDIRECT_QUERY_STRING=", + "REDIRECT_REMOTE_USER=", + "REDIRECT_STATUS=", + "REDIRECT_URL=", + "REQUEST_METHOD=", + "REQUEST_URI=", + "SCRIPT_FILENAME=", + "SCRIPT_NAME=", + "SCRIPT_URI=", + "SCRIPT_URL=", + "SERVER_ADMIN=", + "SERVER_NAME=", + "SERVER_ADDR=", + "SERVER_PORT=", + "SERVER_PROTOCOL=", + "SERVER_SIGNATURE=", + "SERVER_SOFTWARE=", + "UNIQUE_ID=", + "USER_NAME=", + "TZ=", + NULL +}; + + +static void err_output(const char *fmt, va_list ap) +{ +#ifdef AP_LOG_EXEC + time_t timevar; + struct tm *lt; + + if (!log) { + if ((log = fopen(AP_LOG_EXEC, "a")) == NULL) { + fprintf(stderr, "failed to open log file\n"); + perror("fopen"); + exit(1); + } + } + + time(&timevar); + lt = localtime(&timevar); + + fprintf(log, "[%d-%.2d-%.2d %.2d:%.2d:%.2d]: ", + lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, + lt->tm_hour, lt->tm_min, lt->tm_sec); + + vfprintf(log, fmt, ap); + + fflush(log); +#endif /* AP_LOG_EXEC */ + return; +} + +static void log_err(const char *fmt,...) +{ +#ifdef AP_LOG_EXEC + va_list ap; + + va_start(ap, fmt); + err_output(fmt, ap); + va_end(ap); +#endif /* AP_LOG_EXEC */ + return; +} + +static void clean_env(void) +{ + char pathbuf[512]; + char **cleanenv; + char **ep; + int cidx = 0; + int idx; + + /* While cleaning the environment, the environment should be clean. + * (e.g. malloc() may get the name of a file for writing debugging info. + * Bad news if MALLOC_DEBUG_FILE is set to /etc/passwd. Sprintf() may be + * susceptible to bad locale settings....) + * (from PR 2790) + */ + char **envp = environ; + char *empty_ptr = NULL; + + environ = &empty_ptr; /* VERY safe environment */ + + if ((cleanenv = (char **) calloc(AP_ENVBUF, sizeof(char *))) == NULL) { + log_err("failed to malloc memory for environment\n"); + exit(120); + } + + sprintf(pathbuf, "PATH=%s", AP_SAFE_PATH); + cleanenv[cidx] = strdup(pathbuf); + cidx++; + + for (ep = envp; *ep && cidx < AP_ENVBUF-1; ep++) { + for (idx = 0; safe_env_lst[idx]; idx++) { + if (!strncmp(*ep, safe_env_lst[idx], + strlen(safe_env_lst[idx]))) { + cleanenv[cidx] = *ep; + cidx++; + break; + } + } + } + + cleanenv[cidx] = NULL; + + environ = cleanenv; +} + +int main(int argc, char *argv[]) +{ + int userdir = 0; /* ~userdir flag */ + uid_t uid; /* user information */ + gid_t gid; /* target group placeholder */ + char *target_uname; /* target user name */ + char *target_gname; /* target group name */ + char *target_homedir; /* target home directory */ + char *actual_uname; /* actual user name */ + char *actual_gname; /* actual group name */ + char *prog; /* name of this program */ + char *cmd; /* command to be executed */ + char cwd[AP_MAXPATH]; /* current working directory */ + char dwd[AP_MAXPATH]; /* docroot working directory */ + struct passwd *pw; /* password entry holder */ + struct group *gr; /* group entry holder */ + struct stat dir_info; /* directory info holder */ + struct stat prg_info; /* program info holder */ + + /* + * Start with a "clean" environment + */ + clean_env(); + + prog = argv[0]; + /* + * Check existence/validity of the UID of the user + * running this program. Error out if invalid. + */ + uid = getuid(); + if ((pw = getpwuid(uid)) == NULL) { + log_err("crit: invalid uid: (%ld)\n", uid); + exit(102); + } + /* + * See if this is a 'how were you compiled' request, and + * comply if so. + */ + if ((argc > 1) + && (! strcmp(argv[1], "-V")) + && ((uid == 0) +#ifdef _OSD_POSIX + /* User name comparisons are case insensitive on BS2000/OSD */ + || (! strcasecmp(AP_HTTPD_USER, pw->pw_name))) +#else /* _OSD_POSIX */ + || (! strcmp(AP_HTTPD_USER, pw->pw_name))) +#endif /* _OSD_POSIX */ + ) { +#ifdef AP_DOC_ROOT + fprintf(stderr, " -D AP_DOC_ROOT=\"%s\"\n", AP_DOC_ROOT); +#endif +#ifdef AP_GID_MIN + fprintf(stderr, " -D AP_GID_MIN=%d\n", AP_GID_MIN); +#endif +#ifdef AP_HTTPD_USER + fprintf(stderr, " -D AP_HTTPD_USER=\"%s\"\n", AP_HTTPD_USER); +#endif +#ifdef AP_LOG_EXEC + fprintf(stderr, " -D AP_LOG_EXEC=\"%s\"\n", AP_LOG_EXEC); +#endif +#ifdef AP_SAFE_PATH + fprintf(stderr, " -D AP_SAFE_PATH=\"%s\"\n", AP_SAFE_PATH); +#endif +#ifdef AP_SUEXEC_UMASK + fprintf(stderr, " -D AP_SUEXEC_UMASK=%03o\n", AP_SUEXEC_UMASK); +#endif +#ifdef AP_UID_MIN + fprintf(stderr, " -D AP_UID_MIN=%d\n", AP_UID_MIN); +#endif +#ifdef AP_USERDIR_SUFFIX + fprintf(stderr, " -D AP_USERDIR_SUFFIX=\"%s\"\n", AP_USERDIR_SUFFIX); +#endif + exit(0); + } + /* + * If there are a proper number of arguments, set + * all of them to variables. Otherwise, error out. + */ + if (argc < 4) { + log_err("too few arguments\n"); + exit(101); + } + target_uname = argv[1]; + target_gname = argv[2]; + cmd = argv[3]; + + /* + * Check to see if the user running this program + * is the user allowed to do so as defined in + * suexec.h. If not the allowed user, error out. + */ +#ifdef _OSD_POSIX + /* User name comparisons are case insensitive on BS2000/OSD */ + if (strcasecmp(AP_HTTPD_USER, pw->pw_name)) { + log_err("user mismatch (%s instead of %s)\n", pw->pw_name, AP_HTTPD_USER); + exit(103); + } +#else /*_OSD_POSIX*/ + if (strcmp(AP_HTTPD_USER, pw->pw_name)) { + log_err("user mismatch (%s instead of %s)\n", pw->pw_name, AP_HTTPD_USER); + exit(103); + } +#endif /*_OSD_POSIX*/ + + /* + * Check for a leading '/' (absolute path) in the command to be executed, + * or attempts to back up out of the current directory, + * to protect against attacks. If any are + * found, error out. Naughty naughty crackers. + */ + if ((cmd[0] == '/') || (!strncmp(cmd, "../", 3)) + || (strstr(cmd, "/../") != NULL)) { + log_err("invalid command (%s)\n", cmd); + exit(104); + } + + /* + * Check to see if this is a ~userdir request. If + * so, set the flag, and remove the '~' from the + * target username. + */ + if (!strncmp("~", target_uname, 1)) { + target_uname++; + userdir = 1; + } + + /* + * Error out if the target username is invalid. + */ + if (strspn(target_uname, "1234567890") != strlen(target_uname)) { + if ((pw = getpwnam(target_uname)) == NULL) { + log_err("invalid target user name: (%s)\n", target_uname); + exit(105); + } + } + else { + if ((pw = getpwuid(atoi(target_uname))) == NULL) { + log_err("invalid target user id: (%s)\n", target_uname); + exit(121); + } + } + + /* + * Error out if the target group name is invalid. + */ + if (strspn(target_gname, "1234567890") != strlen(target_gname)) { + if ((gr = getgrnam(target_gname)) == NULL) { + log_err("invalid target group name: (%s)\n", target_gname); + exit(106); + } + gid = gr->gr_gid; + actual_gname = strdup(gr->gr_name); + } + else { + gid = atoi(target_gname); + actual_gname = strdup(target_gname); + } + +#ifdef _OSD_POSIX + /* + * Initialize BS2000 user environment + */ + { + pid_t pid; + int status; + + switch (pid = ufork(target_uname)) { + case -1: /* Error */ + log_err("failed to setup bs2000 environment for user %s: %s\n", + target_uname, strerror(errno)); + exit(150); + case 0: /* Child */ + break; + default: /* Father */ + while (pid != waitpid(pid, &status, 0)) + ; + /* @@@ FIXME: should we deal with STOP signals as well? */ + if (WIFSIGNALED(status)) { + kill (getpid(), WTERMSIG(status)); + } + exit(WEXITSTATUS(status)); + } + } +#endif /*_OSD_POSIX*/ + + /* + * Save these for later since initgroups will hose the struct + */ + uid = pw->pw_uid; + actual_uname = strdup(pw->pw_name); + target_homedir = strdup(pw->pw_dir); + + /* + * Log the transaction here to be sure we have an open log + * before we setuid(). + */ + log_err("uid: (%s/%s) gid: (%s/%s) cmd: %s\n", + target_uname, actual_uname, + target_gname, actual_gname, + cmd); + + /* + * Error out if attempt is made to execute as root or as + * a UID less than AP_UID_MIN. Tsk tsk. + */ + if ((uid == 0) || (uid < AP_UID_MIN)) { + log_err("cannot run as forbidden uid (%d/%s)\n", uid, cmd); + exit(107); + } + + /* + * Error out if attempt is made to execute as root group + * or as a GID less than AP_GID_MIN. Tsk tsk. + */ + if ((gid == 0) || (gid < AP_GID_MIN)) { + log_err("cannot run as forbidden gid (%d/%s)\n", gid, cmd); + exit(108); + } + + /* + * Change UID/GID here so that the following tests work over NFS. + * + * Initialize the group access list for the target user, + * and setgid() to the target group. If unsuccessful, error out. + */ + if (((setgid(gid)) != 0) || (initgroups(actual_uname, gid) != 0)) { + log_err("failed to setgid (%ld: %s)\n", gid, cmd); + exit(109); + } + + /* + * setuid() to the target user. Error out on fail. + */ + if ((setuid(uid)) != 0) { + log_err("failed to setuid (%ld: %s)\n", uid, cmd); + exit(110); + } + + /* + * Get the current working directory, as well as the proper + * document root (dependant upon whether or not it is a + * ~userdir request). Error out if we cannot get either one, + * or if the current working directory is not in the docroot. + * Use chdir()s and getcwd()s to avoid problems with symlinked + * directories. Yuck. + */ + if (getcwd(cwd, AP_MAXPATH) == NULL) { + log_err("cannot get current working directory\n"); + exit(111); + } + + if (userdir) { + if (((chdir(target_homedir)) != 0) || + ((chdir(AP_USERDIR_SUFFIX)) != 0) || + ((getcwd(dwd, AP_MAXPATH)) == NULL) || + ((chdir(cwd)) != 0)) { + log_err("cannot get docroot information (%s)\n", target_homedir); + exit(112); + } + } + else { + if (((chdir(AP_DOC_ROOT)) != 0) || + ((getcwd(dwd, AP_MAXPATH)) == NULL) || + ((chdir(cwd)) != 0)) { + log_err("cannot get docroot information (%s)\n", AP_DOC_ROOT); + exit(113); + } + } + + if ((strncmp(cwd, dwd, strlen(dwd))) != 0) { + log_err("command not in docroot (%s/%s)\n", cwd, cmd); + exit(114); + } + + /* + * Stat the cwd and verify it is a directory, or error out. + */ + if (((lstat(cwd, &dir_info)) != 0) || !(S_ISDIR(dir_info.st_mode))) { + log_err("cannot stat directory: (%s)\n", cwd); + exit(115); + } + + /* + * Error out if cwd is writable by others. + */ + if ((dir_info.st_mode & S_IWOTH) || (dir_info.st_mode & S_IWGRP)) { + log_err("directory is writable by others: (%s)\n", cwd); + exit(116); + } + + /* + * Error out if we cannot stat the program. + */ + if (((lstat(cmd, &prg_info)) != 0) || (S_ISLNK(prg_info.st_mode))) { + log_err("cannot stat program: (%s)\n", cmd); + exit(117); + } + + /* + * Error out if the program is writable by others. + */ + if ((prg_info.st_mode & S_IWOTH) || (prg_info.st_mode & S_IWGRP)) { + log_err("file is writable by others: (%s/%s)\n", cwd, cmd); + exit(118); + } + + /* + * Error out if the file is setuid or setgid. + */ + if ((prg_info.st_mode & S_ISUID) || (prg_info.st_mode & S_ISGID)) { + log_err("file is either setuid or setgid: (%s/%s)\n", cwd, cmd); + exit(119); + } + + /* + * Error out if the target name/group is different from + * the name/group of the cwd or the program. + */ + if ((uid != dir_info.st_uid) || + (gid != dir_info.st_gid) || + (uid != prg_info.st_uid) || + (gid != prg_info.st_gid)) { + log_err("target uid/gid (%ld/%ld) mismatch " + "with directory (%ld/%ld) or program (%ld/%ld)\n", + uid, gid, + dir_info.st_uid, dir_info.st_gid, + prg_info.st_uid, prg_info.st_gid); + exit(120); + } + /* + * Error out if the program is not executable for the user. + * Otherwise, she won't find any error in the logs except for + * "[error] Premature end of script headers: ..." + */ + if (!(prg_info.st_mode & S_IXUSR)) { + log_err("file has no execute permission: (%s/%s)\n", cwd, cmd); + exit(121); + } + +#ifdef AP_SUEXEC_UMASK + /* + * umask() uses inverse logic; bits are CLEAR for allowed access. + */ + if ((~AP_SUEXEC_UMASK) & 0022) { + log_err("notice: AP_SUEXEC_UMASK of %03o allows " + "write permission to group and/or other\n", AP_SUEXEC_UMASK); + } + umask(AP_SUEXEC_UMASK); +#endif /* AP_SUEXEC_UMASK */ + + /* + * Be sure to close the log file so the CGI can't + * mess with it. If the exec fails, it will be reopened + * automatically when log_err is called. Note that the log + * might not actually be open if AP_LOG_EXEC isn't defined. + * However, the "log" cell isn't ifdef'd so let's be defensive + * and assume someone might have done something with it + * outside an ifdef'd AP_LOG_EXEC block. + */ + if (log != NULL) { + fclose(log); + log = NULL; + } + + /* + * Execute the command, replacing our image with its own. + */ +#ifdef NEED_HASHBANG_EMUL + /* We need the #! emulation when we want to execute scripts */ + { + extern char **environ; + + ap_execve(cmd, &argv[3], environ); + } +#else /*NEED_HASHBANG_EMUL*/ + execv(cmd, &argv[3]); +#endif /*NEED_HASHBANG_EMUL*/ + + /* + * (I can't help myself...sorry.) + * + * Uh oh. Still here. Where's the kaboom? There was supposed to be an + * EARTH-shattering kaboom! + * + * Oh well, log the failure and error out. + */ + log_err("(%d)%s: exec failed (%s)\n", errno, strerror(errno), cmd); + exit(255); +} diff --git a/rubbos/app/httpd-2.0.64/support/suexec.h b/rubbos/app/httpd-2.0.64/support/suexec.h new file mode 100644 index 00000000..8c350b8e --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/suexec.h @@ -0,0 +1,108 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * suexec.h -- user-definable variables for the suexec wrapper code. + * (See README.configure on how to customize these variables.) + */ + + +#ifndef _SUEXEC_H +#define _SUEXEC_H + +/* + * Include ap_config_layout so we can work out where the default htdocsdir + * and logsdir are. + */ +#include "ap_config_layout.h" + +/* + * HTTPD_USER -- Define as the username under which Apache normally + * runs. This is the only user allowed to execute + * this program. + */ +#ifndef AP_HTTPD_USER +#define AP_HTTPD_USER "www" +#endif + +/* + * UID_MIN -- Define this as the lowest UID allowed to be a target user + * for suEXEC. For most systems, 500 or 100 is common. + */ +#ifndef AP_UID_MIN +#define AP_UID_MIN 100 +#endif + +/* + * GID_MIN -- Define this as the lowest GID allowed to be a target group + * for suEXEC. For most systems, 100 is common. + */ +#ifndef AP_GID_MIN +#define AP_GID_MIN 100 +#endif + +/* + * USERDIR_SUFFIX -- Define to be the subdirectory under users' + * home directories where suEXEC access should + * be allowed. All executables under this directory + * will be executable by suEXEC as the user so + * they should be "safe" programs. If you are + * using a "simple" UserDir directive (ie. one + * without a "*" in it) this should be set to + * the same value. suEXEC will not work properly + * in cases where the UserDir directive points to + * a location that is not the same as the user's + * home directory as referenced in the passwd file. + * + * If you have VirtualHosts with a different + * UserDir for each, you will need to define them to + * all reside in one parent directory; then name that + * parent directory here. IF THIS IS NOT DEFINED + * PROPERLY, ~USERDIR CGI REQUESTS WILL NOT WORK! + * See the suEXEC documentation for more detailed + * information. + */ +#ifndef AP_USERDIR_SUFFIX +#define AP_USERDIR_SUFFIX "public_html" +#endif + +/* + * LOG_EXEC -- Define this as a filename if you want all suEXEC + * transactions and errors logged for auditing and + * debugging purposes. + */ +#ifndef AP_LOG_EXEC +#define AP_LOG_EXEC DEFAULT_EXP_LOGFILEDIR "/suexec_log" /* Need me? */ +#endif + +/* + * DOC_ROOT -- Define as the DocumentRoot set for Apache. This + * will be the only hierarchy (aside from UserDirs) + * that can be used for suEXEC behavior. + */ +#ifndef AP_DOC_ROOT +#define AP_DOC_ROOT DEFAULT_EXP_HTDOCSDIR +#endif + +/* + * SAFE_PATH -- Define a safe PATH environment to pass to CGI executables. + * + */ +#ifndef AP_SAFE_PATH +#define AP_SAFE_PATH "/usr/local/bin:/usr/bin:/bin" +#endif + +#endif /* _SUEXEC_H */ diff --git a/rubbos/app/httpd-2.0.64/support/utilitiesnw.def b/rubbos/app/httpd-2.0.64/support/utilitiesnw.def new file mode 100644 index 00000000..426b8c96 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/utilitiesnw.def @@ -0,0 +1,3 @@ +MODULE APRLIB.NLM +MODULE LIBC.NLM + diff --git a/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.c b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.c new file mode 100644 index 00000000..6d97fb7b --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.c @@ -0,0 +1,1945 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* ==================================================================== + * ApacheMonitor.c Simple program to manage and monitor Apache services. + * + * Contributed by Mladen Turk <mturk mappingsoft.com> + * + * 05 Aug 2001 + * ==================================================================== + */ + +#define _WIN32_WINNT 0x0500 +#ifndef STRICT +#define STRICT +#endif +#ifndef OEMRESOURCE +#define OEMRESOURCE +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1400 +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#include <windows.h> +#include <windowsx.h> +#include <commctrl.h> +#include <objbase.h> +#include <shlobj.h> +#include <stdlib.h> +#include <stdio.h> +#include <WtsApi32.h> +#include <tchar.h> +#include "ApacheMonitor.h" + +#ifndef AM_STRINGIFY +/** Properly quote a value as a string in the C preprocessor */ +#define AM_STRINGIFY(n) AM_STRINGIFY_HELPER(n) +/** Helper macro for AM_STRINGIFY */ +#define AM_STRINGIFY_HELPER(n) #n +#endif + +#define OS_VERSION_WIN9X 1 +#define OS_VERSION_WINNT 2 +#define OS_VERSION_WIN2K 3 + +/* Should be enough */ +#define MAX_APACHE_SERVICES 128 +#define MAX_APACHE_COMPUTERS 32 + +#define WM_TRAYMESSAGE (WM_APP+1) +#define WM_UPDATEMESSAGE (WM_USER+1) +#define WM_MANAGEMESSAGE (WM_USER+2) +#define WM_TIMER_REFRESH 10 +#define WM_TIMER_RESCAN 11 +#define SERVICE_APACHE_RESTART 128 +#define XBITMAP 16 +#define YBITMAP 16 +#define MAX_LOADSTRING 100 +#define REFRESH_TIME 2000 /* service refresh time (ms) */ +#define RESCAN_TIME 20000 /* registry rescan time (ms) */ + +typedef struct _st_APACHE_SERVICE +{ + LPTSTR szServiceName; + LPTSTR szDisplayName; + LPTSTR szDescription; + LPTSTR szImagePath; + LPTSTR szComputerName; + DWORD dwPid; +} ST_APACHE_SERVICE; + +typedef struct _st_MONITORED_COMPUTERS +{ + LPTSTR szComputerName; + HKEY hRegistry; +} ST_MONITORED_COMP; + +/* Global variables */ +HINSTANCE g_hInstance = NULL; +TCHAR *g_szTitle; /* The title bar text */ +TCHAR *g_szWindowClass; /* Window Class Name */ +HICON g_icoStop; +HICON g_icoRun; +UINT g_bUiTaskbarCreated; +DWORD g_dwOSVersion; +BOOL g_bDlgServiceOn = FALSE; +BOOL g_bConsoleRun = FALSE; +ST_APACHE_SERVICE g_stServices[MAX_APACHE_SERVICES]; +ST_MONITORED_COMP g_stComputers[MAX_APACHE_COMPUTERS]; + +HBITMAP g_hBmpStart, g_hBmpStop; +HBITMAP g_hBmpPicture, g_hBmpOld; +BOOL g_bRescanServices; +HWND g_hwndServiceDlg; +HWND g_hwndMain; +HWND g_hwndStdoutList; +HWND g_hwndConnectDlg; +HCURSOR g_hCursorHourglass; +HCURSOR g_hCursorArrow; + +HANDLE g_hpipeOutRead; +HANDLE g_hpipeOutWrite; +HANDLE g_hpipeInRead; +HANDLE g_hpipeInWrite; +HANDLE g_hpipeStdError; +LANGID g_LangID; +PROCESS_INFORMATION g_lpRedirectProc; +CRITICAL_SECTION g_stcSection; +LPTSTR g_szLocalHost; + +/* locale language support */ +static TCHAR *g_lpMsg[IDS_MSG_LAST - IDS_MSG_FIRST + 1]; + + +void am_ClearServicesSt() +{ + int i; + for (i = 0; i < MAX_APACHE_SERVICES; i++) + { + if (g_stServices[i].szServiceName) { + free(g_stServices[i].szServiceName); + } + if (g_stServices[i].szDisplayName) { + free(g_stServices[i].szDisplayName); + } + if (g_stServices[i].szDescription) { + free(g_stServices[i].szDescription); + } + if (g_stServices[i].szImagePath) { + free(g_stServices[i].szImagePath); + } + if (g_stServices[i].szComputerName) { + free(g_stServices[i].szComputerName); + } + + } + memset(g_stServices, 0, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES); + +} + + +void am_ClearComputersSt() +{ + int i; + for (i = 0; i < MAX_APACHE_COMPUTERS; i++) { + if (g_stComputers[i].szComputerName) { + free(g_stComputers[i].szComputerName); + RegCloseKey(g_stComputers[i].hRegistry); + } + } + memset(g_stComputers, 0, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS); + +} + + +BOOL am_IsComputerConnected(LPTSTR szComputerName) +{ + int i = 0; + while (g_stComputers[i].szComputerName != NULL) { + if (_tcscmp(g_stComputers[i].szComputerName, szComputerName) == 0) { + return TRUE; + } + ++i; + } + return FALSE; +} + + +void am_DisconnectComputer(LPTSTR szComputerName) +{ + int i = 0, j; + while (g_stComputers[i].szComputerName != NULL) { + if (_tcscmp(g_stComputers[i].szComputerName, szComputerName) == 0) { + break; + } + ++i; + } + if (g_stComputers[i].szComputerName != NULL) { + free(g_stComputers[i].szComputerName); + RegCloseKey(g_stComputers[i].hRegistry); + for (j = i; j < MAX_APACHE_COMPUTERS - 1; j++) { + g_stComputers[j].szComputerName= g_stComputers[j+1].szComputerName; + g_stComputers[j].hRegistry = g_stComputers[j+1].hRegistry; + } + g_stComputers[j].szComputerName = NULL; + g_stComputers[j].hRegistry = NULL; + } +} + + +void ErrorMessage(LPCTSTR szError, BOOL bFatal) +{ + LPVOID lpMsgBuf = NULL; + if (szError) { + MessageBox(NULL, szError, g_lpMsg[IDS_MSG_ERROR - IDS_MSG_FIRST], + MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION)); + } + else { + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, GetLastError(), g_LangID, + (LPTSTR) &lpMsgBuf, 0, NULL); + MessageBox(NULL, (LPCTSTR)lpMsgBuf, + g_lpMsg[IDS_MSG_ERROR - IDS_MSG_FIRST], + MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION)); + LocalFree(lpMsgBuf); + } + if (bFatal) { + PostQuitMessage(0); + } +} + + +int am_RespawnAsUserAdmin(HWND hwnd, DWORD op, LPCTSTR szService, + LPCTSTR szComputerName) +{ + TCHAR args[MAX_PATH + MAX_COMPUTERNAME_LENGTH + 12]; + + if (g_dwOSVersion < OS_VERSION_WIN2K) { + ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], FALSE); + return 0; + } + + _sntprintf(args, sizeof(args) / sizeof(TCHAR), + _T("%d \"%s\" \"%s\""), op, szService, + szComputerName ? szComputerName : _T("")); + if (!ShellExecute(hwnd, _T("runas"), __targv[0], args, NULL, SW_NORMAL)) { + ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], + FALSE); + return 0; + } + + return 1; +} + + +BOOL am_ConnectComputer(LPTSTR szComputerName) +{ + int i = 0; + HKEY hKeyRemote; + TCHAR szTmp[MAX_PATH]; + + while (g_stComputers[i].szComputerName != NULL) { + if (_tcscmp(g_stComputers[i].szComputerName, szComputerName) == 0) { + return FALSE; + } + ++i; + } + if (i > MAX_APACHE_COMPUTERS - 1) { + return FALSE; + } + if (RegConnectRegistry(szComputerName, HKEY_LOCAL_MACHINE, &hKeyRemote) + != ERROR_SUCCESS) { + _sntprintf(szTmp, sizeof(szTmp) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_ECONNECT - IDS_MSG_FIRST], + szComputerName); + ErrorMessage(szTmp, FALSE); + return FALSE; + } + else { + g_stComputers[i].szComputerName = _tcsdup(szComputerName); + g_stComputers[i].hRegistry = hKeyRemote; + return TRUE; + } +} + + +LPTSTR GetStringRes(int id) +{ + static TCHAR buffer[MAX_PATH]; + + buffer[0] = 0; + LoadString(GetModuleHandle(NULL), id, buffer, MAX_PATH); + return buffer; +} + + +BOOL GetSystemOSVersion(LPDWORD dwVersion) +{ + OSVERSIONINFO osvi; + /* + Try calling GetVersionEx using the OSVERSIONINFOEX structure. + If that fails, try using the OSVERSIONINFO structure. + */ + memset(&osvi, 0, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + if (!GetVersionEx(&osvi)) { + return FALSE; + } + + switch (osvi.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: + if (osvi.dwMajorVersion >= 5) + *dwVersion = OS_VERSION_WIN2K; + else + *dwVersion = OS_VERSION_WINNT; + break; + + case VER_PLATFORM_WIN32_WINDOWS: + *dwVersion = OS_VERSION_WIN9X; + break; + + case VER_PLATFORM_WIN32s: + default: + *dwVersion = 0; + return FALSE; + } + return TRUE; +} + + +static VOID ShowNotifyIcon(HWND hWnd, DWORD dwMessage) +{ + NOTIFYICONDATA nid; + int i = 0, n = 0; + + memset(&nid, 0, sizeof(nid)); + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hWnd; + nid.uID = 0xFF; + nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nid.uCallbackMessage = WM_TRAYMESSAGE; + + while (g_stServices[i].szServiceName != NULL) + { + if (g_stServices[i].dwPid != 0) { + ++n; + } + ++i; + } + if (dwMessage != NIM_DELETE) + { + if (n) { + nid.hIcon = g_icoRun; + } + else { + nid.hIcon = g_icoStop; + } + } + else { + nid.hIcon = NULL; + } + if (n == i && n > 0) { + _tcscpy(nid.szTip, g_lpMsg[IDS_MSG_RUNNINGALL - IDS_MSG_FIRST]); + } + else if (n) { + _sntprintf(nid.szTip, sizeof(nid.szTip) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_RUNNING - IDS_MSG_FIRST], n, i); + } + else if (i) { + _sntprintf(nid.szTip, sizeof(nid.szTip) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_RUNNINGNONE - IDS_MSG_FIRST], i); + } + else { + _tcscpy(nid.szTip, g_lpMsg[IDS_MSG_NOSERVICES - IDS_MSG_FIRST]); + } + Shell_NotifyIcon(dwMessage, &nid); +} + + +void appendMenuItem(HMENU hMenu, UINT uMenuId, LPTSTR szName, + BOOL fDefault, BOOL fEnabled) +{ + MENUITEMINFO mii; + + memset(&mii, 0, sizeof(MENUITEMINFO)); + mii.cbSize = sizeof(MENUITEMINFO); + mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE; + if (_tcslen(szName)) + { + mii.fType = MFT_STRING; + mii.wID = uMenuId; + if (fDefault) { + mii.fState = MFS_DEFAULT; + } + if (!fEnabled) { + mii.fState |= MFS_DISABLED; + } + mii.dwTypeData = szName; + } + else { + mii.fType = MFT_SEPARATOR; + } + InsertMenuItem(hMenu, uMenuId, FALSE, &mii); +} + + +void appendServiceMenu(HMENU hMenu, UINT uMenuId, + LPTSTR szServiceName, BOOL fRunning) +{ + MENUITEMINFO mii; + HMENU smh; + + smh = CreatePopupMenu(); + + appendMenuItem(smh, IDM_SM_START + uMenuId, + g_lpMsg[IDS_MSG_SSTART - IDS_MSG_FIRST], FALSE, !fRunning); + appendMenuItem(smh, IDM_SM_STOP + uMenuId, + g_lpMsg[IDS_MSG_SSTOP - IDS_MSG_FIRST], FALSE, fRunning); + appendMenuItem(smh, IDM_SM_RESTART + uMenuId, + g_lpMsg[IDS_MSG_SRESTART - IDS_MSG_FIRST], FALSE, fRunning); + + memset(&mii, 0, sizeof(MENUITEMINFO)); + mii.cbSize = sizeof(MENUITEMINFO); + mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU + | MIIM_CHECKMARKS; + mii.fType = MFT_STRING; + mii.wID = uMenuId; + mii.hbmpChecked = g_hBmpStart; + mii.hbmpUnchecked = g_hBmpStop; + mii.dwTypeData = szServiceName; + mii.hSubMenu = smh; + mii.fState = fRunning ? MFS_CHECKED : MFS_UNCHECKED; + InsertMenuItem(hMenu, IDM_SM_SERVICE + uMenuId, FALSE, &mii); +} + + +void ShowTryPopupMenu(HWND hWnd) +{ + /* create popup menu */ + HMENU hMenu = CreatePopupMenu(); + POINT pt; + + if (hMenu) + { + appendMenuItem(hMenu, IDM_RESTORE, + g_lpMsg[IDS_MSG_MNUSHOW - IDS_MSG_FIRST], + TRUE, TRUE); + if (g_dwOSVersion >= OS_VERSION_WINNT) { + appendMenuItem(hMenu, IDC_SMANAGER, + g_lpMsg[IDS_MSG_MNUSERVICES - IDS_MSG_FIRST], + FALSE, TRUE); + } + appendMenuItem(hMenu, 0, _T(""), FALSE, TRUE); + appendMenuItem(hMenu, IDM_EXIT, + g_lpMsg[IDS_MSG_MNUEXIT - IDS_MSG_FIRST], + FALSE, TRUE); + + if (!SetForegroundWindow(hWnd)) { + SetForegroundWindow(NULL); + } + GetCursorPos(&pt); + TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, + pt.x, pt.y, 0, hWnd, NULL); + DestroyMenu(hMenu); + } +} + + +void ShowTryServicesMenu(HWND hWnd) +{ + /* create services list popup menu and submenus */ + HMENU hMenu = CreatePopupMenu(); + POINT pt; + int i = 0; + + if (hMenu) + { + while (g_stServices[i].szServiceName != NULL) + { + appendServiceMenu(hMenu, i, g_stServices[i].szDisplayName, + g_stServices[i].dwPid != 0); + ++i; + } + if (i) + { + if (!SetForegroundWindow(hWnd)) { + SetForegroundWindow(NULL); + } + GetCursorPos(&pt); + TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, + pt.x, pt.y, 0, hWnd, NULL); + DestroyMenu(hMenu); + } + } +} + + +BOOL CenterWindow(HWND hwndChild) +{ + RECT rChild, rWorkArea; + int wChild, hChild; + int xNew, yNew; + BOOL bResult; + + /* Get the Height and Width of the child window */ + GetWindowRect(hwndChild, &rChild); + wChild = rChild.right - rChild.left; + hChild = rChild.bottom - rChild.top; + + /* Get the limits of the 'workarea' */ + bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT), + &rWorkArea, 0); + if (!bResult) { + rWorkArea.left = rWorkArea.top = 0; + rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); + rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); + } + + /* Calculate new X and Y position*/ + xNew = (rWorkArea.right - wChild) / 2; + yNew = (rWorkArea.bottom - hChild) / 2; + return SetWindowPos(hwndChild, HWND_TOP, xNew, yNew, 0, 0, + SWP_NOSIZE | SWP_SHOWWINDOW); +} + + +static void addListBoxItem(HWND hDlg, LPTSTR lpStr, HBITMAP hBmp) +{ + LRESULT nItem; + + nItem = SendMessage(hDlg, LB_ADDSTRING, 0, (LPARAM)lpStr); + SendMessage(hDlg, LB_SETITEMDATA, nItem, (LPARAM)hBmp); +} + + +static void addListBoxString(HWND hListBox, LPTSTR lpStr) +{ + static int nItems = 0; + if (!g_bDlgServiceOn) { + return; + } + ++nItems; + if (nItems > MAX_LOADSTRING) + { + SendMessage(hListBox, LB_RESETCONTENT, 0, 0); + nItems = 1; + } + ListBox_SetCurSel(hListBox, + ListBox_AddString(hListBox, lpStr)); + +} + + +#ifndef UNICODE +#define addListBoxStringA addListBoxString +#else +static void addListBoxStringA(HWND hListBox, LPSTR lpStr) +{ + static int nItems = 0; + TCHAR WStr[16384]; + + if (!g_bDlgServiceOn) { + return; + } + if (!MultiByteToWideChar(CP_ACP, 0, lpStr, (int)strlen(lpStr) + 1, + WStr, (int) (sizeof(WStr) / sizeof(TCHAR)))) + return; + ++nItems; + if (nItems > MAX_LOADSTRING) + { + SendMessage(hListBox, LB_RESETCONTENT, 0, 0); + nItems = 1; + } + ListBox_SetCurSel(hListBox, + ListBox_AddString(hListBox, WStr)); +} +#endif + + +static DWORD WINAPI ConsoleOutputThread(LPVOID lpThreadParameter) +{ + static BYTE lpBuffer[MAX_PATH+1]; + int nPtr = 0; + BYTE ch; + DWORD dwReaded; + + while (ReadFile(g_hpipeOutRead, &ch, 1, &dwReaded, NULL) == TRUE) + { + if (dwReaded > 0) + { + if (ch == '\n' || nPtr >= MAX_PATH) + { + lpBuffer[nPtr] = '\0'; + addListBoxStringA(g_hwndStdoutList, lpBuffer); + nPtr = 0; + } + else if (ch == '\t' && nPtr < (MAX_PATH - 4)) + { + int i; + for (i = 0; i < 4; ++i) { + lpBuffer[nPtr++] = ' '; + } + } + else if (ch != '\r') { + lpBuffer[nPtr++] = ch; + } + } + } + CloseHandle(g_hpipeInWrite); + CloseHandle(g_hpipeOutRead); + CloseHandle(g_hpipeStdError); + return 0; +} + + +DWORD WINAPI ConsoleWaitingThread(LPVOID lpThreadParameter) +{ + WaitForSingleObject(g_lpRedirectProc.hThread, INFINITE); + CloseHandle(g_lpRedirectProc.hThread); + MessageBeep(100); + g_bConsoleRun = FALSE; + SetCursor(g_hCursorArrow); + return 0; +} + + +BOOL RunRedirectedConsole(LPTSTR szCmdLine) +{ + DWORD dwThreadId; + HANDLE hProc; + STARTUPINFO stInfo; + BOOL bResult; + + memset(&stInfo, 0, sizeof(stInfo)); + stInfo.cb = sizeof(stInfo); + stInfo.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + stInfo.wShowWindow = SW_HIDE; + + hProc = GetCurrentProcess(); + + if (!CreatePipe(&g_hpipeInRead, &g_hpipeInWrite, NULL, MAX_PATH)) { + ErrorMessage(NULL, TRUE); + } + if (!CreatePipe(&g_hpipeOutRead, &g_hpipeOutWrite, NULL, MAX_PATH*8)) { + ErrorMessage(NULL, TRUE); + } + DuplicateHandle(hProc, g_hpipeInRead, hProc, &g_hpipeInRead, 0, TRUE, + DUPLICATE_CLOSE_SOURCE|DUPLICATE_SAME_ACCESS); + DuplicateHandle(hProc, g_hpipeOutWrite, hProc, &g_hpipeOutWrite, 0, TRUE, + DUPLICATE_CLOSE_SOURCE|DUPLICATE_SAME_ACCESS); + DuplicateHandle(hProc, g_hpipeOutWrite, hProc, &g_hpipeStdError, 0, TRUE, + DUPLICATE_SAME_ACCESS); + if (!g_hpipeInRead && !g_hpipeOutWrite && !g_hpipeStdError) { + ErrorMessage(NULL, TRUE); + } + stInfo.hStdInput = g_hpipeInRead; + stInfo.hStdOutput = g_hpipeOutWrite; + stInfo.hStdError = g_hpipeStdError; + + bResult = CreateProcess(NULL, + szCmdLine, + NULL, + NULL, + TRUE, + CREATE_SUSPENDED, + NULL, + NULL, + &stInfo, + &g_lpRedirectProc); + + + CloseHandle(g_hpipeInRead); + CloseHandle(g_hpipeOutWrite); + CloseHandle(g_hpipeStdError); + + if (!bResult) + { + CloseHandle(g_hpipeInWrite); + CloseHandle(g_hpipeOutRead); + CloseHandle(g_hpipeStdError); + return FALSE; + } + + CloseHandle(CreateThread(NULL, 0, ConsoleOutputThread, + 0, 0, &dwThreadId)); + ResumeThread(g_lpRedirectProc.hThread); + CloseHandle(CreateThread(NULL, 0, ConsoleWaitingThread, + 0, 0, &dwThreadId)); + + return TRUE; +} + + +BOOL RunAndForgetConsole(LPTSTR szCmdLine, BOOL bRedirectConsole) +{ + STARTUPINFO stInfo; + PROCESS_INFORMATION prInfo; + BOOL bResult; + + if (bRedirectConsole) { + return RunRedirectedConsole(szCmdLine); + } + + memset(&stInfo, 0, sizeof(stInfo)); + stInfo.cb = sizeof(stInfo); + stInfo.dwFlags = STARTF_USESHOWWINDOW; + stInfo.wShowWindow = SW_HIDE; + + bResult = CreateProcess(NULL, + szCmdLine, + NULL, + NULL, + TRUE, + CREATE_NEW_CONSOLE, + NULL, + NULL, + &stInfo, + &prInfo); + + if (!bResult) { + return FALSE; + } + if (g_dwOSVersion == OS_VERSION_WIN9X) { + /* give some time to rescan the status */ + Sleep(2000); + } + CloseHandle(prInfo.hThread); + CloseHandle(prInfo.hProcess); + return TRUE; +} + + +BOOL ApacheManageService(LPCTSTR szServiceName, LPCTSTR szImagePath, + LPTSTR szComputerName, DWORD dwCommand) +{ + TCHAR szBuf[MAX_PATH]; + TCHAR szMsg[MAX_PATH]; + LPTSTR sPos; + BOOL retValue; + BOOL serviceFlag = TRUE; + SC_HANDLE schService; + SC_HANDLE schSCManager; + SERVICE_STATUS schSStatus; + int ticks; + + if (g_dwOSVersion == OS_VERSION_WIN9X) + { + sPos = _tcsstr(szImagePath, _T("-k start")); + if (sPos) + { + _tcsncpy(szBuf, szImagePath, (int)(sPos - szImagePath)); + switch (dwCommand) + { + case SERVICE_CONTROL_STOP: + _tcscat(szBuf, _T(" -k shutdown -n ")); + break; + + case SERVICE_CONTROL_CONTINUE: + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTART - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + _tcscat(szBuf, _T(" -k start -n ")); + serviceFlag = FALSE; + break; + + case SERVICE_APACHE_RESTART: + _tcscat(szBuf, _T(" -k restart -n ")); + break; + + default: + return FALSE; + } + _tcscat(szBuf, szServiceName); + } + else { + return FALSE; + } + g_bConsoleRun = TRUE; + SetCursor(g_hCursorHourglass); + if (!RunAndForgetConsole(szBuf, serviceFlag)) + { + ErrorMessage(NULL, FALSE); + g_bConsoleRun = FALSE; + SetCursor(g_hCursorArrow); + return FALSE; + } + else if (!serviceFlag) + { + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTARTED - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + g_bConsoleRun = FALSE; + SetCursor(g_hCursorArrow); + return TRUE; + } + } + else + { + schSCManager = OpenSCManager(szComputerName, NULL, + SC_MANAGER_CONNECT); + if (!schSCManager) { + ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], + FALSE); + return FALSE; + } + + schService = OpenService(schSCManager, szServiceName, + SERVICE_QUERY_STATUS | SERVICE_START | + SERVICE_STOP | SERVICE_USER_DEFINED_CONTROL); + if (schService == NULL) + { + /* Avoid recursion of ImagePath NULL (from this Respawn) */ + if (szImagePath) { + am_RespawnAsUserAdmin(g_hwndMain, dwCommand, + szServiceName, szComputerName); + } + else { + ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], + FALSE); + } + CloseServiceHandle(schSCManager); + return FALSE; + } + else + { + retValue = FALSE; + g_bConsoleRun = TRUE; + SetCursor(g_hCursorHourglass); + switch (dwCommand) + { + case SERVICE_CONTROL_STOP: + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTOP - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + if (ControlService(schService, SERVICE_CONTROL_STOP, + &schSStatus)) { + Sleep(1000); + while (QueryServiceStatus(schService, &schSStatus)) + { + if (schSStatus.dwCurrentState == SERVICE_STOP_PENDING) + { + Sleep(1000); + } + else { + break; + } + } + } + if (QueryServiceStatus(schService, &schSStatus)) + { + if (schSStatus.dwCurrentState == SERVICE_STOPPED) + { + retValue = TRUE; + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTOPPED - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + } + } + break; + + case SERVICE_CONTROL_CONTINUE: + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTART - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + + if (StartService(schService, 0, NULL)) + { + Sleep(1000); + while (QueryServiceStatus(schService, &schSStatus)) + { + if (schSStatus.dwCurrentState == SERVICE_START_PENDING) + { + Sleep(1000); + } + else { + break; + } + } + } + if (QueryServiceStatus(schService, &schSStatus)) + { + if (schSStatus.dwCurrentState == SERVICE_RUNNING) + { + retValue = TRUE; + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVSTARTED - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + } + } + break; + + case SERVICE_APACHE_RESTART: + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVRESTART - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + if (ControlService(schService, SERVICE_APACHE_RESTART, + &schSStatus)) + { + ticks = 60; + while (schSStatus.dwCurrentState == SERVICE_START_PENDING) + { + Sleep(1000); + if (!QueryServiceStatus(schService, &schSStatus)) + { + CloseServiceHandle(schService); + CloseServiceHandle(schSCManager); + g_bConsoleRun = FALSE; + SetCursor(g_hCursorArrow); + return FALSE; + } + if (!--ticks) { + break; + } + } + } + if (schSStatus.dwCurrentState == SERVICE_RUNNING) + { + retValue = TRUE; + _sntprintf(szMsg, sizeof(szMsg) / sizeof(TCHAR), + g_lpMsg[IDS_MSG_SRVRESTARTED - IDS_MSG_FIRST], + szServiceName); + addListBoxString(g_hwndStdoutList, szMsg); + } + break; + } + CloseServiceHandle(schService); + CloseServiceHandle(schSCManager); + if (!retValue) { + ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], + FALSE); + } + g_bConsoleRun = FALSE; + SetCursor(g_hCursorArrow); + return retValue; + } + return FALSE; + } + + return FALSE; +} + + +BOOL IsServiceRunning(LPCTSTR szServiceName, LPCTSTR szComputerName, + LPDWORD lpdwPid) +{ + DWORD dwPid; + HWND hWnd; + SC_HANDLE schService; + SC_HANDLE schSCManager; + SERVICE_STATUS schSStatus; + + if (g_dwOSVersion == OS_VERSION_WIN9X) + { + hWnd = FindWindow(_T("ApacheWin95ServiceMonitor"), szServiceName); + if (hWnd && GetWindowThreadProcessId(hWnd, &dwPid)) + { + *lpdwPid = 1; + return TRUE; + } + else { + return FALSE; + } + } + else + { + dwPid = 0; + schSCManager = OpenSCManager(szComputerName, NULL, + SC_MANAGER_CONNECT); + if (!schSCManager) { + return FALSE; + } + + schService = OpenService(schSCManager, szServiceName, + SERVICE_QUERY_STATUS); + if (schService != NULL) + { + if (QueryServiceStatus(schService, &schSStatus)) + { + dwPid = schSStatus.dwCurrentState; + if (lpdwPid) { + *lpdwPid = 1; + } + } + CloseServiceHandle(schService); + CloseServiceHandle(schSCManager); + return dwPid == SERVICE_RUNNING ? TRUE : FALSE; + } + else { + g_bRescanServices = TRUE; + } + CloseServiceHandle(schSCManager); + return FALSE; + + } + + return FALSE; +} + + +BOOL FindRunningServices(void) +{ + int i = 0; + DWORD dwPid; + BOOL rv = FALSE; + while (g_stServices[i].szServiceName != NULL) + { + if (!IsServiceRunning(g_stServices[i].szServiceName, + g_stServices[i].szComputerName, &dwPid)) { + dwPid = 0; + } + if (g_stServices[i].dwPid != dwPid) { + rv = TRUE; + } + g_stServices[i].dwPid = dwPid; + ++i; + } + return rv; +} + + +BOOL GetApacheServicesStatus() +{ + TCHAR szKey[MAX_PATH]; + TCHAR achKey[MAX_PATH]; + TCHAR szImagePath[MAX_PATH]; + TCHAR szBuf[MAX_PATH]; + TCHAR szTmp[MAX_PATH]; + HKEY hKey, hSubKey, hKeyRemote; + DWORD retCode, rv, dwKeyType; + DWORD dwBufLen = MAX_PATH; + int i, stPos = 0; + int computers = 0; + + g_bRescanServices = FALSE; + + am_ClearServicesSt(); + while (g_stComputers[computers].szComputerName != NULL) { + hKeyRemote = g_stComputers[computers].hRegistry; + retCode = RegOpenKeyEx(hKeyRemote, + _T("System\\CurrentControlSet\\Services\\"), + 0, KEY_READ, &hKey); + if (retCode != ERROR_SUCCESS) + { + ErrorMessage(NULL, FALSE); + return FALSE; + } + for (i = 0, retCode = ERROR_SUCCESS; retCode == ERROR_SUCCESS; i++) + { + retCode = RegEnumKey(hKey, i, achKey, MAX_PATH); + if (retCode == ERROR_SUCCESS) + { + _tcscpy(szKey, _T("System\\CurrentControlSet\\Services\\")); + _tcscat(szKey, achKey); + + if (RegOpenKeyEx(hKeyRemote, szKey, 0, + KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) + { + dwBufLen = MAX_PATH; + rv = RegQueryValueEx(hSubKey, _T("ImagePath"), NULL, + &dwKeyType, (LPBYTE)szImagePath, &dwBufLen); + + if (rv == ERROR_SUCCESS + && (dwKeyType == REG_SZ + || dwKeyType == REG_EXPAND_SZ) + && dwBufLen) + { + _tcscpy(szBuf, szImagePath); + CharLower(szBuf); + /* the service name could be httpd*.exe or Apache*.exe */ + if (((_tcsstr(szBuf, _T("\\apache")) != NULL) + || (_tcsstr(szBuf, _T("\\httpd")) != NULL)) + && _tcsstr(szBuf, _T(".exe")) + && (_tcsstr(szBuf, _T("--ntservice")) != NULL + || _tcsstr(szBuf, _T("-k ")) != NULL)) + { + g_stServices[stPos].szServiceName = _tcsdup(achKey); + g_stServices[stPos].szImagePath = _tcsdup(szImagePath); + g_stServices[stPos].szComputerName = + _tcsdup(g_stComputers[computers].szComputerName); + dwBufLen = MAX_PATH; + if (RegQueryValueEx(hSubKey, _T("Description"), NULL, + &dwKeyType, (LPBYTE)szBuf, &dwBufLen) + == ERROR_SUCCESS) { + g_stServices[stPos].szDescription = _tcsdup(szBuf); + } + dwBufLen = MAX_PATH; + if (RegQueryValueEx(hSubKey, _T("DisplayName"), NULL, + &dwKeyType, (LPBYTE)szBuf, &dwBufLen) + == ERROR_SUCCESS) + { + if (_tcscmp(g_stComputers[computers] + .szComputerName, g_szLocalHost) != 0) + { + _tcscpy(szTmp, g_stComputers[computers] + .szComputerName + 2); + _tcscat(szTmp, _T("@")); + _tcscat(szTmp, szBuf); + } + else { + _tcscpy(szTmp, szBuf); + } + g_stServices[stPos].szDisplayName = _tcsdup(szTmp); + + } + ++stPos; + if (stPos >= MAX_APACHE_SERVICES) { + retCode = !ERROR_SUCCESS; + } + } + } + RegCloseKey(hSubKey); + } + } + } + ++computers; + RegCloseKey(hKey); + } + FindRunningServices(); + return TRUE; +} + + +LRESULT CALLBACK ConnectDlgProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam) +{ + TCHAR szCmp[MAX_COMPUTERNAME_LENGTH+4]; + switch (message) + { + case WM_INITDIALOG: + ShowWindow(hDlg, SW_HIDE); + g_hwndConnectDlg = hDlg; + CenterWindow(hDlg); + ShowWindow(hDlg, SW_SHOW); + SetFocus(GetDlgItem(hDlg, IDC_COMPUTER)); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + memset(szCmp, 0, sizeof(szCmp)); + _tcscpy(szCmp, _T("\\\\")); + SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_GETTEXT, + (WPARAM) MAX_COMPUTERNAME_LENGTH, + (LPARAM) szCmp+2); + + _tcsupr(szCmp); + if (_tcslen(szCmp) < 3) { + EndDialog(hDlg, TRUE); + return TRUE; + } + am_ConnectComputer(szCmp); + SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0); + + case IDCANCEL: + EndDialog(hDlg, TRUE); + return TRUE; + + case IDC_LBROWSE: + { + BROWSEINFO bi; + ITEMIDLIST *il; + LPMALLOC pMalloc; + memset(&bi, 0, sizeof(BROWSEINFO)); + SHGetSpecialFolderLocation(hDlg, CSIDL_NETWORK, &il); + + bi.lpszTitle = _T("ApacheMonitor :\nSelect Network Computer!"); + bi.pszDisplayName = szCmp; + bi.hwndOwner = hDlg; + bi.ulFlags = BIF_BROWSEFORCOMPUTER; + bi.lpfn = NULL; + bi.lParam = 0; + bi.iImage = 0; + bi.pidlRoot = il; + + if (SHBrowseForFolder(&bi) != NULL) { + SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), + WM_SETTEXT, + (WPARAM) NULL, (LPARAM) szCmp); + } + if (SHGetMalloc(&pMalloc)) { + pMalloc->lpVtbl->Free(pMalloc, il); + pMalloc->lpVtbl->Release(pMalloc); + } + return TRUE; + } + } + break; + + case WM_QUIT: + case WM_CLOSE: + EndDialog(hDlg, TRUE); + return TRUE; + + default: + return FALSE; + } + return FALSE; + +} + + +LRESULT CALLBACK ServiceDlgProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam) +{ + TCHAR szBuf[MAX_PATH]; + HWND hListBox; + static HWND hStatusBar; + TEXTMETRIC tm; + int i, y; + HDC hdcMem; + RECT rcBitmap; + LRESULT nItem; + LPMEASUREITEMSTRUCT lpmis; + LPDRAWITEMSTRUCT lpdis; + + memset(szBuf, 0, sizeof(szBuf)); + switch (message) + { + case WM_INITDIALOG: + ShowWindow(hDlg, SW_HIDE); + g_hwndServiceDlg = hDlg; + SetWindowText(hDlg, g_szTitle); + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE); + SetWindowText(GetDlgItem(hDlg, IDC_SSTART), + g_lpMsg[IDS_MSG_SSTART - IDS_MSG_FIRST]); + SetWindowText(GetDlgItem(hDlg, IDC_SSTOP), + g_lpMsg[IDS_MSG_SSTOP - IDS_MSG_FIRST]); + SetWindowText(GetDlgItem(hDlg, IDC_SRESTART), + g_lpMsg[IDS_MSG_SRESTART - IDS_MSG_FIRST]); + SetWindowText(GetDlgItem(hDlg, IDC_SMANAGER), + g_lpMsg[IDS_MSG_SERVICES - IDS_MSG_FIRST]); + SetWindowText(GetDlgItem(hDlg, IDC_SCONNECT), + g_lpMsg[IDS_MSG_CONNECT - IDS_MSG_FIRST]); + SetWindowText(GetDlgItem(hDlg, IDC_SEXIT), + g_lpMsg[IDS_MSG_MNUEXIT - IDS_MSG_FIRST]); + if (g_dwOSVersion < OS_VERSION_WINNT) + { + ShowWindow(GetDlgItem(hDlg, IDC_SMANAGER), SW_HIDE); + ShowWindow(GetDlgItem(hDlg, IDC_SCONNECT), SW_HIDE); + ShowWindow(GetDlgItem(hDlg, IDC_SDISCONN), SW_HIDE); + } + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + g_hwndStdoutList = GetDlgItem(hDlg, IDL_STDOUT); + hStatusBar = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */ + | WS_CHILD | WS_VISIBLE, + _T(""), hDlg, IDC_STATBAR); + if (GetApacheServicesStatus()) + { + i = 0; + while (g_stServices[i].szServiceName != NULL) + { + addListBoxItem(hListBox, g_stServices[i].szDisplayName, + g_stServices[i].dwPid == 0 ? g_hBmpStop + : g_hBmpStart); + ++i; + } + } + CenterWindow(hDlg); + ShowWindow(hDlg, SW_SHOW); + SetFocus(hListBox); + SendMessage(hListBox, LB_SETCURSEL, 0, 0); + return TRUE; + break; + + case WM_MANAGEMESSAGE: + ApacheManageService(g_stServices[LOWORD(wParam)].szServiceName, + g_stServices[LOWORD(wParam)].szImagePath, + g_stServices[LOWORD(wParam)].szComputerName, + LOWORD(lParam)); + + return TRUE; + break; + + case WM_UPDATEMESSAGE: + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + SendMessage(hListBox, LB_RESETCONTENT, 0, 0); + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)_T("")); + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE); + i = 0; + while (g_stServices[i].szServiceName != NULL) + { + addListBoxItem(hListBox, g_stServices[i].szDisplayName, + g_stServices[i].dwPid == 0 ? g_hBmpStop : g_hBmpStart); + ++i; + } + SendMessage(hListBox, LB_SETCURSEL, 0, 0); + /* Dirty hack to bring the window to the foreground */ + SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); + SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); + SetFocus(hListBox); + return TRUE; + break; + + case WM_MEASUREITEM: + lpmis = (LPMEASUREITEMSTRUCT) lParam; + lpmis->itemHeight = YBITMAP; + return TRUE; + + case WM_SETCURSOR: + if (g_bConsoleRun) { + SetCursor(g_hCursorHourglass); + } + else { + SetCursor(g_hCursorArrow); + } + return TRUE; + + case WM_DRAWITEM: + lpdis = (LPDRAWITEMSTRUCT) lParam; + if (lpdis->itemID == -1) { + break; + } + switch (lpdis->itemAction) + { + case ODA_SELECT: + case ODA_DRAWENTIRE: + g_hBmpPicture = (HBITMAP)SendMessage(lpdis->hwndItem, + LB_GETITEMDATA, + lpdis->itemID, (LPARAM) 0); + + hdcMem = CreateCompatibleDC(lpdis->hDC); + g_hBmpOld = SelectObject(hdcMem, g_hBmpPicture); + + BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + lpdis->rcItem.right - lpdis->rcItem.left, + lpdis->rcItem.bottom - lpdis->rcItem.top, + hdcMem, 0, 0, SRCCOPY); + SendMessage(lpdis->hwndItem, LB_GETTEXT, + lpdis->itemID, (LPARAM) szBuf); + + GetTextMetrics(lpdis->hDC, &tm); + y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2; + + SelectObject(hdcMem, g_hBmpOld); + DeleteDC(hdcMem); + + rcBitmap.left = lpdis->rcItem.left + XBITMAP + 2; + rcBitmap.top = lpdis->rcItem.top; + rcBitmap.right = lpdis->rcItem.right; + rcBitmap.bottom = lpdis->rcItem.top + YBITMAP; + + if (lpdis->itemState & ODS_SELECTED) + { + if (g_hBmpPicture == g_hBmpStop) + { + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), TRUE); + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE); + } + else if (g_hBmpPicture == g_hBmpStart) + { + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), TRUE); + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE); + } + else { + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE); + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE); + } + if (_tcscmp(g_stServices[lpdis->itemID].szComputerName, + g_szLocalHost) == 0) { + Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE); + } + else { + Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), TRUE); + } + + if (g_stServices[lpdis->itemID].szDescription) { + SendMessage(hStatusBar, SB_SETTEXT, 0, + (LPARAM)g_stServices[lpdis->itemID].szDescription); + } + else { + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)_T("")); + } + SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); + FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_HIGHLIGHTTEXT)); + } + else + { + SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT)); + SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW)); + FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_WINDOW+1)); + } + TextOut(lpdis->hDC, XBITMAP + 6, y, szBuf, (int)_tcslen(szBuf)); + break; + + case ODA_FOCUS: + break; + } + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDL_SERVICES: + switch (HIWORD(wParam)) + { + case LBN_DBLCLK: + /* if started then stop, if stopped then start */ + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); + if (nItem != LB_ERR) + { + g_hBmpPicture = (HBITMAP)SendMessage(hListBox, + LB_GETITEMDATA, + nItem, (LPARAM) 0); + if (g_hBmpPicture == g_hBmpStop) { + SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, + SERVICE_CONTROL_CONTINUE); + } + else { + SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, + SERVICE_CONTROL_STOP); + } + + } + return TRUE; + } + break; + + case IDOK: + EndDialog(hDlg, TRUE); + return TRUE; + + case IDC_SSTART: + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE); + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); + if (nItem != LB_ERR) { + SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, + SERVICE_CONTROL_CONTINUE); + } + Button_Enable(GetDlgItem(hDlg, IDC_SSTART), TRUE); + return TRUE; + + case IDC_SSTOP: + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE); + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); + if (nItem != LB_ERR) { + SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, + SERVICE_CONTROL_STOP); + } + Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), TRUE); + return TRUE; + + case IDC_SRESTART: + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE); + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); + if (nItem != LB_ERR) { + SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, + SERVICE_APACHE_RESTART); + } + Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE); + return TRUE; + + case IDC_SMANAGER: + if (g_dwOSVersion >= OS_VERSION_WIN2K) { + ShellExecute(hDlg, _T("open"), _T("services.msc"), _T("/s"), + NULL, SW_NORMAL); + } + else { + WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL); + } + return TRUE; + + case IDC_SEXIT: + EndDialog(hDlg, TRUE); + SendMessage(g_hwndMain, WM_COMMAND, (WPARAM)IDM_EXIT, 0); + return TRUE; + + case IDC_SCONNECT: + DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGCONNECT), + hDlg, (DLGPROC)ConnectDlgProc); + return TRUE; + + case IDC_SDISCONN: + hListBox = GetDlgItem(hDlg, IDL_SERVICES); + nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); + if (nItem != LB_ERR) { + am_DisconnectComputer(g_stServices[nItem].szComputerName); + SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0); + } + return TRUE; + } + break; + + case WM_SIZE: + switch (LOWORD(wParam)) + { + case SIZE_MINIMIZED: + EndDialog(hDlg, TRUE); + return TRUE; + break; + } + break; + + case WM_QUIT: + case WM_CLOSE: + EndDialog(hDlg, TRUE); + return TRUE; + + default: + return FALSE; + } + return FALSE; +} + + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + if (message == g_bUiTaskbarCreated) + { + /* restore the tray icon on shell restart */ + ShowNotifyIcon(hWnd, NIM_ADD); + return DefWindowProc(hWnd, message, wParam, lParam); + } + switch (message) + { + case WM_CREATE: + GetApacheServicesStatus(); + ShowNotifyIcon(hWnd, NIM_ADD); + SetTimer(hWnd, WM_TIMER_REFRESH, REFRESH_TIME, NULL); + SetTimer(hWnd, WM_TIMER_RESCAN, RESCAN_TIME, NULL); + break; + + case WM_TIMER: + switch (wParam) + { + case WM_TIMER_RESCAN: + { + int nPrev = 0, nNew = 0; + EnterCriticalSection(&g_stcSection); + if (FindRunningServices() || g_bRescanServices) + { + ShowNotifyIcon(hWnd, NIM_MODIFY); + if (g_hwndServiceDlg) + PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0); + } + /* check if services list changed */ + while (g_stServices[nPrev].szServiceName != NULL) + ++nPrev; + GetApacheServicesStatus(); + while (g_stServices[nNew].szServiceName != NULL) + ++nNew; + if (nPrev != nNew) + { + ShowNotifyIcon(hWnd, NIM_MODIFY); + if (g_hwndServiceDlg) { + PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0); + } + } + LeaveCriticalSection(&g_stcSection); + break; + } + + case WM_TIMER_REFRESH: + { + int nPrev = 0, nNew = 0; + EnterCriticalSection(&g_stcSection); + if (g_bRescanServices) + { + GetApacheServicesStatus(); + ShowNotifyIcon(hWnd, NIM_MODIFY); + if (g_hwndServiceDlg) { + PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0); + } + } + else if (FindRunningServices()) + { + ShowNotifyIcon(hWnd, NIM_MODIFY); + if (g_hwndServiceDlg) { + PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0); + } + } + LeaveCriticalSection(&g_stcSection); + break; + } + } + break; + + case WM_QUIT: + ShowNotifyIcon(hWnd, NIM_DELETE); + break; + + case WM_TRAYMESSAGE: + switch (lParam) + { + case WM_LBUTTONDBLCLK: + if (!g_bDlgServiceOn) + { + g_bDlgServiceOn = TRUE; + DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES), + hWnd, (DLGPROC)ServiceDlgProc); + g_bDlgServiceOn = FALSE; + g_hwndServiceDlg = NULL; + } + else if (IsWindow(g_hwndServiceDlg)) + { + /* Dirty hack to bring the window to the foreground */ + SetWindowPos(g_hwndServiceDlg, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); + SetWindowPos(g_hwndServiceDlg, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); + SetFocus(g_hwndServiceDlg); + } + break; + + case WM_LBUTTONUP: + ShowTryServicesMenu(hWnd); + break; + + case WM_RBUTTONUP: + ShowTryPopupMenu(hWnd); + break; + } + break; + + case WM_COMMAND: + if ((LOWORD(wParam) & IDM_SM_START) == IDM_SM_START) + { + ApacheManageService(g_stServices[LOWORD(wParam) + - IDM_SM_START].szServiceName, + g_stServices[LOWORD(wParam) + - IDM_SM_START].szImagePath, + g_stServices[LOWORD(wParam) + - IDM_SM_START].szComputerName, + SERVICE_CONTROL_CONTINUE); + return TRUE; + } + else if ((LOWORD(wParam) & IDM_SM_STOP) == IDM_SM_STOP) + { + ApacheManageService(g_stServices[LOWORD(wParam) + - IDM_SM_STOP].szServiceName, + g_stServices[LOWORD(wParam) + - IDM_SM_STOP].szImagePath, + g_stServices[LOWORD(wParam) + - IDM_SM_STOP].szComputerName, + SERVICE_CONTROL_STOP); + return TRUE; + } + else if ((LOWORD(wParam) & IDM_SM_RESTART) == IDM_SM_RESTART) + { + ApacheManageService(g_stServices[LOWORD(wParam) + - IDM_SM_RESTART].szServiceName, + g_stServices[LOWORD(wParam) + - IDM_SM_RESTART].szImagePath, + g_stServices[LOWORD(wParam) + - IDM_SM_RESTART].szComputerName, + SERVICE_APACHE_RESTART); + return TRUE; + } + switch (LOWORD(wParam)) + { + case IDM_RESTORE: + if (!g_bDlgServiceOn) + { + g_bDlgServiceOn = TRUE; + DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES), + hWnd, (DLGPROC)ServiceDlgProc); + g_bDlgServiceOn = FALSE; + g_hwndServiceDlg = NULL; + } + else if (IsWindow(g_hwndServiceDlg)) { + SetFocus(g_hwndServiceDlg); + } + break; + + case IDC_SMANAGER: + if (g_dwOSVersion >= OS_VERSION_WIN2K) { + ShellExecute(NULL, _T("open"), _T("services.msc"), _T("/s"), + NULL, SW_NORMAL); + } + else { + WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL); + } + return TRUE; + + case IDM_EXIT: + ShowNotifyIcon(hWnd, NIM_DELETE); + PostQuitMessage(0); + return TRUE; + } + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return FALSE; +} + + +static int KillAWindow(HWND appwindow) +{ + HANDLE appproc; + DWORD procid; + BOOL postres; + + SetLastError(0); + GetWindowThreadProcessId(appwindow, &procid); + if (GetLastError()) + return(2); + + appproc = OpenProcess(SYNCHRONIZE, 0, procid); + postres = PostMessage(appwindow, WM_COMMAND, IDM_EXIT, 0); + if (appproc && postres) { + if (WaitForSingleObject(appproc, 10 /* seconds */ * 1000) + == WAIT_OBJECT_0) { + CloseHandle(appproc); + return (0); + } + } + if (appproc) + CloseHandle(appproc); + + if ((appproc = OpenProcess(PROCESS_TERMINATE, 0, procid)) != NULL) { + if (TerminateProcess(appproc, 0)) { + CloseHandle(appproc); + return (0); + } + CloseHandle(appproc); + } + + /* Perhaps we were short of permissions? */ + return (2); +} + + +static int KillAllMonitors(void) +{ + HWND appwindow; + int exitcode = 0; + PWTS_PROCESS_INFO tsProcs; + DWORD tsProcCount, i; + DWORD thisProcId; + + /* This is graceful, close our own Window, clearing the icon */ + if ((appwindow = FindWindow(g_szWindowClass, g_szTitle)) != NULL) + exitcode = KillAWindow(appwindow); + + if (g_dwOSVersion < OS_VERSION_WIN2K) + return exitcode; + + thisProcId = GetCurrentProcessId(); + + if (!WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, + &tsProcs, &tsProcCount)) + return exitcode; + + /* This is ungraceful; close other Windows, with a lingering icon. + * Since on terminal server it's not possible to post the message + * to exit across sessions, we have to suffer this side effect + * of a taskbar 'icon' which will evaporate the next time that + * the user hovers over it or when the taskbar area is updated. + */ + for (i = 0; i < tsProcCount; ++i) { + if (_tcscmp(tsProcs[i].pProcessName, _T(AM_STRINGIFY(BIN_NAME))) == 0 + && tsProcs[i].ProcessId != thisProcId) + WTSTerminateProcess(WTS_CURRENT_SERVER_HANDLE, + tsProcs[i].ProcessId, 1); + } + WTSFreeMemory(tsProcs); + return exitcode; +} + + +/* Create main invisible window */ +HWND CreateMainWindow(HINSTANCE hInstance) +{ + HWND hWnd = NULL; + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON), + IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR); + wcex.hCursor = g_hCursorArrow; + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = g_szWindowClass; + wcex.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON), + IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + + if (RegisterClassEx(&wcex)) { + hWnd = CreateWindow(g_szWindowClass, g_szTitle, + 0, 0, 0, 0, 0, + NULL, NULL, hInstance, NULL); + } + return hWnd; +} + + +#ifndef UNICODE +/* Borrowed from CRT internal.h for _MBCS argc/argv parsing in this GUI app */ +int __cdecl _setargv(void); +#endif + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) +{ + TCHAR szTmp[MAX_LOADSTRING]; + TCHAR szCmp[MAX_COMPUTERNAME_LENGTH+4]; + MSG msg; + /* existing window */ + HWND appwindow; + DWORD dwControl; + int i; + DWORD d; + + if (!GetSystemOSVersion(&g_dwOSVersion)) + { + ErrorMessage(NULL, TRUE); + return 1; + } + + g_LangID = GetUserDefaultLangID(); + if ((g_LangID & 0xFF) != LANG_ENGLISH) { + g_LangID = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); + } + for (i = IDS_MSG_FIRST; i <= IDS_MSG_LAST; ++i) { + LoadString(hInstance, i, szTmp, MAX_LOADSTRING); + g_lpMsg[i - IDS_MSG_FIRST] = _tcsdup(szTmp); + } + LoadString(hInstance, IDS_APMONITORTITLE, szTmp, MAX_LOADSTRING); + d = MAX_COMPUTERNAME_LENGTH+1; + _tcscpy(szCmp, _T("\\\\")); + GetComputerName(szCmp + 2, &d); + _tcsupr(szCmp); + g_szLocalHost = _tcsdup(szCmp); + + memset(g_stComputers, 0, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS); + g_stComputers[0].szComputerName = _tcsdup(szCmp); + g_stComputers[0].hRegistry = HKEY_LOCAL_MACHINE; + g_szTitle = _tcsdup(szTmp); + LoadString(hInstance, IDS_APMONITORCLASS, szTmp, MAX_LOADSTRING); + g_szWindowClass = _tcsdup(szTmp); + + appwindow = FindWindow(g_szWindowClass, g_szTitle); + +#ifdef UNICODE + __wargv = CommandLineToArgvW(GetCommandLineW(), &__argc); +#else + _setargv(); +#endif + + if ((__argc == 2) && (_tcscmp(__targv[1], _T("--kill")) == 0)) + { + /* Off to chase and close up every ApacheMonitor taskbar window */ + return KillAllMonitors(); + } + else if ((__argc == 4) && (g_dwOSVersion >= OS_VERSION_WIN2K)) + { + dwControl = _ttoi(__targv[1]); + if ((dwControl != SERVICE_CONTROL_CONTINUE) && + (dwControl != SERVICE_APACHE_RESTART) && + (dwControl != SERVICE_CONTROL_STOP)) + { + return 1; + } + + /* Chase down and close up our session's previous window */ + if ((appwindow) != NULL) + KillAWindow(appwindow); + } + else if (__argc != 1) { + return 1; + } + else if (appwindow) + { + ErrorMessage(g_lpMsg[IDS_MSG_APPRUNNING - IDS_MSG_FIRST], FALSE); + return 0; + } + + g_icoStop = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICOSTOP), + IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_icoRun = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICORUN), + IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hCursorHourglass = LoadImage(NULL, MAKEINTRESOURCE(OCR_WAIT), + IMAGE_CURSOR, LR_DEFAULTSIZE, + LR_DEFAULTSIZE, LR_SHARED); + g_hCursorArrow = LoadImage(NULL, MAKEINTRESOURCE(OCR_NORMAL), + IMAGE_CURSOR, LR_DEFAULTSIZE, + LR_DEFAULTSIZE, LR_SHARED); + g_hBmpStart = LoadImage(hInstance, MAKEINTRESOURCE(IDB_BMPRUN), + IMAGE_BITMAP, XBITMAP, YBITMAP, + LR_DEFAULTCOLOR); + g_hBmpStop = LoadImage(hInstance, MAKEINTRESOURCE(IDB_BMPSTOP), + IMAGE_BITMAP, XBITMAP, YBITMAP, + LR_DEFAULTCOLOR); + + memset(g_stServices, 0, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES); + CoInitialize(NULL); + InitCommonControls(); + g_hInstance = hInstance; + g_hwndMain = CreateMainWindow(hInstance); + g_bUiTaskbarCreated = RegisterWindowMessage(_T("TaskbarCreated")); + InitializeCriticalSection(&g_stcSection); + g_hwndServiceDlg = NULL; + if (g_hwndMain != NULL) + { + /* To avoid recursion, pass ImagePath NULL (a noop on NT and later) */ + if ((__argc == 4) && (g_dwOSVersion >= OS_VERSION_WIN2K)) + ApacheManageService(__targv[2], NULL, __targv[3], dwControl); + + while (GetMessage(&msg, NULL, 0, 0) == TRUE) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + am_ClearServicesSt(); + } + am_ClearComputersSt(); + DeleteCriticalSection(&g_stcSection); + DestroyIcon(g_icoStop); + DestroyIcon(g_icoRun); + DestroyCursor(g_hCursorHourglass); + DestroyCursor(g_hCursorArrow); + DeleteObject(g_hBmpStart); + DeleteObject(g_hBmpStop); + CoUninitialize(); + return 0; +} + diff --git a/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.dsp b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.dsp new file mode 100644 index 00000000..84369aaa --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.dsp @@ -0,0 +1,143 @@ +# Microsoft Developer Studio Project File - Name="ApacheMonitor" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=ApacheMonitor - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ApacheMonitor.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ApacheMonitor.mak" CFG="ApacheMonitor - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ApacheMonitor - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "ApacheMonitor - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ApacheMonitor - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /MD /W3 /EHsc /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "STRICT" /Fd"Release/ApacheMonitor_src" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "../../include" /I "../../srclib/apr/include" /d "NDEBUG" /d "APP_FILE" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib wtsapi32.lib /nologo /subsystem:windows +# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib wtsapi32.lib /nologo /subsystem:windows /debug /opt:ref +# Begin Special Build Tool +TargetPath=.\Release\ApacheMonitor.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ELSEIF "$(CFG)" == "ApacheMonitor - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "STRICT" /Fd"Debug/ApacheMonitor_src" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /i "../../include" /I "../../srclib/apr/include" /d "_DEBUG" /d "APP_FILE" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib wtsapi32.lib /nologo /subsystem:windows /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib wtsapi32.lib /nologo /subsystem:windows /incremental:no /debug +# Begin Special Build Tool +TargetPath=.\Debug\ApacheMonitor.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Embed .manifest +PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "ApacheMonitor - Win32 Release" +# Name "ApacheMonitor - Win32 Debug" +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\apache_header.bmp +# End Source File +# Begin Source File + +SOURCE=.\ApacheMonitor.ico +# End Source File +# Begin Source File + +SOURCE=.\aprun.ico +# End Source File +# Begin Source File + +SOURCE=.\apstop.ico +# End Source File +# Begin Source File + +SOURCE=.\srun.bmp +# End Source File +# Begin Source File + +SOURCE=.\sstop.bmp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ApacheMonitor.c +# End Source File +# Begin Source File + +SOURCE=.\ApacheMonitor.h +# End Source File +# Begin Source File + +SOURCE=.\ApacheMonitor.rc +# End Source File +# End Target +# End Project diff --git a/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.h b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.h new file mode 100644 index 00000000..085c45f8 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.h @@ -0,0 +1,78 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file ApacheMonitor.h + * @brief Resource definitions for ApacheMonitor.rc and ApacheMonitor.c + */ +#define BIN_NAME ApacheMonitor.exe + +#define IDD_DLGSERVICES 101 +#define IDS_APMONITORTITLE 102 +#define IDS_APMONITORCLASS 103 +#define IDM_RESTORE 104 +#define IDM_EXIT 105 +#define IDI_APSRVMON 106 +#define IDI_ICOSTOP 107 +#define IDI_ICORUN 108 +#define IDC_STATBAR 109 +#define IDC_SSTATUS 110 +#define IDB_BMPSTOP 111 +#define IDB_BMPRUN 112 +#define IDB_BMPHEADER 114 +#define IDL_SERVICES 115 +#define IDL_STDOUT 116 +#define IDC_SSTART 117 +#define IDC_SSTOP 118 +#define IDC_SRESTART 119 +#define IDC_SEXIT 120 +#define IDC_SMANAGER 121 +#define IDD_DLGCONNECT 122 +#define IDC_LREMOTE 123 +#define IDC_LBROWSE 124 +#define IDC_COMPUTER 125 +#define IDC_SCONNECT 126 +#define IDC_SDISCONN 127 +#define IDS_MSG_FIRST 256 +#define IDS_MSG_APPRUNNING 256 +#define IDS_MSG_ERROR 257 +#define IDS_MSG_RUNNINGALL 258 +#define IDS_MSG_RUNNING 259 +#define IDS_MSG_RUNNINGNONE 260 +#define IDS_MSG_NOSERVICES 261 +#define IDS_MSG_MNUSERVICES 262 +#define IDS_MSG_MNUSHOW 263 +#define IDS_MSG_MNUEXIT 264 +#define IDS_MSG_SRVSTART 265 +#define IDS_MSG_SRVSTARTED 266 +#define IDS_MSG_SRVSTOP 267 +#define IDS_MSG_SRVSTOPPED 268 +#define IDS_MSG_SRVRESTART 269 +#define IDS_MSG_SRVRESTARTED 270 +#define IDS_MSG_SRVFAILED 271 +#define IDS_MSG_SSTART 272 +#define IDS_MSG_SSTOP 273 +#define IDS_MSG_SRESTART 274 +#define IDS_MSG_SERVICES 275 +#define IDS_MSG_CONNECT 276 +#define IDS_MSG_ECONNECT 277 +#define IDS_MSG_LAST 277 +#define IDM_SM_SERVICE 0x1100 +#define IDM_SM_START 0x1200 +#define IDM_SM_STOP 0x1400 +#define IDM_SM_RESTART 0x1800 +#define IDC_STATIC -1 + diff --git a/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.ico b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.ico Binary files differnew file mode 100644 index 00000000..cd28dc52 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.ico diff --git a/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.rc b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.rc new file mode 100644 index 00000000..099934e6 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/ApacheMonitor.rc @@ -0,0 +1,97 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <windows.h> + +#include "ApacheMonitor.h" + +IDI_APSRVMON ICON DISCARDABLE "ApacheMonitor.ico" +IDI_ICOSTOP ICON DISCARDABLE "apstop.ico" +IDI_ICORUN ICON DISCARDABLE "aprun.ico" + +IDD_DLGSERVICES DIALOGEX 0, 0, 350, 188 +STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_MINIMIZEBOX | WS_VISIBLE | + WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Apache Service Monitor" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "&OK",IDOK,298,49,50,14 + LTEXT "Service St&atus :",IDC_SSTATUS,3,40,272,8 + LISTBOX IDL_SERVICES,2,49,285,73,LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | + LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP + LISTBOX IDL_STDOUT,2,124,285,51,LBS_NOINTEGRALHEIGHT | + LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL + PUSHBUTTON "&Start",IDC_SSTART,298,65,50,14 + PUSHBUTTON "S&top",IDC_SSTOP,298,81,50,14 + PUSHBUTTON "&Restart",IDC_SRESTART,298,97,50,14 + PUSHBUTTON "Ser&vices",IDC_SMANAGER,298,113,50,14 + CONTROL IDB_BMPHEADER,IDC_STATIC,"Static",SS_BITMAP,0,0,349,38 + PUSHBUTTON "&Connect",IDC_SCONNECT,298,129,50,14 + PUSHBUTTON "&Disconnect",IDC_SDISCONN,298,145,50,14 + PUSHBUTTON "E&xit",IDC_SEXIT,298,161,50,14 +END + +IDD_DLGCONNECT DIALOGEX 0, 0, 240, 54 +STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_VISIBLE | WS_CLIPCHILDREN | + WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Connect To A Remote Computer" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Computer &Name:",IDC_LREMOTE,7,4,155,8 + EDITTEXT IDC_COMPUTER,7,14,169,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "&OK",IDOK,183,14,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,183,34,50,14 + PUSHBUTTON "&Browse",IDC_LBROWSE,7,34,50,14 +END + +IDB_BMPSTOP BITMAP DISCARDABLE "sstop.bmp" +IDB_BMPRUN BITMAP DISCARDABLE "srun.bmp" +IDB_BMPHEADER BITMAP DISCARDABLE "apache_header.bmp" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APMONITORTITLE "Apache Service Monitor" + IDS_APMONITORCLASS "ApacheServiceMonitorClass" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_MSG_APPRUNNING "Apache monitor is already started" + IDS_MSG_ERROR "Error" + IDS_MSG_RUNNINGALL "Running all Apache services" + IDS_MSG_RUNNING "Running %d of %d Apache services" + IDS_MSG_RUNNINGNONE "Running none of %d Apache services" + IDS_MSG_NOSERVICES "No services installed" + IDS_MSG_MNUSERVICES "Open &Services" + IDS_MSG_MNUSHOW "&Open Apache Monitor" + IDS_MSG_MNUEXIT "E&xit" + IDS_MSG_SRVSTART "The %s service is starting." + IDS_MSG_SRVSTARTED "The %s service has started." + IDS_MSG_SRVSTOP "The %s service is stopping." + IDS_MSG_SRVSTOPPED "The %s service has stopped." + IDS_MSG_SRVRESTART "The %s service is restarting." + IDS_MSG_SRVRESTARTED "The %s service has restarted." + IDS_MSG_SRVFAILED "The requested operation has failed!" + IDS_MSG_SSTART "&Start" + IDS_MSG_SSTOP "S&top" + IDS_MSG_SRESTART "&Restart" + IDS_MSG_SERVICES "Ser&vices" + IDS_MSG_CONNECT "&Connect" + IDS_MSG_ECONNECT "Unable to connect to the remote registry on %s" +END diff --git a/rubbos/app/httpd-2.0.64/support/win32/apache_header.bmp b/rubbos/app/httpd-2.0.64/support/win32/apache_header.bmp Binary files differnew file mode 100644 index 00000000..7340fac2 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/apache_header.bmp diff --git a/rubbos/app/httpd-2.0.64/support/win32/aprun.ico b/rubbos/app/httpd-2.0.64/support/win32/aprun.ico Binary files differnew file mode 100644 index 00000000..dbd58326 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/aprun.ico diff --git a/rubbos/app/httpd-2.0.64/support/win32/apstop.ico b/rubbos/app/httpd-2.0.64/support/win32/apstop.ico Binary files differnew file mode 100644 index 00000000..fba49ad2 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/apstop.ico diff --git a/rubbos/app/httpd-2.0.64/support/win32/srun.bmp b/rubbos/app/httpd-2.0.64/support/win32/srun.bmp Binary files differnew file mode 100644 index 00000000..90ecd46f --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/srun.bmp diff --git a/rubbos/app/httpd-2.0.64/support/win32/sstop.bmp b/rubbos/app/httpd-2.0.64/support/win32/sstop.bmp Binary files differnew file mode 100644 index 00000000..ba73d87a --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/sstop.bmp diff --git a/rubbos/app/httpd-2.0.64/support/win32/wintty.c b/rubbos/app/httpd-2.0.64/support/win32/wintty.c new file mode 100644 index 00000000..21391bdd --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/wintty.c @@ -0,0 +1,375 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* -------------------------------------------------------------------- + * + * wintty : a Apache/WinNT support utility for monitoring and + * reflecting user feedback from the Apache process via + * stdin/stdout, even as running within the service context. + * + * Originally contributed by William Rowe <wrowe covalent.net> + * + * Note: this implementation is _very_ experimental, and error handling + * is far from complete. Using it as a cgi or pipe process allows the + * programmer to discover if facilities such as reliable piped logs + * are working as expected, or answer operator prompts that would + * otherwise be discarded by the service process. + * + * Also note the isservice detection semantics, which far exceed any + * mechanism we have discovered thus far. + * + * -------------------------------------------------------------------- + */ + +#define WIN32_LEAN_AND_MEAN + +#if defined(_MSC_VER) && _MSC_VER >= 1400 +#define _CRT_SECURE_NO_DEPRECATE +#pragma warning(disable: 4996) +#endif + +#include <windows.h> +#include <stdlib.h> +#include <stdio.h> + +const char *options = +"\nwintty: a utility for echoing the stdin stream to a new console window,\n" +"\teven when invoked from within a service (such as the Apache server.)\n" +"\tAlso reflects the console input back to the stdout stream, allowing\n" +"\tthe operator to respond to prompts from the context of a service.\n\n" +"Syntax: %s [opts] [-t \"Window Title\"]\n\n" +" opts: -c{haracter} or -l{ine} input\n" +"\t-q{uiet} or -e{cho} input\n" +"\t-u{nprocessed} or -p{rocessed} input\n" +"\t-n{owrap} or -w{rap} output lines\n" +"\t-f{ormatted} or -r{aw} output lines\n" +"\t-O{output} [number of seconds]\n" +"\t-v{erbose} error reporting (for debugging)\n" +"\t-? for this message\n\n"; + +BOOL verbose = FALSE; + +void printerr(char *fmt, ...) +{ + char str[1024]; + va_list args; + if (!verbose) + return; + va_start(args, fmt); + wvsprintf(str, fmt, args); + OutputDebugString(str); +} + +DWORD WINAPI feedback(LPVOID args); + +typedef struct feedback_args_t { + HANDLE in; + HANDLE out; +} feedback_args_t; + +int main(int argc, char** argv) +{ + char str[1024], *contitle = NULL; + HANDLE hproc, thread; + HANDLE hwinsta = NULL, hsavewinsta; + HANDLE hdesk = NULL, hsavedesk = NULL; + HANDLE conin, conout; + HANDLE hstdin, hstdout, hstderr, hdup; + feedback_args_t feed; + DWORD conmode; + DWORD newinmode = 0, notinmode = 0; + DWORD newoutmode = 0, notoutmode = 0; + DWORD tid; + DWORD len; + DWORD timeout = INFINITE; + BOOL isservice = FALSE; + char *arg0 = argv[0]; + + while (--argc) { + ++argv; + if (**argv == '/' || **argv == '-') { + switch (tolower((*argv)[1])) { + case 'c': + notinmode |= ENABLE_LINE_INPUT; break; + case 'l': + newinmode |= ENABLE_LINE_INPUT; break; + case 'q': + notinmode |= ENABLE_ECHO_INPUT; break; + case 'e': + newinmode |= ENABLE_ECHO_INPUT; break; + case 'u': + notinmode |= ENABLE_PROCESSED_INPUT; break; + case 'p': + newinmode |= ENABLE_PROCESSED_INPUT; break; + case 'n': + notoutmode |= ENABLE_WRAP_AT_EOL_OUTPUT; break; + case 'w': + newoutmode |= ENABLE_WRAP_AT_EOL_OUTPUT; break; + case 'r': + notoutmode |= ENABLE_PROCESSED_OUTPUT; break; + case 'f': + newoutmode |= ENABLE_PROCESSED_OUTPUT; break; + case 'o': + if (*(argv + 1) && *(argv + 1)[0] != '-') { + *(++argv); + timeout = atoi(*argv) / 1000; + --argc; + } + else { + timeout = 0; + } + break; + case 'v': + verbose = TRUE; + break; + case 't': + contitle = *(++argv); + --argc; + break; + case '?': + printf(options, arg0); + exit(1); + default: + printf("wintty option %s not recognized, use -? for help.\n\n", *argv); + exit(1); + } + } + else { + printf("wintty argument %s not understood, use -? for help.\n\n", *argv); + exit(1); + } + } + + hproc = GetCurrentProcess(); + hsavewinsta = GetProcessWindowStation(); + if (!hsavewinsta || hsavewinsta == INVALID_HANDLE_VALUE) { + printerr("GetProcessWindowStation() failed (%d)\n", GetLastError()); + } + else if (!GetUserObjectInformation(hsavewinsta, UOI_NAME, str, sizeof(str), &len)) { + printerr("GetUserObjectInfoformation(hWinSta) failed (%d)\n", GetLastError()); + } + else if (strnicmp(str, "Service-", 8) == 0) { + printerr("WindowStation Name %s is a service\n", str); + isservice = TRUE; + } + SetLastError(0); + + hstdin = GetStdHandle(STD_INPUT_HANDLE); + if (!hstdin || hstdin == INVALID_HANDLE_VALUE) { + printerr("GetStdHandle(STD_INPUT_HANDLE) failed (%d)\n", + GetLastError()); + } + else if (DuplicateHandle(hproc, hstdin, hproc, &hdup, 0, + isservice, DUPLICATE_SAME_ACCESS)) { + CloseHandle(hstdin); + hstdin = hdup; + } + else { + printerr("DupHandle(stdin [%x]) failed (%d)\n", + hstdin, GetLastError()); + } + + hstdout = GetStdHandle(STD_OUTPUT_HANDLE); + if (!hstdout || hstdout == INVALID_HANDLE_VALUE) { + printerr("GetStdHandle(STD_OUTPUT_HANDLE) failed (%d)\n", + GetLastError()); + } + else if (DuplicateHandle(hproc, hstdout, hproc, &hdup, 0, + isservice, DUPLICATE_SAME_ACCESS)) { + CloseHandle(hstdout); + hstdout = hdup; + } + else { + printerr("DupHandle(stdout [%x]) failed (%d)\n", + hstdout, GetLastError()); + } + + hstderr = GetStdHandle(STD_ERROR_HANDLE); + if (!hstderr || hstderr == INVALID_HANDLE_VALUE) { + printerr("GetStdHandle(STD_ERROR_HANDLE) failed (%d)\n", + GetLastError()); + } + else if (DuplicateHandle(hproc, hstderr, hproc, &hdup, 0, + isservice, DUPLICATE_SAME_ACCESS)) { + CloseHandle(hstderr); + hstderr = hdup; + } + else { + printerr("DupHandle(stderr [%x]) failed (%d)\n", + hstderr, GetLastError()); + } + + /* You can't close the console till all the handles above were + * rescued by DuplicateHandle() + */ + if (!FreeConsole()) + printerr("FreeConsole() failed (%d)\n", GetLastError()); + + if (isservice) { +#ifdef WE_EVER_FIGURE_OUT_WHY_THIS_DOESNT_WORK + hsavedesk = GetThreadDesktop(GetCurrentThreadId()); + if (!hsavedesk || hsavedesk == INVALID_HANDLE_VALUE) { + printerr("GetThreadDesktop(GetTID()) failed (%d)\n", GetLastError()); + } + CloseWindowStation(hwinsta); + hwinsta = OpenWindowStation("WinSta0", TRUE, MAXIMUM_ALLOWED); + if (!hwinsta || hwinsta == INVALID_HANDLE_VALUE) { + printerr("OpenWinSta(WinSta0) failed (%d)\n", GetLastError()); + } + else if (!SetProcessWindowStation(hwinsta)) { + printerr("SetProcWinSta(WinSta0) failed (%d)\n", GetLastError()); + } + hdesk = OpenDesktop("Default", 0, TRUE, MAXIMUM_ALLOWED); + if (!hdesk || hdesk == INVALID_HANDLE_VALUE) { + printerr("OpenDesktop(Default) failed (%d)\n", GetLastError()); + } + else if (!SetThreadDesktop(hdesk)) { + printerr("SetThreadDesktop(Default) failed (%d)\n", GetLastError()); + } +#else + PROCESS_INFORMATION pi; + STARTUPINFO si; + DWORD exitcode = 1; + char appbuff[MAX_PATH]; + char *appname = NULL; + char *cmdline = GetCommandLine(); + + if (!GetModuleFileName(NULL, appbuff, sizeof(appbuff))) { + appname = appbuff; + } + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW + | STARTF_USESTDHANDLES; + si.lpDesktop = "WinSta0\\Default"; + si.wShowWindow = 1; /* SW_SHOWNORMAL */ + si.hStdInput = hstdin; + si.hStdOutput = hstdout; + si.hStdError = hstderr; + + /* Instantly, upon creating the new process, we will close our + * copies of the handles so our parent isn't confused when the + * child closes their copy of the handle. Without this action, + * we would hold a copy of the handle, and the parent would not + * receive their EOF notification. + */ + if (CreateProcess(appname, cmdline, NULL, NULL, TRUE, + CREATE_SUSPENDED | CREATE_NEW_CONSOLE, + NULL, NULL, &si, &pi)) { + CloseHandle(si.hStdInput); + CloseHandle(si.hStdOutput); + CloseHandle(si.hStdError); + ResumeThread(pi.hThread); + CloseHandle(pi.hThread); + WaitForSingleObject(pi.hProcess, INFINITE); + GetExitCodeProcess(pi.hProcess, &exitcode); + CloseHandle(pi.hProcess); + return exitcode; + } + return 1; +#endif + } + + if (!AllocConsole()) { + printerr("AllocConsole(Default) failed (%d)\n", GetLastError()); + } + + if (contitle && !SetConsoleTitle(contitle)) { + printerr("SetConsoleTitle() failed (%d)\n", GetLastError()); + } + + conout = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FALSE, OPEN_EXISTING, 0, NULL); + if (!conout || conout == INVALID_HANDLE_VALUE) { + printerr("CreateFile(CONOUT$) failed (%d)\n", GetLastError()); + } + else if (!GetConsoleMode(conout, &conmode)) { + printerr("GetConsoleMode(CONOUT) failed (%d)\n", GetLastError()); + } + else if (!SetConsoleMode(conout, conmode = ((conmode | newoutmode) + & ~notoutmode))) { + printerr("SetConsoleMode(CONOUT, 0x%x) failed (%d)\n", + conmode, GetLastError()); + } + + conin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FALSE, OPEN_EXISTING, 0, NULL); + if (!conin || conin == INVALID_HANDLE_VALUE) { + printerr("CreateFile(CONIN$) failed (%d)\n", GetLastError()); + } + else if (!GetConsoleMode(conin, &conmode)) { + printerr("GetConsoleMode(CONIN) failed (%d)\n", GetLastError()); + } + else if (!SetConsoleMode(conin, conmode = ((conmode | newinmode) + & ~notinmode))) { + printerr("SetConsoleMode(CONIN, 0x%x) failed (%d)\n", + conmode, GetLastError()); + } + + feed.in = conin; + feed.out = hstdout; + thread = CreateThread(NULL, 0, feedback, (LPVOID)&feed, 0, &tid); + + while (ReadFile(hstdin, str, sizeof(str), &len, NULL)) + if (!len || !WriteFile(conout, str, len, &len, NULL)) + break; + + printerr("[EOF] from stdin (%d)\n", GetLastError()); + + CloseHandle(stdout); + if (!GetConsoleTitle(str, sizeof(str))) { + printerr("SetConsoleTitle() failed (%d)\n", GetLastError()); + } + else { + strcat(str, " - [Finished]"); + if (!SetConsoleTitle(str)) { + printerr("SetConsoleTitle() failed (%d)\n", GetLastError()); + } + } + + WaitForSingleObject(thread, timeout); + FreeConsole(); + if (isservice) { + if (!SetProcessWindowStation(hsavewinsta)) { + len = GetLastError(); + } + if (!SetThreadDesktop(hsavedesk)) { + len = GetLastError(); + } + CloseDesktop(hdesk); + CloseWindowStation(hwinsta); + } + return 0; +} + + +DWORD WINAPI feedback(LPVOID arg) +{ + feedback_args_t *feed = (feedback_args_t*)arg; + char *str[1024]; + DWORD len; + + while (ReadFile(feed->in, str, sizeof(str), &len, NULL)) + if (!len || !WriteFile(feed->out, str, len, &len, NULL)) + break; + + printerr("[EOF] from Console (%d)\n", GetLastError()); + + return 0; +} diff --git a/rubbos/app/httpd-2.0.64/support/win32/wintty.dsp b/rubbos/app/httpd-2.0.64/support/win32/wintty.dsp new file mode 100644 index 00000000..17e7c33c --- /dev/null +++ b/rubbos/app/httpd-2.0.64/support/win32/wintty.dsp @@ -0,0 +1,123 @@ +# Microsoft Developer Studio Project File - Name="wintty" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=wintty - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "wintty.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "wintty.mak" CFG="wintty - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "wintty - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "wintty - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "wintty - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MD /W3 /Zi /O2 /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Release/wintty_src" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /subsystem:console +# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /subsystem:console /debug /opt:ref + +!ELSEIF "$(CFG)" == "wintty - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../srclib/apr/include" /I "../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /Fd"Debug/wintty_src" /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug +# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /subsystem:console /incremental:no /debug + +!ENDIF + +# Begin Target + +# Name "wintty - Win32 Release" +# Name "wintty - Win32 Debug" +# Begin Source File + +SOURCE=..\..\build\win32\win32ver.awk + +!IF "$(CFG)" == "wintty - Win32 Release" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\..\build\win32\win32ver.awk + +".\wintty.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../../build/win32/win32ver.awk wintty.exe "wintty Console Utility" ../../include/ap_release.h > .\wintty.rc + +# End Custom Build + +!ELSEIF "$(CFG)" == "wintty - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build - Creating Version Resource +InputPath=..\..\build\win32\win32ver.awk + +".\wintty.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + awk -f ../../build/win32/win32ver.awk wintty.exe "wintty Console Utility" ../../include/ap_release.h > .\wintty.rc + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\wintty.c +# End Source File +# Begin Source File + +SOURCE=.\wintty.rc +# End Source File +# End Target +# End Project |