summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/readconf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2011-05-06 21:31:39 +0000
committerDamien Miller <djm@cvs.openbsd.org>2011-05-06 21:31:39 +0000
commitdee1c204721a0d2467af0b9b46d6dec8b06dd515 (patch)
treea0cc8b64df2ec8ef97e7da3b13fdc5a7ba1b42c7 /usr.bin/ssh/readconf.c
parent16c21d6b9cfc035d737ccce9c93fb37c581b5af0 (diff)
support negated Host matching, e.g.
Host *.example.org !c.example.org User mekmitasdigoat Will match "a.example.org", "b.example.org", but not "c.example.org" ok markus@
Diffstat (limited to 'usr.bin/ssh/readconf.c')
-rw-r--r--usr.bin/ssh/readconf.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c
index 6a9d176cd80..1f9ecee2f6c 100644
--- a/usr.bin/ssh/readconf.c
+++ b/usr.bin/ssh/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.190 2010/11/13 23:27:50 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.191 2011/05/06 21:31:38 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -350,7 +350,7 @@ process_config_line(Options *options, const char *host,
int *activep)
{
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2, fwdarg[256];
- int opcode, *intptr, value, value2, scale;
+ int negated, opcode, *intptr, value, value2, scale;
LogLevel *log_level_ptr;
long long orig, val64;
size_t len;
@@ -789,12 +789,28 @@ parse_int:
case oHost:
*activep = 0;
- while ((arg = strdelim(&s)) != NULL && *arg != '\0')
+ arg2 = NULL;
+ while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
+ negated = *arg == '!';
+ if (negated)
+ arg++;
if (match_pattern(host, arg)) {
- debug("Applying options for %.100s", arg);
+ if (negated) {
+ debug("%.200s line %d: Skipping Host "
+ "block because of negated match "
+ "for %.100s", filename, linenum,
+ arg);
+ *activep = 0;
+ break;
+ }
+ if (!*activep)
+ arg2 = arg; /* logged below */
*activep = 1;
- break;
}
+ }
+ if (*activep)
+ debug("%.200s line %d: Applying options for %.100s",
+ filename, linenum, arg2);
/* Avoid garbage check below, as strdelim is done. */
return 0;