LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-20-2005, 08:27 AM   #1
clau_bolson
Member
 
Registered: Nov 2003
Location: Argentina
Distribution: Debian Sarge
Posts: 52

Rep: Reputation: 15
php exec() function in chrooted apache


Hi,
I have two apache servers installed in the same computer, one is chrooted and the other isn't.
So far the chrooted apache is working well, but I can't use exec() to copy some files I need.

This code run from the non-chrooted apache
<?php
$com="/chroot/bin/cp /chroot/usr/local/apache2/htdocs/file1 /chroot/usr/local/apache2/htdocs/file2;
exec($com,$res,$a);
echo $a;
?>

exits with error code 0 and the file is copied

This code run from whithin the chrooted apache

<?php
$com="/bin/cp /usr/local/apache2/htdocs/file1 /usr/local/apache2/htdocs/file2;
exec($com,$res,$a);
echo $a;
?>

always exits with error code 127 (command not found)

command used to run the chrooted apache:
/usr/sbin/chroot /chroot/ /usr/local/apache2/bin/httpd -k start

inside the /chroot directory I have copied everything needed

in /chroot/etc/passwd I have only one user: nobody, with shell /bin/bash

in /chroot/etc/bin I have copied /bin/bash and /bin/cp

I have copied also the libraries cp needed in /chroot/lib

php.ini is the same for both apaches, and safe_mode is off.

Please help!
 
Old 12-21-2005, 07:46 AM   #2
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
You do know that PHP has a function called "copy" that can do this, don't you?

http://uk.php.net/copy

The exec function should always be a last resort.
 
Old 12-21-2005, 08:29 AM   #3
clau_bolson
Member
 
Registered: Nov 2003
Location: Argentina
Distribution: Debian Sarge
Posts: 52

Original Poster
Rep: Reputation: 15
No, I didnīt know!
Thanks!

Last edited by clau_bolson; 12-21-2005 at 08:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work gtrawoger Linux - Software 3 12-21-2005 06:51 AM
php mail() funtion in chrooted Apache clau_bolson Linux - Software 0 12-06-2005 10:02 AM
exec function in C... Scrag Programming 2 12-18-2004 01:08 PM
Help php exec, system function for compile javac or java antony_csf Programming 0 06-15-2004 01:45 AM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration