|
From: James C. <qu...@us...> - 2007-03-06 01:36:34
|
Update of /cvsroot/pptpclient/pptp-extras/pptpconfig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19184 Modified Files: ChangeLog NEWS pptpconfig.php Log Message: sf.net #1662620 Index: ChangeLog =================================================================== RCS file: /cvsroot/pptpclient/pptp-extras/pptpconfig/ChangeLog,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- ChangeLog 21 Aug 2006 06:08:43 -0000 1.16 +++ ChangeLog 6 Mar 2007 01:36:22 -0000 1.17 @@ -1,3 +1,20 @@ +Tue Mar 6 12:21:30 2007 mvsfnet <mv...@us...> + + * pptpconfig.php: tracker item 1662620 CLI patches. + + pptpconfig.php fails from the command line because the pipe to + pppd is set to nonblocking, the reader function is reached much + faster than under the GUI, fgets returns an empty line as pppd + hasn't output anything yet, and the else GUI case loops on while + line is not blank, when it should be looping until feof. There's a + === typo in that while too. + + While at it added a couple of $use_gui checks, as gui + functions/settings are being called/done even when the code is + running from the gui, and attempted to include a patch similar to + one in the list to make pptpconfig.php runable from the command + line, i.e. no env DISPLAY variable. + Mon Aug 21 15:32:58 2006 James Cameron <qu...@us...> * pptpconfig-20060821: released. Index: NEWS =================================================================== RCS file: /cvsroot/pptpclient/pptp-extras/pptpconfig/NEWS,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- NEWS 19 Jul 2006 06:13:06 -0000 1.11 +++ NEWS 6 Mar 2007 01:36:22 -0000 1.12 @@ -1,3 +1,4 @@ + - CLI patches [ 1662620 anonymous ] - add command line start, stop and status options [DiVerdi] - call setsid() to prevent process group kill hitting parent [Cameron] Index: pptpconfig.php =================================================================== RCS file: /cvsroot/pptpclient/pptp-extras/pptpconfig/pptpconfig.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- pptpconfig.php 21 Aug 2006 06:19:12 -0000 1.12 +++ pptpconfig.php 6 Mar 2007 01:36:22 -0000 1.13 @@ -27,9 +27,6 @@ # $Id$ "; -# load the php-gtk functions -dl("php_gtk.so"); - # paths and files # root path, change to ./ for non-root testing @@ -96,25 +93,6 @@ # process group kill from going beyond us posix_setsid(); -# define text highlight colours -$colours['no'] = &new GdkColor(0, 0, 0); -$colours['me'] = &new GdkColor(32768, 0, 32768); -$colours['tx'] = &new GdkColor(0, 32768, 32768); -$colours['rx'] = &new GdkColor(32768, 32768, 0); -$colours['uh'] = &new GdkColor(32768, 0, 0); -$colours['ok'] = &new GdkColor(0, 32768, 0); - -$colours['red'] = &new GdkColor(65535, 32768, 32768); -$colours['green'] = &new GdkColor(32768, 65535, 32768); -$colours['blue'] = &new GdkColor(32768, 32768, 65535); -$colours['red-selected'] = &new GdkColor(0x9c9c, 0, 0); -$colours['green-selected'] = &new GdkColor(0, 0x7070, 0); -$colours['blue-selected'] = &new GdkColor(0, 0, 0x9c9c); - -# point at the glade file containing the widget tree -$xml = $me.'.xml'; -if (!@is_readable($xml)) $xml = PATH_LIB.$me.'.xml'; - $use_gui = TRUE; $quiet = FALSE; @@ -165,6 +143,27 @@ exit(0); } +# load the php-gtk functions +dl("php_gtk.so"); + +# define text highlight colours +$colours['no'] = &new GdkColor(0, 0, 0); +$colours['me'] = &new GdkColor(32768, 0, 32768); +$colours['tx'] = &new GdkColor(0, 32768, 32768); +$colours['rx'] = &new GdkColor(32768, 32768, 0); +$colours['uh'] = &new GdkColor(32768, 0, 0); +$colours['ok'] = &new GdkColor(0, 32768, 0); + +$colours['red'] = &new GdkColor(65535, 32768, 32768); +$colours['green'] = &new GdkColor(32768, 65535, 32768); +$colours['blue'] = &new GdkColor(32768, 32768, 65535); +$colours['red-selected'] = &new GdkColor(0x9c9c, 0, 0); +$colours['green-selected'] = &new GdkColor(0, 0x7070, 0); +$colours['blue-selected'] = &new GdkColor(0, 0, 0x9c9c); + +# point at the glade file containing the widget tree +$xml = $me.'.xml'; +if (!@is_readable($xml)) $xml = PATH_LIB.$me.'.xml'; function usage() { echo "usage: $argv[0] [-q] [tunnel {start|stop|status}]\n"; exit(1); @@ -816,7 +815,9 @@ $pipe = popen($command.' 2>&1', 'r'); stream_set_blocking($pipe, true); while (!feof($pipe)) { - while(Gtk::events_pending()) Gtk::main_iteration(); + if ($use_gui) { + while(Gtk::events_pending()) Gtk::main_iteration(); + } $text .= fgets($pipe, 2048); } $status = pclose($pipe); @@ -1368,10 +1369,10 @@ function reader($ignore, $ignore, $context) { global $me, $gtk_inputs, $use_gui, $quiet; - $line = fgets($context['pipe'], 1024); if ($use_gui) { # in the gui, the reader is a callback that processes on line at a time - if (!($line == false)) { + if (!feof($context['pipe'])) { + $line = fgets($context['pipe'], 1024); scribe($context, $line); if (ereg("Using interface (ppp[0-9]*)", $line, $regs)) { @@ -1394,7 +1395,8 @@ } } else { # in the CLI, reader should read all input right away - while (!($line === false)) { + while (!feof($context['pipe'])) { + $line = fgets($context['pipe'], 1024); scribe($context, $line); if (ereg("Using interface (ppp[0-9]*)", $line, $regs)) { @@ -1406,8 +1408,6 @@ if (ereg('^remote IP address ([0-9.]*)', $line, $regs)) { $context['remoteip'] = $regs[1]; } - - $line = fgets($context['pipe'], 1024); } } @@ -1454,13 +1454,15 @@ $state = 'initialising'; if ($state == 'stopping') { - $statusbar->push($window->get_data('id'), 'Stopped'); - $window->set_data('state', 'stopped'); - setup_list_set_state($context['name'], 'stopped'); + if ($use_gui) { + $statusbar->push($window->get_data('id'), 'Stopped'); + $window->set_data('state', 'stopped'); + setup_list_set_state($context['name'], 'stopped'); + $stop->set_sensitive(0); + $ping->set_sensitive(0); + $start->set_sensitive(1); + } scribe($context, "$me: stopped\n"); - $stop->set_sensitive(0); - $ping->set_sensitive(0); - $start->set_sensitive(1); } else { if ($use_gui ) $interface = $window->get_data('interface'); @@ -1746,8 +1748,10 @@ # if it was stopped, change to initialising, clear the old log if ($state == 'stopped') { $state = 'initialising'; - $text = $gx[$name]->get_widget('text'); - $text->delete_text(0, -1); + if ($use_gui) { + $text = $gx[$name]->get_widget('text'); + $text->delete_text(0, -1); + } } # if it is now initialising, start the pppd process @@ -1801,9 +1805,9 @@ $command .= 'exit $pppd_exit_code;'; $context['pipe'] = popen($command.' 2>&1', 'r'); - socket_set_blocking($context['pipe'], FALSE); if ($use_gui) { + socket_set_blocking($context['pipe'], FALSE); $window->set_data('state', 'starting'); setup_list_set_state($name, 'starting'); |