Improvements on pathname handling of maxkeys and maxpasswd

The default pathname for maxkeys was a hardcoded value and it didn't use
the default directory location functions. If encrypted passwords were used
nothing was written into the log.
This commit is contained in:
Markus Makela
2016-02-25 11:25:06 +02:00
parent 8ebc887e1d
commit 955187d9fa
2 changed files with 20 additions and 4 deletions

View File

@ -68,7 +68,15 @@ secrets_readKeys(const char* path)
if (path != NULL)
{
snprintf(secret_file, PATH_MAX, "%s/.secrets", path);
snprintf(secret_file, PATH_MAX, "%s", path);
char *file;
if ((file = strrchr(secret_file, '.')) == NULL || strcmp(file, ".secrets") != 0)
{
/** This is a possible path to a directory */
strncat(secret_file, "/.secrets", PATH_MAX);
}
clean_up_pathname(secret_file);
}
else
@ -201,6 +209,14 @@ secrets_readKeys(const char* path)
return NULL;
}
ss_dassert(keys != NULL);
/** Successfully loaded keys, log notification */
if (!reported)
{
MXS_NOTICE("Using encrypted passwords. Encryption key: '%s'.", secret_file);
reported = 1;
}
return keys;
}