Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no php environment when using pipe #16

Open
GoogleCodeExporter opened this issue Mar 24, 2015 · 5 comments
Open

no php environment when using pipe #16

GoogleCodeExporter opened this issue Mar 24, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. use mod-auth-external

What is the expected output? What do you see instead?
$_ENV containing vars like the AUTHENTICATORS file says
Nothing there ...

What version of the product are you using? On what operating system?
Gentoo, apache 2.4.7, mod-auth-external-3.3.2

Please provide any additional information below.

I have the following auth php script .. 

#!/usr/bin/php
<?php
function flog($msg){
        $fh = fopen("/tmp/apache_auth", "a");
        fwrite($fh, date("Y-m-d H:i:s")." - ".$msg."\n");
        fclose($fh);
}
$user = trim(fgets(STDIN));
$pass = trim(fgets(STDIN));
$pass = sha1($pass);
flog($user." - ".$pass);
flog(print_r($_ENV, 1));
foreach ($_ENV as $k => $v){
        flog($k . '=' . $v);
}
$conn = mysql_connect(...);
mysql_select_db(...);
$checkquery = "SELECT `id`, `expiry` FROM `auth` WHERE `user` = 
'".mysql_real_escape_string($user)."' AND `password` = 
'".mysql_real_escape_string($pass)."' AND `enabled` = '1' AND (`expiry` > NOW() 
OR `expiry` = '0000-00-00 00:00:00') LIMIT 1;";
flog($checkquery);
$check = mysql_query($checkquery, $conn) or die(mysql_error($conn));
if (mysql_num_rows($check) > 0){
        $row = mysql_fetch_array($check);
        if($row['expiry'] != '0000-00-00 00:00:00'){
                $update = "UPDATE `auth` SET `expiry` = NOW()+INTERVAL 1 MONTH WHERE `id` = '".$row['id']."' LIMIT 1;";
                $update = mysql_query($update, $conn) or die(mysql_error($conn));
        }
        flog("Yes");
        exit(0);
}else{
        flog("NO");
        exit(1);
}
?>

Here's what /tmp/apache_auth contains:
2013-12-12 19:30:17 - SELECT `id`, `expiry` FROM `auth` WHERE `user` = '...' 
AND `password` = '...' AND `enabled` = '1' AND (`expiry` > NOW() OR `expiry` = 
'0000-00-00 00:00:00') LIMIT 1;
2013-12-12 19:30:17 - Yes
2013-12-12 19:30:17 - dex - ...
2013-12-12 19:30:17 - Array
(
)

Am I doing it wrong ? Do I need to enable special flags in php/apache ?

Original issue reported on code.google.com by [email protected] on 12 Dec 2013 at 5:35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant