|
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); |