summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-07-06 13:51:13 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-07-06 13:51:25 +0200
commitcad9a9b1f8f09a3d7f4597bf1d68bd9c2e0c5879 (patch)
treeddd8af753b334c029673f413966579a1396e0dfe
parent6163af93975d4084580363321e5edfaebfb800cd (diff)
downloadmariadb-git-cad9a9b1f8f09a3d7f4597bf1d68bd9c2e0c5879.tar.gz
MDEV-23098 mariadb-upgrade-service.exe does not work on WAMPServer
While trying to detect datadir, take into account that one can use Windows service name as section name in options file, for Windows service. The historical obscurity is being used by WAMP installations.
-rw-r--r--sql/winservice.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/sql/winservice.c b/sql/winservice.c
index fe1fb0cb2bb..7a7e7616e76 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
{