This file is indexed.

/usr/lib/python3/dist-packages/pysnmp/carrier/asyncore/base.py is in python3-pysnmp4 4.3.2-2.

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2016, Ilya Etingof <ilya@glas.net>
# License: http://pysnmp.sf.net/license.html
#
import socket, sys
import asyncore
from pysnmp.carrier import error
from pysnmp.carrier.base import AbstractTransport
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
from pysnmp import debug

class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport):
    protoTransportDispatcher = AsyncoreDispatcher
    sockFamily = sockType = None
    retryCount = 0
    retryInterval = 0
    bufferSize = 131070
    def __init__(self, sock=None, sockMap=None):
        asyncore.dispatcher.__init__(self)
        if sock is None:
            if self.sockFamily is None:
                raise error.CarrierError(
                    'Address family %s not supported' % self.__class__.__name__
                    )
            if self.sockType is None:
                raise error.CarrierError(
                    'Socket type %s not supported' % self.__class__.__name__
                    )
            try:
                sock = socket.socket(self.sockFamily, self.sockType)
            except socket.error:
                raise error.CarrierError('socket() failed: %s' % sys.exc_info()[1])

            try:
                for b in socket.SO_RCVBUF, socket.SO_SNDBUF:
                    bsize = sock.getsockopt(socket.SOL_SOCKET, b)
                    if bsize < self.bufferSize:
                        sock.setsockopt(socket.SOL_SOCKET, b, self.bufferSize)
                        debug.logger & debug.flagIO and debug.logger('%s: socket %d buffer size increased from %d to %d for buffer %d' % (self.__class__.__name__, sock.fileno(), bsize, self.bufferSize, b))
            except Exception:
                debug.logger & debug.flagIO and debug.logger('%s: socket buffer size option mangling failure for buffer %d: %s' % (self.__class__.__name__, b, sys.exc_info()[1]))

        # The socket map is managed by the AsyncoreDispatcher on
        # which this transport is registered. Here we just prepare
        # socket and postpone transport registration at dispatcher
        # till AsyncoreDispatcher invokes registerSocket()

        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.setblocking(0)
        self.set_socket(sock)

    def __hash__(self):
        return hash(self.socket)

    # The following two methods are part of base class so here we overwrite
    # them to separate socket management from dispatcher registration tasks.
    # These two are just for dispatcher registration.
    def add_channel(self, map=None):
        if map is not None:
            map[self._fileno] = self
            self.connected = True

    def del_channel(self, map=None):
        if map is not None and self._fileno in map:
            del map[self._fileno]
            self.connected = False

    def registerSocket(self, sockMap=None):
        self.add_channel(sockMap)

    def unregisterSocket(self, sockMap=None):
        self.del_channel(sockMap)

    def closeTransport(self):
        AbstractTransport.closeTransport(self)
        self.close()

    # asyncore API
    def handle_close(self):
        raise error.CarrierError('Transport unexpectedly closed')

    def handle_error(self):
        raise