]> granicus.if.org Git - apache-authnz-external/blob - mod_authnz_external/test/test.pipe.php
7d19c2436b06e6a9420fb2c82b8005d909de056e
[apache-authnz-external] / mod_authnz_external / test / test.pipe.php
1 #!/usr/bin/php
2 <?php
3
4 // Test authenticator using pipe method.  Logins will be accepted if the
5 // login and the password are identical, and will be rejected otherwise.
6 //
7 // This authenticator does copious logging by writing all sorts of stuff to
8 // STDERR.  A production authenticator would not normally do this, and it
9 // *especially* would not write the plain text password out to the log file.
10
11 // Get the name of this program
12 $prog = $argv[0];
13
14 // Get the user name
15 $user = trim(fgets(STDIN));
16
17 // Get the password
18 $pass = trim(fgets(STDIN));
19
20 // Print them to the error_log file
21 fwrite(STDERR, $prog . ": user='" . $user . "' pass='" . $pass . "'\n");
22
23 foreach ($_ENV as $k => $v)
24 {
25         fwrite(STDERR, $prog . ': ' . $k . '=' . $v . "\n");
26 }
27
28 // Accept the login if the user name matchs the password
29 if ($user == $pass)
30 {
31         fwrite(STDERR, $prog . ": login matches password - Accepted\n");
32         exit(0);
33 }
34 else
35 {
36         fwrite(STDERR, $prog . ": login doesn't match password - Rejected\n");
37         exit(1);
38 }
39
40 ?>