-/* $OpenBSD: clientloop.c,v 1.422 2026/03/05 05:40:35 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.423 2026/04/19 23:37:22 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
{
size_t i, j, len;
int matched, r;
- char *name, *val;
+ char *type = NULL, *cmdstring = NULL, *name, *val;
Channel *c = NULL;
debug2_f("id %d", id);
len = sshbuf_len(cmd);
if (len > 0) {
+ if ((cmdstring = sshbuf_dup_string(cmd)) == NULL)
+ fatal_f("sshbuf_dup_string failed");
if (len > 900)
len = 900;
if (want_subsystem) {
- debug("Sending subsystem: %.*s",
- (int)len, (const u_char*)sshbuf_ptr(cmd));
+ debug("Sending subsystem: %.*s", (int)len, cmdstring);
channel_request_start(ssh, id, "subsystem", 1);
client_expect_confirm(ssh, id, "subsystem",
CONFIRM_CLOSE);
+ xasprintf(&type, "session:subsystem:%s", cmdstring);
} else {
- debug("Sending command: %.*s",
- (int)len, (const u_char*)sshbuf_ptr(cmd));
+ debug("Sending command: %.*s", (int)len, cmdstring);
channel_request_start(ssh, id, "exec", 1);
client_expect_confirm(ssh, id, "exec", CONFIRM_CLOSE);
+ xasprintf(&type, "session:command");
}
if ((r = sshpkt_put_stringb(ssh, cmd)) != 0 ||
(r = sshpkt_send(ssh)) != 0)
client_expect_confirm(ssh, id, "shell", CONFIRM_CLOSE);
if ((r = sshpkt_send(ssh)) != 0)
fatal_fr(r, "send shell");
+ xasprintf(&type, "session:shell");
}
+ channel_set_xtype(ssh, id, type);
+ free(cmdstring);
+ free(type);
session_setup_complete = 1;
client_repledge();