[X2go-Commits] cups-x2go.git - master (branch) updated: 3.0.0.2-18-g2a54f66

X2go dev team git-admin at x2go.org
Thu Sep 8 00:00:06 CEST 2011


The branch, master has been updated
       via  2a54f6694a95b24c915dfafc04b7a1e9123b94d4 (commit)
       via  87f5a7a16778541a45e631d1a7004443a5f44df1 (commit)
      from  e6bae2cd4b9cbed83cee9f8d495985d713d676fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2a54f6694a95b24c915dfafc04b7a1e9123b94d4
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Sep 8 00:00:45 2011 +0200

    Call x2goprint directly with root privileges if x2goserver and CUPS server share the same machine.

commit 87f5a7a16778541a45e631d1a7004443a5f44df1
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Sep 7 23:52:37 2011 +0200

    tab'ified cups-x2go backend script

-----------------------------------------------------------------------

Summary of changes:
 cups-x2go        |  200 +++++++++++++++++++++++++++---------------------------
 cups-x2go.conf   |   11 ++-
 debian/changelog |    3 +-
 3 files changed, 108 insertions(+), 106 deletions(-)

The diff of changes is:
diff --git a/cups-x2go b/cups-x2go
index ddba23d..ab0d1ef 100755
--- a/cups-x2go
+++ b/cups-x2go
@@ -1,4 +1,5 @@
 !/usr/bin/perl
+
 # X2go CUPS backend 
 # Copyright 2009-2011 Obviously Nice
 #
@@ -27,114 +28,112 @@ setlogsock('unix');
 openlog($0,'cons,pid','user');
 
 my $x2goserver = "local";
-my $printdsa = "/root/.x2go/ssh/.x2goprint/id_dsa";
+my $printdsa = "/root/.ssh/id_dsa-x2goprint";
 my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f \"%s\"";
-#my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f /usr/bin/margen-offset.ps \"%s\"";
+#my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f /usr/bin/margin-offset.ps \"%s\"";
 my $cfgfile="/etc/cups/cups-x2go.conf";
 my $userName;
 my @sessions;
 my $host=hostname();
 
-
 sub readconfig
 {
- if( -e $cfgfile)
- {
-     open(CFG,"<$cfgfile");
-     while(!eof(CFG))
-     {
-         my $ln=<CFG>;
-         my $nocomln=(split("#",$ln))[0];
-         $nocomln=~s/\n//g;
-         my @valarr=split("=",$nocomln);
-         my $option=@valarr[0];
-         shift(@valarr);
-         my $value=join("=", at valarr);
-         $option=~s/ //g;
-         if($option eq "x2goserver")
-         {
-             $x2goserver=$value;
-             $x2goserver=~s/ //g
-         }
-         if($option eq "printdsa")
-         {
-             $printdsa=$value;
-         }
-         if($option eq "ps2pdf")
-         {
-             $ps2pdf=$value;
-         }
-     }
-     close(CFG);
- }
+	if( -e $cfgfile)
+	{
+		open(CFG,"<$cfgfile");
+		while(!eof(CFG))
+			{
+				my $ln=<CFG>;
+				my $nocomln=(split("#",$ln))[0];
+				$nocomln=~s/\n//g;
+				my @valarr=split("=",$nocomln);
+				my $option=@valarr[0];
+				shift(@valarr);
+				my $value=join("=", at valarr);
+				$option=~s/ //g;
+				if($option eq "x2goserver")
+				{
+					$x2goserver=$value;
+					$x2goserver=~s/ //g
+				}
+				if($option eq "printdsa")
+				{
+					$printdsa=$value;
+				}
+				if($option eq "ps2pdf")
+				{
+					$ps2pdf=$value;
+				}
+			}
+		close(CFG);
+	}
 }
 
 
 sub getsessions
 {
-  my $sesslist;
-  if ( $x2goserver eq "local" )
-  {
-       $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
-
-       ### Suggested patch from Mario OROZ, probably not acceptable here...
-       #-$sesslist=`su $userName -c "x2golistsessions --all-servers"`;
-       #+open (SQLCONF, "</etc/x2go/x2gosql/sql");
-       #+my $cfgline=<SQLCONF>;
-       #+close (SQLCONF);
-       #+if(($cfgline=~m/local/)||($cfgline=~m/sqlite/))
-       #+{
-       #+    $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
-       #+}
-
-  }
-  else
-  {
-          # Calling x2goprint with a single parameter <username> will result in an x2golistsessions --all-servers command on the
-          # remote X2go server.
-          $sesslist=`ssh -i $printdsa x2goprint\@$x2goserver "which x2gobasepath &>/dev/null && test -f \$(x2gobasepath)/lib/x2go/x2goprint.pl && x2goprint $userName || sudo x2goprint $userName"`;
-  }
-  @sessions=split("\n",$sesslist);
+	my $sesslist;
+	if ( $x2goserver eq "local" )
+	{
+		$sesslist=`su $userName -c "x2golistsessions --all-servers"`;
+
+		### Suggested patch from Mario OROZ, probably not acceptable here...
+		#-$sesslist=`su $userName -c "x2golistsessions --all-servers"`;
+		#+open (SQLCONF, "</etc/x2go/x2gosql/sql");
+		#+my $cfgline=<SQLCONF>;
+		#+close (SQLCONF);
+		#+if(($cfgline=~m/local/)||($cfgline=~m/sqlite/))
+		#+{
+		#+    $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
+		#+}
+	}
+	else
+	{
+		# Calling x2goprint with a single parameter <username> will result in an x2golistsessions --all-servers command on the
+		# remote X2go server.
+		$sesslist=`ssh -i $printdsa x2goprint\@$x2goserver "sudo x2goprint $userName"`;
+	}
+	@sessions=split("\n",$sesslist);
 }
 
 
 sub printfile
 {
-    my ($pfile,$tfile,$phost, $sess)=@_;
-    my $bname=basename($pfile);
-    if($phost eq $host)
-    {
-       my ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$spooldir)=getpwnam("x2goprint");
-       my $spfile="$spooldir/$sess$bname";
-       copy($pfile, $spfile);
-       copy($tfile, "$spfile.title");
-       chown $uid,$gid,"$spfile";
-       chown $uid,$gid,"$spfile.title";
-       system( "su x2goprint -c \"which x2gobasepath &>/dev/null && test -f \$(x2gobasepath)/lib/x2go/x2goprint.pl && x2goprint $userName $sess $sess$bname $sess$bname.title || sudo x2goprint $userName $sess $sess$bname $sess$bname.title\"" );
-
-       # log that we processed a print job
-       syslog('debug', "su x2goprint -c \"which x2gobasepath &>/dev/null && test -f \$(x2gobasepath)/lib/x2go/x2goprint.pl && x2goprint $userName $sess $bname $bname.title || sudo x2goprint $userName $sess $bname $bname.title\"");
-    }
-    else
-    {
-           system ("scp -i $printdsa $pfile $tfile x2goprint\@$x2goserver:~x2goprint/");
-           system( "ssh -i $printdsa  x2goprint\@$x2goserver \"which x2gobasepath &>/dev/null && test -f \$(x2gobasepath)/lib/x2go/x2goprint.pl && x2goprint $userName $sess $bname $bname.title || sudo x2goprint $userName $sess $bname $bname.title\"" );
-    }
+	my ($pfile,$tfile,$phost, $sess)=@_;
+	my $bname=basename($pfile);
+	if($phost eq $host)
+	{
+		my ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$spooldir)=getpwnam("x2goprint");
+		my $spfile="$spooldir/$sess$bname";
+		copy($pfile, $spfile);
+		copy($tfile, "$spfile.title");
+		chown $uid,$gid,"$spfile";
+		chown $uid,$gid,"$spfile.title";
+		system( "x2goprint $userName $sess $sess$bname $sess$bname.title" );
+		# log that we processed a print job
+		syslog('debug', "x2goprint $userName $sess $bname $bname.title");
+	}
+	else
+	{
+		system ("scp -i $printdsa $pfile $tfile x2goprint\@$x2goserver:~x2goprint/");
+		system( "ssh -i $printdsa  x2goprint\@$x2goserver \"sudo x2goprint $userName $sess $bname $bname.title\"" );
+	}
 }
 
 
-my $uname=$ENV{USER};
+### main ###
 
+my $uname=$ENV{USER};
 if (!$ARGV[0])
 {
-    print "file cups-x2go:/ \"Virtual X2GO Printer\" \"CUPS-X2GO\" \"MFG:Generic;MDL:CUPS-X2GO Printer;DES:Generic CUPS-X2GO Printer;CLS:PRINTER;CMD:POSTSCRIPT;\"\n";
-    exit 0;
+	print "file cups-x2go:/ \"Virtual X2GO Printer\" \"CUPS-X2GO\" \"MFG:Generic;MDL:CUPS-X2GO Printer;DES:Generic CUPS-X2GO Printer;CLS:PRINTER;CMD:POSTSCRIPT;\"\n";
+	exit 0;
 }
 
 if (scalar(@ARGV) < 5 || scalar(@ARGV) > 6)
 {
-    print STDERR "ERROR: Usage: cups-x2go job-id user title copies options [file]\n";
-    exit 1;
+	print STDERR "ERROR: Usage: cups-x2go job-id user title copies options [file]\n";
+	exit 1;
 }
 
 my $jobID;
@@ -149,20 +148,20 @@ syslog('info', "Print job received from cups -> $jobID $userName $jobTitle $copi
 my $tempFile;
 if (!$printFile)
 {
-    my $jid = $jobID;
-    my $uid = $userName;
-    $jid =~ s/\W//g; #sanity check
-    $uid =~ s/\W//g; #sanity check
-    $tempFile = "/tmp/$jid-$uid-cupsjob$$";
-    open (OUT, ">$tempFile") or die "ERROR: Cannot write $tempFile: $!\n";
-    syslog('info', "Print job comes from STDIN, writing incoming job to temp file $tempFile\n");
-    while(<STDIN>)
-    {
-        print OUT "$_";
-    }
-    close OUT;
-
-    $printFile = $tempFile;
+	my $jid = $jobID;
+	my $uid = $userName;
+	$jid =~ s/\W//g; #sanity check
+	$uid =~ s/\W//g; #sanity check
+	$tempFile = "/tmp/$jid-$uid-cupsjob$$";
+	open (OUT, ">$tempFile") or die "ERROR: Cannot write $tempFile: $!\n";
+	syslog('info', "Print job comes from STDIN, writing incoming job to temp file $tempFile\n");
+	while(<STDIN>)
+	{
+		print OUT "$_";
+	}
+	close OUT;
+
+	$printFile = $tempFile;
 }
 
 readconfig();
@@ -178,12 +177,12 @@ close (TITLE);
 getsessions();
 for(my $i=0; $i<scalar(@sessions);$i++ )
 {
-     my @sinfo=split("\\|", at sessions[$i]);
-     if(@sinfo[4] eq "R")
-     {
-         printfile( $printFile, $titleFile, @sinfo[3], @sinfo[1]);
-         syslog('debug', "Call to printfile function with: $printFile $titleFile @sinfo[3] @sinfo[1]\n");
-     }
+	my @sinfo=split("\\|", at sessions[$i]);
+	if(@sinfo[4] eq "R")
+	{
+		printfile( $printFile, $titleFile, @sinfo[3], @sinfo[1]);
+		syslog('debug', "Call to printfile function with: $printFile $titleFile @sinfo[3] @sinfo[1]\n");
+	}
 }
 
 unlink ($printFile);
@@ -191,4 +190,3 @@ unlink ($titleFile);
 
 # closing syslog 
 closelog;
-
diff --git a/cups-x2go.conf b/cups-x2go.conf
index 1c3579e..0480381 100644
--- a/cups-x2go.conf
+++ b/cups-x2go.conf
@@ -1,12 +1,15 @@
-##  cups-x2go.conf -- CUPS Backend Configuration
-##
-##
+###
+###  cups-x2go.conf -- CUPS Backend Configuration
+###
 
 ## Server with x2go system
 #x2goserver = local
 
-## dsa key for user x2goprint
+## DSA key for user x2goprint (old path and filename)
 #printdsa = /root/.x2go/ssh/.x2goprint/id_dsa
 
+## DSA key for user x2goprint (new path and filename, default in cups-x2go backend)
+#printdsa = /root/.ssh/id_dsa-x2goprint
+
 ## command to generate pdf files
 #ps2pdf = /usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile="%s.pdf" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f "%s"
diff --git a/debian/changelog b/debian/changelog
index c860558..8d94388 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,7 +4,8 @@ cups-x2go (3.0.0.2-0~x2go2) UNRELEASED; urgency=low
   * Add dpkg-statoverride for CUPS backend cups-x2go, file permission 0700
     on CUPS backend makes CUPS run this backend with root-privileges which
     is needed for cups-x2go to work.
-  * Adapt to x2goprint setgid change in x2goserver package (>=3.0.99.6).
+  * Call x2goprint directly with root privileges if x2goserver and CUPS
+    server share the same machine.
   * Add a proper dpkg-statoverride check in postinst script.
 
   [ Mario Oroz ]


hooks/post-receive
-- 
cups-x2go.git (CUPS Backend for X2go Printing)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "cups-x2go.git" (CUPS Backend for X2go Printing).




More information about the x2go-commits mailing list