Re: [stunnel-users] launch stunnel server daemon from php?

This is a discussion on Re: [stunnel-users] launch stunnel server daemon from php? within the Stunnel Users forums, part of the Networking and Network Related category; --===============0469016452== Content-Type: multipart/alternative; boundary="----=_Part_29221_25531488.1210024892022" ------=_Part_29221_25531488.1210024892022 Content-Type: text/plain; charset=ISO-8859-1 ...


Go Back   Usenet Forums > Networking and Network Related > Stunnel Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 1 Week Ago
Wesley Kenzie
 
Posts: n/a
Default Re: [stunnel-users] launch stunnel server daemon from php?

--===============0469016452==
Content-Type: multipart/alternative;
boundary="----=_Part_29221_25531488.1210024892022"

------=_Part_29221_25531488.1210024892022
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks, Brian.

The following php script works fine to start up the polipo web proxy cache
program. /etc/polipo/standard.conf contains some standard config file
settings. The command line parameters proxyPort, socksParentProxy, pidFile,
and logFile are additional config settings passed to the polipo executable.
<?php
//
$exec_command = 'polipo -c /etc/polipo/standard.conf proxyPort=8123
socksParentProxy=localhost:9050 pidFile=/var/lib/polipo/9050.pid
logFile=/var/log/polipo/9050.log ';
$exec_output = '';
$exec_result_string = @exec($exec_command, $exec_output,
$exec_result_int);
$exec_output_lines = count($exec_output);
if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {
$log_datetime = date('Y-m-d H:i:s');
@syslog(LOG_INFO, "polipo started on port 8123 at " .
$log_datetime);
@closelog();
}
?>

The following php script does not work. It hangs and has to be
interrupted. If I run the same command from the shell as root it works
fine. I have tried changing the foreground = yes to foreground = no and
removing the & character at the end of the $exec_command but neither works.
<?php
//
$exec_command = '/usr/local/bin/stunnel /etc/stunnel/test.conf &';
$exec_output = '';
$exec_result_string = @exec($exec_command, $exec_output,
$exec_result_int);
$exec_output_lines = count($exec_output);
if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {
$log_datetime = date('Y-m-d H:i:s');
@syslog(LOG_INFO, "stunnel started at " . $log_datetime);
@closelog();
}
?>
/etc/stunnel/test.conf is as follows:
setuid = apache
setgid = apache
pid = /var/lib/stunnel/test.pid
output = /var/log/stunnel/test.log
foreground = yes
syslog = yes

[stunnelTest]
accept = 7199
connect = 8123
client = no
transparent = no



On Mon, May 5, 2008 at 11:15 AM, Brian Hatch <bri@stunnel.org> wrote:

> Around 2008-05-02 12:19 -0700, Wesley Kenzie implored:
>
> > I am having problems launching stunnel from a php "exec" command. I

> would
> > like to have it launch as a server daemon and then have the exec command
> > return control to the php script. The best I have been able to do is

> launch
> > it in foreground with a command like "/usr/local/bin/stunnel
> > /etc/stunnel/test.conf &" but control never returns to the php script.
> >
> > I do not want to use inetd mode, and would prefer to specify command

> line
> > arguments, but I see they are no longer available in version 4.

>
>
> Can you show code that works for other excutables, but not stunnel,
> plus your configuration file?
>
> Stunnel will stop when it has no more input to send to the remote
> end. It could be that stunnel is hanging because its input isn't
> closed, so it assumes it's not 'done' yet.
>
>
>
> --
> Brian Hatch Deja moo (n)
> Systems and - The feeling that you've
> Security Engineer heard that bull before.
> http://www.ifokr.org/bri/
>
> Every message PGP signed
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQFIH06zVkMj8/ymYEsRAjNmAKCeECb09c13cV9rz3Yx1SMf4W49KQCcDWBb
> +q2h5JnGr6jmfHuvG8F7q0U=
> =OOxW
> -----END PGP SIGNATURE-----
>
>


------=_Part_29221_25531488.1210024892022
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div>Thanks, Brian.</div>
<div>&nbsp;</div>
<div>The following php script works fine to start up the polipo web proxy cache program.&nbsp; /etc/polipo/standard.conf contains some standard config file settings.&nbsp; The command line parameters proxyPort, socksParentProxy, pidFile, and logFile are additional config settings passed to the polipo executable.</div>

<div>&lt;?php </div>
<div>&nbsp; &nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_command = 'polipo -c /etc/polipo/standard.conf proxyPort=8123 socksParentProxy=localhost:9050 pidFile=/var/lib/polipo/9050.pid logFile=/var/log/polipo/9050.log ';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_output = '';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_result_string = @exec($exec_command, $exec_output, $exec_result_int);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; $exec_output_lines = count($exec_output);<br>&nbsp;&nbsp;&nbsp;&nbsp;&n bsp; if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $log_datetime = date('Y-m-d H:i:s');<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @syslog(LOG_INFO,&nbsp;&quot;polipo started on port 8123 at &quot;&nbsp;. $log_datetime);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; @closelog();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div>
<div>?&gt;</div>
<div>&nbsp;</div>
<div>
<div>The following php script does not work.&nbsp; It hangs and has to be interrupted.&nbsp; If I run the same command from the shell as root it works fine.&nbsp; I have tried changing the foreground = yes to foreground = no and removing the &amp; character at the end of the $exec_command but neither works.</div>

<div>&lt;?php </div>
<div>&nbsp; &nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_command = '/usr/local/bin/stunnel&nbsp;/etc/stunnel/test.conf &amp;';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_output = '';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_result_string = @exec($exec_command, $exec_output, $exec_result_int);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $exec_output_lines = count($exec_output);<br>&nbsp;&nbsp;&nbsp;&nbsp;&n bsp; if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $log_datetime = date('Y-m-d H:i:s');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp; @syslog(LOG_INFO,&nbsp;&quot;stunnel started at &quot;&nbsp;. $log_datetime);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @closelog();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div>
<div>?&gt;<br></div>
<div>/etc/stunnel/test.conf is as follows:</div>
<div>setuid = apache</div>
<div>setgid = apache</div>
<div>pid = /var/lib/stunnel/test.pid</div>
<div>output = /var/log/stunnel/test.log</div>
<div>foreground = yes</div>
<div>syslog = yes</div>
<div>&nbsp;</div>
<div>[stunnelTest]</div>
<div>accept = 7199</div>
<div>connect = 8123</div>
<div>client = no</div>
<div>transparent = no</div>
<div><br>&nbsp;</div></div>
<p>On Mon, May 5, 2008 at 11:15 AM, Brian Hatch &lt;<a href="mailto:bri@stunnel.org">bri@stunnel.org</a>&gt; wrote:<br></p>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Around 2008-05-02 12:19 -0700, Wesley Kenzie implored:<br>
<div>
<div></div>
<div class="Wj3C7c"><br>&gt; I am having problems launching stunnel from a php &quot;exec&quot; command. &nbsp;I would<br>&gt; like to have it launch as a server daemon and then have the exec command<br>&gt; return control to the php script. &nbsp;The best I have been able to do is launch<br>
&gt; it in foreground with a command like &quot;/usr/local/bin/stunnel<br>&gt; /etc/stunnel/test.conf &amp;&quot; but control never returns to the php script.<br>&gt;<br>&gt; I do not want to use inetd mode, and would prefer to specify command line<br>
&gt; arguments, but I see they are no longer available in version 4.<br><br><br></div></div>Can you show code that works for other excutables, but not stunnel,<br>plus your configuration file?<br><br>Stunnel will stop when it has no more input to send to the remote<br>
end. &nbsp;It could be that stunnel is hanging because its input isn't<br>closed, so it assumes it's not 'done' yet.<br><font color="#888888"><br><br><br>--<br>Brian Hatch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Deja moo (n)<br>&nbsp; Systems and &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- The feeling that you've<br>
&nbsp; Security Engineer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heard that bull before.<br><a href="http://www.ifokr.org/bri/" target="_blank">http://www.ifokr.org/bri/</a><br><br>Every message PGP signed<br></font><br>-----BEGIN PGP SIGNATURE-----<br>Version: GnuPG v1.2.1 (GNU/Linux)<br>
<br>iD8DBQFIH06zVkMj8/ymYEsRAjNmAKCeECb09c13cV9rz3Yx1SMf4W49KQCcDWBb<br> +q2h5JnGr6jmfHuvG8F7q0U=<br>=OOxW<br>-----END PGP SIGNATURE-----<br><br></blockquote></div>

------=_Part_29221_25531488.1210024892022--

--===============0469016452==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
stunnel-users mailing list
stunnel-users@mirt.net
http://stunnel.mirt.net/mailman/listinfo/stunnel-users

--===============0469016452==--
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:19 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0