mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -138,9 +138,8 @@ static int search_default_file_with_ext(Process_option_func func,
|
||||
- Windows: GetWindowsDirectory()
|
||||
- Windows: C:/
|
||||
- Windows: Directory above where the executable is located
|
||||
- Unix: /etc/
|
||||
- Unix: /etc/mysql/
|
||||
- Unix: --sysconfdir=<path> (compile-time option)
|
||||
- Unix: /etc/ or the value of DEFAULT_SYSCONFDIR, if defined
|
||||
- Unix: /etc/mysql/ unless DEFAULT_SYSCONFDIR is defined
|
||||
- ALL: getenv("MYSQL_HOME")
|
||||
- ALL: --defaults-extra-file=<path> (run-time option)
|
||||
- Unix: ~/
|
||||
@ -1224,12 +1223,12 @@ static const char **init_default_directories(MEM_ROOT *alloc)
|
||||
|
||||
#else
|
||||
|
||||
errors += add_directory(alloc, "/etc/", dirs);
|
||||
errors += add_directory(alloc, "/etc/mysql/", dirs);
|
||||
|
||||
#if defined(DEFAULT_SYSCONFDIR)
|
||||
if (DEFAULT_SYSCONFDIR[0])
|
||||
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
|
||||
|
@ -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})
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user