This file is indexed.

/usr/lib/python2.7/dist-packages/ZEO/scripts/zeopack.py is in python-zodb 1:3.10.7-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
 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
#!/usr/bin/env python2.3

import logging
import optparse
import socket
import sys
import time
import traceback
import ZEO.ClientStorage

usage = """Usage: %prog [options] [servers]

Pack one or more storages hosted by ZEO servers.

The positional arguments specify 0 or more tcp servers to pack, where
each is of the form:

    host:port[:name]

"""

WAIT = 10 # wait no more than 10 seconds for client to connect

def _main(args=None, prog=None):
    if args is None:
        args = sys.argv[1:]

    parser = optparse.OptionParser(usage, prog=prog)

    parser.add_option(
        "-d", "--days", dest="days", type='int', default=0,
        help=("Pack objects that are older than this number of days")
        )

    parser.add_option(
        "-t", "--time", dest="time",
        help=("Time of day to pack to of the form: HH[:MM[:SS]]. "
              "Defaults to current time.")
        )

    parser.add_option(
        "-u", "--unix", dest="unix_sockets", action="append",
        help=("A unix-domain-socket server to connect to, of the form: "
              "path[:name]")
        )

    parser.remove_option('-h')
    parser.add_option(
        "-h", dest="host",
        help=("Deprecated: "
              "Used with the -p and -S options, specified the host to "
              "connect to.")
        )

    parser.add_option(
        "-p", type="int", dest="port",
        help=("Deprecated: "
              "Used with the -h and -S options, specifies "
              "the port to connect to.")
        )

    parser.add_option(
        "-S", dest="name", default='1',
        help=("Deprecated: Used with the -h and -p, options, or with the "
              "-U option specified the storage name to use. Defaults to 1.")
        )

    parser.add_option(
        "-U", dest="unix",
        help=("Deprecated: Used with the -S option, "
              "Unix-domain socket to connect to.")
        )

    if not args:
        parser.print_help()
        return

    def error(message):
        sys.stderr.write("Error:\n%s\n" % message)
        sys.exit(1)

    options, args = parser.parse_args(args)

    packt = time.time()
    if options.time:
        time_ = map(int, options.time.split(':'))
        if len(time_) == 1:
            time_ += (0, 0)
        elif len(time_) == 2:
            time_ += (0,)
        elif len(time_) > 3:
            error("Invalid time value: %r" % options.time)

        packt = time.localtime(packt)
        packt = time.mktime(packt[:3]+tuple(time_)+packt[6:])

    packt -= options.days * 86400

    servers = []

    if options.host:
        if not options.port:
            error("If host (-h) is specified then a port (-p) must be "
                  "specified as well.")
        servers.append(((options.host, options.port), options.name))
    elif options.port:
        servers.append(((socket.gethostname(), options.port), options.name))

    if options.unix:
        servers.append((options.unix, options.name))

    for server in args:
        data = server.split(':')
        if len(data) in (2, 3):
            host = data[0]
            try:
                port = int(data[1])
            except ValueError:
                error("Invalid port in server specification: %r" % server)
            addr = host, port
            if len(data) == 2:
                name = '1'
            else:
                name = data[2]
        else:
            error("Invalid server specification: %r" % server)

        servers.append((addr, name))

    for server in options.unix_sockets or ():
        data = server.split(':')
        if len(data) == 1:
            addr = data[0]
            name = '1'
        elif len(data) == 2:
            addr = data[0]
            name = data[1]
        else:
            error("Invalid server specification: %r" % server)

        servers.append((addr, name))

    if not servers:
        error("No servers specified.")

    for addr, name in servers:
        try:
            cs = ZEO.ClientStorage.ClientStorage(
                addr, storage=name, wait=False, read_only=1)
            for i in range(60):
                if cs.is_connected():
                    break
                time.sleep(1)
            else:
                sys.stderr.write("Couldn't connect to: %r\n"
                                 % ((addr, name), ))
                cs.close()
                continue
            cs.pack(packt, wait=True)
            cs.close()
        except:
            traceback.print_exception(*(sys.exc_info()+(99, sys.stderr)))
            error("Error packing storage %s in %r" % (name, addr))

def main(*args):
    root_logger = logging.getLogger()
    old_level = root_logger.getEffectiveLevel()
    logging.getLogger().setLevel(logging.WARNING)
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter(
        "%(name)s %(levelname)s %(message)s"))
    logging.getLogger().addHandler(handler)
    try:
        _main(*args)
    finally:
        logging.getLogger().setLevel(old_level)
        logging.getLogger().removeHandler(handler)

if __name__ == "__main__":
    main()