[X2go-User] Problems setting print system in x2go [Resolved]

Mike Gabriel mike.gabriel at das-netzwerkteam.de
Wed Aug 17 23:22:24 CEST 2011


Hi Mario,

sorry for top posting...

THANKS for sharing your work, Mario!!!

Could you please do this:

   git clone git://code.x2go.org/cups-x2go.git
   cd cups-x2go
   <put your changes into the files there>
   git diff
   -> then send the diff to patches at x2go.org

Same for x2goserver.git.

This will be much easier to read and use.

Thanks,
Mike

@Morty: how do you send Git patches via mail. With you they seem to  
come directly from the git command. Could you add some lines in the  
wiki on that?

On Mo 15 Aug 2011 20:56:53 CEST Mario OROZ wrote:

> El 02/08/2011 11:47 p.m., John A. Sullivan III escribió:
>> On Tue, 2011-08-02 at 17:10 -0300, Mario OROZ wrote:
>>> El 02/08/2011 03:20 p.m., John A. Sullivan III escribió:
>>>> On Tue, 2011-08-02 at 15:12 -0300, Mario OROZ wrote:
>>>>> El 02/08/2011 02:37 p.m., John A. Sullivan III escribi:
>>>>>> On Mon, 2011-08-01 at 16:49 -0300, Mario OROZ wrote:
>>>>>>> Hello, I'm new to the list.
>>>>>>> I use a server x2go on a Debian 6.0 with Windows XP clients.
>>>>>>> I do not understand how to set the printing to print on  
>>>>>>> printers on the client side.
>>>>>>> I installed cups-x2go, and created a printer with cups  
>>>>>>> cups-driver that provides
>>>>>>> x2go.
>>>>>>> I installed cups-x2go, and created a printer using the driver  
>>>>>>> that provides
>>>>>>> cups-x2go.
>>>>>>> On the client windows, menu Option / Settings / Printing tab  
>>>>>>> is checked the
>>>>>>> "Show this dialog Before start printing"
>>>>>>>
>>>>>>> Can anyone tell me of some howto or explain how to configure  
>>>>>>> the local client
>>>>>>> printing from the server windows x2go
>>>>>>>
>>>>>>> Already, thanks
>>>>>> <snip>
>>>>>> Hi, Mario.  Could you be a bit more detailed about where you are finding
>>>>>> the problem.  When you print from your X2Go desktop to the X2Go printer,
>>>>>> what happens? Thanks - John
>>>>>>
>>>>> When I try to print from the client x2go desktop to the x2go  
>>>>> printer nothings
>>>>> happens!
>>>>> The print job is queued in the spool of the x2go printer (cups
>>>>> server), nothings happens from the client side!
>>>>>
>>>>> What I need is to understand how to configure the printing  
>>>>> system, on both the
>>>>> client
>>>>> and the server side, to achieve redirect the print jobs on the  
>>>>> server side to
>>>>> client's local printer.
>>>>> I saw no documentation on this configuration.
>>>>>
>>>>> This is achievable with the current version of  
>>>>> x2goserver/x2goprint/cups-x2go?
>>>>>
>>>>> Since then, thanks for your answer
>>>> <snip>
>>>> Is the cups server running on the X2Go server?
>>> Yes! x2go server and tne cups server are in the same PC.
>>>
>>>> If not, I believe it
>>>> needs the ability to SSH to it to transfer the file.
>>>>
>>>> The printing is also dependent upon sshfs working properly.  This should
>>>> be relatively automagic assuming it is not being blocked by Windows.
>>>>
>>>> On the X2Go server side, if you issue a mount command, do you see a
>>>> print spool directory, e.g.,
>>>> sshuser at 127.0.0.1:/cygdrive/C/DOCUME~1/MYID~1/X2GO~1/S-9270~1/spool
>>>> on /tmp/spool_myid/myid-63-1312305869_stDKDE_dp32 type fuse.sshfs
>>>> (rw,nosuid,nodev,max_read=65536,user=myid)
>>> I can see this type of mount!
>>> being logged in with my username, from the server in a console;   
>>> can change dir
>>> to /tmp/spool_mario/mario-60-1312310981_stDGNOME_dp32
>>> and I created 2 files in that directory:
>>> $ Echo "some text"> x.txt
>>> $ Echo "x.txt"> x.txt.ready
>>>
>>> On the client PC, the window for print for x2go emerged.
>>>
>>> Pressing the print button gave an error:
>>>
>>> Window Title: Printing error
>>> Failed to execute command:
>>> C:Archivos de programaGhostGumgsviewgsprint.exe -query -color C:/Documents
>>> and Settings/mario/.x2go/S-mario-60-1312310981_stDGNOME_dp32/spool/x.txt
>>> [OK button]
>>>
>>> But that is not important; for now!
>>>
>>> The important thing is that apparently the print jobs are not  
>>> placed / created
>>> in the directory
>>> /tmp/spool_mario/mario-60-1312310981_stDGNOME_dp32
>>>
>>> why?
>> <snip>
>> I really don't know.  It has been quite a while since I setup X2Go
>> printing and our environment is very specialized.  If I recall
>> correctly, the X2Go print driver is a script or somewhere there is a
>> script involved which places the files in the appropriate tmp directory.
>> Is there any chance that script is not executable?
>>
>> You may wish to find that script and edit it by adding some debug
>> information.  I usually add a logger command to send output or simply
>> statements about where I am in the script to the syslog.  This way, you
>> can find out where the script is breaking.  Hope that helps - John
>>
>
>
> Hello people!
>
> I changed the cups-x2go script, so I could print on a client XP.
> Also modify x2goprint, but not its functionality, just add a few  
> lines to logging.
> The problem, from what little I could understand, is that the user  
> x2goprint it
> is not created
> in the installation package x2goserver.*.deb,
> #·addgroup --system x2goprint
> # adduser --system --no-create-home --shell /bin/bash --group --home
> /var/spool/cups/x2goprint  x2goprint
> # passwd -d x2goprint
> ####  Surely there is a better way to create this user.
> Besides having some leftover variables like $sess.
> And x2goprint generates a problem when it checks if there is a mount point in
> the session called
> $spooldir when there is *additionaly* a shared directory configured for the
> remote user on
> the client PC for export.
>
> Y commented the 2 script with #mario# tags for clarity
>
> I copy here:
>
> [BEGIN_cups-x2go]
>
> #!/usr/bin/perl
> # x2go CUPS backend
> # Copyright 2009-2011 Obviously Nice
> #
> #  This program is free software; you can redistribute it and/or modify it
> #  under the terms of the GNU General Public License as published by the
> #  Free Software Foundation; either version 2 of the License, or (at your
> #  option) any later version.
> #
> #  This program is distributed in the hope that it will be useful, but
> #  WITHOUT ANY WARRANTY; without even the implied warranty of
> #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> #  Public License for more details.
> #
> #  You should have received a copy of the GNU General Public License
> #  along with this program; if not, write to the Free Software
> #  Free Software Foundation, Inc.,
> #  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
>
> use Sys::Syslog qw( :DEFAULT setlogsock);
> #mario# module to log to syslog
> use Sys::Hostname;
> use File::Basename;
> use File::Copy;
> use strict;
>
> setlogsock('unix');
> openlog($0,'','user');
> #mario# for log to syslog
>
> my $x2goserver = "local";
> my $printdsa = "/root/.x2go/ssh/.x2goprint/id_dsa";
> 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 $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);
>  }
> }
>
> sub getsessions
> {
>   my $sesslist;
>   if ( $x2goserver eq "local" )
>   {
>        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
>   {
>           $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");
>        #mario# I create the user x2goprint with  
> home=/var/spool/cups/x2goprint
>        #mario# drwxrwxr-x 2 x2goprint x2goprint 4096 ago 12 20:20
> /var/spool/cups/x2goprint
>        #mario# and put x2goprint to sudoers like the manual.
>        my $spfile="$spooldir/$bname";
>        #mario# eliminate $sess from $spooldir$sess$bname and put "/" here.
>        syslog('info', "spfile-> $spfile");
>
>        copy($pfile, $spfile);
>        syslog('info', "printfile copy pfile-> $pfile to spfile-> $spfile");
>
>        copy($tfile, "$spfile.title");
>        syslog('info', "printfile copy tfile-> $tfile to spfile.title->
> $spfile.title");
>
>        chown $uid,$gid,$spfile;
>        chown $uid,$gid,"$spfile.title";
>        #mario# added the above line to $spfile.title
>        system( "su x2goprint -c "sudo x2goprint $userName $sess $bname
> $bname.title"" );
>        #mario# eliminate 2nd and 3th mention off $sess; in $bname  
> and $bname.title
>        syslog('info', "su x2goprint -c sudo 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};
>
>
> 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;
> }
>
> if (scalar(@ARGV) < 5 || scalar(@ARGV) > 6)
> {
>     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 $sepa = "->-";
> #mario# to separate de printjob filename
> syslog('info', "I received from cups-> $jobID $userName $jobTitle $copies
> $printOptions $sepa $printFile");
> #mario# to see what he received from cups
> my $tempFile;
> if (!$printFile)
> {
>     my $jid = $jobID;
>     my $uid = $userName;
>     $jid =~ s/W//g; #sanity check
>     $uid =~ s/W//g; #sanity check
>     $tempFile = "$ENV{TMPDIR}/$jid-$uid-cupsjob$$";
>     syslog('info', "Come from STDIN -> it create tempFile = $tempFilen");
>     #mario# Come from stdin?
>     open (OUT, ">$tempFile") or die "ERROR: Cannot write $tempFile: $!n";
>     while(<STDIN>)
>     {
>         print OUT "$_";
>     }
>     close OUT;
>
>     $printFile = $tempFile;
> }
>
> readconfig();
>
> $ps2pdf=~s/%s/$printFile/g;
> system($ps2pdf);
> $printFile="$printFile.pdf";
> my $titleFile="$printFile.title";
> open (TITLE,">$titleFile");
> print TITLE $jobTitle;
> 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('info', "Call to printfile function with: $printFile  
> $titleFile
> @sinfo[3] @sinfo[1]n");
>          #mario# to see how i call printfile function!
>      }
> }
>
> unlink ($printFile);
> unlink ($titleFile);
> closelog;
> #mario# to close syslog logging.
>
> [END_cups-x2go]
>
> ======================//======================//=====================
> ======================//======================//=====================
>
> [BEGIN_x2goprint]
>
> #!/usr/bin/perl
>
> # Copyright (C) 2007-2011 X2go Project - http://wiki.x2go.org
> #
> # This program is free software; you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation; either version 2 of the License, or
> # (at your option) any later version.
> #
> # This program is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> # GNU General Public License for more details.
> #
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write to the
> # Free Software Foundation, Inc.,
> # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
> #
> # Copyright (C) 2007-2011  Oleksandr Shneyder  
> <oleksandr.shneyder at obviously-nice.de>
> # Copyright (C) 2007-2011  Heinz-Markus Graesing
> <heinz-m.graesing at obviously-nice.de>
>
> use Sys::Syslog qw( :DEFAULT setlogsock);
> #mario# module to log to syslog
> use File::Basename;
> use File::Copy;
> use File::Path;
> use strict;
>
> use lib "/usr/lib/x2go";
> use x2godbwrapper;
>
>
> setlogsock('unix');
> openlog($0,'','user');
> #mario# for log to syslog
>
>
>
> if (scalar(@ARGV) ==1)
> {
>      system ("su @ARGV[0] -c "x2golistsessions --all-servers" ");
> }
> elsif (scalar(@ARGV) != 4)
> {
>     print STDERR "ERROR: Usage:nx2goprint user session file
> titleFilenx2goprint usern";
>     exit 1;
> }
>
> my ($user, $session, $file, $titleFile)=@ARGV;
> syslog('info', "X2GOPRINT receive ARGS: $user $session $file $titleFile");
> #mario# wath args come from cups-x2go
> my ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$homedir)=getpwnam("x2goprint");
> my $printdir=$homedir;
>
>
> my $title;
> if( -e "$printdir/$titleFile")
> {
>      open (TITLE,"<$printdir/$titleFile");
>      $title=<TITLE>;
>      close (TITLE);
>      unlink("$printdir/$titleFile");
> }
>
>
> ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$homedir)=getpwnam($user);
>
> my $spoolbase="/tmp/spool_$user";
> my $spooldir="$spoolbase/$session";
> my $spooltmp="$spoolbase/tmp";
> mkpath($spooltmp);
> chown $uid, $gid, "$spooltmp";
> chmod 0700, "$spooltmp";
>
> my ($mounts)=db_getmounts($session);
>
> if( $mounts=~m/$spooldir/)
> #mario# here, if I have an exported directory (shared folder) from the client
> does not match the conditions outlined in the if
> #mario# and jump the copy of the printjob to the client. PLEASE see  
> this problem!
> {
>      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"");
>      syslog('info', "X2GOPRINT: su $user -c mv $spooltmp/$file $spooldir");
>      #mario# $user move file from the server to client sshfs  
> $spooldir direcoty
> mounted
>      open (RFILE,">$spooltmp/$file.ready");
>      print RFILE "$filen$title";
>      close (RFILE);
>
>      chown $uid, $gid, "$spooltmp/$file.ready";
>      system ("su $user -c "mv $spooltmp/$file.ready $spooldir"");
>      syslog('info', "X2GOPRINT: su $user -c mv $spooltmp/$file.ready  
> $spooldir");
>      #mario# the same as above...
> }
> else
> {
>      unlink("$printdir/$file");
> }
>
> closelog;
> #mario# close the log to syslog
>
> [END_x2goprint]
>
> =====================================/////===============================
>
> with Debian 6.0 server
> repository apt-get:
>     deb http://packages.x2go.org/debian squeeze main
>     deb-src http://packages.x2go.org/debian squeeze main
> And Win XP SP3
>
> What are the repositories of *Production*?
>
> I hope will be useful to someone
>
> Mario.
> _______________________________________________
> X2go-User mailing list
> X2go-User at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/x2go-user
>



-- 

DAS-NETZWERKTEAM
mike gabriel, dorfstr. 27, 24245 barmissen
fon: +49 (4302) 281418, fax: +49 (4302) 281419

GnuPG Key ID 0xB588399B
mail: mike.gabriel at das-netzwerkteam.de, http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digitale PGP-Unterschrift
URL: <http://lists.x2go.org/pipermail/x2go-user/attachments/20110817/35b00815/attachment.pgp>


More information about the x2go-user mailing list