[omd-commits] OMD Git: omd: apache: fixed fcgid for centos

git version control git at mathias-kettner.de
Wed Dec 29 11:08:28 CET 2010


Module: omd
Branch: master
Commit: 85c366b5c5f6869098acb78c05cbc065d697e159
URL:    http://omdistro.org/projects/omd/repository/revisions/85c366b5c5f6869098acb78c05cbc065d697e159

Author: Sven Nierlein <sven at nierlein.de>
Date:   Wed Dec 29 10:56:30 2010 +0100

apache: fixed fcgid for centos

---

 distros/Makefile.CENTOS_5.5                        |    2 +-
 packages/apache-omd/.gitignore                     |    1 +
 packages/apache-omd/Makefile                       |   34 +++++++++++++++++---
 packages/apache-omd/mod_fcgid-2.3.6.tar.gz         |  Bin 0 -> 101883 bytes
 packages/apache-omd/patches/0001-mod_fcgid.patch   |   25 ++++++++++++++
 packages/apache-omd/patches/0002-mod_fcgid.patch   |   18 ++++++++++
 packages/apache-omd/skel/etc/apache/apache.conf    |    8 -----
 .../apache-omd/skel/etc/apache/conf.d/fcgid.conf   |    9 +++++
 packages/thruk/Makefile                            |    9 -----
 packages/thruk/skel/etc/thruk/apache.conf          |    8 +----
 10 files changed, 84 insertions(+), 30 deletions(-)

diff --git a/distros/Makefile.CENTOS_5.5 b/distros/Makefile.CENTOS_5.5
index 596bdb7..f77eeed 100644
--- a/distros/Makefile.CENTOS_5.5
+++ b/distros/Makefile.CENTOS_5.5
@@ -1,5 +1,5 @@
 DISTRO_CODE       = rh55
-BUILD_PACKAGES    = libxml2-devel cairo-devel pango-devel patch gcc gcc-c++ openssl-devel gd-devel rpm-build which expat-devel readline-devel ncurses-devel mysql-devel python-devel
+BUILD_PACKAGES    = libxml2-devel cairo-devel pango-devel patch gcc gcc-c++ openssl-devel gd-devel rpm-build which expat-devel readline-devel ncurses-devel mysql-devel python-devel httpd-devel
 OS_PACKAGES       = httpd mod_python mod_fcgid php php-pdo php-mbstring graphviz rsync dialog pango curl expat patch readline
 USERADD_OPTIONS   = -M
 ADD_USER_TO_GROUP = gpasswd -a %(user)s %(group)s
diff --git a/packages/apache-omd/.gitignore b/packages/apache-omd/.gitignore
new file mode 100644
index 0000000..3393050
--- /dev/null
+++ b/packages/apache-omd/.gitignore
@@ -0,0 +1 @@
+mod_fcgid-2.3.6
diff --git a/packages/apache-omd/Makefile b/packages/apache-omd/Makefile
index fdf49e8..35d830f 100644
--- a/packages/apache-omd/Makefile
+++ b/packages/apache-omd/Makefile
@@ -3,27 +3,41 @@ include ../../Makefile.omd
 NAME = apache-omd
 VERSION = 1.0
 DIR = $(NAME)-$(VERSION)
+FCGI_FILE="mod_fcgid-2.3.6"
+
+MODULE_DIR=$(APACHE_MODULE_DIR)
 ifeq ($(shell uname -m),x86_64)
   MODULE_DIR=$(APACHE_MODULE_DIR_64)
-else
-  MODULE_DIR=$(APACHE_MODULE_DIR)
+endif
+
+APACHE_MODULES=
+APACHE_MODULES_INSTALL=
+APACHE_FCGID_PATH=$(MODULE_DIR)/$(APACHE_FCGID_MODULE)
+ifeq ($(shell ../../distro),CENTOS 5.5)
+  APACHE_MODULES=modfcgid
+  APACHE_MODULES_INSTALL=modfcgid_install
+  APACHE_FCGID_PATH=$(OMD_ROOT)/lib/apache/mod_fcgid.so
 endif
 
 .PHONY: skel
 
-build:
+build: $(APACHE_MODULES)
 	# Unpack source code, apply patches, call configure, call make
 
-install:
+install: $(APACHE_MODULES_INSTALL)
 	# Install software below $(DESTDIR)$(OMD_ROOT)/{bin,lib,share}
+	mkdir -p $(DESTDIR)$(OMD_ROOT)/lib/apache
 
 skel:
 	# Replace macros
 	sed -i -e 's|###APACHE_MODULE_DIR###|$(MODULE_DIR)|g' \
 	       -e 's|###APACHE_PHP_MODULE###|$(APACHE_PHP_MODULE)|g' \
 	       -e 's|###APACHE_PYTHON_MODULE###|$(APACHE_PYTHON_MODULE)|g' \
-	       -e 's|###APACHE_FCGID_MODULE###|$(APACHE_FCGID_MODULE)|g' \
 	       $(SKEL)/etc/apache/apache.conf
+
+	sed -i -e 's|###APACHE_FCGID_MODULE###|$(APACHE_FCGID_PATH)|g' \
+	       $(SKEL)/etc/apache/conf.d/fcgid.conf
+
 	sed -i 's|###APACHE_BIN###|$(APACHE_BIN)|g' $(SKEL)/etc/init.d/apache
 	# Create working directories
 	mkdir -p $(SKEL)/var/log/apache
@@ -35,3 +49,13 @@ skel:
 
 clean:
 	# Remove files created by build/install
+
+modfcgid:
+	tar zxf $(FCGI_FILE).tar.gz
+	patch -p0 < ./patches/0001-mod_fcgid.patch
+	patch -p0 < ./patches/0002-mod_fcgid.patch
+	cd $(FCGI_FILE) && ./configure.apxs
+	$(MAKE) -C $(FCGI_FILE)
+
+modfcgid_install:
+	cp $(FCGI_FILE)/modules/fcgid/.libs/mod_fcgid.so $(DESTDIR)$(OMD_ROOT)/lib/apache
diff --git a/packages/apache-omd/mod_fcgid-2.3.6.tar.gz b/packages/apache-omd/mod_fcgid-2.3.6.tar.gz
new file mode 100644
index 0000000..113605a
Binary files /dev/null and b/packages/apache-omd/mod_fcgid-2.3.6.tar.gz differ
diff --git a/packages/apache-omd/patches/0001-mod_fcgid.patch b/packages/apache-omd/patches/0001-mod_fcgid.patch
new file mode 100644
index 0000000..46fb767
--- /dev/null
+++ b/packages/apache-omd/patches/0001-mod_fcgid.patch
@@ -0,0 +1,25 @@
+--- mod_fcgid-2.3.6/modules/fcgid/fcgid_proc_unix.c.orig	2010-12-28 23:13:16.000000000 +0100
++++ mod_fcgid-2.3.6/modules/fcgid/fcgid_proc_unix.c	2010-12-28 23:14:29.000000000 +0100
+@@ -180,13 +180,15 @@
+  */
+ static apr_status_t exec_setuid_cleanup(void *dummy)
+ {
+-    if (seteuid(0) == -1) {
+-        log_setid_failure("mod_fcgid child", "effective uid", 0);
+-        _exit(1);
+-    }
+-    if (setuid(ap_unixd_config.user_id) == -1) {
+-        log_setid_failure("mod_fcgid child", "uid", ap_unixd_config.user_id);
+-        _exit(1);
++    if (getuid() != ap_unixd_config.user_id) {
++        if (seteuid(0) == -1) {
++            log_setid_failure("mod_fcgid child", "effective uid", 0);
++            _exit(1);
++        }
++        if (setuid(ap_unixd_config.user_id) == -1) {
++            log_setid_failure("mod_fcgid child", "uid", ap_unixd_config.user_id);
++            _exit(1);
++        }
+     }
+     return APR_SUCCESS;
+ }
diff --git a/packages/apache-omd/patches/0002-mod_fcgid.patch b/packages/apache-omd/patches/0002-mod_fcgid.patch
new file mode 100644
index 0000000..aee01c5
--- /dev/null
+++ b/packages/apache-omd/patches/0002-mod_fcgid.patch
@@ -0,0 +1,18 @@
+--- mod_fcgid-2.3.6/modules/fcgid/fcgid_pm_unix.c.orig	2010-12-28 23:29:34.000000000 +0100
++++ mod_fcgid-2.3.6/modules/fcgid/fcgid_pm_unix.c	2010-12-28 23:30:07.000000000 +0100
+@@ -282,6 +282,7 @@
+          * When running children as the configured user, the real uid
+          * is switched.
+          */
++        /*
+         if (ap_unixd_config.suexec_enabled) {
+             if (getuid() != 0) {
+                 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, main_server,
+@@ -290,6 +291,7 @@
+             }
+             suexec_setup_child();
+         } else
++        */
+             ap_unixd_setup_child();
+         apr_file_pipe_timeout_set(g_pm_read_pipe,
+                                   apr_time_from_sec(g_wakeup_timeout));
diff --git a/packages/apache-omd/skel/etc/apache/apache.conf b/packages/apache-omd/skel/etc/apache/apache.conf
index 61e0b23..abd11f1 100644
--- a/packages/apache-omd/skel/etc/apache/apache.conf
+++ b/packages/apache-omd/skel/etc/apache/apache.conf
@@ -118,7 +118,6 @@ LoadModule rewrite_module ###APACHE_MODULE_DIR###/mod_rewrite.so
 LoadModule cgi_module ###APACHE_MODULE_DIR###/mod_cgi.so
 LoadModule php5_module ###APACHE_MODULE_DIR###/###APACHE_PHP_MODULE###
 LoadModule python_module ###APACHE_MODULE_DIR###/###APACHE_PYTHON_MODULE###
-LoadModule fcgid_module ###APACHE_MODULE_DIR###/###APACHE_FCGID_MODULE###
 
 <Directory />
     Options FollowSymLinks
@@ -202,13 +201,6 @@ php_value session.save_path "###ROOT###/tmp/php/session"
 php_admin_value upload_tmp_dir "###ROOT###/tmp/php/upload"
 php_admin_value soap.wsdl_cache_dir "###ROOT###/tmp/php/wsdl-cache"
 
-<IfModule mod_fcgid.c>
-  AddHandler    fcgid-script .fcgi
-  IPCConnectTimeout 20
-  SharememPath "###ROOT###/tmp/apache/fcgid_shm"
-  SocketPath "###ROOT###/tmp/apache/fcgid_sock"
-</IfModule>
-
 # Load config files from the include dir. You can put your own
 # configuration there. Also addons put default files there.
 Include ###ROOT###/etc/apache/conf.d/*.conf
diff --git a/packages/apache-omd/skel/etc/apache/conf.d/fcgid.conf b/packages/apache-omd/skel/etc/apache/conf.d/fcgid.conf
new file mode 100644
index 0000000..9b985c4
--- /dev/null
+++ b/packages/apache-omd/skel/etc/apache/conf.d/fcgid.conf
@@ -0,0 +1,9 @@
+<IfModule !mod_fcgid.c>
+  LoadModule fcgid_module ###APACHE_FCGID_MODULE###
+  AddHandler fcgid-script .fcgi
+  AddHandler fcgid-script .pl
+  MaxRequestsPerProcess 100
+  IPCConnectTimeout 20
+  SharememPath "###ROOT###/tmp/apache/fcgid_shm"
+  SocketPath "###ROOT###/tmp/apache/fcgid_sock"
+</IfModule>
diff --git a/packages/thruk/Makefile b/packages/thruk/Makefile
index 18e8ba5..5a8cdc3 100644
--- a/packages/thruk/Makefile
+++ b/packages/thruk/Makefile
@@ -4,11 +4,6 @@ NAME     = Thruk
 VERSION  = 0.76
 DIR      = $(NAME)-$(VERSION)
 PERLARCH = $(shell $(PERL) -e 'use Config; print $$Config{archname}')
-ifeq ($(shell uname -m),x86_64)
-  MODULE_DIR=$(APACHE_MODULE_DIR_64)
-else
-  MODULE_DIR=$(APACHE_MODULE_DIR)
-endif
 
 .PHONY: skel
 
@@ -37,10 +32,6 @@ skel:
 	# logfile has to be group writeable for shared apache
 	mkdir -p $(SKEL)/var/log
 	touch $(SKEL)/var/log/thruk.log
-	# set right path for apache module
-	sed -i -e 's|###APACHE_MODULE_DIR###|$(MODULE_DIR)|g' \
-	       -e 's|###APACHE_FCGID_MODULE###|$(APACHE_FCGID_MODULE)|g' \
-	       $(SKEL)/etc/apache/conf.d/thruk.conf
 
 clean:
 	rm -rf $(DIR)
diff --git a/packages/thruk/skel/etc/thruk/apache.conf b/packages/thruk/skel/etc/thruk/apache.conf
index b6f2505..a87f3e1 100644
--- a/packages/thruk/skel/etc/thruk/apache.conf
+++ b/packages/thruk/skel/etc/thruk/apache.conf
@@ -1,8 +1,5 @@
-<IfModule !mod_fcgid.c>
-  LoadModule fcgid_module ###APACHE_MODULE_DIR###/mod_fcgid.so
-</IfModule>
-
 <IfModule mod_fcgid.c>
+  AddHandler fcgid-script .pl
 
   <Directory ###ROOT###/share/thruk/root/>
     Options FollowSymLinks
@@ -17,7 +14,4 @@
   <Location /###SITE###/thruk>
     Options ExecCGI
   </Location>
-
-  AddHandler fcgid-script .pl
-  MaxRequestsPerProcess 100
 </IfModule>



More information about the omd-commits mailing list