CUPS configuration files

Parsers provided by this module are:

CupsdConf - file /etc/cups/cupsd.conf

CupsBrowsedConf - file /etc/cups/cups-browsed.conf

CupsFilesConf - file /etc/cups/cups-files.conf

class insights.parsers.cups_confs.CupsBrowsedConf(context)[source]

Bases: Parser, dict

Class for parsing the file /etc/cups/cups-browsed.conf

Note

The admin can add multiple directives into the configuration file, and restart service without issue. However, item like BrowseRemoteProtocols only works for the last one, and the item like BrowseAllow works for all directives. So the values of each directives will get stored to a list with the original order, and duplicated values will be kept without de-duplication.

Sample file content:

BrowseRemoteProtocols dnssd cups
BrowseAllow cups.example.com

Examples

>>> type(cups_browsed_conf)
<class 'insights.parsers.cups_confs.CupsBrowsedConf'>
>>> 'dnssd cups' in cups_browsed_conf['BrowseRemoteProtocols']
True
>>> 'cups.example.com' in cups_browsed_conf['BrowseAllow']
True
parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.cups_confs.CupsFilesConf(context)[source]

Bases: Parser, dict

Class for parsing the file /etc/cups/cups-files.conf

Sample file content:

FatalErrors config
SyncOnClose Yes
SystemGroup sys root wheel
AccessLog syslog
ErrorLog syslog
PageLog syslog

Examples

>>> type(cups_files_conf)
<class 'insights.parsers.cups_confs.CupsFilesConf'>
>>> cups_files_conf['FatalErrors']
'config'
>>> cups_files_conf['SyncOnClose']
'Yes'
>>> 'wheel' in cups_files_conf['SystemGroup']
True
parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.cups_confs.CupsdConf(*args, **kwargs)[source]

Bases: ConfigParser

Class for parsing the file /etc/cups/cupsd.conf

Sample file content:

MaxLogSize 0
LogLevel warn
Listen localhost:631
Listen /var/run/cups/cups.sock
Browsing On
BrowseLocalProtocols dnssd

<Location />
  Order allow,deny
</Location>

<Policy default>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default

  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

Examples

>>> type(cupsd_conf)
<class 'insights.parsers.cups_confs.CupsdConf'>
>>> cupsd_conf['MaxLogSize'][-1].value
0
>>> cupsd_conf['Listen'][0].value
'localhost:631'
>>> cupsd_conf['Listen'][-1].value
'/var/run/cups/cups.sock'
>>> cupsd_conf[('Location', '/')]['Order'][-1].value
'allow,deny'
>>> cupsd_conf[('Policy','default')][('Limit','Send-Document')]['Order'][0].value
'deny,allow'
>>> 'JobPrivateAccess' in cupsd_conf[('Policy','default')]
True