Hi all.
I am calling a BASH script from a php program to change a user's
password on a Linux system.
Basically the php program writes the username and password to a file
called /tmp/chpasswd in the format "user:password" and then executes a
BASH script called chpasswd.sh which looks like this:
=====================================================================
#!/bin/bash
grep root /tmp/chpasswd
if [ "$?" -eq "0" ]
then
exit 1
else
/usr/sbin/chpasswd /tmp/chpasswd
fi
=====================================================================
It is a simple script and it works if I run it as root from the shell.
Now the problem I have is to get it to work when it is executed from
the php.
I have set the permissions and ownership like this:
-rwsr-xr-x 1 root www 127 Aug 23 09:11 chpasswd.sh
SO if I understand it correctly, the script should run with the UID of
root no matter which user runs it. However, when I try to execute it as
a non root user, I get this error:
Cannot lock password file: already locked.
chpasswd: line 1: cannot update password entry
chpasswd: errors occured, 1 passwords not updated
And runing it from the php just fails.
Any ideas?
THanks
--
kholloi
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------