assert(cc);
if (!result->size)
return 1;
- if (cc->use_sideband)
- return send_sb(&cc->scc, result->data, result->size, band,
- true);
- return sc_send_bin_buffer(&cc->scc, result->data, result->size);
+ return send_sb(&cc->scc, result->data, result->size, band, true);
}
int com_select(struct command_context *cc)
}
ret = send_callback_request(create_tables_callback, &query,
afs_cb_result_handler, cc);
- if (ret < 0 && !cc->use_sideband)
- /* ignore return value */
- sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret));
return ret;
}
ret = 1;
if (pb && (pad->flags & ADD_FLAG_LAZY)) { /* lazy is really cheap */
if (pad->flags & ADD_FLAG_VERBOSE)
- send_ret = pad->cc->use_sideband?
- send_sb_va(&pad->cc->scc, SBD_OUTPUT,
- "lazy-ignore: %s\n", path)
- :
- sc_send_va_buffer(&pad->cc->scc,
- "lazy-ignore: %s\n", path);
+ send_ret = send_sb_va(&pad->cc->scc, SBD_OUTPUT,
+ "lazy-ignore: %s\n", path);
goto out_free;
}
/* We still want to add this file. Compute its hash. */
ret = 1;
if (pb && hs && hs == pb && !(pad->flags & ADD_FLAG_FORCE)) {
if (pad->flags & ADD_FLAG_VERBOSE)
- send_ret = pad->cc->use_sideband?
- send_sb_va(&pad->cc->scc, SBD_OUTPUT,
- "%s exists, not forcing update\n", path)
- :
- sc_send_va_buffer(&pad->cc->scc,
- "%s exists, not forcing update\n", path);
+ send_ret = send_sb_va(&pad->cc->scc, SBD_OUTPUT,
+ "%s exists, not forcing update\n", path);
goto out_unmap;
}
/*
munmap(map.data, map.size);
close(fd);
if (pad->flags & ADD_FLAG_VERBOSE) {
- send_ret = pad->cc->use_sideband?
- send_sb_va(&pad->cc->scc, SBD_OUTPUT,
- "adding %s\n", path)
- :
- sc_send_va_buffer(&pad->cc->scc,
- "adding %s\n", path);
+ send_ret = send_sb_va(&pad->cc->scc, SBD_OUTPUT,
+ "adding %s\n", path);
if (send_ret < 0)
goto out_free;
}
munmap(map.data, map.size);
out_free:
if (ret < 0 && send_ret >= 0)
- send_ret = pad->cc->use_sideband?
- send_sb_va(&pad->cc->scc, SBD_ERROR_LOG,
- "failed to add %s (%s)\n", path,
- para_strerror(-ret))
- :
- sc_send_va_buffer(&pad->cc->scc,
- "failed to add %s (%s)\n", path,
- para_strerror(-ret));
+ send_ret = send_sb_va(&pad->cc->scc, SBD_ERROR_LOG,
+ "failed to add %s (%s)\n", path, para_strerror(-ret));
free(obj.data);
clear_afhi(afhi_ptr);
/* Stop adding files only on send errors. */
char *path;
ret = verify_path(cc->argv[i], &path);
if (ret < 0) {
- ret = cc->use_sideband?
- send_sb_va(&cc->scc, SBD_ERROR_LOG, "%s: %s\n",
- cc->argv[i], para_strerror(-ret))
- :
- sc_send_va_buffer(&cc->scc, "%s: %s\n",
+ ret = send_sb_va(&cc->scc, SBD_ERROR_LOG, "%s: %s\n",
cc->argv[i], para_strerror(-ret));
if (ret < 0)
return ret;
}
ret = stat(path, &statbuf);
if (ret < 0) {
- ret = cc->use_sideband?
- send_sb_va(&cc->scc, SBD_ERROR_LOG,
- "failed to stat %s (%s)\n", path,
- strerror(errno))
- :
- sc_send_va_buffer(&cc->scc,
- "failed to stat %s (%s)\n", path,
- strerror(errno));
+ ret = send_sb_va(&cc->scc, SBD_ERROR_LOG,
+ "failed to stat %s (%s)\n", path,
+ strerror(errno));
free(path);
if (ret < 0)
return ret;
else
ret = add_one_audio_file(path, &pad);
if (ret < 0) {
- if (cc->use_sideband)
- send_sb_va(&cc->scc, SBD_OUTPUT, "%s: %s\n", path,
- para_strerror(-ret));
- else
- sc_send_va_buffer(&cc->scc, "%s: %s\n", path,
- para_strerror(-ret));
+ send_sb_va(&cc->scc, SBD_OUTPUT, "%s: %s\n", path,
+ para_strerror(-ret));
free(path);
return ret;
}
if (ret < 0)
send_strerror(cc, -ret);
else if (ret == 0 && cc->argc > 1)
- ret = cc->use_sideband?
- send_sb_va(&cc->scc, SBD_ERROR_LOG, "no matches\n")
- :
- sc_send_va_buffer(&cc->scc, "no matches\n");
+ ret = send_sb_va(&cc->scc, SBD_ERROR_LOG, "no matches\n");
return ret;
}
struct osl_object query, stdin_obj;
int ret;
- if (cc->use_sideband)
- ret = send_sb(&cc->scc, NULL, 0, SBD_AWAITING_DATA, false);
- else
- ret = sc_send_buffer(&cc->scc, AWAITING_DATA_MSG);
+ ret = send_sb(&cc->scc, NULL, 0, SBD_AWAITING_DATA, false);
if (ret < 0)
return ret;
ret = fd2buf(&cc->scc, &stdin_obj);
int status;
/** The file descriptor and the session keys. */
struct stream_cipher_context scc;
- /** True if this connections uses the sideband API. */
- bool use_sideband;
- /** The sideband context, ignored if \a use_sideband is false. */
+ /** The sideband context. */
struct sb_context *sbc;
/** The hash value of the decrypted challenge. */
unsigned char *challenge_hash;
case CL_RECEIVED_WELCOME: /* send auth command */
if (!FD_ISSET(ct->scc.fd, &s->wfds))
return;
- if (has_feature("sideband", ct)) {
- ct->use_sideband = true;
- sprintf(buf, AUTH_REQUEST_MSG "%s sideband", ct->user);
- } else
- sprintf(buf, AUTH_REQUEST_MSG "%s", ct->user);
+ sprintf(buf, AUTH_REQUEST_MSG "%s sideband", ct->user);
PARA_INFO_LOG("--> %s\n", buf);
ret = write_buffer(ct->scc.fd, buf);
if (ret < 0)
{
/* decrypted challenge/session key buffer */
unsigned char crypt_buf[1024];
- /* the SHA1 of the decrypted challenge */
+ struct sb_buffer sbb;
- if (ct->use_sideband) {
- struct sb_buffer sbb;
- ret = recv_sb(ct, &s->rfds, &sbb);
- if (ret <= 0)
- goto out;
- if (sbb.band != SBD_CHALLENGE) {
- ret = -E_BAD_BAND;
- free(sbb.iov.iov_base);
- goto out;
- }
- n = sbb.iov.iov_len;
- PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n);
- ret = priv_decrypt(ct->key_file, crypt_buf,
- sbb.iov.iov_base, n);
+ ret = recv_sb(ct, &s->rfds, &sbb);
+ if (ret <= 0)
+ goto out;
+ if (sbb.band != SBD_CHALLENGE) {
+ ret = -E_BAD_BAND;
free(sbb.iov.iov_base);
- if (ret < 0)
- goto out;
- } else {
- ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
- if (ret < 0 || n == 0)
- goto out;
- PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n);
- ret = priv_decrypt(ct->key_file, crypt_buf,
- (unsigned char *)buf, n);
- if (ret < 0)
goto out;
}
+ n = sbb.iov.iov_len;
+ PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n);
+ ret = priv_decrypt(ct->key_file, crypt_buf,
+ sbb.iov.iov_base, n);
+ free(sbb.iov.iov_base);
+ if (ret < 0)
+ goto out;
ct->challenge_hash = para_malloc(HASH_SIZE);
hash_function((char *)crypt_buf, CHALLENGE_SIZE, ct->challenge_hash);
ct->scc.send = sc_new(crypt_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
return;
}
case CL_RECEIVED_CHALLENGE:
- if (ct->use_sideband) {
- ret = send_sb(ct, ct->challenge_hash, HASH_SIZE,
- SBD_CHALLENGE_RESPONSE, false);
- if (ret != 0)
- ct->challenge_hash = NULL;
- if (ret <= 0)
- goto out;
- } else {
- ret = write_all(ct->scc.fd, (char *)ct->challenge_hash, HASH_SIZE);
- if (ret < 0)
- goto out;
- }
+ ret = send_sb(ct, ct->challenge_hash, HASH_SIZE,
+ SBD_CHALLENGE_RESPONSE, false);
+ if (ret != 0)
+ ct->challenge_hash = NULL;
+ if (ret <= 0)
+ goto out;
ct->status = CL_SENT_CH_RESPONSE;
goto out;
case CL_SENT_CH_RESPONSE: /* read server response */
{
- if (ct->use_sideband) {
- struct sb_buffer sbb;
- ret = recv_sb(ct, &s->rfds, &sbb);
- if (ret <= 0)
- goto out;
- free(sbb.iov.iov_base);
- if (sbb.band != SBD_PROCEED)
- ret = -E_BAD_BAND;
- else
- ct->status = CL_RECEIVED_PROCEED;
- goto out;
- }
- ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
- if (ret < 0 || n == 0)
- goto out;
- /* check if server has sent "Proceed" message */
- ret = -E_CLIENT_AUTH;
- if (n < PROCEED_MSG_LEN)
- goto out;
- if (!strstr(buf, PROCEED_MSG))
+ struct sb_buffer sbb;
+ ret = recv_sb(ct, &s->rfds, &sbb);
+ if (ret <= 0)
goto out;
- ct->status = CL_RECEIVED_PROCEED;
- return;
+ free(sbb.iov.iov_base);
+ if (sbb.band != SBD_PROCEED)
+ ret = -E_BAD_BAND;
+ else
+ ct->status = CL_RECEIVED_PROCEED;
+ goto out;
}
case CL_RECEIVED_PROCEED: /* concat args and send command */
{
- int i;
- char *command = NULL;
if (!FD_ISSET(ct->scc.fd, &s->wfds))
return;
- if (ct->use_sideband) {
- ret = send_sb_command(ct);
- if (ret <= 0)
- goto out;
- ct->status = CL_SENT_COMMAND;
- return;
- }
- for (i = 0; i < ct->conf.inputs_num; i++) {
- char *tmp = command;
- command = make_message("%s\n%s", command?
- command : "", ct->conf.inputs[i]);
- free(tmp);
- }
- command = para_strcat(command, EOC_MSG "\n");
- PARA_DEBUG_LOG("--> %s\n", command);
- ret = sc_send_buffer(&ct->scc, command);
- free(command);
- if (ret < 0)
+ ret = send_sb_command(ct);
+ if (ret <= 0)
goto out;
ct->status = CL_SENT_COMMAND;
return;
}
case CL_SENT_COMMAND:
{
- char *buf2;
- if (ct->use_sideband) {
- struct sb_buffer sbb;
- ret = recv_sb(ct, &s->rfds, &sbb);
- if (ret <= 0)
- goto out;
- if (sbb.band == SBD_AWAITING_DATA) {
- ct->status = CL_SENDING;
- free(sbb.iov.iov_base);
- goto out;
- }
- ct->status = CL_RECEIVING;
- ret = dispatch_sbb(ct, &sbb);
+ struct sb_buffer sbb;
+ ret = recv_sb(ct, &s->rfds, &sbb);
+ if (ret <= 0)
+ goto out;
+ if (sbb.band == SBD_AWAITING_DATA) {
+ ct->status = CL_SENDING;
+ free(sbb.iov.iov_base);
goto out;
}
- /* can not use "buf" here because we need a malloced buffer */
- buf2 = para_malloc(CLIENT_BUFSIZE);
- ret = client_recv_buffer(ct, &s->rfds, buf2, CLIENT_BUFSIZE, &n);
- if (n > 0) {
- if (strstr(buf2, AWAITING_DATA_MSG)) {
- free(buf2);
- ct->status = CL_SENDING;
- return;
- }
- ct->status = CL_RECEIVING;
- btr_add_output(buf2, n, btrn);
- } else
- free(buf2);
+ ct->status = CL_RECEIVING;
+ ret = dispatch_sbb(ct, &sbb);
goto out;
}
case CL_SENDING:
}
case CL_RECEIVING:
{
- char *buf2;
+ struct sb_buffer sbb;
ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
if (ret < 0)
goto out;
*/
if (!FD_ISSET(ct->scc.fd, &s->rfds))
return;
- if (ct->use_sideband) {
- struct sb_buffer sbb;
- ret = recv_sb(ct, &s->rfds, &sbb);
- if (ret > 0)
- ret = dispatch_sbb(ct, &sbb);
- goto out;
- }
- buf2 = para_malloc(CLIENT_BUFSIZE);
- ret = client_recv_buffer(ct, &s->rfds, buf2, CLIENT_BUFSIZE, &n);
- if (n > 0) {
- buf2 = para_realloc(buf2, n);
- btr_add_output(buf2, n, btrn);
- } else
- free(buf2);
+ ret = recv_sb(ct, &s->rfds, &sbb);
+ if (ret > 0)
+ ret = dispatch_sbb(ct, &sbb);
goto out;
}
}
out:
t->error = ret;
- if (ret < 0) {
- if (!ct->use_sideband && ret != -E_SERVER_EOF &&
- ret != -E_BTR_EOF && ret != -E_EOF)
- PARA_ERROR_LOG("%s\n", para_strerror(-t->error));
+ if (ret < 0)
btr_remove_node(&ct->btrn);
- }
}
/**
*/
int send_strerror(struct command_context *cc, int err)
{
- return cc->use_sideband?
- send_sb_va(&cc->scc, SBD_ERROR_LOG, "%s\n", para_strerror(err))
- :
- sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(err));
+ return send_sb_va(&cc->scc, SBD_ERROR_LOG, "%s\n", para_strerror(err));
}
/**
free(msg);
msg = tmp;
}
- if (cc->use_sideband)
- return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
- ret = sc_send_buffer(&cc->scc, msg);
- free(msg);
- return ret;
+ return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
}
ret = check_sender_args(cc->argc, cc->argv, &scd);
if (ret < 0) {
if (scd.sender_num < 0)
return ret;
msg = senders[scd.sender_num].help();
- if (cc->use_sideband)
- return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT,
- false);
- ret = sc_send_buffer(&cc->scc, msg);
- free(msg);
- return ret;
+ return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
}
switch (scd.cmd_num) {
mutex_unlock(mmd_mutex);
free(ut);
free(sender_info);
- if (cc->use_sideband)
- return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
- ret = sc_send_bin_buffer(&cc->scc, msg, ret);
- free(msg);
- return ret;
+ return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
}
/* version */
msg = VERSION_TEXT("server") "built: " BUILD_DATE "\n" UNAME_RS
", " CC_VERSION "\n";
len = strlen(msg);
- if (cc->use_sideband)
- return send_sb(&cc->scc, msg, len, SBD_OUTPUT, true);
- return sc_send_bin_buffer(&cc->scc, msg, len);
+ return send_sb(&cc->scc, msg, len, SBD_OUTPUT, true);
}
#define EMPTY_STATUS_ITEMS \
for (;;) {
mmd_dup(nmmd);
ret = get_status(nmmd, parser_friendly, &s);
- if (cc->use_sideband)
- ret = send_sb(&cc->scc, s, ret, SBD_OUTPUT, false);
- else {
- ret = sc_send_bin_buffer(&cc->scc, s, ret);
- free(s);
- }
+ ret = send_sb(&cc->scc, s, ret, SBD_OUTPUT, false);
if (ret < 0)
goto out;
if (nmmd->vss_status_flags & VSS_NEXT) {
ret = empty_status_items(parser_friendly, &esi);
- if (cc->use_sideband)
- ret = send_sb(&cc->scc, esi, ret, SBD_OUTPUT,
- true);
- else
- ret = sc_send_bin_buffer(&cc->scc, esi, ret);
+ ret = send_sb(&cc->scc, esi, ret, SBD_OUTPUT, true);
if (ret < 0)
goto out;
} else
static int send_list_of_commands(struct command_context *cc, struct server_command *cmd,
const char *handler)
{
- int ret;
char *msg = NULL;
for (; cmd->name; cmd++) {
msg = para_strcat(msg, tmp);
free(tmp);
}
- if (cc->use_sideband)
- return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
- ret = sc_send_buffer(&cc->scc, msg);
- free(msg);
- return ret;
+ return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
}
/* returns string that must be freed by the caller */
);
free(perms);
free(handler);
- if (cc->use_sideband)
- return send_sb(&cc->scc, buf, ret, SBD_OUTPUT, false);
- ret = sc_send_buffer(&cc->scc, buf);
- free(buf);
- return ret;
+ return send_sb(&cc->scc, buf, ret, SBD_OUTPUT, false);
}
/* hup */
return (cmd_ptr->perms & perms) < cmd_ptr->perms ? -E_PERM : 0;
}
-/*
- * Parse first string from *cmd and lookup in table of valid commands.
- * On error, NULL is returned.
- */
-static struct server_command *parse_cmd(const char *cmdstr)
-{
- char buf[255];
- int n = 0;
-
- sscanf(cmdstr, "%200s%n", buf, &n);
- if (!n)
- return NULL;
- buf[n] = '\0';
- return get_cmd_ptr(buf, NULL);
-}
-
-static int read_command(struct stream_cipher_context *scc, char **result)
-{
- int ret;
- char buf[4096];
- char *command = NULL;
-
- for (;;) {
- size_t numbytes;
- char *p;
-
- ret = sc_recv_buffer(scc, buf, sizeof(buf));
- if (ret < 0)
- goto out;
- if (!ret)
- break;
- numbytes = ret;
- ret = -E_COMMAND_SYNTAX;
- if (command && numbytes + strlen(command) > MAX_COMMAND_LEN) /* DOS */
- goto out;
- command = para_strcat(command, buf);
- p = strstr(command, EOC_MSG);
- if (p) {
- *p = '\0';
- break;
- }
- }
- ret = command? 1 : -E_COMMAND_SYNTAX;
-out:
- if (ret < 0)
- free(command);
- else
- *result = command;
- return ret;
-
-}
-
static void reset_signals(void)
{
para_sigaction(SIGCHLD, SIG_IGN);
para_sigaction(SIGHUP, SIG_DFL);
}
-static int parse_auth_request(char *buf, int len, struct user **u,
- bool *use_sideband)
+static int parse_auth_request(char *buf, int len, struct user **u)
{
int ret;
char *p, *username, **features = NULL;
size_t auth_rq_len = strlen(AUTH_REQUEST_MSG);
+ bool sideband_requested = false;
*u = NULL;
- *use_sideband = false;
if (len < auth_rq_len + 2)
return -E_AUTH_REQUEST;
if (strncmp(buf, AUTH_REQUEST_MSG, auth_rq_len) != 0)
create_argv(p, ",", &features);
for (i = 0; features[i]; i++) {
if (strcmp(features[i], "sideband") == 0)
- *use_sideband = true;
+ sideband_requested = true;
else {
ret = -E_BAD_FEATURE;
goto out;
}
}
}
- if (*use_sideband == false) { /* sideband is mandatory */
+ if (sideband_requested == 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");
+ PARA_DEBUG_LOG("received auth request for user %s\n", username);
*u = lookup_user(username);
ret = 1;
out:
char *p, *command = NULL, *buf = para_malloc(HANDSHAKE_BUFSIZE) /* must be on the heap */;
size_t numbytes;
struct command_context cc_struct = {.peer = peername}, *cc = &cc_struct;
+ struct iovec iov;
cc->scc.fd = fd;
reset_signals();
ret = recv_buffer(fd, buf, HANDSHAKE_BUFSIZE);
if (ret < 0)
goto net_err;
- ret = parse_auth_request(buf, ret, &cc->u, &cc->use_sideband);
+ ret = parse_auth_request(buf, ret, &cc->u);
if (ret < 0)
goto net_err;
p = buf + strlen(AUTH_REQUEST_MSG);
}
PARA_DEBUG_LOG("sending %u byte challenge + rc4 keys (%zu bytes)\n",
CHALLENGE_SIZE, numbytes);
- if (cc->use_sideband) {
- struct iovec iov;
- ret = send_sb(&cc->scc, buf, numbytes, SBD_CHALLENGE, false);
- buf = NULL;
- if (ret < 0)
- goto net_err;
- ret = recv_sb(&cc->scc, SBD_CHALLENGE_RESPONSE,
- HANDSHAKE_BUFSIZE, &iov);
- if (ret < 0)
- goto net_err;
- buf = iov.iov_base;
- numbytes = iov.iov_len;
- } else {
- ret = write_all(fd, buf, numbytes);
- if (ret < 0)
- goto net_err;
- /* recv challenge response */
- ret = recv_bin_buffer(fd, buf, HASH_SIZE);
- if (ret < 0)
- goto net_err;
- numbytes = ret;
- }
+ ret = send_sb(&cc->scc, buf, numbytes, SBD_CHALLENGE, false);
+ buf = NULL;
+ if (ret < 0)
+ goto net_err;
+ ret = recv_sb(&cc->scc, SBD_CHALLENGE_RESPONSE,
+ HANDSHAKE_BUFSIZE, &iov);
+ if (ret < 0)
+ goto net_err;
+ buf = iov.iov_base;
+ numbytes = iov.iov_len;
PARA_DEBUG_LOG("received %zu bytes challenge response\n", numbytes);
ret = -E_BAD_USER;
if (!cc->u)
/* init stream cipher keys with the second part of the random buffer */
cc->scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
cc->scc.send = sc_new(rand_buf + CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN);
- if (cc->use_sideband)
- ret = send_sb(&cc->scc, NULL, 0, SBD_PROCEED, false);
- else
- ret = sc_send_buffer(&cc->scc, PROCEED_MSG);
+ ret = send_sb(&cc->scc, NULL, 0, SBD_PROCEED, false);
if (ret < 0)
goto net_err;
- if (cc->use_sideband) {
- struct iovec iov;
- ret = recv_sb(&cc->scc, SBD_COMMAND, MAX_COMMAND_LEN, &iov);
- if (ret < 0)
- goto net_err;
- ret = parse_sb_command(cc, &iov);
- if (ret < 0)
- goto err_out;
- cc->argc = ret;
- } else {
- ret = read_command(&cc->scc, &command);
- if (ret == -E_COMMAND_SYNTAX)
- goto err_out;
- if (ret < 0)
- goto net_err;
- ret = -E_BAD_CMD;
- cc->cmd = parse_cmd(command);
- if (!cc->cmd)
- goto err_out;
- /* valid command, check permissions */
- ret = check_perms(cc->u->perms, cc->cmd);
- if (ret < 0)
- goto err_out;
- /* valid command and sufficient perms */
- ret = create_argv(command, "\n", &cc->argv);
- if (ret < 0)
- goto err_out;
- cc->argc = ret;
- }
+ ret = recv_sb(&cc->scc, SBD_COMMAND, MAX_COMMAND_LEN, &iov);
+ if (ret < 0)
+ goto net_err;
+ ret = parse_sb_command(cc, &iov);
+ if (ret < 0)
+ goto err_out;
+ cc->argc = ret;
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cc->cmd->name,
cc->u->name, peername);
ret = cc->cmd->handler(cc);
if (ret >= 0)
goto out;
err_out:
- if (send_strerror(cc, -ret) >= 0 && cc->use_sideband)
+ if (send_strerror(cc, -ret) >= 0)
send_sb(&cc->scc, NULL, 0, SBD_EXIT__FAILURE, true);
net_err:
PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
mmd->events++;
mmd->active_connections--;
mutex_unlock(mmd_mutex);
- if (ret >= 0 && cc->use_sideband) {
+ if (ret >= 0) {
ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
if (ret < 0)
PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
struct server_command *cmd;
/** File descriptor and crypto keys. */
struct stream_cipher_context scc;
- /** Whether to use the sideband API for this command. */
- bool use_sideband;
};
/**
/** Sent by para_client to initiate the authentication procedure. */
#define AUTH_REQUEST_MSG "auth rsa "
-/** Sent by para_server for commands that expect a data file. */
-#define AWAITING_DATA_MSG "\nAwaiting Data."
-/** Sent by para_server if authentication was successful. */
-#define PROCEED_MSG "Proceed."
-/** Length of the \p PROCEED_MSG string. */
-#define PROCEED_MSG_LEN strlen(PROCEED_MSG)
-/** Sent by para_client to indicate the end of the command line. */
-#define EOC_MSG "\nEnd of Command."
/* exec */
int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds);