Skip to content

Commit

Permalink
utils: make pg_util_ssh printf-like
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Jutteau <[email protected]>
  • Loading branch information
jerome-jutteau committed Feb 9, 2017
1 parent dc590f8 commit d800fdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/utils/qemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ int pg_util_cmdloop(const char *cmd, int timeout_s)
int pg_util_ssh(const char *host,
int port,
const char *key_path,
const char *cmd)
const char *cmd, ...)
{
gchar *ssh_cmd;
gint status;
va_list args;
char *c;

va_start(args, cmd);
c = g_strdup_vprintf(cmd, args);
va_end(args);

ssh_cmd = g_strdup_printf("%s%s%s%s%s%s%u%s%s%s",
"ssh ", host, " -l root -q",
" -i ", key_path,
" -p ", port,
" -oConnectTimeout=1",
" -oStrictHostKeyChecking=no ", cmd);
" -oStrictHostKeyChecking=no ", c);
g_spawn_command_line_sync(ssh_cmd, NULL, NULL, &status, NULL);
g_free(ssh_cmd);
g_free(c);
return g_spawn_check_exit_status(status, NULL) ? 0 : -1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ int pg_util_cmdloop(const char *cmd, int timeout_s);
int pg_util_ssh(const char *host,
int port,
const char *key_path,
const char *cmd);
const char *cmd, ...)
__attribute__((__format__(__printf__, 4, 5)));

int pg_util_spawn_qemu(const char *socket_path_0,
const char *socket_path_1,
Expand Down

0 comments on commit d800fdc

Please sign in to comment.