diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-11-08 09:24:48 -0500 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-11-08 09:24:48 -0500 |
commit | 8d32a3f93313041d990a45bccb99d433cdbde3fd (patch) | |
tree | bdd28d790775d32f147a2ad12e8a82949ff0220b /backend | |
parent | 9eacf61969314738435cd28fd6a14a70dbc692ee (diff) | |
download | cups-8d32a3f93313041d990a45bccb99d433cdbde3fd.tar.gz |
Disable SNMP supply levels when the community name is cleared (Issue #5354)
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.
Diffstat (limited to 'backend')
-rw-r--r-- | backend/snmp-supplies.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/backend/snmp-supplies.c b/backend/snmp-supplies.c index 40fefcc9f..687e7ae35 100644 --- a/backend/snmp-supplies.c +++ b/backend/snmp-supplies.c @@ -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, ¤t_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, ¤t_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, ¤t_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, ¤t_addr, CUPS_SNMP_VERSION_1, - _cupsSNMPDefaultCommunity(), prtMarkerColorantValue, + community, prtMarkerColorantValue, CUPS_SUPPLY_TIMEOUT, backend_walk_cb, NULL); /* |