This file is indexed.

/usr/share/pyshared/tp/netlib/twist.py is in python-tp-netlib 0.2.5-3.

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
import sys, traceback

from twisted.internet import protocol, reactor

import xstruct

from common import ConnectionCommon, StringQueue
from objects import Fail
from support.output import red, green

class TwistedConnection(ConnectionCommon, protocol.Protocol):
	def __init__(self, *args, **kw):
		ConnectionCommon.__init__(self)
		self.buffered['bytes-received'] = StringQueue()

	def _sendBytes(self, bytes=''):
		"""\
		Send bytes onto the socket.
		"""
		if self.debug and len(bytes) > 0:
			green("Sending: %s \n" % xstruct.hexbyte(bytes))
		self.transport.write(bytes)

	def _recvBytes(self, size, peek=False):
		"""\
		Receive a bunch of bytes onto the socket.
		"""
		buffer = self.buffered['bytes-received']
		if len(buffer) < size:
			return ''
		else:
			return [buffer.read, buffer.peek][peek](size)

	def dataReceived(self, data):
		"""\
		"""
		if self.debug and len(data) > 0:
			red("Received: %s \n" % xstruct.hexbyte(data))

		# Push the data onto the buffer
		buffer = self.buffered['bytes-received']
		buffer.write(data)

		self._recvFrame(-1)

		sequences = self.buffered['frames-received'].keys()
		sequences.sort()

		for sequence in sequences:
			p = self._recvFrame(sequence)
			if not p:
				continue

			bases = [p.__class__]
			while len(bases) > 0:
				c = bases.pop(0)
				function = "On" + c.__name__

				if hasattr(self, function):
					try:
						success = getattr(self, function)(p)
					except:
						type, val, tb = sys.exc_info()
						print ''.join(traceback.format_exception(type, val, tb))
					break
				else:
					print "No handler for packet of %s" % c.__name__

				bases += list(c.__bases__)
			if len(bases) == 0:
				self._sendFrame(Fail(p.sequence, 2, "Service Unavailable..."))

class TwistedFactory(protocol.ServerFactory):
    protocol = TwistedConnection

def run():
	from twisted.internet import reactor
	reactor.listenTCP(6923, TwistedFactory())
	reactor.run()

if __name__ == "__main__":
	run()