[X2go-Commits] cups-x2go.git - build-main (branch) updated: 3.0.0.3
X2go dev team
git-admin at x2go.org
Wed Oct 12 10:41:44 CEST 2011
The branch, build-main has been updated
via 5c686c05a0b21a1b46a5cefb7b5714f978a11c49 (commit)
via dc9440484640c352fdfe2780692fef048569575d (commit)
via 1bf0849263317a9baa1f9001db5dec3c1e93805f (commit)
via 247294d3841c7233c1c0159ca3ebbec7d3346f4e (commit)
via d94e29dcd1b5cf40aad6505b7a2d004b828b5554 (commit)
via 8599d986f186442a9c9c150657bba930d1da2c6f (commit)
via 264353530bff5c54a5f2294a8af9c8fea00ddc03 (commit)
via 3c6993f6a0afa679bfdf4c5a0d3375f4284db81d (commit)
via 698c43d6d21dfed60db3e70fcb8a987e8514f103 (commit)
via 8f363bfe62295b8dc722e4970c7f44151fe89fa9 (commit)
via 3d504f393caf5d3942e22578695f8fcc73ef1409 (commit)
via 2a54f6694a95b24c915dfafc04b7a1e9123b94d4 (commit)
via 87f5a7a16778541a45e631d1a7004443a5f44df1 (commit)
via e6bae2cd4b9cbed83cee9f8d495985d713d676fc (commit)
via 5b51e6ffce26af411dc17311ff5fa49b54355fe6 (commit)
via 2eac6643e69cb7046a22fd228dbd4a09beeb525d (commit)
via c75449e1439bab59f673fd62113466d956aeb60c (commit)
via 59c2429e0897568b5815eb50a71dbcd7b9a40188 (commit)
via 66ceeab13cba84ed0e23e09310465d9bb3c184fc (commit)
via 0b36c971b50eafced979f4656caeb214292b681c (commit)
from 868d3ef21a4cc3338a98a1f85ffd30128693d63d (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 -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
cups-x2go | 264 ++++++++++++++++++++++++++++-----------------
cups-x2go.conf | 24 +++--
debian/changelog | 26 ++++-
debian/cups-x2go.postinst | 5 +-
4 files changed, 209 insertions(+), 110 deletions(-)
The diff of changes is:
diff --git a/cups-x2go b/cups-x2go
index 771eecd..2275525 100755
--- a/cups-x2go
+++ b/cups-x2go
@@ -1,5 +1,6 @@
#!/usr/bin/perl
-# x2go CUPS backend
+
+# X2go CUPS backend
# Copyright 2009-2011 Obviously Nice
#
# This program is free software; you can redistribute it and/or modify it
@@ -17,141 +18,204 @@
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+use Sys::Syslog qw( :standard :macros );
use Sys::Hostname;
use File::Basename;
use File::Copy;
use strict;
+openlog($0,'cons,pid','user');
+
+## if the CUPS server is X2go server at the same time, use ,,local'' here, otherwise
+## name the hostname of your master X2go server within in your X2go cluster. This
+## host then is used for querying session information.
my $x2goserver = "local";
-my $printdsa = "/root/.x2go/ssh/.x2goprint/id_dsa";
+
+## DSA key for user x2goprint (new path and filename, default in cups-x2go backend)
+## this private key has to be valid for all X2go servers that print via the CUPS
+## server that cups-x2go is installed on. The corresponding public key has to
+## be installed in <remote-x2goserverX>:~x2goprint/.ssh/authorized_keys
+my $printdsa = "/root/.ssh/id_dsa-x2goprint";
+
+# PS2PDF command
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/margin-offset.ps \"%s\"";
+
+## loglevel for cups-x2go, possible values: emerg, alert, crit, err, warning, notice, info, debug
+my $strloglevel = "notice";
+
+# override hardcoded settings via config file
my $cfgfile="/etc/cups/cups-x2go.conf";
+
my $userName;
my @sessions;
-my $host=hostname();
-
+my $this_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;
+ }
+ if($option eq "loglevel")
+ {
+ $strloglevel=$value;
+ $strloglevel=~s/ //g;
+ }
+ }
+ close(CFG);
+ }
+}
+
+
+sub setmylogmask {
+ my $loglevel = LOG_ERR;
+ if ( $strloglevel eq "emerg" ) { $loglevel = LOG_EMERG; }
+ elsif ( $strloglevel eq "alert" ) { $loglevel = LOG_ALERT; }
+ elsif ( $strloglevel eq "crit" ) { $loglevel = LOG_CRIT; }
+ elsif ( $strloglevel eq "err" ) { $loglevel = LOG_ERR; }
+ elsif ( $strloglevel eq "warning" ) { $loglevel = LOG_WARNING; }
+ elsif ( $strloglevel eq "notice" ) { $loglevel = LOG_NOTICE; }
+ elsif ( $strloglevel eq "info" ) { $loglevel = LOG_INFO; }
+ elsif ( $strloglevel eq "debug" ) { $loglevel = LOG_DEBUG; }
+ setlogmask( LOG_UPTO( $loglevel ) );
}
sub getsessions
{
- my $sesslist;
- if ( $x2goserver eq "local" )
- {
- open (SQLCONF, "</etc/x2go/sql");
- my $cfgline=<SQLCONF>;
- close (SQLCONF);
- if(($cfgline=~m/local/)||($cfgline=~m/sqlite/))
- {
- $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
- }
- }
- else
- {
- $sesslist=`ssh -i $printdsa x2goprint\@$x2goserver "sudo x2goprint $userName"`;
- }
- @sessions=split("\n",$sesslist);
+ my $sesslist;
+ if ( $x2goserver eq "local" )
+ {
+ # run x2golistsessions locally
+ $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;
- system( "su x2goprint -c \"sudo x2goprint $userName $sess $sess$bname $sess$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 ($pfile,$tfile,$x2gosession_host, $sess)=@_;
+ my $bname=basename($pfile);
+ if($x2gosession_host eq $this_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";
+ # log that we are about to process a print job
+ syslog('debug', "x2goprint $userName $sess ${sess}_$bname ${sess}_$bname.title");
+
+ # process print job
+ system( "x2goprint $userName $sess ${sess}_$bname ${sess}_$bname.title" );
+ }
+ else
+ {
+ # push spool job to remote X2go server... and launch x2goprint there (with sudo!!!)
+
+ # PDF file
+ syslog('debug', "scp -i $printdsa $pfile x2goprint\@$x2gosession_host:~x2goprint/${sess}_$bname");
+ system ("scp -i $printdsa $pfile x2goprint\@$x2gosession_host:~x2goprint/${sess}_$bname");
+ # title file
+ syslog('debug', "scp -i $printdsa $tfile x2goprint\@$x2gosession_host:~x2goprint/${sess}_$bname.title");
+ system ("scp -i $printdsa $tfile x2goprint\@$x2gosession_host:~x2goprint/${sess}_$bname.title");
+ # run x2goprint on remote X2go server
+ syslog('debug', "ssh -i $printdsa x2goprint\@$x2gosession_host \"sudo x2goprint $userName $sess ${sess}_$bname ${sess}_$bname.title\"" );
+ system( "ssh -i $printdsa x2goprint\@$x2gosession_host \"sudo x2goprint $userName $sess ${sess}_$bname ${sess}_$bname.title\"" );
+
+ }
}
-my $uname=$ENV{USER};
+
+### main ###
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;
}
+# read config file before we go on...
+readconfig();
+setmylogmask();
+
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;
my $jobTitle;
my $copies;
my $printOptions;
-my $printFile;
-
-($jobID, $userName, $jobTitle, $copies, $printOptions, $printFile) = @ARGV;
+my $psFile;
+($jobID, $userName, $jobTitle, $copies, $printOptions, $psFile) = @ARGV;
+syslog('notice', "Print job received from cups -> $jobID $userName $jobTitle $copies $printOptions $psFile");
my $tempFile;
-if (!$printFile)
+if (!$psFile)
{
- my $jid = $jobID;
- my $uid = $userName;
- $jid =~ s/\W//g; #sanity check
- $uid =~ s/\W//g; #sanity check
- $tempFile = "$ENV{TMPDIR}/$jid-$uid-cupsjob$$";
- open (OUT, ">$tempFile") or die "ERROR: Cannot write $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;
+
+ $psFile = $tempFile;
}
-readconfig();
+# converting PS file that we retrieved from CUPS into PDF format
+$ps2pdf=~s/%s/$psFile/g;
+syslog('info', "Converting printjob with command: $ps2pdf\n");
+
+# the TMPDIR env var is needed for ghostscript...
+$ENV{TMPDIR}="/tmp";
+system("$ps2pdf");
-$ps2pdf=~s/%s/$printFile/g;
-system($ps2pdf);
-$printFile="$printFile.pdf";
-my $titleFile="$printFile.title";
+# after we have created the PDF from CUPS's PS file, we can drop the PS file
+unlink ($psFile);
+
+my $pdfFile="$psFile.pdf";
+my $titleFile="$pdfFile.title";
open (TITLE,">$titleFile");
print TITLE $jobTitle;
close (TITLE);
@@ -159,12 +223,16 @@ 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]);
- }
+ my @sinfo=split("\\|", at sessions[$i]);
+ if(@sinfo[4] eq "R")
+ {
+ syslog('debug', "Call to printfile function with: $pdfFile $titleFile @sinfo[3] @sinfo[1]\n");
+ printfile( $pdfFile, $titleFile, @sinfo[3], @sinfo[1]);
+ }
}
-unlink ($printFile);
+unlink ($pdfFile);
unlink ($titleFile);
+
+# closing syslog
+closelog;
diff --git a/cups-x2go.conf b/cups-x2go.conf
index 1c3579e..e44f6dc 100644
--- a/cups-x2go.conf
+++ b/cups-x2go.conf
@@ -1,12 +1,20 @@
-## cups-x2go.conf -- CUPS Backend Configuration
-##
-##
+###
+### cups-x2go.conf -- CUPS Backend Configuration
+###
-## Server with x2go system
+## if the CUPS server is X2go server at the same time, use ,,local'' here, otherwise
+## name the hostname of your master X2go server within in your X2go cluster. This
+## host then is used for querying session information.
#x2goserver = local
-## dsa key for user x2goprint
-#printdsa = /root/.x2go/ssh/.x2goprint/id_dsa
+## DSA key for user x2goprint (new path and filename, default in cups-x2go backend)
+## this private key has to be valid for all X2go servers that print via the CUPS
+## server that cups-x2go is installed on. The corresponding public key has to
+## be installed in <remote-x2goserverX>:~x2goprint/.ssh/authorized_keys
+#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"
+## command to generate PDF file
+#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\"
+
+## loglevel for cups-x2go, possible values: emerg, alert, crit, err, warning, notice, info, debug
+#loglevel = notice
diff --git a/debian/changelog b/debian/changelog
index 6bfa28b..1847fe7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,30 @@
-cups-x2go (3.0.0.2-0~x2go2) UNRELEASED; urgency=low
-
+cups-x2go (3.0.0.3-0~x2go1) unstable; urgency=low
+
+ [ Mike Gabriel ]
+ * New upstream release (3.0.0.3):
+ - Call x2goprint directly with root privileges if x2goserver and CUPS
+ server share the same machine.
+ - Major change of code, add comments, syslogging, fix ghostscript call.
+ - Fix remote printing, use host specified in X2go session information for
+ destination of print jobs, not the host specified in cups-x2go.conf.
+ - Add loglevel config option, allow different log levels (i.e. levels of
+ syslog verbosity).
* 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.
+ * Add a proper dpkg-statoverride check in postinst script.
+
+ [ Mario Oroz ]
+ * New upstream release (3.0.0.3):
+ - Add syslog support for cups-x2go.
+ - Ownership fix for .title file.
+
+ [ Oleksandr Shneyder ]
+ * New upstream release (3.0.0.3):
+ - fixed reading deprecated /etc/x2go/sql.
+ - fixed saving temprary file in / instead of /tmp.
- -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de> Thu, 07 Jul 2011 00:05:46 +0200
+ -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de> Wed, 12 Oct 2011 10:40:12 +0200
cups-x2go (3.0.0.2-0~x2go1) unstable; urgency=low
diff --git a/debian/cups-x2go.postinst b/debian/cups-x2go.postinst
index 2608a7e..896ddeb 100755
--- a/debian/cups-x2go.postinst
+++ b/debian/cups-x2go.postinst
@@ -21,7 +21,10 @@ set -e
case "$1" in
configure)
- dpkg-statoverride --add --update root root 0700 /usr/lib/cups/backend/cups-x2go || true
+ # the x2goprint command can only be run by users that are in group x2goprint
+ if ! dpkg-statoverride --list /usr/lib/cups/backend/cups-x2go >/dev/null; then
+ dpkg-statoverride --add --update root root 0700 /usr/lib/cups/backend/cups-x2go
+ fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
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