Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 Dec 2006 00:10:04 -0700
From:      Ray Still <rastill@shaw.ca>
To:        freebsd-questions@freebsd.org
Subject:   problem with script execution
Message-ID:  <039401c71517$b9ef5750$6700a8c0@New>

next in thread | raw e-mail | index | archive | help
Hello;
I have a problem that I have put considerable time into, but I keep 
coming up empty. short form is that the script works from the command 
line, but doesn't work from a php script. (I've already stumped the php 
list.)
details follow.

I have a shell script , 'copy' consisting of 4 lines
echo * | sudo -u admn -S rm /path/to/file1
echo * | sudo -u admn -S cp /some/path/to/source1 /path/to/file1
echo * | sudo -u admn -S rm /path/to/file2
echo * | sudo -u admn -S cp /some/path/to/source2 /path/to/file2

copy is owned by www:www and is mode 777
file1 and file2 are owned by admn:www and are mode 666
copy, file1 and file2 are in the same directory which is owned by 
www:www and is mode 777
I have enabled targetpw in the sudoers file as www doesn't really have 
a password.
I also have a php script 
<?php
echo exec ('whoami');
exec ('/path/to/copy');
?>
(just for the sake of completeness, exec passes a command to the OS and 
echo prints what ever is passed to it.)
my output is "www" which is the expected result of the whoami for the 
php/apache user. however no file changes happen.

however, from root:
sudo -u www /path/to/copy  
changes the files exactly as expected/desired.
any suggestions/pointers/links would be appreciated.

system:
FreeBSD www.domain.tld 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Mon Feb 13 
09:28:07 MST 2006 user@www.domain.tld:/usr/src/sys/i386/compile/WWW 
i386
Apache/2.2.3 (FreeBSD) mod_ssl/2.2.3 OpenSSL/0.9.7e-p1 PHP/5.1.5

(potentially sensitve info removed)

Ray



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?039401c71517$b9ef5750$6700a8c0>