
비밀번호 변경을 위한 다음 PHP 스크립트가 있습니다: <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); ini_set('display_error', true);
$cmd = 'sudo -u root sh -c \'/usr/bin/echo "username:pass" | sudo /usr/sbin/chpasswd 2>&1\'';
exec($cmd,$output,$return_val);
print_r($output);
echo $return_val;
?>
이 스크립트는 브라우저에 오류를 표시합니다.
pam_chauthtok() failed, error: [1] => Authentication token lock busy [2] => chpasswd
그러나 명령은
sudo -u root sh -c '/usr/bin/echo "username:pass" | sudo /usr/sbin/chpasswd 2>&1'
잘 작동합니다. 누군가 나에게 팁을 줄 수 있습니까? 브라우저에 위의 오류가 나타나는 이유는 무엇입니까?
파일 시스템이 rw 모드에 있습니다. /etc/{passwd,shadow} 파일에 올바른 권한이 있습니다.
미리 감사드립니다
답변1
ProtectSystem=full
해결책은 php-fpm.service 단위에서 주석 처리하는 것이었습니다 :
# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by this unit.
#ProtectSystem=full
답변2
브라우저 PHP는 www-data
사용자를 사용하여 실행됩니다.
명령을 사용하여 셸을 통해 www-data
사용할 권한을 추가 하고 이 줄을 추가하세요.sudo
visudo
www-data ALL=(ALL:ALL) ALL
그 구문은 다음과 같습니다
user hosts=(users:groups) commands