From ce58b0a648ffa3b4f819c588f5e49c7b40418a7c Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 2 Aug 2017 09:25:39 +0200 Subject: [PATCH] Works with php-fpm if available --- ipasserelle-phpmyadmin.spec | 2 ++ .../etc/httpd/conf/httpd.conf/98phpMyAdmin | 31 +++++++++++++++++----- root/usr/share/phpMyAdmin/sso.php | 20 +++++++++----- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/ipasserelle-phpmyadmin.spec b/ipasserelle-phpmyadmin.spec index dacef8c..9b36f82 100644 --- a/ipasserelle-phpmyadmin.spec +++ b/ipasserelle-phpmyadmin.spec @@ -1,6 +1,7 @@ %define version 0.1.8 %define release 1 %define name ipasserelle-phpmyadmin +%define phpversion 71 Name: %{name} Version: %{version} @@ -65,6 +66,7 @@ phpMyAdmin integration for iPasserelle %build %{__mkdir_p} root/var/lib/phpMyAdmin/tmp perl ./createlinks +find root/ -type f | xargs grep -l __PHP_VERSION__ | xargs sed -i -e "s/__PHP_VERSION__/%{phpversion}/g" %install rm -rf $RPM_BUILD_ROOT diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin index 08c2520..6292076 100644 --- a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin @@ -5,6 +5,29 @@ my $status = $phpmyadmin{'status'} || 'disabled'; if ($status eq 'enabled'){ my $access = (($phpmyadmin{'access'} || 'private') eq 'public') ? 'all':"$localAccess $externalSSLAccess"; + my $php; + my $php =<<'_EOF'; + AddType application/x-httpd-php .php + php_admin_value openbase_dir /usr/share/phpMyAdmin:/etc/phpMyAdmin:/var/lib/phpMyAdmin + php_admin_value session.save_path /var/lib/phpMyAdmin/tmp + php_admin_value post_max_size 100M + php_admin_value upload_max_filesize 100M + php_admin_value memory_limit 500M + php_admin_flag session.use_trans_sid 0 +_EOF + + if ($fastcgi_mod eq 'mod_fastcgi'){ + $php =<<'_EOF'; + AddHandler php__PHP_VERSION__-fastcgi .php +_EOF + } + elsif ($fastcgi_mod eq 'mod_proxy_fcgi'){ + $php =<<'_EOF'; + + SetHandler "proxy:unix:/var/run/php-fpm/php__PHP_VERSION__.sock|fcgi://localhost" + +_EOF + } $OUT .=<<"END"; @@ -15,13 +38,7 @@ $OUT .=<<"END"; order deny,allow deny from all allow from $access - AddType application/x-httpd-php .php .php3 - php_admin_value openbase_dir /usr/share/phpMyAdmin:/etc/phpMyAdmin:/var/lib/phpMyAdmin - php_admin_value session.save_path /var/lib/phpMyAdmin/tmp - php_admin_value post_max_size 100M - php_admin_value upload_max_filesize 100M - php_admin_value memory_limit 500M - php_admin_flag session.use_trans_sid 0 +$php diff --git a/root/usr/share/phpMyAdmin/sso.php b/root/usr/share/phpMyAdmin/sso.php index 8aba855..0bca6a0 100644 --- a/root/usr/share/phpMyAdmin/sso.php +++ b/root/usr/share/phpMyAdmin/sso.php @@ -2,20 +2,26 @@ require('/etc/phpMyAdmin/sso.inc.php'); -if(isset($_SERVER['REMOTE_USER']) && isset($login[$_SERVER['REMOTE_USER']]) && isset($password[$_SERVER['REMOTE_USER']])) { +if (isSet($_SERVER['REDIRECT_REMOTE_USER'])){ + $ssologin = $_SERVER['REDIRECT_REMOTE_USER']; +} +else{ + $ssologin = $_SERVER['REMOTE_USER']; +} + +if(isset($ssologin) && isset($login[$ssologin]) && isset($password[$ssologin]])) { session_set_cookie_params(0, '/', '', 0); session_name('SignonSession'); session_start(); - $_SESSION['PMA_single_signon_user'] = $login[$_SERVER['REMOTE_USER']]; - $_SESSION['PMA_single_signon_password'] = $password[$_SERVER['REMOTE_USER']]; + $_SESSION['PMA_single_signon_user'] = $login[$ssologin]; + $_SESSION['PMA_single_signon_password'] = $password[$ssologin]; session_write_close(); header('Location: /index.php'); } else { - // This location is forbiden - // So it will just display the access denied - // msg from LemonLDAP - header('Location: /libraries'); + header('HTTP/1.0 403 Forbidden'); + echo 'Not logged in the SSO system'; + die; } ?>