summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2014-08-06 22:10:57 +0800
committerMatt Johnston <matt@ucc.asn.au>2014-08-06 22:10:57 +0800
commitb969101b332e143109ef374e3b13872b6544656a (patch)
tree7a62d3513ef2aa46a43503ab7afd0af5401adc1b
parent86a742f6356a950cb351e6c7e80b733cc4efe238 (diff)
Be a bit safer in case pw_name doesn't exist
-rw-r--r--cli-runopts.c6
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