This file is indexed.

/usr/bin/horde-db-migrate is in php-horde 5.2.9+debian0-1build1.

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
#!/usr/bin/php
<?php
/**
 * Database migration script.
 *
 * Usage: horde-db-migrate
 *        [--config=filename]
 *        [--debug]
 *        [(application|directory) [(up|down|version)]]
 *
 * Copyright 2010-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL-2). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @author   Jan Schneider <jan@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL-2
 * @package  Horde
 */

$baseFile = __DIR__ . '/../lib/Application.php';
if (file_exists($baseFile)) {
    require_once $baseFile;
} else {
    require_once 'PEAR/Config.php';
    require_once PEAR_Config::singleton()
        ->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php';
}
Horde_Registry::appInit('horde', array(
    'authentication' => 'none',
    'cli' => true
));

// Parse command line arguments.
$parser = new Horde_Argv_Parser(
    array(
        'usage' => "%prog\n\t[--config=filename]\n\t[--debug]\n\t[--halt-on-error]\n\t[(application|directory) [(up|down|version)]]",
        'optionList' => array(
            new Horde_Argv_Option(
                '-c',
                '--config',
                array(
                    'help'   => 'Path to PEAR configuration file.'
                )
            ),
            new Horde_Argv_Option(
                '-d',
                '--debug',
                array(
                    'action' => 'store_true',
                    'help'   => 'Provide full debugging output.'
                )
            ),
            new Horde_Argv_Option(
                '-s',
                '--halt-on-error',
                array(
                    'action' => 'store_true',
                    'help'   => 'Halt migration immediately on error.'
                )
            ),
        )
    )
);
list($options, $args) = $parser->parseArgs();

$migration = new Horde_Core_Db_Migration(__DIR__ . '/../..', $options['config']);
if (empty($args[0])) {
    // Run all migrations.
    $apps = $migration->apps;
    $dirs = $migration->dirs;
} else {
    // Run a specific migration.
    $app = $args[0];
    if (($key = array_search($app, $migration->apps)) !== false) {
        $dir = $migration->dirs[$key];
    } elseif (($key = array_search($app, $migration->dirs)) !== false) {
        $dir = $app;
        $app = $migration->apps[$key];
    } else {
        $cli->fatal(
            sprintf(
                '%s is neither a configured Horde application nor a migration directory

Supported applications:

%s

Supported directories:

%s',
                $app,
                join("\n  ", $migration->apps),
                join("\n  ", $migration->dirs)
            )
        );
    }
    $dirs = array($dir);
    $apps = array($app);
}

$action = 'up';
if (!empty($args[1])) {
    switch ($args[1]) {
    case 'up':
    case 'down':
        $action = $args[1];
        break;

    default:
        $action = 'migrate';
        $targetVersion = $args[1];
        break;
    }
}

// Run
$db = $injector->getInstance('Horde_Db_Adapter');
if (!empty($options['debug'])) {
    $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream(STDOUT));
    $db->setLogger($logger);
}

switch ($action) {
case 'up':
    $cli->message('Migrating DB up.');
    break;

case 'down':
    $cli->message('Migrating DB down.');
    break;

case 'migrate':
    $cli->message('Migrating DB to schema version ' . $targetVersion . '.');
    break;
}

$logger = new Horde_Log_Logger(
    new Horde_Log_Handler_Stream(
        STDOUT, null, new Horde_Log_Formatter_Simple('%message%' . PHP_EOL)));

foreach ($apps as $app) {
    $migrator = $migration->getMigrator($app, $logger);

    $cli->message("Current $app schema version: " . $migrator->getCurrentVersion());

    try {
        switch ($action) {
        case 'up':
            $migrator->up();
            break;

        case 'down':
            $migrator->down();
            break;

        case 'migrate':
            $migrator->migrate($targetVersion);
            break;
        }
    } catch (Exception $e) {
        echo $e->getMessage() . "\n";
        if (empty($options['halt-on-error'])) {
            continue;
        } else {
            exit(1);
        }
    }

    $cli->message("Ending $app schema version: " . $migrator->getCurrentVersion());
}