changeset 1228:f7f2c3714269

Don't fail if can't get the username
author Matt Johnston <matt@ucc.asn.au>
date Tue, 19 Jan 2016 00:34:37 +0800
parents 5dde22e8a189
children 32cdbbe4b67e 00d7fc7b112b
files scp.c
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scp.c	Tue Jan 19 00:23:19 2016 +0800
+++ b/scp.c	Tue Jan 19 00:34:37 2016 +0800
@@ -289,7 +289,6 @@
 void run_err(const char *,...);
 void verifydir(char *);
 
-struct passwd *pwd;
 uid_t userid;
 int errs, remin, remout;
 int pflag, iamremote, iamrecursive, targetshouldbedirectory;
@@ -396,9 +395,6 @@
 	argc -= optind;
 	argv += optind;
 
-	if ((pwd = getpwuid(userid = getuid())) == NULL)
-		fatal("unknown user %u", (u_int) userid);
-
 	if (!isatty(STDERR_FILENO))
 		showprogress = 0;
 
@@ -514,7 +510,7 @@
 				host = cleanhostname(host);
 				suser = argv[i];
 				if (*suser == '\0')
-					suser = pwd->pw_name;
+					continue; /* pretend there wasn't any @ at all */
 				else if (!okname(suser))
 					continue;
 				addargs(&alist, "-l");
@@ -582,7 +578,7 @@
 			*host++ = 0;
 			suser = argv[i];
 			if (*suser == '\0')
-				suser = pwd->pw_name;
+				suser = NULL;
 		}
 		host = cleanhostname(host);
 		len = strlen(src) + CMDNEEDS + 20;