Module Name: src
Committed By: uwe
Date: Sun Jun 14 00:30:20 UTC 2020
Modified Files:
src/usr.sbin/puffs/mount_9p: mount_9p.8 ninepuffs.c
Log Message:
Support optional square brackets around the host name.
The brackets are required when using numeric IPv6 addresses as they
contain colons as part of their syntax. We do not enforce that the
thing in the brackets is a numeric IPv6 address - this matches scp
syntax and behavior.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/puffs/mount_9p/mount_9p.8
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/puffs/mount_9p/ninepuffs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/puffs/mount_9p/mount_9p.8
diff -u src/usr.sbin/puffs/mount_9p/mount_9p.8:1.14 src/usr.sbin/puffs/mount_9p/mount_9p.8:1.15
--- src/usr.sbin/puffs/mount_9p/mount_9p.8:1.14 Sat Jun 13 13:45:06 2020
+++ src/usr.sbin/puffs/mount_9p/mount_9p.8 Sun Jun 14 00:30:20 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_9p.8,v 1.14 2020/06/13 13:45:06 uwe Exp $
+.\" $NetBSD: mount_9p.8,v 1.15 2020/06/14 00:30:20 uwe Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@@ -58,6 +58,10 @@ is supplied, it is used as the mount roo
.Ar path
must be an absolute path.
.Pp
+The host name may be optionally enclosed in square brackets.
+This is required when using numeric IPv6 addresses as they contain
+colons as part of their syntax.
+.Pp
The
.Fl c
option enables to mount a file system exported by a VM host through
Index: src/usr.sbin/puffs/mount_9p/ninepuffs.c
diff -u src/usr.sbin/puffs/mount_9p/ninepuffs.c:1.32 src/usr.sbin/puffs/mount_9p/ninepuffs.c:1.33
--- src/usr.sbin/puffs/mount_9p/ninepuffs.c:1.32 Sat Jun 13 21:23:27 2020
+++ src/usr.sbin/puffs/mount_9p/ninepuffs.c Sun Jun 14 00:30:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ninepuffs.c,v 1.32 2020/06/13 21:23:27 uwe Exp $ */
+/* $NetBSD: ninepuffs.c,v 1.33 2020/06/14 00:30:20 uwe Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ninepuffs.c,v 1.32 2020/06/13 21:23:27 uwe Exp $");
+__RCSID("$NetBSD: ninepuffs.c,v 1.33 2020/06/14 00:30:20 uwe Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -262,16 +262,34 @@ main(int argc, char *argv[])
user = pw->pw_name;
}
- /* :/mountpath */
- if ((p = strchr(srvhost, ':')) != NULL) {
- *p = '\0';
- srvpath = p+1;
- if (*srvpath != '/')
- errx(1, "%s is not an absolute path", srvpath);
- } else {
- srvpath = "/";
+ /* [host] or [host]:/path with square brackets around host */
+ if (server == P9P_SERVER_TCP && *srvhost == '[') {
+ ++srvhost;
+ if ((p = strchr(srvhost, ']')) == NULL)
+ errx(EXIT_FAILURE, "Missing bracket after the host name");
+ *p++ = '\0';
+ if (*p == '\0') /* [host] */
+ srvpath = "/";
+ else if (*p == ':') /* [host]:path */
+ srvpath = p+1;
+ else /* [foo]bar */
+ errx(EXIT_FAILURE, "Invalid brackets in the host name");
+
+ } else { /* host or host:/path without brackets around host */
+ if ((p = strchr(srvhost, ':')) != NULL) {
+ *p = '\0';
+ srvpath = p+1;
+ } else {
+ srvpath = "/";
+ }
}
+ if (*srvpath == '\0')
+ errx(1, "Empty path");
+ if (*srvpath != '/')
+ errx(1, "%s: Not an absolute path", srvpath);
+
+
if (p9p.server == P9P_SERVER_TCP) {
p9p.servsock = serverconnect(srvhost, port, family);
} else {