Hello, this is my first patch.
vnconfig(8) should print absolute pathnames of configured disk images,
instead of repeating whatever was given to -c.
Contrived example:
$ doas vnconfig -l
vnd0: covering ../images/../images/foo on sd4l, inode 15301672
vnd1: covering foo on sd4l, inode 15562887
vnd2: covering foo on sd4l, inode 15562888
With this patch:
$ doas vnconfig -l
vnd0: covering /home/user/images/foo on sd4l, inode 15301672
vnd1: covering /home/user/images/a/foo on sd4l, inode 15562887
vnd2: covering /home/user/images/b/foo on sd4l, inode 15562888
Index: mount_vnd.c
===================================================================
RCS file: /cvs/src/sbin/mount_vnd/mount_vnd.c,v
retrieving revision 1.20
diff -u -p -r1.20 mount_vnd.c
--- mount_vnd.c 24 Jan 2016 06:32:33 -0000 1.20
+++ mount_vnd.c 16 Sep 2018 06:05:02 -0000
@@ -143,6 +143,7 @@ main(int argc, char **argv)
if (action == VND_CONFIG && argc == 2) {
int ind_raw, ind_reg;
+ char realfile[PATH_MAX];
if (opt_k || opt_K) {
fprintf(stderr,
@@ -167,7 +168,12 @@ main(int argc, char **argv)
ind_raw = 0;
ind_reg = 1;
}
- rv = config(argv[ind_raw], argv[ind_reg], action, dp, key,
+
+ if (realpath(argv[ind_reg], realfile) == NULL) {
+ err(1, "invalid file path");
+ }
+
+ rv = config(argv[ind_raw], realfile, action, dp, key,
keylen);
} else if (action == VND_UNCONFIG && argc == 1)
rv = config(argv[0], NULL, action, NULL, NULL, 0);