xpra icon
Bug tracker and wiki

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1048 closed enhancement (fixed)

win32 forwarded printer filtering

Reported by: Antoine Martin Owned by: J. Max Mena
Priority: major Milestone: 0.16
Component: printing Version: trunk
Keywords: Cc:

Description

The current code only forwards the printer definitions for printers marked as "LOCAL", maybe we want to allow more than that, see EnumPrinters.

Change History (17)

comment:1 Changed 4 years ago by Antoine Martin

Owner: changed from Antoine Martin to alas

Implemented in r11383:

To see more debugging, run the Print.exe tool with printing debugging turned on:

SET XPRA_PRINTING_DEBUG=1
Print.exe

Note: although the documentation seems to imply that flags values can be OR-ed together, in my testing this was not the case. So the code will just iterate over each flag and query each type individually.
ie querying both LOCAL and SHARED printers:

C:\Program Files\Xpra>SET XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED
C:\Program Files\Xpra>Print.exe
PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTIONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
PRINTER_FLAGS=SHARED, LOCAL
PRINTER_ENUMS=['SHARED', 'LOCAL']
querying SHARED printers
SHARED printers: []
querying LOCAL printers
skipped printer: 8388608, Microsoft XPS Document Writer,Microsoft XPS Document Writer,, Microsoft XPS Document Writer,
found printer: 8388608, Canon iP2700 series,Canon iP2700 series,hello, Canon iP2700 series, a1
LOCAL printers: ['Canon iP2700 series']
win32.get_printers()={'Canon iP2700 series': {'printer-info': 'Canon iP2700 series,hello', 'type': 'LOCAL', 'printer-make-and-model': 'a1'}}
* Canon iP2700 series
        printer-info                     : Canon iP2700 series,hello
        type                             : LOCAL
        printer-make-and-model           : a1

@afarr / llippold: do we want to change the default? how does that play with network printers? AD? Samba shared printers? Cups shared printers? More importantly: does this cause loops if the client can see the cups server where we forward the printer? etc..

Last edited 4 years ago by Antoine Martin (previous) (diff)

comment:2 Changed 4 years ago by J. Max Mena

Re-attempting with a Win8.1 64-bit machine with a 0.17.0 r11765 client:

  • Print.exe finds 0 printers. Local or network shared
  • Note: setting XPRA_PRINTING_DEBUG=1 has no effect on the output.
  • Earlier versions would work with networked printers that were added through the control panel (Oh, Microsoft, so in love with Wizards), but not through AD shared printers.
  • Not entirely sure how to setup a CUPS shared printer.
    • at least we have network'd and AD shared printers. Will look into Samba sharing.

output:

C:\Program Files (x86)\Xpra>set XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED

C:\Program Files (x86)\Xpra>Print.exe
2016-01-28 14:02:59,510 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 14:02:59,510 PRINTER_FLAGS=LOCAL, SHARED
2016-01-28 14:02:59,512 PRINTER_ENUMS=['LOCAL', 'SHARED']
get_printers() gsview is missing, not querying any printers
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

comment:3 Changed 4 years ago by Antoine Martin

Owner: changed from alas to J. Max Mena

Your problem comes from:

get_printers() gsview is missing, not querying any printers

This was caused by r11583 (for #1041), and should be fixed in r11772. New beta build uploaded.

comment:4 Changed 4 years ago by J. Max Mena

Owner: changed from J. Max Mena to Antoine Martin

Upped to r11772:

  • Still won't detect the AD shared printer.
C:\Program Files (x86)\Xpra>Print.exe
2016-01-28 15:40:40,249 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 15:40:40,249 PRINTER_FLAGS=LOCAL, SHARED
2016-01-28 15:40:40,249 PRINTER_ENUMS=['LOCAL', 'SHARED']
init_printing(None) printers_modified_callback=None
querying LOCAL printers
LOCAL printers: []
querying SHARED printers
SHARED printers: []
win32.get_printers()={}
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Not sure what other logs to give you, I still have the debug enabled, along with the local and shared flags. The printer is added, and I can print to it from Notepad.

comment:5 Changed 4 years ago by Antoine Martin

Owner: changed from Antoine Martin to J. Max Mena

Have you tried tweaking the XPRA_WIN32_PRINTER_FLAGS?
ie:

SET XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED,REMOTE,NETWORK

comment:6 Changed 4 years ago by J. Max Mena

Owner: changed from J. Max Mena to Antoine Martin

Same result with XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED,REMOTE,NETWORK.

comment:7 Changed 4 years ago by Antoine Martin

Owner: changed from Antoine Martin to J. Max Mena

maxmylyn: please include the Print.exe -v output for this case

comment:8 Changed 4 years ago by J. Max Mena

Output as requested(with debug flag enabled):

C:\Program Files (x86)\Xpra>Print.exe -v
2016-01-28 15:57:45,318 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 15:57:45,318 PRINTER_FLAGS=LOCAL, SHARED, REMOTE, NETWORK
2016-01-28 15:57:45,318 PRINTER_ENUMS=['LOCAL', 'SHARED', 'REMOTE', 'NETWORK']
init_printing(None) printers_modified_callback=None
querying LOCAL printers
LOCAL printers: []
querying SHARED printers
SHARED printers: []
querying REMOTE printers
REMOTE printers: []
querying NETWORK printers
NETWORK printers: []
win32.get_printers()={}
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

comment:9 Changed 4 years ago by Antoine Martin

Not sure it will help but it is worth a try, can you try with values 2, 4 and 5:

set XPRA_WIN32_PRINTER_LEVEL=2
Print.exe -v
Last edited 4 years ago by Antoine Martin (previous) (diff)

comment:10 Changed 4 years ago by J. Max Mena

Owner: changed from J. Max Mena to Antoine Martin

Setting it to 2(and 4 and 5) added a new line to the print output:

Warning: failed to query REMOTE printers: (124, 'EnumPrinters', 'The system call
 level is not correct.')

comment:11 Changed 4 years ago by Antoine Martin

Owner: changed from Antoine Martin to J. Max Mena

Damn. The documentation is not very helpful: EnumPrinters.

I did find one similar query for pywin32: printer identification on Windows network - and it seems that in order to query network printers we may need to pass all 3 flags at once... so r11775 allows you to do just that:

set XPRA_WIN32_PRINTER_FLAGS=LOCAL,NETWORK+SHARED+CONNECTIONS
Print.exe -v

You should first clear XPRA_WIN32_PRINTER_LEVEL (or reset to 1 which is the default), and maybe if you are desperate try different flag combinations and different printer levels.. (seems easier than understanding the API docs).
I really hope this helps because my systems don't have such network printers available for testing, and I've wasted a lot of time on this already.

New beta posted.

comment:12 Changed 4 years ago by J. Max Mena

Owner: changed from J. Max Mena to Antoine Martin

upped the client to r11776:

  • the flag XPRA_WIN32_PRINTER_FLAGS=LOCAL,NETWORK+SHARED+CONNECTIONS now outputs the following (with only an AD printer installed):
C:\Program Files (x86)\Xpra>Print.exe
* \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQARack
        printer-info                     : \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQA
Rack,HP Color LaserJet A4/Letter PCL6 Class Driver
        type                             : NETWORK, SHARED, CONNECTIONS
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Looks like that did it.

Added a Windows Shared Printer(same flags):

C:\Program Files (x86)\Xpra>Print.exe
* \\DESKTOP-6OGV4KM\OfficePrinter (HP LaserJet CM1415fnw)
        printer-info                     : \\DESKTOP-6OGV4KM\OfficePrinter (HP L
aserJet CM1415fnw),HP LaserJet Professional CM1410 Series PCL 6,End of testbench

        type                             : NETWORK, SHARED, CONNECTIONS
        printer-make-and-model           : This is for testing, please do not us
e.
* \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQARack
        printer-info                     : \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQA
Rack,HP Color LaserJet A4/Letter PCL6 Class Driver
        type                             : NETWORK, SHARED, CONNECTIONS
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Again looks like that worked. After chatting with Jok, it sounds like setting up a printer in CUPS, then sharing it over the network will be quite time consuming for little results. In his words, anyone that bothers to do it that way will definitely know what they're doing. I'll leave it up to you if you want us to try setting it up. I'll also look into sharing a printer from OSX, but I have a distinct feeling that Apple will make that hard. In the meantime, it's detecting the printers without difficulty.


Review

comment:13 Changed 4 years ago by Antoine Martin

Owner: changed from Antoine Martin to J. Max Mena

@maxmylyn: cups should definitely be tested, as this is what we setup server side. We don't want to end up creating loops where a client then forwards a printer to the server, which adds it in cups, and gets picked up by the client again..
The machines will need to be on the same network with mdns enabled for the printers to be automatically added, Fedora does this by default I believe.
Same for osx, which also uses cups.
Until that is confirmed, I am reluctant to make it auto-add network printers.

Last edited 4 years ago by Antoine Martin (previous) (diff)

comment:14 Changed 4 years ago by J. Max Mena

That took the better part of today. (Somebody owes Jok and me several beers now)

  • Printer added in CUPS on a Fedora 23 server (0.16.1 from Winswitch r17741 I believe)
  • SMB share set up on the server
  • Windows client/computer connected to said SMB share
  • Windows printer configured from the CUPS SMB shared printer

From here:

  • Test prints from Windows work (test page)
  • installed Xpra 0.16.1 on server (same client version from earlier today r11776) and started a session
  • Connected to said computer (this is the one with the CUPS printer added and SMB share enabled) from the Windows machine
    • In attempt to see if I can create the loop you mentioned

Now that I'm connected, I can print to the printer in Windows - the one I added from the SMB Share. This works. Refreshing the SMB share shows no new printers. This is a relatively clean Fedora 23 machine, so it seems to work here.

Still TODO:

  • Investigate MDNS - see if it's enabled or not.
  • Deal with OSX. - regretting this one in advance.

comment:15 Changed 4 years ago by Antoine Martin

r11843 makes querying network printers the default in trunk.

r11844 backports both changes to v0.16.x

Please close if this works for you.

comment:16 Changed 4 years ago by alas

Resolution: fixed
Status: newclosed

Ok... confirmed that maxmylyn set up the CUPS printer on a Fedora 23 machine as well as setting up the same printer as a local printer... then connected a windows client to the server which also had an AD network set up for the same printer, the same printer set up as a local printer on the windows client, and the same printer set up as a shared printer via yet another windows machine on the same network.

There were a lot of choices of icons to use in order to print to that printer (maybe the printer should be re-named to Rome)... but we didn't come up with any sane configuration that would produce any loops.

  • As for the MDNS/other osx networking systems, since we seemed able to find networked printers with osx clients previously, I imagine any loop threats are already present and will hopefully not bite anyone in the future... but this change shouldn't impact that possibility.

Closing - but will open a new ticket promptly if it turns out there's a configuration we missed which causes a problem.

comment:17 Changed 4 years ago by Antoine Martin

Contrary to what comment:15 says, network printers were not enabled by default in 0.16.x (and no one told me), r12222 fixes that.

Note: See TracTickets for help on using tickets.