Bug 53598 - cups-pdf printer setup broken for printermoderation
cups-pdf printer setup broken for printermoderation
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Print services
UCS@school 5.0
Other Linux
: P5 normal (vote)
: UCS@school 5.0 v1
Assigned To: Felix Botner
Florian Best
:
Depends on:
Blocks: 53702
  Show dependency treegraph
 
Reported: 2021-07-19 12:23 CEST by Felix Botner
Modified: 2021-11-29 17:19 CET (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Botner univentionstaff 2021-07-19 12:23:23 CEST
current setup creates a PDFDrucker like this

DN: cn=PDFDrucker,cn=printers,dc=five,dc=local
  ACLtype: allow all
  description: Moderierter PDF-Drucker
  location: None
  model: None
  name: PDFDrucker
  producer: cn=misc,cn=cups,cn=univention,dc=five,dc=local
  sambaName: None
  spoolHost: master.five.local
  uri: cups-pdf:/ .

with this, only one job is stored in "/var/spool/cups-pdf/%U" 

-> lp -d PDFDrucker /etc/fstab # (4x)
-> find
/var/spool/cups-pdf/Administrator/fstab__ol_cups-pdf_root.pdf

and it is an empty pdf

with this setup (model, uri!)

DN: cn=PDFDrucker,cn=printers,dc=five,dc=local
  ACLtype: allow all
  description: Moderierter PDF-Drucker
  location: None    
  model: cups-pdf/CUPS-PDF_noopt.ppd
  name: PDFDrucker
  producer: cn=PDF,cn=cups,cn=univention,dc=five,dc=local  
  sambaName: None     
  spoolHost: master.five.local
  uri: None

it works

-> lp -d PDFDrucker /etc/fstab # (4x)
-> find
find /var/spool/cups-pdf/Administrator/
/var/spool/cups-pdf/Administrator/
/var/spool/cups-pdf/Administrator/job_39-fstab__ol_cups-pdf_Administrator.pdf
/var/spool/cups-pdf/Administrator/job_37-fstab__ol_cups-pdf_Administrator.pdf
/var/spool/cups-pdf/Administrator/job_38-fstab__ol_cups-pdf_Administrator.pdf
/var/spool/cups-pdf/Administrator/job_36-fstab__ol_cups-pdf_Administrator.pdf

so probably 99ucs-school-umc-printermoderation.inst has to be modified (installation, update)
Comment 2 Felix Botner univentionstaff 2021-08-23 12:06:45 CEST
dc16c7c1e18d372e88eb3789498acea80035c5c9 - ucs-school-umc-printermoderation

set proper model (cups-pdf/CUPS-PDF_noopt.ppd) and uri (cups-pdf:/) for PDFDrucker

QA: test update and installation
Comment 3 Florian Best univentionstaff 2021-08-23 18:14:55 CEST
1. ldapmodify needs to be called with Administrator credentials, otherwise:
modifying entry "cn=PDFDrucker,cn=printers,l=school,l=dev"
ldap_modify: Insufficient access (50)

Object exists: cn=PDFDrucker,cn=printers,l=school,l=dev

2. Please use udm instead of ldapmodify to set the value:
--set 'uri="cups-pdf:/" ""'

3. Please add `|| die` error handling to the modify-call, otherwise failure in 1 looks like successful.

4. The new value is not compliant with what UDM displays on the CLI: PrinterURI.tostring() returns None for that URI.

We should patch the UDM syntax classs in a cloned bug:

diff --git management/univention-directory-manager-modules/modules/univention/admin/syntax.py management/univention-directory-manager-modules/modules/univention/admin/syntax.py
index f19ea715fd..36fbec58e4 100644
--- management/univention-directory-manager-modules/modules/univention/admin/syntax.py
+++ management/univention-directory-manager-modules/modules/univention/admin/syntax.py
@@ -434,7 +434,7 @@ class complex(ISyntax):
                        return self.delimiter.join(texts)
 
                # FIXME: s/(delimiter)s/\1/
-               return ''.join([s for sub in zip(self.delimiters, texts) for s in sub] + [self.delimiter[-1]])
+               return ''.join([s for sub in zip(self.delimiter, texts) for s in sub] + [self.delimiter[-1]])
 
        @classmethod
        def new(self):
@@ -5352,6 +5352,8 @@ class PrinterURI(complex):
        Syntax to configure printer.
        >>> PrinterURI.parse(["uri://", "localhost"])
        ['uri://', 'localhost']
+       >>> PrinterURI.parse(["cups-pdf:/", ""])
+       ['cups-pdf:/', '']
        >>> PrinterURI.parse(["uri://", None]) #doctest: +IGNORE_EXCEPTION_DETAIL
        Traceback (most recent call last):
        ...
@@ -5367,6 +5369,7 @@ class PrinterURI(complex):
        """
        subsyntaxes = ((_('Protocol'), PrinterProtocol), (_('Destination'), string))
        subsyntax_names = ('protocol', 'destination')
+       all_required = False
 
        @classmethod
        def parse(self, texts):
@@ -5383,17 +5386,13 @@ class PrinterURI(complex):
                if len(texts) > len(self.subsyntaxes):
                        raise univention.admin.uexceptions.valueInvalidSyntax(_("too many arguments"))
 
-               for i in range(len(texts)):
-                       ud.debug(ud.ADMIN, ud.INFO, 'syntax.py: self.subsyntax[%s] is %s, texts is %s' % (i, self.subsyntaxes[i], texts))
-                       if not inspect.isclass(self.subsyntaxes[i][1]):
-                               s = self.subsyntaxes[i][1]
-                       else:
-                               s = self.subsyntaxes[i][1]()
-                       if texts[i] is None:
-                               if self.min_elements is None or (i + 1) < self.min_elements:
-                                       raise univention.admin.uexceptions.valueInvalidSyntax(_("Invalid syntax"))
-                       p = s.parse(texts[i])
-                       if p:
+               for i, (text, (desc, syn)) in enumerate(zip(texts, self.subsyntaxes)):
+                       ud.debug(ud.ADMIN, ud.INFO, 'syntax.py: subsyntax[%s]=%s, text=%s' % (i, syn, text))
+                       if text is None and (self.min_elements is None or (i + 1) < count):
+                               raise univention.admin.uexceptions.valueInvalidSyntax(_("Invalid syntax: %s > %s") % (self.name, desc,))
+                       s = syn() if inspect.isclass(syn) else syn
+                       p = s.parse(text)
+                       if p is not None:
                                parsed.append(p)
                return parsed
Comment 4 Florian Best univentionstaff 2021-08-23 18:22:53 CEST
5. model=$(univention-ldapsearch -b "$dn" | sed -ne 's|univentionPrinterModel: ||p')

→ please include the filter instead of using sed:

univention-ldapsearch -b "$dn" '(|(univentionPrinterModel=None)(!(univentionPrinterModel=*)))' dn
Comment 5 Florian Best univentionstaff 2021-08-25 16:55:02 CEST
4. has been outsourced into Bug #53702
Comment 6 Felix Botner univentionstaff 2021-08-26 14:06:24 CEST
fixed
Comment 7 Florian Best univentionstaff 2021-08-26 14:14:10 CEST
OK :-)
Comment 8 Jürn Brodersen univentionstaff 2021-11-29 17:19:48 CET
UCS@school 5.0 v1 has been released.

https://docs.software-univention.de/release-notes-ucsschool-5.0v1-de.html

If this error occurs again, please clone this bug.