Commit Diff


commit - 9e0cb8280f65c70592dc41030a8a0a18c7c2ef3e
commit + e22049ccccf16f61c96360a85afc0d0a0ef1085f
blob - 858e86c42ae0319bb1aa02b41e4ba3c6e73f69ac
blob + 141d4d4d85a59fd7edafe9de79c393661980e9db
--- kamiftp/ftp.c
+++ kamiftp/ftp.c
@@ -59,6 +59,10 @@ int		 tls;
 const char	*crtpath;
 const char	*keypath;
 
+char		*user;
+char		*host;
+char		*port;
+
 /* state */
 struct tls_config	*tlsconf;
 struct tls		*ctx;
@@ -437,13 +441,10 @@ do_version(void)
 static void
 do_attach(const char *path)
 {
-	const char *user;
 	struct qid qid;
 
 	if (path == NULL)
 		path = "/";
-	if ((user = getenv("USER")) == NULL)
-		user = "flan";
 
 	tattach(pwdfid, NOFID, user, path);
 	do_send();
@@ -928,13 +929,24 @@ do_ctxt_connect(const char *host, const char *port)
 static void
 do_connect(const char *connspec, const char *path)
 {
-	char *host, *colon;
+	char *t;
 	const char *port;
 
 	host = xstrdup(connspec);
-	if ((colon = strchr(host, ':')) != NULL) {
-		*colon = '\0';
-		port = ++colon;
+	if ((t = strchr(host, '@')) != NULL) {
+		if (t == host)
+			errx(1, "invalid connection string: %s", connspec);
+		*t = '\0';
+		user = host;
+		host = ++t;
+	} else if ((user = getenv("USER")) == NULL)
+		errx(1, "USER not defined");
+
+	if ((t = strchr(host, ':')) != NULL) {
+		*t = '\0';
+		port = ++t;
+		if (*port == '\0')
+			errx(1, "invalid connection string: %s", connspec);
 	} else
 		port = "1337";
 
@@ -950,8 +962,6 @@ do_connect(const char *connspec, const char *path)
 
 	do_version();
 	do_attach(path);
-
-	free(host);
 }
 
 static int
blob - b940d9e6682c3ecdd342bc6e9416da2f0c09b8fe
blob + 31026b4df7626814212866faa8e5b75bc10ff333
--- kamiftp/kamiftp.1
+++ kamiftp/kamiftp.1
@@ -23,7 +23,7 @@
 .Op Fl c
 .Op Fl C Ar cert
 .Op Fl K Ar key
-.Ar host : Ns Op Ar port
+.Oo Ar user Ns @ Oc Ns Ar host Ns Op : Ns Ar port
 .Op Ar path
 .Sh DESCRIPTION
 .Nm