summaryrefslogtreecommitdiffstats
path: root/usr.sbin/hoststatectl/parser.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2006-12-16 18:50:33 +0000
committerreyk <reyk@openbsd.org>2006-12-16 18:50:33 +0000
commitef1f233472e12ac307e3057a88d06b3a7752d3c0 (patch)
tree743de263744a3ffad9880af759d2ca72eee52ea6 /usr.sbin/hoststatectl/parser.c
parenttypo (diff)
downloadwireguard-openbsd-ef1f233472e12ac307e3057a88d06b3a7752d3c0.tar.xz
wireguard-openbsd-ef1f233472e12ac307e3057a88d06b3a7752d3c0.zip
- allow to use host/service/table names instead of Ids in hostatectl.
- minor change of the "hostatectl show" command output - increase the max service and tag names (max pf tag name size is 64 now!) thanks to pyr who found a bug in my initial diff
Diffstat (limited to 'usr.sbin/hoststatectl/parser.c')
-rw-r--r--usr.sbin/hoststatectl/parser.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/usr.sbin/hoststatectl/parser.c b/usr.sbin/hoststatectl/parser.c
index 2f535990ed9..43703a6622b 100644
--- a/usr.sbin/hoststatectl/parser.c
+++ b/usr.sbin/hoststatectl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.3 2006/12/16 17:53:03 deraadt Exp $ */
+/* $OpenBSD: parser.c,v 1.4 2006/12/16 18:50:33 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -166,23 +166,29 @@ match_token(const char *word, const struct token table[])
}
break;
case HOSTID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "host id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;
case TABLEID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "table id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;
case SERVICEID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "service id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;