From: Andre Noll Date: Mon, 23 Jul 2012 17:07:07 +0000 (+0200) Subject: Reject non-sideband connections. X-Git-Tag: v0.5.0~10^2~5 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=36ba180901dd97003208ee6c51b0795cf351cb03;p=paraslash.git Reject non-sideband connections. This makes the client abort the connection if the server does not support sideband. Conversely, the server closes the socket if the client did not request a sideband connection. This breaks compatibility with earlier versions of para_server and para_client but allows to clean up the code considerably. --- diff --git a/client_common.c b/client_common.c index 7bdb4738..a3a471ae 100644 --- a/client_common.c +++ b/client_common.c @@ -345,6 +345,11 @@ static void client_post_select(struct sched *s, struct task *t) if (ret < 0 || n == 0) goto out; ct->features = parse_features(buf); + if (!has_feature("sideband", ct)) { + PARA_ERROR_LOG("server has no sideband support\n"); + ret = -E_INCOMPAT_FEAT; + goto out; + } ct->status = CL_RECEIVED_WELCOME; return; case CL_RECEIVED_WELCOME: /* send auth command */ diff --git a/command.c b/command.c index 39470fa9..9b279f7d 100644 --- a/command.c +++ b/command.c @@ -904,6 +904,11 @@ static int parse_auth_request(char *buf, int len, struct user **u, } } } + if (*use_sideband == false) { /* sideband is mandatory */ + PARA_ERROR_LOG("client did not request sideband\n"); + ret = -E_BAD_FEATURE; + goto out; + } PARA_DEBUG_LOG("received auth request for user %s (sideband = %s)\n", username, *use_sideband? "true" : "false"); *u = lookup_user(username); diff --git a/error.h b/error.h index ca172cb4..844c0045 100644 --- a/error.h +++ b/error.h @@ -289,6 +289,7 @@ extern const char **para_errlist[]; PARA_ERROR(SERVER_EOF, "connection closed by para_server"), \ PARA_ERROR(SERVER_CMD_SUCCESS, "command terminated successfully"), \ PARA_ERROR(SERVER_CMD_FAILURE, "command failed"), \ + PARA_ERROR(INCOMPAT_FEAT, "client/server incompatibility"), \ #define SCHED_ERRORS \ @@ -463,7 +464,7 @@ extern const char **para_errlist[]; PARA_ERROR(SENDER_CMD, "command not supported by this sender"), \ PARA_ERROR(SERVER_CRASH, "para_server crashed -- can not live without it"), \ PARA_ERROR(BAD_USER, "auth request for invalid user"), \ - PARA_ERROR(BAD_FEATURE, "request for unknown or invalid feature"), \ + PARA_ERROR(BAD_FEATURE, "invalid feature request"), \ PARA_ERROR(BAD_AUTH, "authentication failure"), \