From 8fe6fbfe5b56d8c13a676b71b11bd3cd552020a1 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sun, 3 Dec 2023 06:40:29 +0100 Subject: [PATCH] Make PySNMP work after 2038 31-bit integers overflow after 2038-01-19 Without this patch, PySNMP cannot spawn an agent and snimpy tests get stuck https://github.com/vincentbernat/snimpy/issues/106 This patch was done while working on reproducible builds for openSUSE. --- pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py b/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py index e547f62b3..b86e0e739 100644 --- a/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py +++ b/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py @@ -62,14 +62,14 @@ class SnmpEngineID(TextualConvention, OctetString): defaultValue = OctetString(defaultValue).asOctets() -class SnmpEngineTime(Integer32): +class SnmpEngineTime(Unsigned32): def clone(self, *args, **kwargs): if not args: try: args = (time.time() - self,) except Exception: pass - return Integer32.clone(self, *args, **kwargs) + return Unsigned32.clone(self, *args, **kwargs) class SnmpSecurityModel(Integer32, TextualConvention): @@ -100,7 +100,7 @@ class SnmpSecurityLevel(Integer32, TextualConvention): snmpEngineBoots = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpEngineBoots.setStatus('current') if mibBuilder.loadTexts: snmpEngineBoots.setDescription('The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was last configured. ') -snmpEngineTime = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 3), SnmpEngineTime().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('seconds').setMaxAccess("readonly") +snmpEngineTime = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 3), SnmpEngineTime()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: snmpEngineTime.setStatus('current') if mibBuilder.loadTexts: snmpEngineTime.setDescription("The number of seconds since the value of the snmpEngineBoots object last changed. When incrementing this object's value would cause it to exceed its maximum, snmpEngineBoots is incremented as if a re-initialization had occurred, and this object's value consequently reverts to zero. ") snmpEngineMaxMessageSize = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(484, 2147483647))).setMaxAccess("readonly")