changeset 961:a4032b946355

Be a bit safer in case pw_name doesn't exist
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Aug 2014 22:10:57 +0800
parents 9e7b0810a4a2
children db9fa5971d24
files cli-runopts.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cli-runopts.c	Wed Aug 06 22:08:16 2014 +0800
+++ b/cli-runopts.c	Wed Aug 06 22:10:57 2014 +0800
@@ -683,11 +683,13 @@
 	uid = getuid();
 
 	pw = getpwuid(uid);
-	if (pw == NULL || pw->pw_name == NULL) {
+	if (pw && pw->pw_name != NULL) {
+		cli_opts.own_user = m_strdup(pw->pw_name);
+	} else {
 		dropbear_log(LOG_INFO, "Warning: failed to identify current user. Trying anyway.");
+		cli_opts.own_user = m_strdup("unknown");
 	}
 
-	cli_opts.own_user = m_strdup(pw->pw_name);
 }
 
 #ifdef ENABLE_CLI_ANYTCPFWD