]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Disable SNMP supply levels when the community name is cleared (Issue #5354)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 8 Nov 2018 14:24:48 +0000 (09:24 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 8 Nov 2018 14:24:48 +0000 (09:24 -0500)
backend/snmp-supplies.c:
- Look for empty community name.

cups/snmp.c:
- Allow empty community name.

man/cups-snmp.conf.man:
- Document behavior of empty community name.

CHANGES.md
backend/snmp-supplies.c
cups/snmp.c
man/cups-snmp.conf.man

index 8d9a5561227e1584a6263b5565ce6dfe2a4309f7..e4689c8a133c36d1d77e5ade3cd7a50b836d84e0 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES - 2.3b6 - 2018-11-07
+CHANGES - 2.3b6 - 2018-11-08
 ============================
 
 Changes in CUPS v2.3b6
@@ -21,6 +21,9 @@ Changes in CUPS v2.3b6
 - The IPP Everywhere "driver" now properly supports face-up printers
   (Issue #5345)
 - Fixed some typos in the label printer drivers (Issue #5350)
+- Setting the `Community` name to the empty string in `snmp.conf` now disables
+  SNMP supply level monitoring by all the standard network backends
+  (Issue #5354)
 - Multi-file jobs could get stuck if the backend failed (Issue #5359,
   Issue #5413)
 - The IPP Everywhere "driver" no longer does local filtering when printing to
index 40fefcc9f796aae7ab938b5c360d1c05a80fc8fc..687e7ae3585f7cfb44e1ff9d524c6a75e9565d31 100644 (file)
@@ -440,6 +440,7 @@ backend_init_supplies(
 {
   int          i,                      /* Looping var */
                type;                   /* Current marker type */
+  const char   *community;             /* SNMP community name */
   cups_file_t  *cachefile;             /* Cache file */
   const char   *cachedir;              /* CUPS_CACHEDIR value */
   char         addrstr[1024],          /* Address string */
@@ -507,6 +508,10 @@ backend_init_supplies(
   * See if we should be getting supply levels via SNMP...
   */
 
+  community = _cupsSNMPDefaultCommunity();
+  if (!*community)
+    return;
+
   if ((ppd = ppdOpenFile(getenv("PPD"))) == NULL ||
       ((ppdattr = ppdFindAttr(ppd, "cupsSNMPSupplies", NULL)) != NULL &&
        ppdattr->value && _cups_strcasecmp(ppdattr->value, "true")))
@@ -528,7 +533,7 @@ backend_init_supplies(
   */
 
   if (!_cupsSNMPWrite(snmp_fd, addr, CUPS_SNMP_VERSION_1,
-                    _cupsSNMPDefaultCommunity(), CUPS_ASN1_GET_REQUEST, 1,
+                    community, CUPS_ASN1_GET_REQUEST, 1,
                     hrDeviceDescr))
     return;
 
@@ -605,7 +610,7 @@ backend_init_supplies(
 
 
     if (!_cupsSNMPWrite(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                       _cupsSNMPDefaultCommunity(), CUPS_ASN1_GET_REQUEST, 1,
+                       community, CUPS_ASN1_GET_REQUEST, 1,
                        prtGeneralCurrentLocalization))
       return;
 
@@ -626,7 +631,7 @@ backend_init_supplies(
 
 
     if (!_cupsSNMPWrite(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                       _cupsSNMPDefaultCommunity(), CUPS_ASN1_GET_REQUEST, 1,
+                       community, CUPS_ASN1_GET_REQUEST, 1,
                        oid))
       return;
 
@@ -651,7 +656,7 @@ backend_init_supplies(
     */
 
     _cupsSNMPWalk(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                 _cupsSNMPDefaultCommunity(), prtMarkerSuppliesEntry,
+                 community, prtMarkerSuppliesEntry,
                  CUPS_SUPPLY_TIMEOUT, backend_walk_cb, NULL);
   }
 
@@ -685,7 +690,7 @@ backend_init_supplies(
     strlcpy(supplies[i].color, "none", sizeof(supplies[i].color));
 
   _cupsSNMPWalk(snmp_fd, &current_addr, CUPS_SNMP_VERSION_1,
-                _cupsSNMPDefaultCommunity(), prtMarkerColorantValue,
+                community, prtMarkerColorantValue,
                CUPS_SUPPLY_TIMEOUT, backend_walk_cb, NULL);
 
  /*
index 10eca15c56ff7d5ef90e965f3f6c73138b415a77..5cefee454159c8162282b47dd15a4938040c6106 100644 (file)
@@ -129,9 +129,13 @@ _cupsSNMPDefaultCommunity(void)
     {
       linenum = 0;
       while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
-       if (!_cups_strcasecmp(line, "Community") && value)
+       if (!_cups_strcasecmp(line, "Community"))
        {
-         strlcpy(cg->snmp_community, value, sizeof(cg->snmp_community));
+         if (value)
+           strlcpy(cg->snmp_community, value, sizeof(cg->snmp_community));
+         else
+           cg->snmp_community[0] = '\0';
+
          break;
        }
 
index 25137eee89057193b8f540a07f39ed64a5bc2905..23e7eb849328b1dca83bc39ced3be1c2a9f6318a 100644 (file)
@@ -6,7 +6,7 @@
 .\"
 .\" Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
 .\"
-.TH snmp.conf 5 "CUPS" "10 June 2014" "Apple Inc."
+.TH snmp.conf 5 "CUPS" "8 November 2018" "Apple Inc."
 .SH NAME
 snmp.conf \- snmp configuration file for cups
 .SH DESCRIPTION
@@ -32,6 +32,7 @@ There is no default for the broadcast address.
 Specifies the community name to use.
 Only a single community name may be specified.
 The default community name is "public".
+If no name is specified, all SNMP functions are disabled.
 .TP 5
 \fBDebugLevel \fInumber\fR
 Specifies the logging level from 0 (none) to 3 (everything).