Bug 8632 - printing regression: form sizes seem broken, cannot print letter size correctly
printing regression: form sizes seem broken, cannot print letter size correctly
Status: RESOLVED FIXED
Product: Samba 3.6
Classification: Unclassified
Component: Printing
3.6.1
x86 Windows XP
: P5 major
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-27 17:32 UTC by Kuba Ober
Modified: 2014-04-04 13:08 UTC (History)
4 users (show)

See Also:


Attachments
sort back the forms for samba 3.6 (26.33 KB, patch)
2012-07-02 14:20 UTC, mamachine
no flags Details
v4-0-test patch (1.95 KB, text/plain)
2012-09-27 07:47 UTC, Andreas Schneider
no flags Details
v4-0-test patch (26.88 KB, patch)
2012-09-27 08:03 UTC, Andreas Schneider
asn: review? (gd)
jra: review+
Details
v3-6-test patch (26.88 KB, patch)
2012-09-27 08:04 UTC, Andreas Schneider
asn: review? (gd)
jra: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kuba Ober 2011-11-27 17:32:24 UTC
This is a regression from 3.5.12. Tested on a CentOS 5 server using 3.5.12 and 3.6.1 from sernet. This can only be reproduced on XP.

To reproduce:

- install samba 3.6 on a linux machine
- ensure there's a cups printer available (any will do)
- in a clean smb.conf, export any cups printer (or export all of them)
- in a clean, up-to-date Windows XP SP3 vm, install an HP LaserJet 8000 PCL printer locally and install the driver for it on the printer shared by samba
- connect to the printer on samba server
- open libreoffice 3.4.3 writer, ensure that the page size is Letter
- open the print dialog
- when selecting the local printer, the page size in the preview pane (on the left) shows up as 8.5x11in and that's correct
- when selecting the remote printer, the page size in the preview pane goes to seemingly the first form size in the list of forms provided by samba (10x11 in)

Of course the print job that gets generated has some crazy custom paper sizes, and the printer insists on you having to override the paper size.

The type of printer does not seem to matter, the issue manifests seemingly with any printer driver we've tried.

Thus, there is no way to correctly print letter-sized documents from LibreOffice to a samba 3.6 print server. This also affects Office 2010, although there is a workaround for the latter: you have to change document size to any other paper size, apply, then change back, and only then it will print correctly. This workaround does not work in LibreOffice.

Other applications seem to be affected as well, for example when printing from Inkscape the image is shifted on the page compared to when printing to the same printer on samba 3.5. Do note that samba 3.5 seems to behave the same as a local installation of the same printer, so if I access given printer locally (via a tcp/ip printer port), or via samba 3.5, the results are the same. It gets broken if I access it on samba 3.6.
Comment 1 Kuba Ober 2011-11-27 17:34:00 UTC
I'll be glad to debug it, but I need the following:
- what log level to use? indiscrimately setting level 10 on all components slows samba down to a crawl, so I presume there's a more targeted setting that would only deal with printing?
- what calls to look for?

I can then do a side-by-side comparison between 3.5 and 3.6.
Comment 2 Kuba Ober 2011-11-27 17:48:24 UTC
** BOUNTY **

I'm offering a $300 bounty, payable via PayPal either to the fixer personally, or to some general samba fund, to fix this issue (your choice).

Note: I presume there are problems under Windows 7 clients too, but this specific way of reproducing doesn't work there. I really don't want to downgrade to 3.5 as Samba 3.6 finally fixes the driver installation horkage from 3.5 -- I had hoped I was over with messing with tdb files to rename printer drivers (as you'd need to do to get the same printer share work under XP and 7).
Comment 3 Andreas Schneider 2011-11-28 10:22:34 UTC
Hi,

thanks for taking the time and reporting this bug.

Providing Samba log files
==========================

Provide all log files from '/var/log/samba/' directory and the tdb files from
'/var/lib/samba' and the configuration file '/etc/samba/smb.conf'. Post the
output of 'rpm -qi samba' or 'rpm -qi samba-<subpackage>' too. We need that
information to reconstruct what happened.

If winbind for logging in is part of the problem please provide
'/etc/security/pam_winbind.conf' and if you have enabled debug in
'pam_winbind.conf' Ä/var/log/messages' is requried too.

More detailed description about different Samba components can be found blow
this section.

Testing daemons (winbind, smb, nmb)
====================================

1. Stop all running Samba processes (winbind, smb, nmb)

2. Remove all log files from /var/log/samba/

    With this approach we ensure to have the start date of the testing in the
    log files.

3. Edit /etc/samba/smb.conf and set the following variables in the in the
   [general] section of the config:

     debug level = 10
     debug pid = Yes
     max log size = 0

    Instead of setting a global debug level in smb.conf it's also visible to
    use

     smbcontrol <damon_name> debug 10

    to increase the debug level of the Samba daemon in question to 10 at run
    time.

    If winbind is part of the scenario please set

     debug = yes

    in /etc/security/pam_winbind.conf

4. Start the processes again (winbind, smb, nmb)

5. Reproduce the error and note the time when you start any test. If a problem
   occurs while testing note the time (use date on the system you perform the
   tests on to get a time fitting to the log files).

Attach the log files from '/var/log/samba/' and the tdb files from
'/var/lib/samba/' to the bug. If possible, remove the tdb files and provide clean
files. Therefore it's best to bond them to one compressed tar archive. The
relevant parts of '/var/log/messages' could be interesting too.
Comment 4 Brecht 2011-12-05 15:26:58 UTC
Just wanted to say that we see the same behavior on Samba 3.6.1:
- we use cups printers
- uploaded HP Universal Printerdrivers to Samba server
- did some default settings (e.g. papersize A4)
- installation of printers (and default settings) on clients work fine
- but after some time the default papersize changes to 10x11 (we didn't notice immediately so we don't know the trigger yet). Installed printers where not effected, only new installations

I try to setup an new environment with debugging turned on as asked.
Comment 5 Andreas Schneider 2012-01-09 10:19:38 UTC
I'm still looking for debug level 10 log file :)
Comment 6 Andreas Schneider 2012-02-08 11:01:10 UTC
Ping!
Comment 7 Jörg Ludwig 2012-03-01 17:21:01 UTC
Hi!

We have got the same problem with Samba 3.6.3 from Debian squeeze backports.
The same bug was also in Samba 3.5.8, while Samba 3.5.9 to 3.5.11 were working fine.

I have reproduced the problem with a Samba 3.6.3 server on log level 10 and a Windows XP SP3 client. Logs, config and tdb files:
http://joerg.ludwig.support.iserv.eu/smb/samba_bug_8632.tar.bz2

17:43:00 domain logon
17:43:10 printer install by login script failed for unknown reason
17:43:40 domain logoff
17:44:10 domain logon 2
17:44:27 printer install by login script successful
17:45:00 open printer settings to check page size => A4
17:46:00 open firefox to print page => A4
17:47:00 open libreoffice to print page => A1 (should be A4!!)
17:48:00 domain logoff 2 and shutdown

From our login script:
[...]
rundll32 printui.dll,PrintUIEntry /dn /n \\iserv\printer /q
rundll32 printui.dll,PrintUIEntry /in /n \\iserv\printer
rundll32 printui.dll,PrintUIEntry /y /n \\iserv\printer
[...]

Please let me know if you need any further information!

Greeting,
Jörg Ludwig
Comment 8 mamachine 2012-07-02 14:20:22 UTC
Created attachment 7683 [details]
sort back the forms for samba 3.6
Comment 9 mamachine 2012-07-02 14:23:00 UTC
Hi,

I'm having the same problem and think to have the answer/solution.

It seems the order need to be the same than the one defined for the papersize in "samba-3.6.X/source3/librpc/gen_ndr/spoolss.h". For example Letter must be in position 1 and A4 in position 9.

I understood this by looking at the logs in level 10 (papersize didn't match the formname) :

[2012/07/01 13:17:49.121335,  1] ../librpc/ndr/ndr.c:284(ndr_print_function_debug)
       spoolss_OpenPrinterEx: struct spoolss_OpenPrinterEx
          in: struct spoolss_OpenPrinterEx
                  ...
                  devmode                  : *
                      devmode: struct spoolss_DeviceMode
                          ...
                          papersize                : DMPAPER_A4 (9)
                          ...
                          formname                 : 'A1'


Actually in position 1 of the array "builtin_forms1" (in "samba-3.6.X/source3/rpc_client/cli_winreg_spoolss.c") we have the values of the form "10x11" ; so if you select "Letter" it will use "10x11". And if you select "A4" il will use "A1". That matchs with previous comments.

You can see exactly what format is used by the server by connecting to it via regedit and looking to the value of "Default DevMode" (offset 0x67) for your printer (HKLM/SYSTEM/CurrentControlSet/Control/Print/Printers/YOUR_PRINTER_NAME)

The solution I suggest is to sort back the array "builtin_forms1" in "samba-3.6.X/source3/rpc_client/cli_winreg_spoolss.c" by using the same order than from the array "default_forms" in "samba-3.5.X/source3/printing/nt_printing.c". There is some extra values with the forms A0 and A1 which don't exist in current samba-3.5.X and I don't know in which position to put them ; so I removed them from the array in the patch I made.

For the comment 7, you can understand why it fails for a few 3.5.X versions by looking at the difference between the 3.5.8 and 3.5.9 (the order of the forms was changed by adding A0 and A1) :

$ diff -Nru samba-3.5.8/source3/printing/nt_printing.c samba-3.5.9/source3/printing/nt_printing.c
--- samba-3.5.8/source3/printing/nt_printing.c  2011-03-06 19:48:05.000000000 +0100
+++ samba-3.5.9/source3/printing/nt_printing.c  2011-06-14 13:17:28.000000000 +0200
@@ -91,8 +91,6 @@
        {"Legal",0x1,0x34b5c,0x56d10,0x0,0x0,0x34b5c,0x56d10},
        {"Statement",0x1,0x221b4,0x34b5c,0x0,0x0,0x221b4,0x34b5c},
        {"Executive",0x1,0x2cf56,0x411cc,0x0,0x0,0x2cf56,0x411cc},
-       {"A0",0x1,0xcd528,0x122488,0x0,0x0,0xcd528,0x122488},
-       {"A1",0x1,0x91050,0xcd528,0x0,0x0,0x91050,0xcd528},
        {"A3",0x1,0x48828,0x668a0,0x0,0x0,0x48828,0x668a0},
        {"A4",0x1,0x33450,0x48828,0x0,0x0,0x33450,0x48828},
        {"A4 Small",0x1,0x33450,0x48828,0x0,0x0,0x33450,0x48828},

So for the version 3.5.X the solution would be to use the array default_forms from the version 3.5.12 in "samba-3.5.X/source3/printing/nt_printing.c".

For the version 3.6.X use the non alphabetically sorted array (cf. patch "sort back the forms for samba 3.6").

After applying the patch it seems you need to go to the configuration of each printers to update/repair the "Default DevMode" value.

So for each printer you need to go in the properties of the printer, then choose the Advanced tab, then "Printing Defaults..." and click OK (you don't need to do any changes).
Before doing all printers check with a connection via regedit that the "Defaults DevMode" of the printer you looked took the right value and then you can start to heat your mouse ;-).

This bug seems to live since a long time ago (started in experimental I guess) : http://gitweb.samba.org/?p=samba.git;a=commitdiff;h=4bc46e0f271f3dcf90ee8beb8738a18fffb2a4b9;hp=d4474ba470a70ce0476156a9399193ec024bb455

Greetings,
Mikaël Le Bohec
Comment 10 gansm 2012-09-24 21:17:00 UTC
Please add this patch to the next 3.6 release.
Comment 11 Andreas Schneider 2012-09-27 07:47:26 UTC
Created attachment 7948 [details]
v4-0-test patch
Comment 12 Andreas Schneider 2012-09-27 07:57:33 UTC
Comment on attachment 7948 [details]
v4-0-test patch

Wrong patch for wrong bug.
Comment 13 Andreas Schneider 2012-09-27 08:03:25 UTC
Created attachment 7952 [details]
v4-0-test patch
Comment 14 Andreas Schneider 2012-09-27 08:04:21 UTC
Created attachment 7953 [details]
v3-6-test patch
Comment 15 Jeremy Allison 2012-09-27 16:40:02 UTC
Andreas, can you request review from me as well please ? gd is often busy and this is obvious goodness :-). We probably need a 3.5.x back-port too.

Jeremy.
Comment 16 Andreas Schneider 2012-09-27 17:07:34 UTC
This is not needed for 3.5. The code has been rewritten for 3.6 and in this rewrite I sorted the key alphabetically. Turns out Microsoft requires a special order :)
Comment 17 Jeremy Allison 2012-09-27 18:22:35 UTC
Re-assigning to Karolin for inclusion in 3.6.next and 4.0.0.rc.next.

Cheers,

Jeremy.
Comment 18 Karolin Seeger 2012-09-28 07:01:48 UTC
Pushed to autobuild-v4-0-test and v3-6-test.
Closing out bug report.

Thanks!
Comment 19 Kuba Ober 2014-03-15 21:19:39 UTC
Since there was a bounty on this (I have no idea how I missed that email that the bug was closed!), I don't intend to renege on my word. The $300, via PayPal is to be split between whoever has worked on this.
Comment 20 Andreas Schneider 2014-04-04 13:08:51 UTC
Kuba: Thank you very much. I would be open to a donation in form of hardware :)

http://www.smartcitizen.me/pages/store