diff svr-chansession.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 52d7301e46bd
children 893a9dd0b9dd
line wrap: on
line diff
--- a/svr-chansession.c	Tue Aug 25 11:11:35 2009 +0000
+++ b/svr-chansession.c	Wed Aug 26 14:09:22 2009 +0000
@@ -578,6 +578,7 @@
 		int iscmd, int issubsys) {
 
 	unsigned int cmdlen;
+	int is_forced;
 	int ret;
 
 	TRACE(("enter sessioncommand"))
@@ -589,9 +590,6 @@
 		return DROPBEAR_FAILURE;
 	}
 
-	/* take public key option 'command' into account */
-	svr_pubkey_set_forced_command(chansess);
-
 	if (iscmd) {
 		/* "exec" */
 		if (chansess->cmd == NULL) {
@@ -616,6 +614,9 @@
 			}
 		}
 	}
+	
+	/* take public key option 'command' into account */
+	svr_pubkey_set_forced_command(chansess);
 
 #ifdef LOG_COMMANDS
 	if (chansess->cmd) {
@@ -883,6 +884,17 @@
 		addnewvar("TERM", chansess->term);
 	}
 
+	printf("adding option %p %s\n", ses.authstate.pubkey_options,
+			ses.authstate.pubkey_options->original_command);
+
+#ifdef ENABLE_SVR_PUBKEY_OPTIONS
+	if (ses.authstate.pubkey_options &&
+			ses.authstate.pubkey_options->original_command) {
+		addnewvar("SSH_ORIGINAL_COMMAND", 
+			ses.authstate.pubkey_options->original_command);
+	}
+#endif
+
 	/* change directory */
 	if (chdir(ses.authstate.pw_dir) < 0) {
 		dropbear_exit("error changing directory");