php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16201 sendmail behaves strangely
Submitted: 2002-03-21 05:21 UTC Modified: 2002-05-26 14:15 UTC
From: rohit dot kaul at gecapital dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.1.2 OS: Solaris 8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rohit dot kaul at gecapital dot com
New email:
PHP Version: OS:

 

 [2002-03-21 05:21 UTC] rohit dot kaul at gecapital dot com
We have installed php4.1.2 on iplanet 6.0 Webserver on a Solaris 8 OS.
The following config options were used:

./configure' '-enable-sysvshm=yes' '--enable-sysvsem=yes'
'--with-nsapi=/ecomm/iplanet/nes60/product' '--enable-libgcc'
Something really strange is happening. I have written this piece of code for sending e-mails.

########################################################

<?
$locat = "/usr/lib/sendmail";
$rk = "/ecomm/iplanet/nes60/product/docs/rohit/kkmail" ;

function doSending($emailFilename)
        {
        global $locat;
        echo "<br> locat ".$locat;
        echo "<br> emailfilename ".$emailFilename;
        unset($do);
        $do = "$locat -oi -t < $emailFilename 2>&1 ";
        echo " SYSTEM  " .$do;
        exec($do,$ret,$ret_var);
        echo "return_code " .$ret_var;
        echo "reta " .$ret[1];
        echo "retb " .$ret[2];
        echo "retc " .$ret[3];
        echo "retd " .$ret[4];
        echo "rete " .$ret[5];
        echo "retf " .$ret[6];
        }
doSending($rk);
?>

########################################################
kkmail contents:
To: <email@testmail.com> 
Line1
Line2
Line3
########################################################

The code works very well when I have:
safe_mode=off in php.ini

But as soon as I put the following parameters in php.ini and restart the web-server:
safe_mode=on
safe_mode_exec_dir=/usr/lib 

(In /usr/lib where we have the sendmail executable).

The code displays this error on the php page:

locat /usr/lib/sendmail
emailfilename /ecomm/iplanet/nes60/product/docs/rohit/kkmailSYSTEM /usr/lib/sendmail -oi -t < /ecomm/iplanet/nes60/product/docs/rohit/kkmail 2>&1 return_code 67
reta <... User unknown
retb /ecomm/iplanet/nes60/product/docs/rohit/kkmail... Cannot mail directly to files
retc 2>&1... Unbalanced '>'
retd 2>&1... User unknown
rete /ecomm/iplanet/dead.letter... Saved message in /ecomm/iplanet/dead.letter
retf 

The php.ini file is like this:

########################################################

doc_root=/ecomm/iplanet/nes60/product/docs
safe_mode=on
safe_mode_exec_dir=/usr/lib
expose_php=Off
display_errors=off
log_errors=On
register_globals=off
magic_quotes_runtime=On
file_uploads=Off
allow_url_fopen=Off
session.cookie_lifetime=1200
session.cookie_path=/ecomm/iplanet/nes60/product/docs/ivor
session.entropy_length=16
session.use_trans_sid=0
session.auto_start=1

########################################################

Any help would be deeply appreciated.

Thanks,
Rohit

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-21 05:33 UTC] mfischer@php.net
Afaik you can't pass multiple parameters separated with spaces (they will be passed as one paramter) because of safe_mode on.

Anyone else can confirm this?
 [2002-03-21 07:16 UTC] sniper@php.net
reclassified
 [2002-03-21 07:28 UTC] rohit dot kaul at gecapital dot com
Changed the code to this to keep the spaces and other parameters as variables as well:

######################################################

<?
$locat = "/usr/lib/sendmail";
$rk = "/ecomm/iplanet/nes60/product/docs/rohit/kkmail" ;
$sp=" ";
$ll = "-oi";
$mm = "-t";
$nn = "<";
$oo = "2>&1";

function doSending($emailFilename)
        {
        global $locat;
        global $sp;
        global $ll;
        global $mm;
        global $nn;
        global $oo;
        echo "<br> locat ".$locat;
        echo "<br> emailfilename ".$emailFilename;
        //$do = "$locat -oi -t < $emailFilename 2>&1 ";
 $do =$locat .$sp .$ll .$mm .$sp .$nn .$sp .$emailFilename .$sp .$oo;
        echo "<br>" .$do;
        exec($do,$ret,$ret_var);
echo "<br> return_code " .$ret_var;
        echo "<br>reta " .$ret[1];
        echo "retb " .$ret[2];
        echo "retc " .$ret[3];
        echo "retd " .$ret[4];
        echo "rete " .$ret[5];
        echo "retf " .$ret[6];
        }
doSending($rk);
?>

######################################################

The output of this page is:

locat /usr/lib/sendmail
emailfilename /ecomm/iplanet/nes60/product/docs/rohit/kkmail
/usr/lib/sendmail -oi-t < /ecomm/iplanet/nes60/product/docs/rohit/kkmail 2>&1
return_code 64
reta retb retc retd rete retf 

##################################################

Is there no other workaround/solution for this problem:

:-(
Worried,
Rohit
 [2002-05-26 14:15 UTC] derick@php.net
This is not a bug, safe_mode is designed to make sure only one parameter is passed here.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 09:01:24 2020 UTC