Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/puffs/mount_9p Support optional square brackets aro...



details:   https://anonhg.NetBSD.org/src/rev/c96ed3b57967
branches:  trunk
changeset: 934567:c96ed3b57967
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sun Jun 14 00:30:20 2020 +0000

description:
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.

diffstat:

 usr.sbin/puffs/mount_9p/mount_9p.8  |   6 ++++-
 usr.sbin/puffs/mount_9p/ninepuffs.c |  38 +++++++++++++++++++++++++++---------
 2 files changed, 33 insertions(+), 11 deletions(-)

diffs (81 lines):

diff -r 0dcb54fbe326 -r c96ed3b57967 usr.sbin/puffs/mount_9p/mount_9p.8
--- a/usr.sbin/puffs/mount_9p/mount_9p.8        Sun Jun 14 00:25:22 2020 +0000
+++ b/usr.sbin/puffs/mount_9p/mount_9p.8        Sun Jun 14 00:30:20 2020 +0000
@@ -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 @@
 .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
diff -r 0dcb54fbe326 -r c96ed3b57967 usr.sbin/puffs/mount_9p/ninepuffs.c
--- a/usr.sbin/puffs/mount_9p/ninepuffs.c       Sun Jun 14 00:25:22 2020 +0000
+++ b/usr.sbin/puffs/mount_9p/ninepuffs.c       Sun Jun 14 00:30:20 2020 +0000
@@ -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 @@
                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 {



Home | Main Index | Thread Index | Old Index