/usr/lib/python3/dist-packages/pysnmp/carrier/asynsock/dgram/unix.py is in python3-pysnmp4 4.2.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # Implements asyncore-based UNIX transport domain
import os
import random
try:
from socket import AF_UNIX
except ImportError:
AF_UNIX = None
from pysnmp.carrier.asynsock.dgram.base import DgramSocketTransport
domainName = snmpLocalDomain = (1, 3, 6, 1, 2, 1, 100, 1, 13)
random.seed()
class UnixSocketTransport(DgramSocketTransport):
sockFamily = AF_UNIX
def openClientMode(self, iface=None):
if iface is None:
# UNIX domain sockets must be explicitly bound
iface = ''
while len(iface) < 8:
iface += chr(random.randrange(65, 91))
iface += chr(random.randrange(97, 123))
iface = os.path.sep + 'tmp' + os.path.sep + 'pysnmp' + iface
if os.path.exists(iface):
os.remove(iface)
DgramSocketTransport.openClientMode(self, iface)
self.__iface = iface
return self
def openServerMode(self, iface):
DgramSocketTransport.openServerMode(self, iface)
self.__iface = iface
return self
def closeTransport(self):
DgramSocketTransport.closeTransport(self)
try:
os.remove(self.__iface)
except:
pass
UnixTransport = UnixSocketTransport
# Compatibility stub
UnixDgramSocketTransport = UnixSocketTransport
|