summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-08-03 17:13:56 +0200
committerSergei Golubchik <sergii@pisem.net>2014-08-03 17:13:56 +0200
commit91c47e6fdf9aff728761177aff731442efc5ab29 (patch)
tree042a0181f419e6d69e67dfcae1ce612757a6e210 /scripts
parent82ce2a2503a95e8bdc76c351a87e98c93445a433 (diff)
downloadmariadb-git-91c47e6fdf9aff728761177aff731442efc5ab29.tar.gz
MDEV-6485 Hard-coded paths in the source cannot be opt-out
when looking for my.cnf files: if DEFAULT_SYSCONFDIR (or INSTALL_SYSCONFDIR) is specified (for rpms it always is), use that instead of hardcoded /etc path.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/CMakeLists.txt6
-rw-r--r--scripts/mysqlaccess.sh12
-rw-r--r--scripts/mysqld_multi.sh10
-rw-r--r--scripts/mytop.sh28
4 files changed, 20 insertions, 36 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index e865edc46c0..13a89368ee6 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -221,7 +221,11 @@ INSTALL_SCRIPT(
ENDIF()
SET(prefix "${CMAKE_INSTALL_PREFIX}")
-SET(sysconfdir ${prefix})
+IF(INSTALL_SYSCONFDIR)
+ SET(sysconfdir ${DEFAULT_SYSCONFDIR})
+ELSE()
+ SET(sysconfdir "/etc")
+ENDIF()
SET(bindir ${prefix}/${INSTALL_BINDIR})
SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
SET(scriptdir ${prefix}/${INSTALL_BINDIR})
diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh
index 1d01c84735a..d8fd239585c 100644
--- a/scripts/mysqlaccess.sh
+++ b/scripts/mysqlaccess.sh
@@ -261,12 +261,12 @@ Release Notes:
* log-file for debug-output : /tmp/mysqlaccess.log
* default values are read from a configuration file $script.conf
first this file is looked for in the current directory; if not
- found it is looked for in /etc/
+ found it is looked for in @sysconfdir@
Note that when default-values are given, these can't get overriden
by empty (blanc) values!
* CGI-BIN version with HTML and forms interface. Simply place the
script in an ScriptAliased directory, make the configuration file
- available in the that directory or in /etc, and point your browser
+ available in the that directory or in @sysconfdir@, and point your browser
to the right URL.
* copy the grant-rules to temporary tables, where you are safe to
play with them.
@@ -480,12 +480,12 @@ MySQLaccess::Report::Print_Header();
if (-f "./$script_conf") {
require "./$script_conf";
}
+ elsif (-f "@prefix@/$script_conf") {
+ require "@prefix@/$script_conf";
+ }
elsif (-f "@sysconfdir@/$script_conf") {
require "@sysconfdir@/$script_conf";
}
- elsif (-f "/etc/$script_conf") {
- require "/etc/$script_conf";
- }
# ****************************
# Read in all parameters
@@ -950,8 +950,8 @@ sub MergeConfigFile {
# =================================
sub MergeConfigFiles {
my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<;
+ MergeConfigFile("@prefix@/my.cnf");
MergeConfigFile("@sysconfdir@/my.cnf");
- MergeConfigFile("/etc/my.cnf");
MergeConfigFile("$dir/.my.cnf");
}
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index cd1b6fc18b7..c567d434047 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -499,9 +499,9 @@ sub list_defaults_files
my %seen; # Don't list the same file more than once
return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
- ('/etc/my.cnf',
- '/etc/mysql/my.cnf',
- '@sysconfdir@/my.cnf',
+ ('@sysconfdir@/my.cnf',
+ '@sysconfdir@/mysql/my.cnf',
+ '@prefix@/my.cnf',
($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
$opt{'extra-file'},
($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
@@ -632,7 +632,7 @@ sub example
{
print <<EOF;
# This is an example of a my.cnf file for $my_progname.
-# Usually this file is located in home dir ~/.my.cnf or /etc/my.cnf
+# Usually this file is located in home dir ~/.my.cnf or @sysconfdir@/my.cnf
#
# SOME IMPORTANT NOTES FOLLOW:
#
@@ -705,7 +705,7 @@ sub example
# (as per Linux/Unix standard). You may even replace the
# /etc/init.d/mysql.server script with it.
#
-# Before using, you must create a my.cnf file either in @sysconfdir@/my.cnf
+# Before using, you must create a my.cnf file either in @prefix@/my.cnf
# or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups.
#
# The script can be found from support-files/mysqld_multi.server.sh
diff --git a/scripts/mytop.sh b/scripts/mytop.sh
index 480805e90b1..1cf1c5313b4 100644
--- a/scripts/mytop.sh
+++ b/scripts/mytop.sh
@@ -70,7 +70,6 @@ sub GetShowStatus();
sub cmd_s;
sub cmd_S;
sub cmd_q;
-sub FindProg($);
## Default Config Values
@@ -1366,9 +1365,9 @@ sub GetInnoDBStatus()
{
if (not $config{pager})
{
- if (not $config{pager} = FindProg('less'))
+ if (not $config{pager} = my_which('less'))
{
- $config{pager} = FindProg('more');
+ $config{pager} = my_which('more');
}
}
@@ -1467,9 +1466,9 @@ sub GetShowVariables()
{
if (not $config{pager})
{
- if (not $config{pager} = FindProg('less'))
+ if (not $config{pager} = my_which('less'))
{
- $config{pager} = FindProg('more');
+ $config{pager} = my_which('more');
}
}
@@ -1825,25 +1824,6 @@ sub Execute($)
return $sth;
}
-sub FindProg($)
-{
- my $prog = shift;
- my $found = undef;
- my @search_dirs = ("/bin", "/usr/bin", "/usr/sbin",
- "/usr/local/bin", "/usr/local/sbin");
-
- for (@search_dirs)
- {
- my $loc = "$_/$prog";
- if (-e $loc)
- {
- $found = $loc;
- last;
- }
- }
- return $found;
-}
-
####
#### my_which is used, because we can't assume that every system has the
#### which -command. my_which can take only one argument at a time.