This file is indexed.

/usr/share/pyshared/pynetsnmp/tableretriever.py is in python-pynetsnmp 0.28.14-1.2build1.

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
from twisted.internet import defer
from twistedsnmp import asOidStr, asOid

class _TableStatus(object):

    def __init__(self, startOidStr):
        self.startOidStr = startOidStr
        self.startOid = asOid(startOidStr)
        self.result = []
        self.finished = False


class TableRetriever(object):

    def __init__(self,
                 proxy,
                 oids,
                 timeout = 1.5,
                 retryCount = 3,
                 maxRepetitions = 100,
                 limit = 1000):
        self.proxy = proxy
        self.tableStatus = [_TableStatus(oid) for oid in oids]
        self.defer = defer.Deferred()
        if proxy.snmpVersion.find('1') > -1:
            self.how = proxy._walk
        else:
            def v2v3how(oids):
                return proxy._getbulk(0, min(maxRepetitions, limit), [oids])
            self.how = v2v3how
        self.limit = limit
        self.count = 0
        self.hit_limit = False

    def __call__(self):
        self.fetchSomeMore()
        return self.defer

    def fetchSomeMore(self):
        for ts in self.tableStatus:
            if ts.finished: continue
            if ts.result:
                lastOid = ts.result[-1][0]
            else:
                lastOid = ts.startOid
            d = self.how(lastOid)
            d.addCallback(self.saveResults, ts)
            d.addErrback(self.error)
            return
        results = {}
        for ts in self.tableStatus:
            results[ts.startOidStr]=dict([(asOidStr(oid), value) for oid, value in ts.result])
        self.defer.callback(results)
        self.defer = None


    def saveResults(self, values, ts):
        if values:
            for oid, value in values:
                self.count += 1
                if oid[:len(ts.startOid)]==ts.startOid and oid > ts.startOid:
                    # defend against going backwards
                    if ts.result and oid<=ts.result[-1][0]:
                        ts.finished = True
                    else:
                        ts.result.append((oid, value))
                else:
                    ts.finished = True
        else:
            ts.finished = True
        if not ts.finished and self.count >= self.limit: 
            ts.finished = True
            self.hit_limit = True
        self.fetchSomeMore()

    def error(self, why):
        self.defer.errback(why)
        self.defer = None