summaryrefslogtreecommitdiff
path: root/usr.sbin/hoststated/parse.y
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-11-21 13:04:43 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-11-21 13:04:43 +0000
commit5d26d48cabb053e50519583e074292f3c86aecac (patch)
tree4b23ce6256f2f600c9aaa411981bb1b1373e7cc2 /usr.sbin/hoststated/parse.y
parent58a45bd3fc8545f2f426bf7208337a15505fabdb (diff)
allow the http digest type to be either SHA1 or MD5 determined by the
digest string length; it is compatible to any existing SHA1-only configurations. ok pyr@ gilles@
Diffstat (limited to 'usr.sbin/hoststated/parse.y')
-rw-r--r--usr.sbin/hoststated/parse.y20
1 files changed, 15 insertions, 5 deletions
diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y
index ab4c572e476..e5ddea110a2 100644
--- a/usr.sbin/hoststated/parse.y
+++ b/usr.sbin/hoststated/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.87 2007/11/20 17:08:44 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.88 2007/11/21 13:04:42 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -523,6 +523,8 @@ tableoptsl : host {
table->sendbuf_len = strlen(table->sendbuf);
}
| CHECK http_type STRING hostname DIGEST STRING {
+ size_t digest_len;
+
if ($2) {
conf->flags |= F_SSL;
table->conf.flags |= F_SSL;
@@ -536,10 +538,18 @@ tableoptsl : host {
if (table->sendbuf == NULL)
fatal("out of memory");
table->sendbuf_len = strlen(table->sendbuf);
- if (strlcpy(table->conf.digest, $6,
- sizeof(table->conf.digest)) >=
- sizeof(table->conf.digest)) {
- yyerror("http digest truncated");
+
+ digest_len = strlcpy(table->conf.digest, $6,
+ sizeof(table->conf.digest));
+ switch (digest_len) {
+ case 40:
+ table->conf.digest_type = DIGEST_SHA1;
+ break;
+ case 32:
+ table->conf.digest_type = DIGEST_MD5;
+ break;
+ default:
+ yyerror("invalid http digest");
free($6);
YYERROR;
}