mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 03:00:26 +09:00
tests/pkd: input test payload buffer
Move the pkd test payload buffer into the arguments struct, to make way for parameterizing the payload using command-line options. Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
104c696bca
commit
410f100968
@@ -368,9 +368,9 @@ static int pkd_exec_hello(int fd, struct pkd_daemon_args *args)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_channel_write(c, "hello\n", 6); /* XXX: customizable payloads */
|
rc = ssh_channel_write(c, args->payload.buf, args->payload.len);
|
||||||
if (rc != 6) {
|
if (rc != args->payload.len) {
|
||||||
pkderr("ssh_channel_write partial (%d)\n", rc);
|
pkderr("ssh_channel_write partial (%d != %zd)\n", rc, args->payload.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_channel_request_send_exit_status(c, 0);
|
rc = ssh_channel_request_send_exit_status(c, 0);
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ struct pkd_daemon_args {
|
|||||||
enum pkd_hostkey_type_e type;
|
enum pkd_hostkey_type_e type;
|
||||||
const char *hostkeypath;
|
const char *hostkeypath;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const uint8_t *buf;
|
||||||
|
size_t len;
|
||||||
|
} payload;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int list;
|
int list;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,12 @@
|
|||||||
#define DEFAULT_ITERATIONS 10
|
#define DEFAULT_ITERATIONS 10
|
||||||
static struct pkd_daemon_args pkd_dargs;
|
static struct pkd_daemon_args pkd_dargs;
|
||||||
|
|
||||||
|
static uint8_t default_payload_buf[] = {
|
||||||
|
'h', 'e', 'l', 'l', 'o', '\n',
|
||||||
|
};
|
||||||
|
|
||||||
|
static size_t default_payload_len = sizeof(default_payload_buf);
|
||||||
|
|
||||||
#ifdef HAVE_ARGP_H
|
#ifdef HAVE_ARGP_H
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#define PROGNAME "pkd_hello"
|
#define PROGNAME "pkd_hello"
|
||||||
@@ -957,6 +963,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
unsetenv("SSH_AUTH_SOCK");
|
unsetenv("SSH_AUTH_SOCK");
|
||||||
|
|
||||||
|
pkd_dargs.payload.buf = default_payload_buf;
|
||||||
|
pkd_dargs.payload.len = default_payload_len;
|
||||||
|
|
||||||
rc = ssh_init();
|
rc = ssh_init();
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
rc = SSH_ERROR;
|
rc = SSH_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user