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:
@ -35,13 +35,13 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *keyfile;
|
const char *keyfile;
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
keyfile = "/var/lib/maxscale/";
|
keyfile = get_datadir();
|
||||||
fprintf(stderr, "Generating .secrets file in /var/lib/maxscale/ ...\n");
|
fprintf(stderr, "Generating .secrets file in %s ...\n", keyfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -68,7 +68,15 @@ secrets_readKeys(const char* path)
|
|||||||
|
|
||||||
if (path != NULL)
|
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);
|
clean_up_pathname(secret_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -201,6 +209,14 @@ secrets_readKeys(const char* path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ss_dassert(keys != 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;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user