diff options
author | Matt Johnston <matt@ucc.asn.au> | 2014-08-06 22:10:57 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2014-08-06 22:10:57 +0800 |
commit | b969101b332e143109ef374e3b13872b6544656a (patch) | |
tree | 7a62d3513ef2aa46a43503ab7afd0af5401adc1b | |
parent | 86a742f6356a950cb351e6c7e80b733cc4efe238 (diff) |
Be a bit safer in case pw_name doesn't exist
-rw-r--r-- | cli-runopts.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cli-runopts.c b/cli-runopts.c index 8c9bc8e..bad991f 100644 --- a/cli-runopts.c +++ b/cli-runopts.c @@ -683,11 +683,13 @@ static void fill_own_user() { 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 |