trivial patch to post overridden command into env
Markus Friedl
markus.friedl at informatik.uni-erlangen.de
Tue Sep 5 05:24:36 EST 2000
On Mon, Sep 04, 2000 at 12:14:53PM -0400, Bennett Todd wrote:
> command="whatever" to force a specific command, and also (b) the
> invoker specified some command on their ssh cmdline, then the
> invoked command will be posted into the $command environment
> variable.
thanks, i forgot about this. in ssh-1.2.27 and friends the
command is stored in $SSH_ORIGINAL_COMMAND. this behaviour
will be in the next release (2.3.0)
-markus
> diff -ruN openssh-2.2.0p1.orig/session.c openssh-2.2.0p1/session.c
> --- openssh-2.2.0p1.orig/session.c Tue Aug 29 18:21:22 2000
> +++ openssh-2.2.0p1/session.c Mon Sep 4 11:47:10 2000
> @@ -125,6 +125,8 @@
> static login_cap_t *lc;
> #endif
>
> +static char *saved_command = 0;
> +
> /*
> * Remove local Xauthority file.
> */
> @@ -377,8 +379,11 @@
> packet_integrity_check(plen, 0, type);
> }
> if (forced_command != NULL) {
> + saved_command = command;
> command = forced_command;
> debug("Forced command '%.500s'", forced_command);
> + } else {
> + saved_command = NULL;
> }
> if (have_pty)
> do_exec_pty(s, command, pw);
> @@ -1042,6 +1047,9 @@
> env = xmalloc(envsize * sizeof(char *));
> env[0] = NULL;
>
> + if (saved_command) {
> + child_set_env(&env, &envsize, "command", saved_command);
> + }
> if (!options.use_login) {
> /* Set basic environment. */
> child_set_env(&env, &envsize, "USER", pw->pw_name);
More information about the openssh-unix-dev
mailing list