[PATCH 07/16] scp: Use "unknown" when the user name cannot be retrieved

Michael Witten mfwitten at gmail.com
Tue Dec 8 06:57:03 AWST 2015


Date: Fri, 6 Nov 2015 19:12:49 -0000
It seems unnecessarily draconian to treat an unspecified user name as a fatal error;
indeed, `dbclient' attempts to use "unknown" in this case, which is better than
nothing, and similarly warns the user about the problem via the usual machinery.

Furthermore, throwing out the error message saves bytes, which could be useful to
embedded systems, where smaller is better.
---
 scp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scp.c b/scp.c
index dd49b68..dd92451 100644
--- a/scp.c
+++ b/scp.c
@@ -1161,12 +1161,11 @@ get_user_name()
 	static const char *user_name = NULL;
 
 	if (user_name == NULL) {
-		uid_t userid;
 		struct passwd *pwd;
-		if (pwd = getpwuid(userid = getuid()))
+		if (pwd = getpwuid(getuid()))
 			user_name = xstrdup(pwd->pw_name);
 		else
-			fatal("unknown user ID '%u'; specify a user name", (u_int) userid);
+			user_name = "unknown";
 	}
 
 	return user_name;
-- 
2.4.3



More information about the Dropbear mailing list