diff svr-authpubkeyoptions.c @ 566:b321aeb57c64

- set $SSH_ORIGINAL_COMMAND if a command is forced, and log it if LOG_COMMANDS is set
author Matt Johnston <matt@ucc.asn.au>
date Wed, 26 Aug 2009 14:09:22 +0000
parents 43bbe17d6ba0
children a98a2138364a
line wrap: on
line diff
--- a/svr-authpubkeyoptions.c	Tue Aug 25 11:11:35 2009 +0000
+++ b/svr-authpubkeyoptions.c	Wed Aug 26 14:09:22 2009 +0000
@@ -88,10 +88,20 @@
 	return 1;
 }
 
-/* Set chansession command to the one forced by 'command' public key option */
+/* Set chansession command to the one forced 
+ * by any 'command' public key option. */
 void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
-	if (ses.authstate.pubkey_options)
+	if (ses.authstate.pubkey_options) {
+		ses.authstate.pubkey_options->original_command = chansess->cmd;
+		if (!chansess->cmd)
+		{
+			ses.authstate.pubkey_options->original_command = m_strdup("");
+		}
 		chansess->cmd = ses.authstate.pubkey_options->forced_command;
+#ifdef LOG_COMMANDS
+		dropbear_log(LOG_INFO, "command forced to '%s'", ses.authstate.pubkey_options->original_command);
+#endif
+	}
 }
 
 /* Free potential public key options */
@@ -124,7 +134,6 @@
 	TRACE(("enter addpubkeyoptions"))
 
 	ses.authstate.pubkey_options = (struct PubKeyOptions*)m_malloc(sizeof( struct PubKeyOptions ));
-	memset(ses.authstate.pubkey_options, '\0', sizeof(*ses.authstate.pubkey_options));
 
 	buf_setpos(options_buf, 0);
 	while (options_buf->pos < options_buf->len) {