[X2Go-Commits] x2goserver.git - build-baikal (branch) updated: 3.0.99-2-219-g7f7ec2c
X2Go dev team
git-admin at x2go.org
Wed Dec 4 06:21:34 CET 2013
The branch, build-baikal has been updated
via 7f7ec2c82959950ef5ef2186b2c2ff658f8508ca (commit)
from cfbadbad8aa07a623c38313799170feae6f63936 (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:
debian/changelog | 1 +
x2goserver/bin/x2goprint | 68 +++++++++++++++++++++++++++++++++++-----------
2 files changed, 53 insertions(+), 16 deletions(-)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 8a9626e..87b6158 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -35,6 +35,7 @@ x2goserver (3.0.99.5-0~x2go3) UNRELEASED; urgency=low
* Create x2goprint user/group on package installation, add same info to
INSTALL howto.
* Add sanity checks to x2goprint, script can only be run as root.
+ * Fix x2goprint, add syslogging, add inline comments.
[ Martin Oehler ]
* Removes old debug code fragment, fixes x2golistsessions parsing.
diff --git a/x2goserver/bin/x2goprint b/x2goserver/bin/x2goprint
index 89028af..8d0da56 100755
--- a/x2goserver/bin/x2goprint
+++ b/x2goserver/bin/x2goprint
@@ -23,44 +23,57 @@
use File::Basename;
use File::Copy;
use File::Path;
+use Sys::Syslog qw( :DEFAULT setlogsock);
use strict;
use lib `echo -n \$(x2gobasepath)/lib/x2go`;
use x2godbwrapper;
+setlogsock('unix');
+openlog($0,'cons,pid','user');
+
sub check_root
{
my ($uname, $pass, $uid, $pgid, $quota, $comment, $gcos, $homedir, $shell, $expire) = getpwuid($<);
my $realuser=$uname;
if ($realuser ne "root")
{
+ syslog('err', "x2goprint was called by user $realuser directly, x2goprint exits now!");
die "$realuser, you cannot use x2goprint as non-root user...";
}
}
-sub usage
+sub check_usage
{
if (scalar(@ARGV) == 1)
{
+ syslog('info', "x2goprint was called with only one cmd line arg, running in x2golistsessions wrapper mode");
system ("su @ARGV[0] -c \"x2golistsessions --all-servers\"");
exit 0;
}
elsif (scalar(@ARGV) != 4)
{
+ syslog('err', "x2goprint was called with a wrong number of cmd line args, x2goprint exits now!");
print STDERR "ERROR: Usage:\nx2goprint user session file titleFile\nx2goprint user\n";
exit 1;
}
}
+# sanity check, this script has to be run with root privileges
check_root();
-usage();
-my ($user, $session, $file, $titleFile)=@ARGV;
+# check number of cmd line args
+check_usage();
+
+# get options from the command line
+my ($user, $session, $pdfFile, $titleFile)=@ARGV;
+# location for incoming jobs is ~x2goprint
my ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$homedir)=getpwnam("x2goprint");
my $printdir=$homedir;
-my $title;
+# extract necessary information from title file and drop it afterwards
+my $title='UNTITLED';
if( -e "$printdir/$titleFile")
{
open (TITLE,"<$printdir/$titleFile");
@@ -68,8 +81,11 @@ if( -e "$printdir/$titleFile")
close (TITLE);
unlink("$printdir/$titleFile");
}
+syslog('info', "x2goprint is processing $printdir/$pdfFile with print job title ,,$title\''");
-
+# temp location for placing incoming spool files, so that
+# they can can be picked by the session user and further processed
+# with user privileges
($tm,$tm,$uid,$gid,$tm,$tm,$tm,$homedir)=getpwnam($user);
my $spoolbase="/tmp/spool_$user";
@@ -79,21 +95,41 @@ mkpath($spooltmp);
chown $uid, $gid, "$spooltmp";
chmod 0700, "$spooltmp";
+# this last part mainly uses the session user's privileges
my ($mounts)=db_getmounts($session);
if ( $mounts=~m/$spooldir/)
{
- move("$printdir/$file", "$spooltmp") or die "$!: Can't move $file to $spooltmp/";
- chown $uid, $gid, "$spooltmp/$file";
- system("su $user -c \"mv $spooltmp/$file $spooldir\"");
- open (RFILE,">$spooltmp/$file.ready");
- print RFILE "$file\n$title";
+ # if the client side spool dir (the directory where x2goclient
+ # waits for incoming print job files) is mounted in the session
+ # we will copy the print files from the temp location above to
+ # the SSHFS share mounted from the client system.
+
+ syslog('info', "client-side spool dir is mounted, transferring printable file $pdfFile to X2go client system");
+
+ if (not move("$printdir/$pdfFile", "$spooltmp")) {
+ syslog('err', "x2goprint failed to process print spool job for file $pdfFile");
+ die "$0: Can't move $printdir/$pdfFile to $spooltmp/";
+ }
+ chown $uid, $gid, "$spooltmp/$pdfFile";
+
+ system("su $user -c \"mv $spooltmp/$pdfFile $spooldir\"");
+ syslog('debug', "x2goprint moved file $pdfFile to X2go client's spool dir");
+
+ open (RFILE,">$spooltmp/$pdfFile.ready");
+ print RFILE "$pdfFile\n$title";
close (RFILE);
- chown $uid, $gid, "$spooltmp/$file.ready";
- system ("su $user -c \"mv $spooltmp/$file.ready $spooldir\"");
-}
-else
-{
- unlink("$printdir/$file");
+ chown $uid, $gid, "$spooltmp/$pdfFile.ready";
+ system ("su $user -c \"mv $spooltmp/$pdfFile.ready $spooldir\"");
+ syslog('debug', "x2goprint moved file $pdfFile.ready to X2go client's spool dir, X2go client should start the print dialog very soon");
+
+} else {
+
+ # if the client-side spool dir is not mounted via SSHFS, we will simply drop the
+ # printable PDF file
+
+ syslog('info', "client-side spool dir is _not_ mounted, dropping spool job $pdfFile");
+
+ unlink("$printdir/$pdfFile");
}
hooks/post-receive
--
x2goserver.git (X2Go Server)
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 "x2goserver.git" (X2Go Server).
More information about the x2go-commits
mailing list