Maxkeys and maxpasswd now use MAXSCALE_HOME or the default installation directory if MAXSCALE_HOME is not set.
If all else fails, /tmp/ is used for logging.
This commit is contained in:
Markus Makela 2015-03-30 20:42:18 +03:00
parent 3a0807251c
commit 97a6bd1b4b
3 changed files with 82 additions and 3 deletions

View File

@ -826,6 +826,7 @@ static bool file_is_readable(
absolute_pathname,
eno,
strerror(eno))));
LOGIF(LE,(skygw_log_sync_all()));
succp = false;
}
return succp;

View File

@ -29,19 +29,60 @@
*/
#include <stdio.h>
#include <secrets.h>
#include <skygw_utils.h>
#include <log_manager.h>
int main(int argc, char **argv)
{
int arg_count = 3;
char *home;
char** arg_vector;
if (argc != 2)
{
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
exit(1);
}
arg_vector = malloc(sizeof(char*)*4);
if(arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation failed.\n");
return 1;
}
arg_vector[0] = strdup("logmanager");
arg_vector[1] = strdup("-j");
if ((home = getenv("MAXSCALE_HOME")) != NULL)
{
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
sprintf(arg_vector[2],"%s/log",home);
}
else
{
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
}
arg_vector[3] = NULL;
skygw_logmanager_init(arg_count,arg_vector);
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOGFILE_DEBUG);
free(arg_vector[0]);
free(arg_vector[1]);
free(arg_vector[2]);
free(arg_vector);
if (secrets_writeKeys(argv[1]))
{
fprintf(stderr, "Failed to encode the password\n");
exit(1);
}
exit(0);
skygw_log_sync_all();
skygw_logmanager_done();
return 0;
}

View File

@ -29,7 +29,8 @@
*/
#include <stdio.h>
#include <secrets.h>
#include <skygw_utils.h>
#include <log_manager.h>
/**
* Encrypt a password for storing in the MaxScale.cnf file
*
@ -40,12 +41,46 @@ int
main(int argc, char **argv)
{
char *enc, *pw;
int arg_count = 3;
char *home;
char** arg_vector;
if (argc != 2)
{
fprintf(stderr, "Usage: %s <password>\n", argv[0]);
exit(1);
}
arg_vector = malloc(sizeof(char*)*4);
if(arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation failed.\n");
return 1;
}
arg_vector[0] = strdup("logmanager");
arg_vector[1] = strdup("-j");
if ((home = getenv("MAXSCALE_HOME")) != NULL)
{
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
sprintf(arg_vector[2],"%s/log",home);
}
else
{
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
}
arg_vector[3] = NULL;
skygw_logmanager_init(arg_count,arg_vector);
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOGFILE_DEBUG);
free(arg_vector[0]);
free(arg_vector[1]);
free(arg_vector[2]);
free(arg_vector);
pw = calloc(81,sizeof(char));
@ -63,5 +98,7 @@ main(int argc, char **argv)
}
free(pw);
skygw_log_sync_all();
skygw_logmanager_done();
return 0;
}