From d657f0facf1616957320073236fb580fb04fa5fa Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Fri, 11 Dec 2015 09:08:06 +0000 Subject: Allow to specify relative pathnames on the command line (eg. -k ./bsd). --- usr.sbin/vmctl/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'usr.sbin') 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 @@ -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) -- cgit v1.2.3