summaryrefslogtreecommitdiff
path: root/sql/winservice.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-04 07:55:16 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-04 07:55:16 +0300
commit9a7948e3f6d3fd7528e49f43eb4d41f8f55c8a35 (patch)
tree68f8e54f6c2484dc7791bee8c594d3d07c611d29 /sql/winservice.c
parent56990b18d914b8150c9f777d134724d2b3390360 (diff)
parentbbd70fcc43cc889e4593594ee5ca436fe1433aac (diff)
downloadmariadb-git-9a7948e3f6d3fd7528e49f43eb4d41f8f55c8a35.tar.gz
Merge 10.5 into 10.6
Diffstat (limited to 'sql/winservice.c')
-rw-r--r--sql/winservice.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/sql/winservice.c b/sql/winservice.c
index 44e9302e3d3..a11087e5cd5 100644
--- a/sql/winservice.c
+++ b/sql/winservice.c
@@ -116,6 +116,24 @@ 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,
+ (DWORD) 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 +153,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;
@@ -163,6 +182,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;
@@ -195,8 +217,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
{
@@ -245,8 +267,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
{