apple / cups

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

MFC autodetected as printer+fax by cups-filters works only as fax by default (Brother MFC-L2720DWR) #5886

Closed darktemplarbasealt closed 3 years ago

darktemplarbasealt commented 3 years ago

Cups 2.3.3 and cups-filters 1.28.7 are used. avahi version 0.8. cups-browsed from cups-filters can detect fax support in printers since version 1.28.1.

Device in question is Brother MFC-L2720DWR. It's connected to LAN and autodetected via cups-browsed from cups-filters. Unfortunately, instead of using it as printer, cups uses it as fax: printed jobs are sent to "ipp/faxout" instead of "ipp/print".

It looks like that here it's not detected as printer: https://github.com/apple/cups/blob/82e3ee0e3230287b76a76fb8f16b92ca6e50b444/cups/http-support.c#L2348-L2354 https://github.com/apple/cups/blob/82e3ee0e3230287b76a76fb8f16b92ca6e50b444/cups/http-support.c#L2587-L2593

I've added a bit of debug information with following debug-only changes:

debug changes ``` diff --git a/cups/backend/ipp.c b/cups/backend/ipp.c index 3f3e1867d..b7607545a 100644 --- a/cups/backend/ipp.c +++ b/cups/backend/ipp.c @@ -18,6 +18,7 @@ #include #include #include +#include #if defined(HAVE_GSSAPI) && defined(HAVE_XPC) # include # define kPMPrintUIToolAgent "com.apple.printuitool.agent" @@ -300,6 +301,9 @@ main(int argc, /* I - Number of command-line args */ signal(SIGTERM, sigterm_handler); #endif /* HAVE_SIGSET */ + setenv("CUPS_DEBUG_LOG", "/tmp/cups.debug.log", 1); + setenv("CUPS_DEBUG_LEVEL", "6", 1); + /* * Check command-line... */ diff --git a/cups/cups/debug.c b/cups/cups/debug.c index 6b3914ed5..155a94507 100644 --- a/cups/cups/debug.c +++ b/cups/cups/debug.c @@ -68,10 +68,13 @@ static _cups_mutex_t debug_init_mutex = _CUPS_MUTEX_INITIALIZER, static int /* O - Local thread ID */ debug_thread_id(void) { +#if 0 _cups_globals_t *cg = _cupsGlobals(); /* Global data */ return (cg->thread_id); +#endif + return 0; } diff --git a/cups/cups/http-support.c b/cups/cups/http-support.c index 63175145e..f85517211 100644 --- a/cups/cups/http-support.c +++ b/cups/cups/http-support.c @@ -2507,6 +2507,7 @@ http_resolve_cb( AvahiStringList *pair; /* Current TXT record key/value pair */ char *value; /* Value for "rp" key */ size_t valueLen = 0; /* Length of "rp" key */ + char *avahidata = NULL; DEBUG_printf(("4http_resolve_cb(resolver=%p, " @@ -2584,6 +2585,12 @@ http_resolve_cb( * Extract the remote resource key from the TXT record... */ + avahidata = avahi_string_list_to_string(txt); + + DEBUG_printf(("4http_resolve_cb(avahi=%s)", avahidata)); + + avahi_free(avahidata); + if ((uribuf->options & _HTTP_RESOLVE_FAXOUT) && (!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) && !avahi_string_list_find(txt, "printer-type")) ```

The resulting log contains following line: T000 09:09:28.842 http_resolve_cb(avahi=\"print_wfds=T\" \"UUID=e3248000-80ce-11db-8000-3c2af42dd2cf\" \"PaperMax=legal-A4\" \"kind=document,envelope,label\" \"URF=W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS200-300-600,V1.3,DM1\" \"rfo=ipp/faxout\" \"TBCP=F\" \"Transparent=T\" \"Binary=T\" \"PaperCustom=T\" \"Scan=T\" \"Fax=T\" \"Duplex=T\" \"Copies=T\" \"Color=F\" \"usb_CMD=PJL,PCL,PCLXL,URF\" \"usb_MDL=MFC-L2720DW series\" \"usb_MFG=Brother\" \"priority=25\" \"adminurl=http://BRWE89EB445B7E5.local./net/net/airprint.html\" \"product=(Brother MFC-L2720DW series)\" \"ty=Brother MFC-L2720DW series\" \"note=\" \"rp=ipp/print\" \"pdl=application/octet-stream,image/urf,image/pwg-raster\" \"qtotal=1\" \"txtvers=1\")

As it may be noticed, there is no "printer-type" attribute reported by avahi. Due to that the printer is used as fax.

I've checked avahi report for another printer, which also has fax, but for some reason not yet detected as one, but it doesn't contain "printer-type" attribute as well: T000 09:28:15.602 http_resolve_cb(avahi=\"URF=DEVW8,CP255,DM1,IFU0,IS19-20,OB10,PQ4-5,RS600,V1.4,W8\" \"UUID=32f00e8c-83a7-41d2-9578-7f3972eb74a6\" \"PaperMax=<legal-A4\" \"kind=document,envelope,label\" \"air=none\" \"TLS=1.2\" \"Scan=T\" \"Fax=T\" \"Duplex=T\" \"Color=F\" \"note=\" \"adminurl=https://oki-mb472-7ed19d.local./airprint_index.htm\" \"priority=60\" \"usb_CMD=PCL,IBMPPR,EPSONFX,PCLXL,HIPERMIP,URF,XPS\" \"usb_MDL=MB472\" \"usb_MFG=OKI DATA CORP\" \"product=(OKI MB472)\" \"ty=OKI MB472\" \"rp=ipp/print\" \"rfo=ipp/faxout\" \"pdl=application/octet-stream,application/vnd.hp-PCL,image/urf\" \"qtotal=1\" \"txtvers=1\")

Brother MFC-L2720DWR is detected as both printer and fax by cups-browsed, due to that it's ppd file contains line *cupsIPPFaxOut: True. Due to that line, uribuf->options contains _HTTP_RESOLVE_FAXOUT, but printer check fails at least when avahi is used. Due to that device is used by cups as fax instead of printer.

darktemplarbasealt commented 3 years ago

If I comment out fax support in cups-filters, and it reports device just as printer, i.e. no line *cupsIPPFaxOut: True or other fax-related info is added to device's ppd file, cups is able to use this device as printer without any issues when device is autodetected and reported by cups-browsed.

michaelrsweet commented 3 years ago

Please report this issue to the OpenPrinting cups-filters project.

darktemplarbasealt commented 3 years ago

While checking issues in mentioned project, I've found https://github.com/OpenPrinting/cups-filters/issues/343, and it looks like it mentions commit https://github.com/OpenPrinting/cups-filters/commit/de0747e8da849661e2d5fb7a6f4bec1caf432124 which fixes issue for me. Thanks!