This file is indexed.

/usr/lib/python3/dist-packages/wormhole/server/cmd_server.py is in magic-wormhole 0.10.3-1.

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
from __future__ import print_function, unicode_literals
import os, time
from twisted.python import usage
from twisted.scripts import twistd

class MyPlugin(object):
    tapname = "xyznode"

    def __init__(self, args):
        self.args = args

    def makeService(self, so):
        # delay this import as late as possible, to allow twistd's code to
        # accept --reactor= selection
        from .server import RelayServer
        return RelayServer(
            str(self.args.rendezvous),
            str(self.args.transit),
            self.args.advertise_version,
            self.args.relay_database_path,
            self.args.blur_usage,
            signal_error=self.args.signal_error,
            stats_file=self.args.stats_json_path,
            allow_list=self.args.allow_list,
        )

class MyTwistdConfig(twistd.ServerOptions):
    subCommands = [("XYZ", None, usage.Options, "node")]

def start_server(args):
    c = MyTwistdConfig()
    #twistd_args = tuple(args.twistd_args) + ("XYZ",)
    base_args = []
    if args.no_daemon:
        base_args.append("--nodaemon")
    twistd_args = base_args + ["XYZ"]
    c.parseOptions(tuple(twistd_args))
    c.loadedPlugins = {"XYZ": MyPlugin(args)}

    print("starting wormhole relay server")
    # this forks and never comes back. The parent calls os._exit(0)
    twistd.runApp(c)

def kill_server():
    try:
        f = open("twistd.pid", "r")
    except EnvironmentError:
        print("Unable to find twistd.pid: is this really a server directory?")
        print("oh well, ignoring 'stop'")
        return
    pid = int(f.read().strip())
    f.close()
    os.kill(pid, 15)
    print("server process %d sent SIGTERM" % pid)
    return

def stop_server(args):
    kill_server()

def restart_server(args):
    kill_server()
    time.sleep(0.1)
    timeout = 0
    while os.path.exists("twistd.pid") and timeout < 10:
        if timeout == 0:
            print(" waiting for shutdown..")
        timeout += 1
        time.sleep(1)
    if os.path.exists("twistd.pid"):
        print("error: unable to shut down old server")
        return 1
    print(" old server shut down")
    start_server(args)