From 684e2e153f013dd0a71581e027dc07812f59fedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 30 May 2017 13:51:06 +0300 Subject: [PATCH] MXS-1277: Improve maxadmin error messages Maxadmin now reports if the default socket was found and suggests actions to take. --- client/maxadmin.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/maxadmin.c b/client/maxadmin.c index 9bfafd577..42333959d 100644 --- a/client/maxadmin.c +++ b/client/maxadmin.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -264,6 +265,11 @@ main(int argc, char **argv) if ((so = connectUsingInetSocket(hostname, port, user, passwd)) == -1) { + if (access(MAXADMIN_DEFAULT_SOCKET, R_OK) == 0) + { + fprintf(stderr, "Found default MaxAdmin socket in: %s\n", MAXADMIN_DEFAULT_SOCKET); + fprintf(stderr, "Try connecting with:\n\n\tmaxadmin -S %s\n\n", MAXADMIN_DEFAULT_SOCKET); + } exit(EXIT_FAILURE); } } @@ -616,7 +622,13 @@ authUnixSocket(int so) if (!authenticated) { - fprintf(stderr, "Could connect to MaxScale, but was not authorized.\n"); + uid_t id = geteuid(); + struct passwd* pw = getpwuid(id); + fprintf(stderr, "Could connect to MaxScale, but was not authorized.\n" + "Check that the current user is added to the list of allowed users.\n" + "To add this user to the list, execute:\n\n" + "\tsudo maxadmin enable account %s\n\n" + "This assumes that the root user account is enabled in MaxScale.\n", pw->pw_name); } return authenticated;