diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-11 09:08:06 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-11 09:08:06 +0000 |
commit | d657f0facf1616957320073236fb580fb04fa5fa (patch) | |
tree | c0bfc57622ac8ec12b3b8a9b81e8aeda9ecdcda3 | |
parent | 4e6c1d3bd7e19d878cfa9e31c86c4f9a47853d7f (diff) |
Allow to specify relative pathnames on the command line (eg. -k ./bsd).
-rw-r--r-- | usr.sbin/vmctl/main.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index e7a7aa6dd80..81b9853efc7 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.9 2015/12/08 13:15:09 reyk Exp $ */ +/* $OpenBSD: main.c,v 1.10 2015/12/11 09:08:05 reyk Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -455,7 +455,8 @@ ctl_load(struct parse_result *res, int argc, char *argv[]) int ctl_start(struct parse_result *res, int argc, char *argv[]) { - int ch; + int ch; + char path[PATH_MAX]; if (argc < 2) ctl_usage(res->ctl); @@ -473,7 +474,9 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) case 'k': if (res->path) errx(1, "kernel specified multiple times"); - if ((res->path = strdup(optarg)) == NULL) + if (realpath(optarg, path) == NULL) + err(1, "invalid kernel path"); + if ((res->path = strdup(path)) == NULL) errx(1, "strdup"); break; case 'm': @@ -483,8 +486,10 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) errx(1, "invalid memory size: %s", optarg); break; case 'd': - if (parse_disk(res, optarg) != 0) - errx(1, "invalid memory size: %s", optarg); + if (realpath(optarg, path) == NULL) + err(1, "invalid disk path"); + if (parse_disk(res, path) != 0) + errx(1, "invalid disk: %s", optarg); break; case 'i': if (res->nifs != -1) |