[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

retrieving the exec command


Bonjour Milo,

Ca va?

Once the SSH_CHANNEL_REQUEST_EXEC message is retrieved by the server
how do I retrieve the command to be executed? Directly accessing the
ssh_message struct is probably not a good idea and also produces the
"Dereferencing pointer to incomplete type" error.

I think there should be a function within libssh similar for functions
to retrieve the X11 auth_cookie etc. I've made changes to the libssh
code I cloned from your tree and it seems to work fine, however I am
not sure if there is already a mechanism in libssh that I have not
discovered. I'm attaching the patch as to what I've done.

Would appreciate if you could let me know if this works or what I
should use instead.

Thanks,
Jeetu
diff --git a/include/libssh/server.h b/include/libssh/server.h
index cb12c13..29d57ed 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -349,6 +349,8 @@ LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel,
                                                 const void *data,
                                                 uint32_t len);
 
+LIBSSH_API const char *ssh_message_channel_request_exec_command(ssh_message msg);
+
 /* deprecated functions */
 SSH_DEPRECATED LIBSSH_API int ssh_accept(ssh_session session);
 SSH_DEPRECATED LIBSSH_API int channel_write_stderr(ssh_channel channel,
diff --git a/src/server.c b/src/server.c
index 48c7716..8f3a4b1 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1025,6 +1025,10 @@ int ssh_message_global_request_port(ssh_message msg){
     return msg->global_request.bind_port;
 }
 
+const char *ssh_message_channel_request_exec_command(ssh_message msg){
+    return msg->channel_request.command;
+}
+
 /** @brief defines the ssh_message callback
  * @param session the current ssh session
  * @param[in] ssh_bind_message_callback a function pointer to a callback taking the

Archive administrator: postmaster@lists.cynapses.org