I have a server-side script executed by Apache running as www-data
. The script runs fine on the server when called remotely (http://example.com/script.sh
).
I am trying to run the same script on the same server as root
, impersonificating www-data
. It does not, even su www-data -c 'id'
or runuser -l www-data -c 'id'
fails with
This account is currently not available.
2016 Nov 4 09:45:54 eu1 Attempted login by root on /dev/pts/0
This account is indeed locked from interactive login (which is normal):
# grep www-data /etc/shadow
www-data:*:15246:0:99999:7:::
# grep www-data /etc/passwd
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
Since Apache manages to run something as www-data
then root
ought to be able to do the same. How to do that?