This file is indexed.

/usr/bin/turba-public-to-horde-share is in php-horde-turba 4.2.2-3.

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
#!/usr/bin/php
<?php
/**
 * Script to migrate an existing 'public' Turba address book to the
 * Horde_Share based system.  This script is designed for a SQL source only.
 * This script will move *ALL* existing entries in the turba_objects table into
 * a single, globally shared Horde_Share owned by the user specified below.
 * DO NOT RUN THIS SCRIPT UNLESS you have been using 'public' => true in
 * a SQL source (such as 'localsql') - otherwise, you will turn every user's
 * private address book into a public source!
 *
 * Copyright 2005-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/apache.
 *
 * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 * @package Turba
 */

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

$cli->writeln('This script will turn all entries in the SQL address book into a globally shared address book.');
$cli->writeln('Make sure you read the script comments and be sure you know what you are doing.');
$sure = $cli->prompt('Are you ' . $cli->bold('sure') . ' you want to do this?', array('no', 'yes'));
if (!$sure) {
    exit;
}

// Find out what our Auth driver will let us do and
// get the list of all users if we can.  If your site
// has a *large* number of users, you may want to comment
// out this section to avoid unnecessary overhead.
$auth = $injector->getInstance('Horde_Core_Factory_Auth')->create();
if ($auth->hasCapability('list')) {
    $users = $auth->listUsers();
}

// Get all the details.
do {
    $owner = $cli->prompt('Username of the user you would like to own the new public source.');
    // Might as well check this if we have the list.
    if (!empty($users) && !in_array($owner, $users)) {
        $cli->message($owner . ' is not a valid user!', 'cli.error');
        $owner = '';
    }
} while(!$owner);

do {
    $title = $cli->prompt('Enter the title you would like to give to the new public source.');
} while (!$title);

$sourceKey = $cli->prompt('What is the internal name of the share we are converting? [localsql]');
if (!$sourceKey) {
    $sourceKey = 'localsql';
}

// Create the new share.
$turba_shares = $injector->getInstance('Turba_Shares');
$owner_uid = strval(new Horde_Support_Randomid());
$share = $turba_shares->newShare($GLOBALS['registry']->getAuth(), $sourceKey . ':' . $owner_uid, $title);
$share->set('owner', $owner);
$share->set('perm_default', Horde_Perms::SHOW | Horde_Perms::READ);
$turba_shares->addShare($share);
$share->save();
$cli->message('Created new Horde_Share object for the shared address book.', 'cli.success');

// Share created, now get a Turba_Driver and make the changes.
$driver = $injector->getInstance('Turba_Factory_Driver')->create($sourceKey);

$db = &$driver->_db;

// Get the tablename in case we aren't using horde defaults.
$tableName = $db->dsn['table'];
$SQL = 'SELECT COUNT(*) FROM ' . $tableName . ';';
$count = $db->getOne($SQL);
$cli->message("Moving $count contacts to $title.", 'cli.message');
$SQL = 'UPDATE ' . $tableName . ' SET owner_id=\'' . $owner_uid . '\';';
$result = $db->query($SQL);
if ($result instanceof PEAR_Error) {
    var_dump($result);
    exit;
}
$prefDriver = $conf['prefs']['driver'];
if ($prefDriver == 'sql') {
    // Automatically append this source to the addressbooks pref if desired.
    $autoAppend = $cli->prompt('Would you like to add the new public source to every user\'s address book preference?', array('no', 'yes'));
    if ($autoAppend) {
        $SQL = 'SELECT pref_uid, pref_value FROM horde_prefs WHERE pref_scope=\'turba\' AND pref_name=\'addressbooks\';';
        $results = $db->getAll($SQL);
        if ($results instanceof PEAR_Error) {
           $cli->message('There was an error updating the user preferences: ' . $results->getMessage(), 'cli.error');
        } else {
            foreach ($results as $row) {
                $newValue = $row[1] . "\n$sourceKey:$owner_uid";
                $SQL = 'UPDATE horde_prefs SET pref_value=\'' . $newValue . '\' WHERE pref_uid=\'' . $row[0] . '\' AND pref_scope=\'turba\' AND pref_name=\'addressbooks\';';
                $result = $db->query($SQL);
                if ($result instanceof PEAR_Error) {
                    $cli->message('Could not update preferences for ' . $row[0] . ': ' . $result->getMessage(), 'cli.error');
                }
            }
        }
        if (!($results instanceof PEAR_Error)) {
            $cli->message('Successfully added new shared address book to the user preferences.', 'cli.success');
        }
    }
} else {
    $cli->message('Your preference backend does not support updating all user preferences.', 'cli.warning');
    $cli->message('Your users may have to manually add the new shared address book to their "addressbook" preference.', 'cli.warning');
}

// Share our success.
$cli->writeln($cli->bold("*** $title successfully created ***"));
$cli->writeln('Share Info:');
$cli->writeln($cli->indent('Title: ' . $share->get('name')));
$cli->writeln($cli->indent('Owner: ' . $share->get('owner')));