From 91c47e6fdf9aff728761177aff731442efc5ab29 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 3 Aug 2014 17:13:56 +0200 Subject: [PATCH] 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. --- mysys/my_default.c | 11 +++++------ scripts/CMakeLists.txt | 6 +++++- scripts/mysqlaccess.sh | 12 ++++++------ scripts/mysqld_multi.sh | 10 +++++----- scripts/mytop.sh | 28 ++++------------------------ 5 files changed, 25 insertions(+), 42 deletions(-) diff --git a/mysys/my_default.c b/mysys/my_default.c index 1e4038d17fb..8eb99d21b73 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -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= (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= (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 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 <