apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.87k stars 459 forks source link

Cannot use IPP printing in SmartOS zone #5834

Closed JVIon6oose closed 3 years ago

JVIon6oose commented 3 years ago

I have a SmartOS zone with CUPS 2.3.3 installed and I am unable to add an IPP printer (Brother HL-L3230CDW) located in the same network segment. Using ipptool :

ipptool -tv ipp://10.0.2.12/ /opt/local/share/cups/ipptool/get-printer-attributes.test
ipptool: Unable to connect to "10.0.2.12" on port 631 - Bad address

lpadmin issues the same error:

lpadmin -p brother -E -v ipp://10.0.2.12/ -m everywhere
lpadmin: Unable to connect to "10.0.2.12:631": Bad address

Printer can be reached however:

ping -I 1 10.0.2.12
PING 10.0.2.12: 56 data bytes
64 bytes from 10.0.2.12: icmp_seq=0. time=0.565 ms
64 bytes from 10.0.2.12: icmp_seq=1. time=0.451 ms
64 bytes from 10.0.2.12: icmp_seq=2. time=0.439 ms
64 bytes from 10.0.2.12: icmp_seq=3. time=0.441 ms

Same query with ipptool from a SmartOS KVM running Debian yields:

ipptool -tv ipp://10.0.2.12/ /usr/share/cups/ipptool/get-printer-attributes.test
"/usr/share/cups/ipptool/get-printer-attributes.test":
    Get-Printer-Attributes:
        attributes-charset (charset) = utf-8
        attributes-natural-language (naturalLanguage) = en
        printer-uri (uri) = ipp://10.0.2.12:631/
    Get printer attributes using Get-Printer-Attributes                  [PASS]
        RECEIVED: 9211 bytes in response
        status-code = successful-ok (successful-ok)
        attributes-charset (charset) = utf-8
        attributes-natural-language (naturalLanguage) = en
        copies-default (integer) = 1
        finishings-default (enum) = none
        media-default (keyword) = na_letter_8.5x11in
        media-col-default (collection) = {media-type=stationery media-size={x-dimension=21590 y-dimension=27940} media-bottom-margin=432 media-left-margin=432 media-right-margin=432 media-top-margin=432 media-source=auto media-auto-dimension=false media-source-properties={media-source-feed-direction=short-edge-first media-source-feed-orientation=3}}
        orientation-requested-default (enum) = portrait
        output-bin-default (keyword) = face-down
        output-mode-default (keyword) = color
        print-quality-default (enum) = normal
        printer-resolution-default (resolution) = 600dpi
        sides-default (keyword) = one-sided
        print-color-mode-default (keyword) = color
        print-content-optimize-default (keyword) = auto
        print-scaling-default (keyword) = auto
        copies-supported (rangeOfInteger) = 1-99
        finishings-supported (enum) = none
        media-supported (1setOf keyword) = iso_a4_210x297mm,na_letter_8.5x11in,na_legal_8.5x14in,na_executive_7.25x10.5in,iso_a5_148x210mm,iso_a6_105x148mm,iso_b5_176x250mm,na_number-10_4.125x9.5in,iso_dl_110x220mm,iso_c5_162x229mm,na_monarch_3.875x7.5in,na_index-3x5_3x5in,na_foolscap_8.5x13in,na_oficio_8.5x13.4in,om_india-legal_215x345mm,custom_min_76.2x127mm,custom_max_215.9x355.6mm
        media-col-supported (1setOf keyword) = media-type,media-size,media-top-margin,media-left-margin,media-right-margin,media-bottom-margin,media-source,media-auto-dimension,media-source-propaties
        orientation-requested-supported (1setOf enum) = portrait,landscape
        output-bin-supported (keyword) = face-down
        output-mode-supported (1setOf keyword) = color,auto,auto-monochrome,monochrome
        print-quality-supported (enum) = normal
        printer-resolution-supported (resolution) = 600dpi
        sides-supported (1setOf keyword) = one-sided,two-sided-long-edge,two-sided-short-edge
        print-color-mode-supported (1setOf keyword) = auto,color,monochrome,auto-monochrome
        print-content-optimize-supported (keyword) = auto
        print-scaling-supported (1setOf keyword) = auto,auto-fit,fill,fit,none
        generated-natural-language-supported (1setOf naturalLanguage) = en,fr,de,it,es,sv,da,no,nl,fi,pt,tr,pl,ru,cs,hu,bg,ro,sk,pt,hr,sl
        printer-uri-supported (uri) = ipp://10.0.2.12/ipp/print
        uri-security-supported (keyword) = none
        uri-authentication-supported (keyword) = none
        ipp-features-supported (1setOf keyword) = airprint-1.7,wfds-print-1.0
        printer-input-tray (1setOf octetString) = type=other;mediafeed=279400;mediaxfeed=215900;maxcapacity=250;level=-3;status=0;name=AUTO;index=1;dimunit=micrometers;unit=sheets;medianame=THIN;mediaweight=-2;mediatype=Unknown;mediacolor=Unknown;,type=sheetFeedManual;mediafeed=-2;mediaxfeed=-2;maxcapacity=1;level=-3;status=0;name=MANUAL\ TRAY;index=2;dimunit=micrometers;unit=sheets;medianame=THIN;mediaweight=-2;mediatype=Unknown;mediacolor=Unknown;,type=sheetFeedAutoNonRemovableTray;mediafeed=279400;mediaxfeed=215900;maxcapacity=250;level=-3;status=0;name=TRAY1;index=3;dimunit=micrometers;unit=sheets;medianame=REGULAR;mediaweight=-2;mediatype=Unknown;mediacolor=Unknown;
        printer-output-tray (octetString) = type=unRemovableBin;maxcapacity=-2;remaining=-2;status=0;name=face-down;index=1;unit=sheets;stackingorder=firstToLast;pagedelivery=notPresent;offsetstacking=notPresent;
        print_wfds (textWithoutLanguage) = T
        document-format-varying-attributes (keyword) = copies
        multiple-operation-time-out-action (keyword) = abort-job
        printer-organization (textWithoutLanguage) =
        printer-organizational-unit (textWithoutLanguage) =
        printer-get-attributes-supported (keyword) = document-format
        which-jobs-supported (1setOf keyword) = completed,not_completed
        printer-current-time (dateTime) = 2020-10-01T15:09:20Z
        printer-config-change-time (integer) = 1
        printer-config-change-date-time (no-value) = no-value
        printer-state-change-time (integer) = 1
        printer-state-change-date-time (no-value) = no-value
        printer-strings-languages-supported (1setOf naturalLanguage) = en,fr,de,nl,es,it,nb,pt,da,sv,fi,cs,pl,hu,ru,ro,sk,tr,hr
        printer-strings-uri (uri) = http://10.0.2.12/ipp/strings/dict/en.txt
        printer-mandatory-job-attributes (1setOf keyword) = attributes-charset,attributes-natural-language,printer-uri
        landscape-orientation-requested-preferred (enum) = 5
        marker-colors (1setOf nameWithoutLanguage) = #000000,#00FFFF,#FF00FF,#FFFF00
        marker-high-levels (1setOf integer) = 100,100,100,100
        marker-levels (1setOf integer) = 100,100,100,100
        marker-low-levels (1setOf integer) = 10,10,10,10
        marker-names (1setOf nameWithoutLanguage) = BK,C,M,Y
        marker-types (1setOf keyword) = toner,toner,toner,toner
        pdf-versions-supported (keyword) = none
        printer-dns-sd-name (nameWithoutLanguage) = Brother HL-L3230CDW series \[3c2af4e223a6]
        printer-firmware-name (1setOf nameWithoutLanguage) = MAIN,SUB5
        printer-firmware-string-version (1setOf textWithoutLanguage) = 1.30,1.00
        printer-firmware-version (1setOf octetString) = 1.30,1.00
        printer-kind (1setOf keyword) = document,envelope,label,postcard
        urf-supported (1setOf keyword) = SRGB24,W8,CP1,IS4-1,MT1-3-4-5-8-11,OB10,PQ4,RS600,V1.4,DM1
        document-format-preferred (mimeMediaType) = image/urf
        jpeg-k-octets-supported (rangeOfInteger) = 0-16384
        jpeg-x-dimension-supported (rangeOfInteger) = 0-15000
        jpeg-y-dimension-supported (rangeOfInteger) = 1-15000
        jpeg-features-supported (keyword) = none
        mopria-certified (textWithoutLanguage) = 1.3
        pwg-raster-document-resolution-supported (resolution) = 600dpi
        pwg-raster-document-sheet-back (keyword) = rotated
        pwg-raster-document-type-supported (1setOf keyword) = sgray_8,srgb_8
        job-password-supported (integer) = 4
        job-password-length-supported (rangeOfInteger) = 4-4
        job-password-encryption-supported (keyword) = none
        job-password-repertoire-supported (keyword) = iana_us-ascii_digits
        job-password-repertoire-configured (keyword) = iana_us-ascii_digits

The cupsd.conf file contents:

# Only listen for connections from the local machine.
#Listen localhost:631
ServerAlias *
Listen *:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseAddress @LOCAL

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Restrict access to the server...
<Location />
  Order allow,deny
  Allow all
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow all
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>

I'm guessing IPP is not working correctly in this environment, since the printer is otherwise reachable and IPP is functional from other machines. I am able to print from all other machines I've tried (IPP) using CUPS. Turned off all firewalls to no avail. Thanks in advance.

Waxhaw commented 3 years ago

Your cupsd.conf file is not correct.

Your listen * line above needs to be changed to: "Port 631"

Then you need to restart CUPS which on most Unix boxes is "systemctl restart cups"

On a Mac you can just log out of your account and back in and that will get it.

That should make the printer 'visible' on your local network.

ghost commented 3 years ago

I can reproduce this issue, and I don't think your cupsd.conf is to blame.

I'm not sure that your problem with the ipptool command is the same issue as cupsd. When running ipptool under truss, it's trying to call getpeername with two null pointers - I haven't investigated further, but I suspect this is just a solaris-related portability bug in there somewhere.

When running snoop in the global zone to capture packets between the cups server and the printer, it looks as though as soon as you submit a print job, CUPS and the printer just ping-pong SNMP packets back and forth forever. There is no other traffic.

Looks like SNMP is indeed part of the IPP protocol, so I suspect it's just never making it past some kind of handshaking stage?

ghost commented 3 years ago

So, there’s (at least) two problems. Pkgsrc (the source of Joyent’s SmartOS packages) doesn’t build Ghostscript with the CUPS option by default - you can see the problem if you crank the logging up to debug in cupsd.conf. I rebuilt a custom Ghostscript package with cups enabled, and that error was solved at least.

Unfortunately, now cups is failing with “The printer is not responding”, and it appears to be the same “bad address” error you discovered in ipptool above. Sad!

ghost commented 3 years ago

I figured out the issue. The NetBSD pkgsrc (from which Joyent builds their packages) includes this patch file, which introduces a bug (at least on Illumos).

The relevant lines from the diff are the following:

-         if (!getpeername(fds[i], (struct sockaddr *)&peer, &len))
+         if (getpeername(fds[i], NULL, 0) == 0) {

Maybe other Unix variants have a hack to to allow NULL being passed as the third argument (socklen_t *namelen), but Illumos does not. The kernel rightly assumes this parameter is a pointer to a socklen_t, and bails out with EFAULT when attempting to copyin a null pointer from userspace.

I think the cups people have nothing to actually do here, we should file a bug against pkgsrc.

ghost commented 3 years ago

BTW I can confirm that after deleting that patch file and rebuilding print/cups-base, I can print to my IPP printer from a SmartOS zone.