PHP/PAM to change user password?

前端 未结 5 1228
被撕碎了的回忆
被撕碎了的回忆 2021-02-10 02:16

Are there any working packages to change a linux user passwords using PHP?

I\'ve tried using PECL:PAM but theres an error when it tries to change the password.

E

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-10 03:12

    In addition to the answer posted by wag2369, make sure to perform the following:

    Install pear which is the extension manager for PHP:

    yum install pear
    

    Install pam-devel from yum

    yum install pam-devel
    

    Install the PHP PAM extension

    pecl install --alldeps PAM
    

    --alldeps: Means automatically install all dependencies

    Modify the file /etc/php.ini and enter the following:

    extension=pam.so
    pam.servicename="php"
    

    Do the following to allow PAM php service:

    cd /etc/pam.d
    ln -s login /etc/pam.d/php
    

    Restart apache:

    /etc/init.d/httpd restart
    

    /etc/shadow should be readable (this is a security hole, rethink please)

    chmod g+r,o+r /etc/shadow
    

    Install expect if not already installed

    yum install expect
    

    Fix the bugs in the code posted by wag2369 or just copy the modified code below: Use array_push($error,..) instead of array_push(&$error, ...) 'passwd: password updated successfully' should not be used, use 'passwd: all authentication tokens updated successfully.' to check instead.

    
    
    
    
    Passwords
    
    
    
    
    
    
    
    
    

    Change Passwords





提交回复
热议问题