pax_global_header00006660000000000000000000000064123523016010014503gustar00rootroot0000000000000052 comment=bc0f11b6ed4dd4a41d2c9cf7f124239c7fad87bd mod_watchcat-1.1.2/000077500000000000000000000000001235230160100141415ustar00rootroot00000000000000mod_watchcat-1.1.2/55_mod_watchcat.conf000066400000000000000000000006101235230160100177530ustar00rootroot00000000000000 LoadModule watchcat_module extramodules/mod_watchcat.so # CatType script application/x-httpd-php CatType script application/x-perl application/x-cgi CatTimeout script 60 CatOrder script #CatLogHandler # mod_watchcat-1.1.2/COPYRIGHT000066400000000000000000000010041235230160100154270ustar00rootroot00000000000000mod_watchcat license -------------------- mod_watchcat is licensed under the GNU General Public License (GPL). This means that mod_watchcat is a free software and can be used for both academic and commercial purposes at absolutely no cost. For details and rationale, see http://www.gnu.org/copyleft/ . =============================================================================== Copyright (c) 2004 Digirati. =============================================================================== (end of COPYRIGHT) mod_watchcat-1.1.2/Makefile000066400000000000000000000020251235230160100156000ustar00rootroot00000000000000PKGNAME= mod_watchcat PKGCONF= 55_mod_watchcat.conf PKGVERSION= 1.1.2 APXS= /usr/bin/apxs2 all: mod_watchcat.so mod_watchcat.so: mod_watchcat.c $(APXS) -c mod_watchcat.c -lwcat install: $(APXS) -i -n mod_watchcat.so mod_watchcat.la clean: rm -f *.o *.c~ *.h~ *.conf~ *.[0-9]~ mod_watchcat.so mod_watchcat.lo mod_watchcat.slo mod_watchcat.la $(PKGNAME)-$(PKGVERSION).tar.bz2 rm -rf .libs rm -f COPYRIGHT~ TODO~ Makefile~ if [ -f $(PKGCONF).bz2 ]; then bunzip2 $(PKGCONF).bz2; fi if [ `basename ${PWD}` != "$(PKGNAME)-$(PKGVERSION)" ]; then \ rm -rf ../$(PKGNAME)-$(PKGVERSION); \ fi rpm: clean if [ `basename ${PWD}` != "$(PKGNAME)-$(PKGVERSION)" ]; then \ cp -a . ../$(PKGNAME)-$(PKGVERSION); \ fi bzip2 -9 $(PKGCONF) tar -jcC .. --exclude CVS -f $(PKGNAME)-$(PKGVERSION).tar.bz2 $(PKGNAME)-$(PKGVERSION) rpm -ta $(PKGNAME)-$(PKGVERSION).tar.bz2 bunzip2 $(PKGCONF).bz2 rm -rf $(PKGNAME)-$(PKGVERSION).tar.bz2 if [ `basename ${PWD}` != "$(PKGNAME)-$(PKGVERSION)" ]; then \ rm -rf ../$(PKGNAME)-$(PKGVERSION); \ fi mod_watchcat-1.1.2/apache-mod_watchcat.spec000066400000000000000000000045541235230160100207010ustar00rootroot00000000000000#Module-Specific definitions %define apache_version 2.0.54 %define mod_name mod_watchcat %define mod_conf 55_%{mod_name}.conf %define mod_so %{mod_name}.so Summary: Mod_watchcat is a DSO module for the apache web server. Name: apache-%{mod_name} Version: 1.0 Release: %mkrel 2 Group: System/Servers Source0: %{mod_name}-%{version}.tar.bz2 Source1: %{mod_conf}.bz2 Requires(pre): rpm-helper Requires(postun): rpm-helper Requires(pre): apache-conf >= %{apache_version} Requires(pre): apache >= %{apache_version} Requires: libwcat1 Requires: apache-conf >= %{apache_version} Requires: apache >= %{apache_version} BuildRequires: libwcat1 BuildRequires: apache-devel >= %{apache_version} Provides: apache2-%{mod_name} Obsoletes: apache2-%{mod_name} License: GPL URL: http://oss.digirati.com.br/mod_watchcat/ BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot %description mod_watchcat allows the Apache webserver to register its processes with the watchcatd daemon. %prep %setup -q -n %{mod_name}-%{version} %build %{_sbindir}/apxs -c mod_watchcat.c -lwcat %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} install -d %{buildroot}%{_libdir}/apache-extramodules install -d %{buildroot}%{_sysconfdir}/httpd/modules.d install -m0755 .libs/*.so %{buildroot}%{_libdir}/apache-extramodules/ bzcat %{SOURCE1} > %{buildroot}%{_sysconfdir}/httpd/modules.d/%{mod_conf} install -d %{buildroot}%{_var}/www/html/addon-modules ln -s ../../../..%{_docdir}/%{name}-%{version} %{buildroot}%{_var}/www/html/addon-modules/%{name}-%{version} %post if [ -f %{_var}/lock/subsys/httpd ]; then %{_initrddir}/httpd restart 1>&2; fi %postun if [ "$1" = "0" ]; then if [ -f %{_var}/lock/subsys/httpd ]; then %{_initrddir}/httpd restart 1>&2 fi fi %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files %doc COPYRIGHT %defattr(-,root,root) %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/httpd/modules.d/%{mod_conf} %attr(0755,root,root) %{_libdir}/apache-extramodules/%{mod_so} %{_var}/www/html/addon-modules/* %changelog * Fri Nov 03 2006 Andre Nathan 2.0.54_1.0-2mdk - Adapt to new Mandriva style. * Fri Feb 05 2003 Andre Nathan 2.0.48_1.0-1mdk - Adapt to Mandrake style. * Thu Feb 05 2003 Andre Nathan 2.0.48_1.0-1mdk - First version. mod_watchcat-1.1.2/debian/000077500000000000000000000000001235230160100153635ustar00rootroot00000000000000mod_watchcat-1.1.2/debian/changelog000066400000000000000000000015001235230160100172310ustar00rootroot00000000000000libapache2-mod-watchcat (1.1.2-0digirati1) precise; urgency=low * Rebuild for 1.1.2 -- Andre Nathan Tue, 24 Jan 2014 10:55:23 -0300 libapache2-mod-watchcat (1.1.1-0digirati1) precise; urgency=low * Rebuild for 1.1.1 -- Andre Nathan Wed, 05 Jan 2014 14:29:16 -0200 libapache2-mod-watchcat (1.1.0-0digirati1) precise; urgency=low * Rebuild for 1.1 -- Andre Nathan Fri, 31 Jan 2014 11:59:21 -0200 libapache2-mod-watchcat (1.0-0digirati1) precise; urgency=low * First build of custom package. -- Andre Nathan Wed, 08 Jul 2009 15:39:34 -0300 libapache2-mod-watchcat (1.0-0digirati1) lucid; urgency=low * First build of custom package. -- Andre Nathan Wed, 08 Jul 2009 15:39:34 -0300 mod_watchcat-1.1.2/debian/compat000066400000000000000000000000021235230160100165610ustar00rootroot000000000000007 mod_watchcat-1.1.2/debian/control000066400000000000000000000016011235230160100167640ustar00rootroot00000000000000Source: libapache2-mod-watchcat Priority: optional Maintainer: Ubuntu MOTU Developers XSBC-Original-Maintainer: Andre Nathan Build-Depends: debhelper (>= 7), apache2-prefork-dev (>= 2.2.11) | apache2-threaded-dev (>= 2.2.11), libwcat-dev Standards-Version: 3.8.2 Section: web Homepage: http://oss.digirati.com.br/mod_watchcat/ Package: libapache2-mod-watchcat Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, apache2.2-common, libwcat1 Description: watchcatd-awareness for apache2 mod_watchcat is a module developed to provide watchcatd-awareness to the Apache 2 webserver. This allows a system administrator to set up timeouts for Apache processes, and thus provide protection against badly coded or malicious scripts. mod_watchcat can be configured to kill those resource-consuming processes before the server locks-up. mod_watchcat-1.1.2/debian/copyright000066400000000000000000000020321235230160100173130ustar00rootroot00000000000000This package was debianized by Andre Nathan on Wed, 08 Jul 2009 15:39:34 -0300. It was downloaded from http://oss.digirati.com.br/mod_watchcat/ Upstream Authors: Michel Machado Andre Nathan Copyright: Copyright (C) 2009 Digirati Informática, Serviços e Telecomuniações LTDA. License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . On a Debian system, the license can be found at /usr/share/common-licenses/GPL-2 . mod_watchcat-1.1.2/debian/libapache2-mod-watchcat.install000066400000000000000000000001451235230160100233160ustar00rootroot00000000000000.libs/mod_watchcat.so usr/lib/apache2/modules debian/watchcat.{conf,load} etc/apache2/mods-available mod_watchcat-1.1.2/debian/rules000077500000000000000000000012531235230160100164440ustar00rootroot00000000000000#!/usr/bin/make -f #export DH_VERBOSE=1 APXS=/usr/bin/apxs2 build: build-stamp build-stamp: dh_testdir $(APXS) -c mod_watchcat.c -lwcat touch $@ clean: dh_testdir dh_testroot dh_clean .libs/* mod_watchcat.l* mod_watchcat.s* mod_watchcat.o build-stamp install-stamp $(RM) -r .libs binary-indep: DH_OPTIONS=-i binary-indep: build binary-arch: DH_OPTIONS=-a binary-arch: build dh_testdir dh_testroot dh_clean dh_install dh_installdocs dh_installchangelogs dh_installexamples dh_installdeb dh_fixperms dh_shlibdeps dh_compress dh_strip dh_md5sums dh_gencontrol dh_builddeb binary: binary-indep binary-arch .PHONY: binary binary-arch binary-indep clean build mod_watchcat-1.1.2/debian/watch000066400000000000000000000001151235230160100164110ustar00rootroot00000000000000version=3 http://oss.digirati.com.br/mod_watchcat/mod_watchcat-(.*)\.tar\.gz mod_watchcat-1.1.2/debian/watchcat.conf000066400000000000000000000003731235230160100200330ustar00rootroot00000000000000 # CatType script application/x-httpd-php CatType script application/x-perl application/x-cgi CatTimeout script 60 CatOrder script #CatLogHandler # mod_watchcat-1.1.2/debian/watchcat.load000066400000000000000000000001041235230160100200150ustar00rootroot00000000000000LoadModule watchcat_module /usr/lib/apache2/modules/mod_watchcat.so mod_watchcat-1.1.2/mod_watchcat.c000066400000000000000000000327201235230160100167460ustar00rootroot00000000000000/* ** $Id$ ** mod_watchcat - Apache module for watchcat service ** See copyright notice in distro's COPYRIGHT file */ #include #include #include #include #include #include #include #include #include #include #include #include #define DEF_NAME "default" #define UNSET (-1) struct wcat_type { char *name; apr_table_t *handlers; int timeout; }; struct wcat_dir_cfg { apr_hash_t *types; apr_array_header_t *order; int log_handler; }; static void *wcat_create_dir_config(apr_pool_t *p, char *dirspec) { struct wcat_dir_cfg *cfg; struct wcat_type *type; cfg = apr_palloc(p, sizeof(struct wcat_dir_cfg)); assert(cfg); cfg->types = apr_hash_make(p); assert(cfg->types); cfg->order = NULL; cfg->log_handler = 0; type = apr_palloc(p, sizeof(struct wcat_type)); assert(type); type->name = DEF_NAME; type->handlers = NULL; type->timeout = UNSET; apr_hash_set(cfg->types, type->name, APR_HASH_KEY_STRING, type); return cfg; } static struct wcat_type *make_type(apr_pool_t *p, const char *name, struct wcat_type *base) { struct wcat_type *type; type = apr_palloc(p, sizeof(struct wcat_type)); assert(type); type->name = apr_pstrdup(p, name); assert(type->name); if (base) { if (base->handlers) type->handlers = apr_table_copy(p, base->handlers); else type->handlers = NULL; type->timeout = base->timeout; } else { type->handlers = apr_table_make(p, 0); assert(type->handlers); type->timeout = UNSET; } return type; } static apr_hash_t *copy_types(apr_pool_t *p, apr_hash_t *types) { apr_hash_index_t *hi; apr_hash_t *ret; ret = apr_hash_make(p); assert(ret); for (hi = apr_hash_first(p, types); hi; hi = apr_hash_next(hi)) { struct wcat_type *type; struct wcat_type *new; void *val; apr_hash_this(hi, NULL, NULL, &val); type = (struct wcat_type *)val; new = make_type(p, type->name, type); assert(new); apr_hash_set(ret, new->name, APR_HASH_KEY_STRING, new); } return ret; } static void overlay_types(apr_pool_t *p, apr_hash_t *overlay, apr_hash_t *base) { apr_hash_index_t *hi; for (hi = apr_hash_first(p, base); hi; hi = apr_hash_next(hi)) { struct wcat_type *type; struct wcat_type *over; void *val; apr_hash_this(hi, NULL, NULL, &val); type = (struct wcat_type *)val; over = apr_hash_get(overlay, type->name, APR_HASH_KEY_STRING); if (over) { if (over->handlers) { /* over isn't the default type. */ assert(type->handlers); over->handlers = apr_table_overlay(p, over->handlers, type->handlers); } else assert(type->handlers == NULL); if (type->timeout != UNSET) over->timeout = type->timeout; } else { struct wcat_type *new = make_type(p, type->name, type); assert(new); apr_hash_set(overlay, new->name, APR_HASH_KEY_STRING, new); } } } static void *wcat_merge_dir_config(apr_pool_t *p, void *parent_conf, void *newloc_conf) { struct wcat_dir_cfg *merged = apr_palloc(p, sizeof(struct wcat_dir_cfg)); struct wcat_dir_cfg *parent = (struct wcat_dir_cfg *) parent_conf; struct wcat_dir_cfg *child = (struct wcat_dir_cfg *) newloc_conf; apr_array_header_t *from_order; assert(merged); merged->log_handler = parent->log_handler || child->log_handler; /* Merge merged->types. */ merged->types = copy_types(p, parent->types); overlay_types(p, merged->types, child->types); /* Merge merged->order. */ from_order = child->order ? child->order : parent->order; if (from_order) { int len = from_order->nelts; struct wcat_type **ltypes = (struct wcat_type **)from_order->elts; int i; assert(len > 0); merged->order = apr_array_make(p, len, sizeof(struct wcat_type *)); assert(merged->order); for (i = 0; i < len; i++) { struct wcat_type *type = ltypes[i]; struct wcat_type **elt = apr_array_push(merged->order); assert(elt); *elt = apr_hash_get(merged->types, type->name, APR_HASH_KEY_STRING); assert(*elt); } } else merged->order = NULL; return merged; } static struct wcat_type *insert_new_type(apr_pool_t *p, struct wcat_dir_cfg *cfg, const char *name) { struct wcat_type *type = make_type(p, name, NULL); assert(type); apr_hash_set(cfg->types, name, APR_HASH_KEY_STRING, type); return type; } static const char *cmd_types(cmd_parms *cmd, void *mconfig, const char *word1, const char *word2) { struct wcat_dir_cfg *cfg = (struct wcat_dir_cfg *)mconfig; struct wcat_type *type; assert(cfg); type = (struct wcat_type *)apr_hash_get(cfg->types, word1, APR_HASH_KEY_STRING); if (type == NULL) type = insert_new_type(cmd->pool, cfg, word1); if (type->handlers == NULL) { assert(strcmp(type->name, DEF_NAME) == 0); return "The special type default doesn't support handlers"; } apr_table_set(type->handlers, word2, ""); return NULL; } static const char *cmd_timeout(cmd_parms *cmd, void *mconfig, const char *word1, const char *word2) { struct wcat_dir_cfg *cfg = (struct wcat_dir_cfg *)mconfig; struct wcat_type *type; int timeout; timeout = atoi(word2); if (timeout == LONG_MIN || timeout == LONG_MAX) return apr_psprintf(cmd->temp_pool, "Invalid integer (== `%s'): %s", word2, strerror(errno)); if (timeout < 0) return apr_psprintf(cmd->temp_pool, "Invalid timeout (== %i)", timeout); assert(cfg); type = (struct wcat_type *)apr_hash_get(cfg->types, word1, APR_HASH_KEY_STRING); if (type == NULL) type = insert_new_type(cmd->pool, cfg, word1); type->timeout = timeout; return NULL; } static const char *cmd_order(cmd_parms *cmd, void *mconfig, const char *word1) { struct wcat_dir_cfg *cfg = (struct wcat_dir_cfg *)mconfig; struct wcat_type *type; struct wcat_type **elt; assert(cfg); type = (struct wcat_type *)apr_hash_get(cfg->types, word1, APR_HASH_KEY_STRING); if (type == NULL) type = insert_new_type(cmd->pool, cfg, word1); if (cfg->order == NULL) cfg->order = apr_array_make(cmd->pool, 1, sizeof(struct wcat_type *)); elt = (struct wcat_type **)apr_array_push(cfg->order); assert(elt); *elt = type; return NULL; } static const char *cmd_log_handler(cmd_parms *cmd, void *mconfig) { struct wcat_dir_cfg *cfg = (struct wcat_dir_cfg *)mconfig; assert(cfg); cfg->log_handler = 1; return NULL; } static const char *cmd_device(cmd_parms *cmd, void *mconfig, const char *path) { struct wcat_dir_cfg *cfg = (struct wcat_dir_cfg *)mconfig; assert(cfg); assert(strlen(path) < CAT_DEVICE_SIZE); cat_set_device(path); return NULL; } #define FD_UUID "4a9426a0-5585-11d8-96e2-000347751b8c" /* * Locate our directory configuration record for the current request. */ module AP_MODULE_DECLARE_DATA watchcat_module; static struct wcat_dir_cfg *our_dconfig(const request_rec *r) { return (struct wcat_dir_cfg *) ap_get_module_config(r->per_dir_config, &watchcat_module); } static request_rec *get_real_req(request_rec *r) { request_rec *prv_r = NULL; for (; r; r = r->prev) prv_r = r; return prv_r; } /* * This routine is called to perform any module-specific fixing of header * fields, et cetera. It is invoked just before any content-handler. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the * server will still call any remaining modules with an handler for this * phase. */ /* * OK ("we did our thing") * DECLINED ("this isn't something with which we want to get involved") * HTTP_mumble ("an error status should be reported") */ static int wcat_fixer_upper(request_rec *r) { struct wcat_dir_cfg *cfg; int timeout; int cat; struct wcat_type **ltypes; int i, len; const char *handler; char *info = NULL; request_rec *real_r; /* Don't handle subrequests. */ if (r->main) return OK; cfg = our_dconfig(r); assert(cfg); handler = r->content_type; if (handler == NULL) handler = r->handler; if (cfg->log_handler) ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, "mod_watchcat: handler=`%s' for filename=`%s'", handler, r->filename); if (cfg->order == NULL) return OK; len = cfg->order->nelts; assert(len > 0); ltypes = (struct wcat_type **)cfg->order->elts; timeout = UNSET; for (i = 0; i < len; i++) { struct wcat_type *type = ltypes[i]; if (type->handlers == NULL || apr_table_get(type->handlers, handler)) { timeout = type->timeout; info = type->name; if (timeout == UNSET) ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "mod_watchcat: timeout == UNSET, use CatTimeout directive " "to correct, type=`%s'", type->name); break; } } if (timeout == UNSET || timeout <= 0) return OK; /* Ok, there is work to do! */ real_r = get_real_req(r); assert(real_r); /* Does the external (real) request already have a cat? */ if (apr_table_get(real_r->notes, FD_UUID)) return OK; info = apr_psprintf(r->pool, "%s: %s", info, r->filename); cat = cat_open1(timeout, SIGKILL, info); if (cat >= 0) { char *strcat = apr_itoa(r->pool, cat); assert(strcat); apr_table_set(real_r->notes, FD_UUID, strcat); cat_heartbeat(cat); } else { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "mod_watchcat: cat_open1(%i, SIGKILL, \"%s\") fail", timeout, info); } return OK; } /* * This routine is called to perform any module-specific logging activities * over and above the normal server things. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, any * remaining modules with an handler for this phase will still be called. */ static int wcat_logger(request_rec *r) { const char *strcat; if (!ap_is_initial_req(r)) return OK; strcat = apr_table_get(r->notes, FD_UUID); if (strcat && cat_close(atoi(strcat)) == -1) ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "mod_watchcat: cat_close(`%s') fail, strerror(%d)=%s", strcat, errno, strerror(errno)); return OK; } /* * The functions are registered using * ap_hook_foo(name, predecessors, successors, position) * where foo is the name of the hook. * * The args are as follows: * name -> the name of the function to call. * predecessors -> a list of modules whose calls to this hook must be * invoked before this module. * successors -> a list of modules whose calls to this hook must be * invoked after this module. * position -> The relative position of this module. One of * APR_HOOK_FIRST, APR_HOOK_MIDDLE, or APR_HOOK_LAST. * Most modules will use APR_HOOK_MIDDLE. If multiple * modules use the same relative position, Apache will * determine which to call first. * If your module relies on another module to run first, * or another module running after yours, use the * predecessors and/or successors. */ static void wcat_register_hooks(apr_pool_t *p) { ap_hook_fixups(wcat_fixer_upper, NULL, NULL, APR_HOOK_LAST); ap_hook_log_transaction(wcat_logger, NULL, NULL, APR_HOOK_FIRST); } static const command_rec wcat_cmds[] = { AP_INIT_ITERATE2("CatType", cmd_types, NULL, OR_OPTIONS, "Insert handlers' name for a type"), AP_INIT_TAKE2("CatTimeout", cmd_timeout, NULL, OR_OPTIONS, "Define a timeout value for a type"), AP_INIT_ITERATE("CatOrder", cmd_order, NULL, OR_OPTIONS, "Define the match order for the handlers"), AP_INIT_NO_ARGS("CatLogHandler", cmd_log_handler, NULL, OR_OPTIONS, "Log the handler of request - no arguments"), AP_INIT_TAKE1("CatDevice", cmd_device, NULL, OR_OPTIONS, "Define the watchcat device path"), {NULL} }; module AP_MODULE_DECLARE_DATA watchcat_module = { STANDARD20_MODULE_STUFF, wcat_create_dir_config, /* Per-directory config creator. */ wcat_merge_dir_config, /* Dir config merger. */ NULL, /* Server config creator. */ NULL, /* Server config merger. */ wcat_cmds, /* Command table. */ wcat_register_hooks, /* Set up other request processing hooks. */ };