This file is indexed.

/usr/bin/italc-launcher is in italc-master 1:1.0.13-0ubuntu4.

This file is owned by root:root, with mode 0o755.

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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/usr/bin/python
# coding=UTF-8

# iTalc master launcher using avahi
# Written by Stéphane Graber <stgraber@ubuntu.com>

from xml.dom import minidom
from hashlib import md5
import subprocess, re, socket, os, sys, urllib2, gettext, pwd

# gettext
gettext.textdomain('italc')
_ = gettext.gettext

# Store the old environment
lang=os.environ["LANG"]

# Empty config file to use if it doesn't already exist
skeleton="""<?xml version="1.0"?>
<!DOCTYPE italc-config-file>
<globalclientconfig version="1.0.9" >
  <body>
  </body>
</globalclientconfig>"""

try:
    confdir=os.environ.get("HOME")+"/.italc/"
except:
    sys.exit('Invalid or undefined env variable \"HOME\"')

try:
    file=open("/etc/italc/keys/public/teacher/key","r")
    md5_1=md5(file.read()).hexdigest()
    file.close()

    file=open("/etc/italc/keys/public/admin/key","r")
    md5_2=md5(file.read()).hexdigest()
    file.close()

    file=open("/etc/italc/keys/public/supporter/key","r")
    md5_3=md5(file.read()).hexdigest()
    file.close()
except:
    sys.exit('iTalc keys not correctly installed')

def getLocalIPs():
    "Scan ifconfig output for local IPV4 addresses"
    os.environ["LANG"]="C" # Set environ LANG to C
    ip=[]
    output=subprocess.Popen("ifconfig",stdout=subprocess.PIPE)
    output.wait()
    for line in output.stdout.readlines():
        line=line.strip()
        if line.startswith("inet addr"):
            ip.append(line.split(" ")[1].split(":")[1])
    return ip

def getHostPort():
    isdhost="127.0.0.1"
    try:
        output=subprocess.Popen(["xprop", "-root", "ICA_PORT"], stdout=subprocess.PIPE).communicate()[0]
        isdport=str(int(output.split('=')[1].strip()))
    except:
        isdport="5800"

    if "LTSP_CLIENT" in os.environ:
        xprop=subprocess.Popen(["xprop","-root","ica_ltsp"],stdout=subprocess.PIPE)
        xprop.wait()
        if xprop.stdout.read().split(" ")[2].strip() == "1":
            isdhost=os.environ["LTSP_CLIENT"]
        else:
            isdport=str(int(os.environ["LTSP_CLIENT"].split(".")[3])+11000)
    return [isdhost,isdport]

def getClusterHosts():
    hosts=[]
    if not os.path.exists("/etc/ltsp/getltscfg-cluster.conf") or not "LTSP_CLIENT" in os.environ:
        return hosts
    conf=open("/etc/ltsp/getltscfg-cluster.conf","r")
    for line in conf.readlines():
        if line.startswith("SERVER="):
            controlcenter=line.replace("SERVER=","").strip()
    conf.close()
    if not controlcenter:
        return hosts
    page=urllib2.urlopen("http://"+controlcenter+"/ltsp-cluster-control/Terminal/TeachTools.php?list/ip="+os.environ["LTSP_CLIENT"])
    for line in page.readlines():
        line=line.strip()
        if line and not line.startswith("CLASSROOM"):
            ip,mac,username=line.split(",")
            try:
                gecos=pwd.getpwnam(username).pw_gecos
            except:
                gecos=username
            hosts.append([ip+":5900",0,gecos])
    return hosts

def getAvahiHosts():
    global local_addr
    hosts=[]
    if not os.path.exists("/usr/bin/avahi-browse"):
        return hosts
    client_list=subprocess.Popen(["avahi-browse","-trp","_italc._tcp"],stdout=subprocess.PIPE)
    client_list.wait()
    for line in client_list.stdout.readlines():
        if line.startswith("="):
            try:
                param=line.split(";")
                comment=re.findall('"(.*)" "(.*)" "(.*)" "(.*)"\n',param[9])[0]
                if (comment[1] == md5_1 or comment[2] == md5_2 or comment[3] == md5_3):
                    if param[7] in local_addr:
                        param[7]="127.0.0.1"
                    host=[param[7]+":"+param[8],1,comment[0]]
                    if host not in hosts:
                        hosts.append(host)
            except:
                print 'Ignoring a client, invalid data received'
    return hosts

if not os.access("/etc/italc/keys/private/teacher/key",os.R_OK):
    md5_1="0"
    if not os.access("/etc/italc/keys/private/admin/key",os.R_OK):
        md5_2="0"
        if not os.access("/etc/italc/keys/private/supporter/key",os.R_OK):
            md5_3="0"
            access="none"
        else:
            access="supporter"
    else:
        access="admin"
else:
    access="teacher"

local_addr=getLocalIPs()
isdhost,isdport=getHostPort()

# Whether to use avahi autodetection. Defaults to true
autodetect_clients=not subprocess.Popen(["sh", "-c", ". /etc/italc/italc.conf >/dev/null 2>&1 && echo $AUTODETECT_CLIENTS"], stdout=subprocess.PIPE).communicate()[0].strip().upper() in ["FALSE", "F", "0"]

if autodetect_clients:
    try:
        xmldoc=minidom.parse(confdir+"globalconfig.xml")
        body=xmldoc.getElementsByTagName("globalclientconfig")[0].getElementsByTagName("body")[0]
        classrooms=body.getElementsByTagName("classroom")
    except:
        mkdir=subprocess.Popen(["mkdir","-p",confdir])
        mkdir.wait()
        try:
            config=open(confdir+"globalconfig.xml","w+")
            config.write(skeleton)
            config.close()
        except:
            sys.exit('Unable to write to config file')
        xmldoc=minidom.parse(confdir+"globalconfig.xml")
        body=xmldoc.getElementsByTagName("globalclientconfig")[0].getElementsByTagName("body")[0]
        classrooms=body.getElementsByTagName("classroom")

    # Scan for an existing classroom and delete it
    for classroom in classrooms:
        if classroom.getAttribute("name") == _("Auto-detected computers"):
            body.removeChild(classroom)

    # Create the Auto-detected computers classroom
    avahi=xmldoc.createElement("classroom")
    avahi.setAttribute("name",_("Auto-detected computers"))
    avahi.setAttribute("forcevisible","yes")
    body.appendChild(avahi)

    # Add computers to the classroom
    clients=sorted(getAvahiHosts()+getClusterHosts(), reverse=True)
    count=0

    if isdhost not in local_addr:
        local_addr=[isdhost]

    for client in clients:
        try:
            line=client[0]
            host,port=line.split(":")
            if (host in local_addr and str(int(isdport)+100) == port):
                continue

            # Do not perform some checks when in ltsp-cluster environment
            if client[1] == 1:
                # Make sure we have a running VNC server
                connection=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                connection.connect((host,int(port)))
                connection.close()

                # Get MAC address
                mac=subprocess.Popen(("arp", host, "-n", "-a"),stdout=subprocess.PIPE)
                mac.wait()
                mac=mac.stdout.read().strip().split(" ")[3]
                if not re.match("^..:..:..:..:..:..$",mac):
                    mac=""
            else:
                mac="" #FIXME: This should be retrieved from the control-center (along with the username)

            # Generate the name
            if client[2] != '':
                name=client[2]
            else:
                name="client "+str(count)

            # Generate the new node
            client=xmldoc.createElement("client")
            client.setAttribute("id",str(count))
            client.setAttribute("localip",host+":"+port)
            client.setAttribute("mac",mac)
            client.setAttribute("name",name)
            client.setAttribute("type","0")
            avahi.appendChild(client)
            count+=1
        except:
            print 'Ignoring a client, invalid data received'

    try:
        file=open(confdir+"globalconfig.xml","w")
        file.write(xmldoc.documentElement.toxml( "utf-8"))
        file.close()
    except:
        exit('Failed to save updated config')

print "Starting italc as "+access+" ("+isdhost+":"+isdport+")"

# Restore environment
os.environ["LANG"]=lang

subprocess.Popen(["italc","-isdport",isdport,"-isdhost",isdhost,"-role",access])