View | Details | Raw Unified | Return to bug 1285 | Differences between
and this patch

Collapse All | Expand All

(-)a/readconf.c (+40 lines)
Lines 684-689 match_cfg_line(Options *options, char **condition, struct passwd *pw, Link Here
684
	return result;
684
	return result;
685
}
685
}
686
686
687
/* Remove environment variable by pattern */
688
static void
689
rm_env(Options *options, const char *arg, const char *filename, int linenum)
690
{
691
	int i, j;
692
	char *cp;
693
694
	/* Remove an environment variable */
695
	for (i = 0; i < options->num_send_env; ) {
696
		cp = xstrdup(options->send_env[i]);
697
		if (strchr(cp, '=') != NULL) {
698
			fatal("%s line %d: environment variable to "
699
			    "remove contains '='", filename, linenum)
700
		}
701
		cp[strcspn(cp, "=")] = '\0';
702
		if (!match_pattern(cp, arg + 1)) {
703
			free(cp);
704
			i++;
705
			continue;
706
		}
707
		debug3("%s line %d: removing environment %s",
708
		    filename, linenum, cp);
709
		free(cp);
710
		free(options->send_env[i]);
711
		options->send_env[i] = NULL;
712
		for (j = i; j < options->num_send_env - 1; j++) {
713
			options->send_env[j] = options->send_env[j + 1];
714
			options->send_env[j + 1] = NULL;
715
		}
716
		options->num_send_env--;
717
		/* NB. don't increment i */
718
	}
719
}
720
687
/*
721
/*
688
 * Returns the number of the token pointed to by cp or oBadOption.
722
 * Returns the number of the token pointed to by cp or oBadOption.
689
 */
723
 */
Lines 1354-1359 parse_keytypes: Link Here
1354
1388
1355
	case oSendEnv:
1389
	case oSendEnv:
1356
		while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
1390
		while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
1391
			if (*arg == '-') {
1392
				/* Removing an env var */
1393
				rm_env(options, arg, filename, linenum);
1394
				continue;
1395
			}
1396
			/* Adding an env var */
1357
			if (strchr(arg, '=') != NULL)
1397
			if (strchr(arg, '=') != NULL)
1358
				fatal("%s line %d: Invalid environment name.",
1398
				fatal("%s line %d: Invalid environment name.",
1359
				    filename, linenum);
1399
				    filename, linenum);
(-)a/ssh_config.5 (-4 / +9 lines)
Lines 1394-1404 Multiple environment variables may be separated by whitespace or spread Link Here
1394
across multiple
1394
across multiple
1395
.Cm SendEnv
1395
.Cm SendEnv
1396
directives.
1396
directives.
1397
.Pp
1398
See
1399
.Sx PATTERNS
1400
for more information on patterns.
1401
.Pp
1402
It is possible to clear previously-set
1403
.Cm SendEnv
1404
variable names by prefixing patterns with
1405
.Pa - .
1397
The default is not to send any environment variables.
1406
The default is not to send any environment variables.
1398
.Pp
1399
See
1400
.Sx PATTERNS
1401
for more information on patterns.
1402
.It Cm ServerAliveCountMax
1407
.It Cm ServerAliveCountMax
1403
Sets the number of server alive messages (see below) which may be
1408
Sets the number of server alive messages (see below) which may be
1404
sent without
1409
sent without

Return to bug 1285