[gimp-perl] Strip down args on Perl-Server.
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Strip down args on Perl-Server.
- Date: Thu, 15 May 2014 18:14:56 +0000 (UTC)
commit 1b3a8c0217f1fd75cb3ee59c0b83ef8400721f16
Author: Ed J <edj src gnome org>
Date: Thu May 15 19:14:33 2014 +0100
Strip down args on Perl-Server.
Net/Net.pm | 34 ++++++++++------------------------
TODO | 2 +-
examples/Perl-Server | 7 +++++--
3 files changed, 16 insertions(+), 27 deletions(-)
---
diff --git a/Net/Net.pm b/Net/Net.pm
index 4084971..64f901b 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -38,11 +38,6 @@ use Gimp::Extension;
$VERSION = 2.3002;
bootstrap Gimp::Net $VERSION;
-use constant {
- PS_FLAG_QUIET => 1 << 0, # do not output messages
- PS_FLAG_BATCH => 1 << 1, # started via Gimp::Net, extra = filehandle
-};
-
my $PROTOCOL_VERSION = 4; # protocol version
my ($server_fh, $gimp_pid, $trace_level, $auth);
@@ -148,10 +143,8 @@ sub start_server {
fcntl $gimp_fh, F_SETFD, 0;
delete $ENV{GIMP_HOST};
open STDIN,"</dev/null";
- my $flags = PS_FLAG_BATCH | ($Gimp::verbose ? 0 : PS_FLAG_QUIET);
my $args = join ' ',
&Gimp::RUN_NONINTERACTIVE,
- $flags,
fileno($gimp_fh),
int($Gimp::verbose);
my @exec_args = ($Gimp::Config{GIMP}, qw(--no-splash --console-messages));
@@ -280,7 +273,7 @@ $server_quit = 0;
my $max_pkt = 1024*1024*8;
sub slog {
- return if $ps_flags & PS_FLAG_QUIET;
+ return unless $Gimp::verbose;
print localtime.": $$-slog(",@_,")\n";
}
@@ -290,17 +283,12 @@ sub handle_request($) {
my($fh)= _;
my ($req, $data);
eval {
- local $SIG{ALRM}=sub { die "1\n" };
- #alarm(6) unless $ps_flags & PS_FLAG_BATCH;
my $length;
read($fh,$length,4) == 4 or die "2\n";
$length=unpack("N",$length);
$length>0 && $length<$max_pkt or die "3\n";
- #alarm(6) unless $ps_flags & PS_FLAG_BATCH;
read($fh,$req,4) == 4 or die "4\n";
- #alarm(20) unless $ps_flags & PS_FLAG_BATCH;
read($fh,$data,$length-4) == $length-4 or die "5\n";
- #alarm(0);
};
warn "$$-handle_request got '$@'" if $@ and $Gimp::verbose;
return 0 if $@;
@@ -409,19 +397,17 @@ sub setup_listen_tcp {
}
sub perl_server_run {
- (my $run_mode, $ps_flags, my $extra, $Gimp::verbose) = @_;
+ (my $run_mode, my $filehandle, $Gimp::verbose) = @_;
warn "$$-".__PACKAGE__."::perl_server_run(@_)\n" if $Gimp::verbose;
if ($run_mode == &Gimp::RUN_NONINTERACTIVE) {
- if ($ps_flags & PS_FLAG_BATCH) {
- die __"unable to open Gimp::Net communications socket: $!\n"
- unless open my $fh,"+<&$extra";
- $fh->autoflush;
- on_accept($fh);
- Glib::IO->add_watch(fileno($fh), 'in', \&on_input, $fh);
- Gtk2->main;
- Gimp->quit(0);
- exit(0);
- }
+ die __"unable to open Gimp::Net communications socket: $!\n"
+ unless open my $fh,"+<&$filehandle";
+ $fh->autoflush;
+ on_accept($fh);
+ Glib::IO->add_watch(fileno($fh), 'in', \&on_input, $fh);
+ Gtk2->main;
+ Gimp->quit(0);
+ exit(0);
} else {
$ps_flags=0;
}
diff --git a/TODO b/TODO
index 4fc30b6..87aec9b 100644
--- a/TODO
+++ b/TODO
@@ -20,7 +20,7 @@ Items as of 2014-04-29 (by Ed J)
- gimp/plug-ins/script-fu/script-fu-console.c
base on this:
http://gtk2-perl.sourceforge.net/doc/gtk2-perl-study-guide/x3661.html
-* PS flags are obsolete - replace with verbose - set_trace may also be obsolete
+* set_trace may also be obsolete
* interactive collab image-editing:
http://users.telenet.be/blendix/verse/#gimp_plugin
https://github.com/verse/verse/wiki/Tutorial-Simple-C-Verse-Client
diff --git a/examples/Perl-Server b/examples/Perl-Server
index 096d46a..6eb3949 100755
--- a/examples/Perl-Server
+++ b/examples/Perl-Server
@@ -31,6 +31,10 @@ If activated by the user, allows Gimp-Perl scripts to connect to the
running GIMP instance. Also provides a working example of a GIMP extension
in Gimp-Perl.
+If C<run_mode> is C<RUN_NONINTERACTIVE>, will run in "batch mode" and
+expect the C<filehandle> argument to be correct to communicate with the
+client. If C<RUN_INTERACTIVE>, expects to wait for connections.
+
There is a security advisory about GIMP scripting servers. This program
will only allow TCP connections if a password is specified (the "auth"
option), thereby eliminating any network-related security risk.
@@ -38,8 +42,7 @@ option), thereby eliminating any network-related security risk.
=head1 PARAMETERS
[&Gimp::PDB_INT32, "run_mode", "Interactive:0=yes,1=no"],
- [&Gimp::PDB_INT32, "flags", "internal flags (must be 0)"],
- [&Gimp::PDB_INT32, "extra", "multi-purpose"],
+ [&Gimp::PDB_INT32, "filehandle", "Batch file-handle"],
[&Gimp::PDB_INT32, "verbose", "Gimp verbose var"],
=head1 AUTHOR
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]