summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-02-10 05:59:07 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-02-10 05:59:07 +0000
commitfb5d610df4cdbcfb21380f737eb84f8e91fe2cc9 (patch)
tree1dac8a06cd9ece884b12cb92970331801630afd6 /distrib
parent040fcac5496fcb05243ae57288d3169ddfb1dbc1 (diff)
installer bits for RFC 7217 support
OK rpe, tb, naddy, sthen
Diffstat (limited to 'distrib')
-rw-r--r--distrib/miniroot/install.sub5
-rw-r--r--distrib/special/sysctl/sysctl.c50
2 files changed, 53 insertions, 2 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index cfbdc13ebfd..4110cb45a24 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sub,v 1.1058 2018/02/06 22:14:52 sthen Exp $
+# $OpenBSD: install.sub,v 1.1059 2018/02/10 05:59:06 florian Exp $
#
# Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback
# Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org>
@@ -3112,6 +3112,9 @@ do_upgrade() {
THESETS="$THESETS site$VERSION-$(hostname -s).tgz"
export PS1='\h# '
+ _f=/mnt/etc/soii.key
+ [[ ! -f $_f ]] || sysctl net.inet6.ip6.soiikey=$(<$_f)
+
# Configure the network.
enable_network
diff --git a/distrib/special/sysctl/sysctl.c b/distrib/special/sysctl/sysctl.c
index 6f3e333ac21..151284524fe 100644
--- a/distrib/special/sysctl/sysctl.c
+++ b/distrib/special/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.9 2015/01/16 06:39:34 deraadt Exp $ */
+/* $OpenBSD: sysctl.c,v 1.10 2018/02/10 05:59:06 florian Exp $ */
/*
* Copyright (c) 2009 Theo de Raadt <deraadt@openbsd.org>
@@ -18,14 +18,19 @@
*/
#include <sys/types.h>
+#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
+#include <netinet/in.h>
+
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#define SOIIKEY_LEN 16
+
struct var {
char *name;
int (*print)(struct var *);
@@ -87,6 +92,39 @@ pstring(struct var *v)
}
int
+parse_hex_char(char ch)
+{
+ if (ch >= '0' && ch <= '9')
+ return (ch - '0');
+
+ ch = tolower((unsigned char)ch);
+ if (ch >= 'a' && ch <= 'f')
+ return (ch - 'a' + 10);
+
+ return (-1);
+}
+
+int
+set_soii_key(char *src)
+{
+ uint8_t key[SOIIKEY_LEN];
+ int mib[4] = {CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_SOIIKEY};
+ int i, c;
+
+ for(i = 0; i < SOIIKEY_LEN; i++) {
+ if ((c = parse_hex_char(src[2 * i])) == -1)
+ return (-1);
+ key[i] = c << 4;
+ if ((c = parse_hex_char(src[2 * i + 1])) == -1)
+ return (-1);
+ key[i] |= c;
+ }
+
+ return sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, NULL, key,
+ SOIIKEY_LEN);
+}
+
+int
main(int argc, char *argv[])
{
int ch, i;
@@ -113,6 +151,16 @@ main(int argc, char *argv[])
while (argc--) {
name = *argv++;
+ /*
+ * strlen("net.inet6.ip6.soiikey="
+ * "00000000000000000000000000000000") == 54
+ * strlen("net.inet6.ip6.soiikey=") == 22
+ */
+ if (strlen(name) == 54 && strncmp(name,
+ "net.inet6.ip6.soiikey=", 22) == 0) {
+ set_soii_key(name + 22);
+ continue;
+ }
for (i = 0; i < sizeof(vars)/sizeof(vars[0]); i++) {
if (strcmp(name, vars[i].name) == 0) {