diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-14 15:10:59 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-14 15:10:59 +0300 |
commit | 646a6005e7882f9d4baf516c7936e5ef88ea89a6 (patch) | |
tree | d5b348bec9d756be164dd83fa052b80512f77e2f /sql/winservice.c | |
parent | 6b6c012f330cbbdcdee32333f16813764e5ed466 (diff) | |
parent | 67a03b7c947f5a0cfddbe1acc5e560fc737b0848 (diff) | |
download | mariadb-git-646a6005e7882f9d4baf516c7936e5ef88ea89a6.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/winservice.c')
-rw-r--r-- | sql/winservice.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/sql/winservice.c b/sql/winservice.c index 2d5cf62b53d..c7883c9f384 100644 --- a/sql/winservice.c +++ b/sql/winservice.c @@ -116,6 +116,23 @@ BOOL exclude_service(mysqld_service_properties *props) } +static void get_datadir_from_ini(const char *ini, char *service_name, char *datadir, size_t sz) +{ + *datadir= 0; + const char *sections[]= {service_name, "mysqld", "server", "mariadb", + "mariadbd"}; + for (int i= 0; i < sizeof(sections) / sizeof(sections[0]); i++) + { + if (sections[i]) + { + GetPrivateProfileStringA(sections[i], "datadir", NULL, datadir, sz, ini); + if (*datadir) + return; + } + } +} + + /* Retrieve some properties from windows mysqld service binary path. We're interested in ini file location and datadir, and also in version of @@ -135,6 +152,7 @@ int get_mysql_service_properties(const wchar_t *bin_path, wchar_t **args= NULL; int retval= 1; BOOL have_inifile; + char service_name[MAX_PATH]; props->datadir[0]= 0; props->inifile[0]= 0; @@ -148,7 +166,7 @@ int get_mysql_service_properties(const wchar_t *bin_path, { /* There are rare cases where service config does not have - --defaults-filein the binary parth . There services were registered with + --defaults-file in the binary parth . There services were registered with plain mysqld --install, the data directory is next to "bin" in this case. */ have_inifile= FALSE; @@ -162,6 +180,9 @@ int get_mysql_service_properties(const wchar_t *bin_path, goto end; } + /* Last parameter is the service name*/ + wcstombs(service_name, args[numargs-1], MAX_PATH); + if(have_inifile && wcsncmp(args[1], L"--defaults-file=", 16) != 0) goto end; @@ -193,8 +214,8 @@ int get_mysql_service_properties(const wchar_t *bin_path, normalize_path(props->inifile, MAX_PATH); if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES) { - GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir, MAX_PATH, - props->inifile); + get_datadir_from_ini(props->inifile, service_name, props->datadir, + sizeof(props->datadir)); } else { @@ -243,8 +264,8 @@ int get_mysql_service_properties(const wchar_t *bin_path, if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES) { /* Ini file found, get datadir from there */ - GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir, - MAX_PATH, props->inifile); + get_datadir_from_ini(props->inifile, service_name, props->datadir, + sizeof(props->datadir)); } else { |