upstream: Allow "SendEnv -PATTERN" to clear environment variables
previously labeled for sendind. bz#1285 ok dtucker@ OpenBSD-Commit-ID: f6fec9e3d0f366f15903094fbe1754cb359a0df9
This commit is contained in:
parent
40f5f03544
commit
555294a727
48
readconf.c
48
readconf.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: readconf.c,v 1.285 2018/04/06 03:51:27 djm Exp $ */
|
/* $OpenBSD: readconf.c,v 1.286 2018/04/06 13:02:39 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -684,6 +684,35 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove environment variable by pattern */
|
||||||
|
static void
|
||||||
|
rm_env(Options *options, const char *arg, const char *filename, int linenum)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
/* Remove an environment variable */
|
||||||
|
for (i = 0; i < options->num_send_env; ) {
|
||||||
|
cp = xstrdup(options->send_env[i]);
|
||||||
|
if (!match_pattern(cp, arg + 1)) {
|
||||||
|
free(cp);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
debug3("%s line %d: removing environment %s",
|
||||||
|
filename, linenum, cp);
|
||||||
|
free(cp);
|
||||||
|
free(options->send_env[i]);
|
||||||
|
options->send_env[i] = NULL;
|
||||||
|
for (j = i; j < options->num_send_env - 1; j++) {
|
||||||
|
options->send_env[j] = options->send_env[j + 1];
|
||||||
|
options->send_env[j + 1] = NULL;
|
||||||
|
}
|
||||||
|
options->num_send_env--;
|
||||||
|
/* NB. don't increment i */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the number of the token pointed to by cp or oBadOption.
|
* Returns the number of the token pointed to by cp or oBadOption.
|
||||||
*/
|
*/
|
||||||
|
@ -1359,11 +1388,18 @@ parse_keytypes:
|
||||||
filename, linenum);
|
filename, linenum);
|
||||||
if (!*activep)
|
if (!*activep)
|
||||||
continue;
|
continue;
|
||||||
if (options->num_send_env >= MAX_SEND_ENV)
|
if (*arg == '-') {
|
||||||
fatal("%s line %d: too many send env.",
|
/* Removing an env var */
|
||||||
filename, linenum);
|
rm_env(options, arg, filename, linenum);
|
||||||
options->send_env[options->num_send_env++] =
|
continue;
|
||||||
xstrdup(arg);
|
} else {
|
||||||
|
/* Adding an env var */
|
||||||
|
if (options->num_send_env >= MAX_SEND_ENV)
|
||||||
|
fatal("%s line %d: too many send env.",
|
||||||
|
filename, linenum);
|
||||||
|
options->send_env[options->num_send_env++] =
|
||||||
|
xstrdup(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
11
ssh_config.5
11
ssh_config.5
|
@ -33,8 +33,8 @@
|
||||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" $OpenBSD: ssh_config.5,v 1.270 2018/04/05 22:54:28 djm Exp $
|
.\" $OpenBSD: ssh_config.5,v 1.271 2018/04/06 13:02:39 djm Exp $
|
||||||
.Dd $Mdocdate: April 5 2018 $
|
.Dd $Mdocdate: April 6 2018 $
|
||||||
.Dt SSH_CONFIG 5
|
.Dt SSH_CONFIG 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -1394,11 +1394,16 @@ Multiple environment variables may be separated by whitespace or spread
|
||||||
across multiple
|
across multiple
|
||||||
.Cm SendEnv
|
.Cm SendEnv
|
||||||
directives.
|
directives.
|
||||||
The default is not to send any environment variables.
|
|
||||||
.Pp
|
.Pp
|
||||||
See
|
See
|
||||||
.Sx PATTERNS
|
.Sx PATTERNS
|
||||||
for more information on patterns.
|
for more information on patterns.
|
||||||
|
.Pp
|
||||||
|
It is possible to clear previously-set
|
||||||
|
.Cm SendEnv
|
||||||
|
variable names by prefixing patterns with
|
||||||
|
.Pa - .
|
||||||
|
The default is not to send any environment variables.
|
||||||
.It Cm ServerAliveCountMax
|
.It Cm ServerAliveCountMax
|
||||||
Sets the number of server alive messages (see below) which may be
|
Sets the number of server alive messages (see below) which may be
|
||||||
sent without
|
sent without
|
||||||
|
|
Loading…
Reference in New Issue