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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
--===============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> </div> <div>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.</div> <div><?php </div> <div> //<br> $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> $exec_output = '';<br> $exec_result_string = @exec($exec_command, $exec_output, $exec_result_int);<br> &nbs p; $exec_output_lines = count($exec_output);<br> &n bsp; if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {<br> $log_datetime = date('Y-m-d H:i:s');<br> @syslog(LOG_INFO, "polipo started on port 8123 at " . $log_datetime);<br> & nbsp; @closelog();<br> }</div> <div>?></div> <div> </div> <div> <div>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.</div> <div><?php </div> <div> //<br> $exec_command = '/usr/local/bin/stunnel /etc/stunnel/test.conf &';<br> $exec_output = '';<br> $exec_result_string = @exec($exec_command, $exec_output, $exec_result_int);<br> $exec_output_lines = count($exec_output);<br> &n bsp; if (@openlog('', LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_LOCAL0)) {<br> $log_datetime = date('Y-m-d H:i:s');<br> &n bsp; @syslog(LOG_INFO, "stunnel started at " . $log_datetime);<br> @closelog();<br> }</div> <div>?><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> </div> <div>[stunnelTest]</div> <div>accept = 7199</div> <div>connect = 8123</div> <div>client = no</div> <div>transparent = no</div> <div><br> </div></div> <p>On Mon, May 5, 2008 at 11:15 AM, Brian Hatch <<a href="mailto:bri@stunnel.org">bri@stunnel.org</a>> 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>> I am having problems launching stunnel from a php "exec" command. I would<br>> like to have it launch as a server daemon and then have the exec command<br>> return control to the php script. The best I have been able to do is launch<br> > it in foreground with a command like "/usr/local/bin/stunnel<br>> /etc/stunnel/test.conf &" but control never returns to the php script.<br>><br>> I do not want to use inetd mode, and would prefer to specify command line<br> > 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. 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 Deja moo (n)<br> Systems and - The feeling that you've<br> Security Engineer 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==-- |
![]() |
| Thread Tools | |
| Display Modes | |
|
|