This file is indexed.

/usr/lib/python3/dist-packages/pyroute2/proxy.py is in python3-pyroute2 0.4.21-0.1ubuntu2.

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
'''
Netlink proxy engine
'''
import errno
import struct
import logging
import traceback
import threading
from pyroute2.netlink.exceptions import NetlinkError

log = logging.getLogger(__name__)


class NetlinkProxy(object):
    '''
    Proxy schemes::

        User -> NetlinkProxy -> Kernel
                       |
             <---------+

        User <- NetlinkProxy <- Kernel

    '''

    def __init__(self, policy='forward', nl=None, lock=None):
        self.nl = nl
        self.lock = lock or threading.Lock()
        self.pmap = {}
        self.policy = policy

    def handle(self, msg):
        #
        # match the packet
        #
        ptype = msg['header']['type']
        plugin = self.pmap.get(ptype, None)
        if plugin is not None:
            with self.lock:
                try:
                    ret = plugin(msg, self.nl)
                    if ret is None:
                        #
                        # The packet is terminated in the plugin,
                        # return the NLMSG_ERR == 0
                        #
                        # FIXME: optimize
                        #
                        newmsg = struct.pack('IHH', 40, 2, 0)
                        newmsg += msg.data[8:16]
                        newmsg += struct.pack('I', 0)
                        # nlmsgerr struct alignment
                        newmsg += b'\0' * 20
                        return {'verdict': self.policy,
                                'data': newmsg}
                    else:
                        return ret

                except Exception as e:
                    log.error(''.join(traceback.format_stack()))
                    log.error(traceback.format_exc())
                    # errmsg
                    if isinstance(e, (OSError, IOError)):
                        code = e.errno
                    elif isinstance(e, NetlinkError):
                        code = e.code
                    else:
                        code = errno.ECOMM
                    newmsg = struct.pack('HH', 2, 0)
                    newmsg += msg.data[8:16]
                    newmsg += struct.pack('I', code)
                    newmsg += msg.data
                    newmsg = struct.pack('I', len(newmsg) + 4) + newmsg
                    return {'verdict': 'error',
                            'data': newmsg}
        return None