diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-10-08 11:41:57 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-10-08 11:41:57 +0000 |
commit | 2e566858daa24513ee4b7246c4d1562db5a939f0 (patch) | |
tree | 8607ade5852b368d7f81f4b7d41772804b7615dc /usr.sbin | |
parent | 61d00dc4b322beea260b6700de730edddefe7f1c (diff) |
if non absolute paths are specified in install commands assume they
are relative to /etc
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ikectl/ikeca.c | 17 | ||||
-rw-r--r-- | usr.sbin/ikectl/ikectl.c | 14 |
2 files changed, 22 insertions, 9 deletions
diff --git a/usr.sbin/ikectl/ikeca.c b/usr.sbin/ikectl/ikeca.c index 2824490415c..9388ea61c7b 100644 --- a/usr.sbin/ikectl/ikeca.c +++ b/usr.sbin/ikectl/ikeca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikeca.c,v 1.16 2010/10/08 10:13:47 jsg Exp $ */ +/* $OpenBSD: ikeca.c,v 1.17 2010/10/08 11:41:56 jsg Exp $ */ /* $vantronix: ikeca.c,v 1.13 2010/06/03 15:52:52 reyk Exp $ */ /* @@ -59,7 +59,8 @@ struct ca { struct { char *dir; mode_t mode; -} exdirs[] = { +} hier[] = { + { "", 0755 }, { "/ca", 0755 }, { "/certs", 0755 }, { "/crls", 0755 }, @@ -513,11 +514,11 @@ ca_hier(char *path) char dst[PATH_MAX]; u_int i; - for (i = 0; i < nitems(exdirs); i++) { + for (i = 0; i < nitems(hier); i++) { strlcpy(dst, path, sizeof(dst)); - strlcat(dst, exdirs[i].dir, sizeof(dst)); + strlcat(dst, hier[i].dir, sizeof(dst)); if (stat(dst, &st) != 0 && errno == ENOENT && - mkdir(dst, exdirs[i].mode) != 0) + mkdir(dst, hier[i].mode) != 0) err(1, "failed to create dir %s", dst); } @@ -587,10 +588,10 @@ ca_export(struct ca *ca, char *keyname, char *myname, char *password) chmod(p, 0755); - for (i = 0; i < nitems(exdirs); i++) { + for (i = 0; i < nitems(hier); i++) { strlcpy(dst, p, sizeof(dst)); - strlcat(dst, exdirs[i].dir, sizeof(dst)); - if (mkdir(dst, exdirs[i].mode) != 0) + strlcat(dst, hier[i].dir, sizeof(dst)); + if (mkdir(dst, hier[i].mode) != 0) err(1, "failed to create dir %s", dst); } diff --git a/usr.sbin/ikectl/ikectl.c b/usr.sbin/ikectl/ikectl.c index 21626187dad..64bdbd5d6b2 100644 --- a/usr.sbin/ikectl/ikectl.c +++ b/usr.sbin/ikectl/ikectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikectl.c,v 1.10 2010/10/08 10:13:47 jsg Exp $ */ +/* $OpenBSD: ikectl.c,v 1.11 2010/10/08 11:41:56 jsg Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -80,12 +80,24 @@ int ca_opt(struct parse_result *res) { struct ca *ca; + size_t len; + char *p; ca = ca_setup(res->caname, (res->action == CA_CREATE), res->quiet, res->pass); if (ca == NULL) errx(1, "ca_setup failed"); + /* assume paths are relative to /etc if not absolute */ + if (res->path && (res->path[0] != '.') && (res->path[0] != '/')) { + len = 5 + strlen(res->path) + 1; + if ((p = malloc(len)) == NULL) + err(1, "malloc"); + snprintf(p, len, "/etc/%s", res->path); + free(res->path); + res->path = p; + } + switch (res->action) { case CA_CREATE: ca_create(ca); |