I am working on a Login-Formular
for Linux servers based on PHP. The requirements are that every user is only able to login with his Unix account. I've read about the PAM-Module, but I can't get it running.
Using lighttpd as webserver on a ubuntu16.04. The error log provides me:
2018-03-06 09:17:19: (mod_fastcgi.c.2695) FastCGI-stderr: PHP message: PHP Fatal error: Uncaught Error: Call to undefined function pam_auth() in /var/www/html/example2/login.php:36
2018-03-06 09:17:19: (mod_fastcgi.c.2695) FastCGI-stderr: Stack trace:
2018-03-06 09:17:19: (mod_fastcgi.c.2695) FastCGI-stderr: #0 {main}
2018-03-06 09:17:19: (mod_fastcgi.c.2695) FastCGI-stderr: thrown in /xxx/xxx/xxx/xxxx/login.php on line 36
login.php minimal view
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username']; $password = $_POST['password'];
if(pam_auth($username, $password)) {
$_SESSION['login'] = true; header('LOCATION:overview.php'); die();
} else {
$errorMsg = "Username or Password is incorrect.";
}
}
?>
I added into /etc/php/7.0/fpm/php.ini:
pam.servicename = "php";
and created: /etc/pam.d/php
auth sufficient /lib/security/pam_pwdb.so shadow nodelay
account sufficient /lib/security/pam_pwdb.so
Do I need to include something into my login.php? Or what else am I missing here? I'm not allowed to use other systems like LDAP, DB's etc
Thanks