This file is indexed.

/usr/bin/mysqluc is in mysql-utilities 1.3.5-2.

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
174
175
176
177
178
#! /usr/bin/python
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

"""
This file contains the mysql utilities client.
"""

from mysql.utilities.common.options import UtilitiesParser
from mysql.utilities.common.tools import check_connector_python
from mysql.utilities.common.tools import check_python_version

# Check Python version compatibility
check_python_version()

import os
import sys

# Check for connector/python
if not check_connector_python():
    sys.exit(1)

try:
    from mysql.utilities.command.utilitiesconsole import UtilitiesConsole
    from mysql.utilities import VERSION_FRM, VERSION_STRING, COPYRIGHT_FULL
    from mysql.utilities.common.options import add_verbosity, check_verbosity
    from mysql.utilities.exception import UtilError
except:
    print("ERROR: MySQL Utilities are either not installed or are not "
          "accessible from this terminal.")
    sys.exit(2)

# Constants
NAME = "MySQL Utilities Client - mysqluc "
DESCRIPTION = "mysqluc - Command line client for running MySQL Utilities"
USAGE = "%prog "
WELCOME_MESSAGE = """
Welcome to the MySQL Utilities Client (mysqluc) version {0}\n{1}
Type 'help' for a list of commands or press TAB twice for list of utilities.
"""
GOODBYE_MESSAGE = "\nThanks for using the MySQL Utilities Client!\n"
PRINT_WIDTH = 75
UTIL_PATH = "/scripts"

def build_variable_dictionary_list(args):
    """Build a variable dictionary from the arguments

    Returns list - list of variables
    """
    variables = []
    arguments = list(args)
    for arg in arguments[:]:
        if '=' in arg:
            try:
                name, value = arg.split('=')
                if not value:
                    raise ValueError
            except ValueError:
                parser.error("Invalid argument assignment: {0}. Please check "
                             "your command.".format(arg))
            variables.append({'name': name, 'value': value})
            arguments.remove(arg)

    if len(arguments) > 0:
        parser.error("Unbalanced arguments. Please check your command.")
    for i in range(0, len(arguments), 2):
        variables.append({'name': arguments[i], 'value': arguments[i+1]})
    return variables

# Setup the command parser
parser = UtilitiesParser(
    version=VERSION_FRM.format(program=os.path.basename(sys.argv[0])),
    description=DESCRIPTION,
    usage=USAGE,
    add_help_option=False)

# Default option to provide help information
parser.add_option("--help", action="help", help="display this help message "
                  "and exit")

# Add display width option
parser.add_option("--width", action="store", dest="width",
                  type="int", help="display width",
                  default=PRINT_WIDTH)

# Add utility directory option
parser.add_option("--utildir", action="store", dest="utildir",
                  type="string", help="location of utilities",
                  default=UTIL_PATH)

# Add execute mode
parser.add_option("-e", "--execute", action="store", dest="commands",
                  type="string", help="execute commands and exit. Multiple "
                  "commands are separated with semi-colons. Note: some "
                  "platforms may require double quotes around command list.",
                  default=None)

# Add utility extra_utilities option
parser.add_option("--add-utility", action="append", dest="add_util",
                  help="append an utility in the format"
                  "mysql<utility_name>. The mysql<utility_name>.py must be "
                  "located inside the folder given by the utildir option",
                  default=[])

# Add utility extra_utilities option
parser.add_option("--hide-utils", action="store_true",
                  dest="hide_util", help="when this option is given,"
                  " the default utilities will not be available, must be used"
                  " only along of --add-utility option", default=False)

# Add verbosity mode
add_verbosity(parser, True)

# Now we process the rest of the arguments.
opt, args = parser.parse_args()

# Warn if quiet and verbosity are both specified
check_verbosity(opt)

if opt.verbosity is None:
    verbosity = 0
else:
    verbosity = opt.verbosity

quiet = opt.quiet
if opt.quiet is None:
    quiet = False

if opt.hide_util and not opt.add_util:
    # TODO: move to common/messages.py
    parser.error("You can only use --hide_utils option along the "
                 "--add-util option.")

extra_utils_dict = {}
for utility in opt.add_util:
    extra_utils_dict[utility] = ()


options = {
    'verbosity' : verbosity,
    'quiet'     : quiet,
    'width'     : opt.width,
    'utildir'   : opt.utildir,
    'variables' : build_variable_dictionary_list(args),
    'prompt'    : 'mysqluc> ',
    'welcome'   : WELCOME_MESSAGE.format(VERSION_STRING, COPYRIGHT_FULL),
    'goodbye'   : GOODBYE_MESSAGE,
    'commands'  : opt.commands,
    'custom'    : True, # We are using custom commands
    'hide_util' : opt.hide_util,
    'add_util'  : extra_utils_dict
}

try:
    print("Launching console ...")
    util_con = UtilitiesConsole(options)
    util_con.run_console()
except KeyboardInterrupt:
    print(options['goodbye'])
except UtilError:
    _, e, _ = sys.exc_info()
    print("ERROR: %s" % e.errmsg)

sys.exit()