This file is indexed.

/usr/bin/swift-recon-cron is in swift-object 2.2.0-1+deb8u1.

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
#! /usr/bin/python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
swift-recon-cron.py
"""

import os
import sys
from ConfigParser import ConfigParser
from gettext import gettext as _

from swift.common.utils import get_logger, dump_recon_cache


def get_async_count(device_dir, logger):
    async_count = 0
    for i in os.listdir(device_dir):
        asyncdir = os.path.join(device_dir, i, "async_pending")
        if os.path.isdir(asyncdir):
            for entry in os.listdir(asyncdir):
                if os.path.isdir(os.path.join(asyncdir, entry)):
                    async_hdir = os.path.join(asyncdir, entry)
                    async_count += len(os.listdir(async_hdir))
    return async_count


def main():
    c = ConfigParser()
    try:
        conf_path = sys.argv[1]
    except Exception:
        print "Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1]
        print "ex: swift-recon-cron /etc/swift/object-server.conf"
        sys.exit(1)
    if not c.read(conf_path):
        print "Unable to read config file %s" % conf_path
        sys.exit(1)
    conf = dict(c.items('filter:recon'))
    device_dir = conf.get('devices', '/srv/node')
    recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift')
    recon_lock_path = conf.get('recon_lock_path', '/var/lock')
    cache_file = os.path.join(recon_cache_path, "object.recon")
    lock_dir = os.path.join(recon_lock_path, "swift-recon-object-cron")
    conf['log_name'] = conf.get('log_name', 'recon-cron')
    logger = get_logger(conf, log_route='recon-cron')
    try:
        os.mkdir(lock_dir)
    except OSError as e:
        logger.critical(str(e))
        print str(e)
        sys.exit(1)
    try:
        asyncs = get_async_count(device_dir, logger)
        dump_recon_cache({'async_pending': asyncs}, cache_file, logger)
    except Exception:
        logger.exception(
            _('Exception during recon-cron while accessing devices'))
    try:
        os.rmdir(lock_dir)
    except Exception:
        logger.exception(_('Exception remove cronjob lock'))

if __name__ == '__main__':
    main()