This file is indexed.

/usr/lib/gdesklets/utils/xdr.py is in gdesklets 0.36.1-5+b1.

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
86
87
88
"""
This module implements a simple tuple transmission protocol. It's kept simple
to be implementable in other languages as well.

The protocol can only transmit lists of strings, which it splits up into chunks.
A chunk consists of a LENGTH byte, the actual PAYLOAD, and a STATUS byte.

A single string is split up into several chunks if it exceeds the maximum length
which can be specified by the LENGTH byte (255), otherwise a string is one
chunk.

The STATUS byte after every chunk tells if the chunk is

 - continued in the next chunk (CONT)
 - the last chunk of a string (NEXT)
 - the last chunk in the transmission (END)

In order to handle empty lists without getting too complicated, all lists are
extended by an arbitrary first element which just gets ignored.


Example:

  ["Hello", "World!"] is transmitted as:

  01  00 01   05   48 65 6C 6C 6F 01   06  57 6F 72 6C 64 21 02

  (1) ?  NEXT (5)  H  e  l  l  o  NEXT (6) W  o  r  l  d  !  END
"""


class XDRError(RuntimeError):
    pass


_SEND_ERROR = "--SEND ERROR--"


_CONT = chr(0)
_NEXT = chr(1)
_END  = chr(2)


def send(s, *args):

    args = ["\0"] + list(args)
    while (args):
        a = args.pop(0)

        chunks = [ a[i:i + 0xff] for i in range(0, len(a), 0xff) ]
        while (chunks):
            c = chunks.pop(0)
            s.send(chr(len(c)))
            s.send(c)
            if (chunks): s.send(_CONT)

        if (args): s.send(_NEXT)

    s.send(_END)


def send_error(s):

    send(s, _SEND_ERROR)


def recv(s):

    args = []
    chunk = ""
    while (True):
        try:
            length = ord(s.recv(1))
        except:
            raise XDRError

        if (length): chunk += s.recv(length)

        flag = s.recv(1)
        if (flag == _CONT): continue

        args.append(chunk)
        chunk = ""

        if (flag == _END): break
    #end while

    return args[1:]