Commit 91c47e6f authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent 82ce2a25
...@@ -138,9 +138,8 @@ static int search_default_file_with_ext(Process_option_func func, ...@@ -138,9 +138,8 @@ static int search_default_file_with_ext(Process_option_func func,
- Windows: GetWindowsDirectory() - Windows: GetWindowsDirectory()
- Windows: C:/ - Windows: C:/
- Windows: Directory above where the executable is located - Windows: Directory above where the executable is located
- Unix: /etc/ - Unix: /etc/ or the value of DEFAULT_SYSCONFDIR, if defined
- Unix: /etc/mysql/ - Unix: /etc/mysql/ unless DEFAULT_SYSCONFDIR is defined
- Unix: --sysconfdir=<path> (compile-time option)
- ALL: getenv("MYSQL_HOME") - ALL: getenv("MYSQL_HOME")
- ALL: --defaults-extra-file=<path> (run-time option) - ALL: --defaults-extra-file=<path> (run-time option)
- Unix: ~/ - Unix: ~/
...@@ -1224,12 +1223,12 @@ static const char **init_default_directories(MEM_ROOT *alloc) ...@@ -1224,12 +1223,12 @@ static const char **init_default_directories(MEM_ROOT *alloc)
#else #else
errors += add_directory(alloc, "/etc/", dirs);
errors += add_directory(alloc, "/etc/mysql/", dirs);
#if defined(DEFAULT_SYSCONFDIR) #if defined(DEFAULT_SYSCONFDIR)
if (DEFAULT_SYSCONFDIR[0]) if (DEFAULT_SYSCONFDIR[0])
errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs); errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
#else
errors += add_directory(alloc, "/etc/", dirs);
errors += add_directory(alloc, "/etc/mysql/", dirs);
#endif /* DEFAULT_SYSCONFDIR */ #endif /* DEFAULT_SYSCONFDIR */
#endif #endif
......
...@@ -221,7 +221,11 @@ INSTALL_SCRIPT( ...@@ -221,7 +221,11 @@ INSTALL_SCRIPT(
ENDIF() ENDIF()
SET(prefix "${CMAKE_INSTALL_PREFIX}") 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(bindir ${prefix}/${INSTALL_BINDIR})
SET(libexecdir ${prefix}/${INSTALL_SBINDIR}) SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
SET(scriptdir ${prefix}/${INSTALL_BINDIR}) SET(scriptdir ${prefix}/${INSTALL_BINDIR})
......
...@@ -261,12 +261,12 @@ Release Notes: ...@@ -261,12 +261,12 @@ Release Notes:
* log-file for debug-output : /tmp/mysqlaccess.log * log-file for debug-output : /tmp/mysqlaccess.log
* default values are read from a configuration file $script.conf * default values are read from a configuration file $script.conf
first this file is looked for in the current directory; if not 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 Note that when default-values are given, these can't get overriden
by empty (blanc) values! by empty (blanc) values!
* CGI-BIN version with HTML and forms interface. Simply place the * CGI-BIN version with HTML and forms interface. Simply place the
script in an ScriptAliased directory, make the configuration file 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. to the right URL.
* copy the grant-rules to temporary tables, where you are safe to * copy the grant-rules to temporary tables, where you are safe to
play with them. play with them.
...@@ -480,12 +480,12 @@ MySQLaccess::Report::Print_Header(); ...@@ -480,12 +480,12 @@ MySQLaccess::Report::Print_Header();
if (-f "./$script_conf") { if (-f "./$script_conf") {
require "./$script_conf"; require "./$script_conf";
} }
elsif (-f "@prefix@/$script_conf") {
require "@prefix@/$script_conf";
}
elsif (-f "@sysconfdir@/$script_conf") { elsif (-f "@sysconfdir@/$script_conf") {
require "@sysconfdir@/$script_conf"; require "@sysconfdir@/$script_conf";
} }
elsif (-f "/etc/$script_conf") {
require "/etc/$script_conf";
}
# **************************** # ****************************
# Read in all parameters # Read in all parameters
...@@ -950,8 +950,8 @@ sub MergeConfigFile { ...@@ -950,8 +950,8 @@ sub MergeConfigFile {
# ================================= # =================================
sub MergeConfigFiles { sub MergeConfigFiles {
my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<; my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<;
MergeConfigFile("@prefix@/my.cnf");
MergeConfigFile("@sysconfdir@/my.cnf"); MergeConfigFile("@sysconfdir@/my.cnf");
MergeConfigFile("/etc/my.cnf");
MergeConfigFile("$dir/.my.cnf"); MergeConfigFile("$dir/.my.cnf");
} }
......
...@@ -499,9 +499,9 @@ sub list_defaults_files ...@@ -499,9 +499,9 @@ sub list_defaults_files
my %seen; # Don't list the same file more than once my %seen; # Don't list the same file more than once
return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ } return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
('/etc/my.cnf', ('@sysconfdir@/my.cnf',
'/etc/mysql/my.cnf', '@sysconfdir@/mysql/my.cnf',
'@sysconfdir@/my.cnf', '@prefix@/my.cnf',
($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef), ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
$opt{'extra-file'}, $opt{'extra-file'},
($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef)); ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
...@@ -632,7 +632,7 @@ sub example ...@@ -632,7 +632,7 @@ sub example
{ {
print <<EOF; print <<EOF;
# This is an example of a my.cnf file for $my_progname. # 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: # SOME IMPORTANT NOTES FOLLOW:
# #
...@@ -705,7 +705,7 @@ sub example ...@@ -705,7 +705,7 @@ sub example
# (as per Linux/Unix standard). You may even replace the # (as per Linux/Unix standard). You may even replace the
# /etc/init.d/mysql.server script with it. # /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. # or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups.
# #
# The script can be found from support-files/mysqld_multi.server.sh # The script can be found from support-files/mysqld_multi.server.sh
......
...@@ -70,7 +70,6 @@ sub GetShowStatus(); ...@@ -70,7 +70,6 @@ sub GetShowStatus();
sub cmd_s; sub cmd_s;
sub cmd_S; sub cmd_S;
sub cmd_q; sub cmd_q;
sub FindProg($);
## Default Config Values ## Default Config Values
...@@ -1366,9 +1365,9 @@ sub GetInnoDBStatus() ...@@ -1366,9 +1365,9 @@ sub GetInnoDBStatus()
{ {
if (not $config{pager}) 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() ...@@ -1467,9 +1466,9 @@ sub GetShowVariables()
{ {
if (not $config{pager}) 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($) ...@@ -1825,25 +1824,6 @@ sub Execute($)
return $sth; 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 #### 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. #### which -command. my_which can take only one argument at a time.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment