Skip to content

Commit

Permalink
Get hostname from the environment variable on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikushin committed Jan 31, 2020
1 parent 6aa1a75 commit 9d524a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions session.c
Original file line number Diff line number Diff line change
Expand Up @@ -2620,9 +2620,14 @@ session_setup_x11fwd(struct ssh *ssh, Session *s)
session_close_single_x11, 0);
}

#ifdef __ANDROID__
if (getenv("HOSTNAME"))
strcpy(hostname, getenv("HOSTNAME"));
#else
/* Set up a suitable value for the DISPLAY variable. */
if (gethostname(hostname, sizeof(hostname)) == -1)
fatal("gethostname: %.100s", strerror(errno));
#endif
/*
* auth_display must be used as the displayname when the
* authorization entry is added with xauth(1). This will be
Expand Down
5 changes: 5 additions & 0 deletions ssh-keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,13 @@ main(int argc, char **argv)
fatal("No user exists for uid %lu", (u_long)getuid());
#endif
}
#ifdef __ANDROID__
if (getenv("HOSTNAME"))
strcpy(hostname, getenv("HOSTNAME"));
#else
if (gethostname(hostname, sizeof(hostname)) == -1)
fatal("gethostname: %s", strerror(errno));
#endif

sk_provider = getenv("SSH_SK_PROVIDER");

Expand Down

0 comments on commit 9d524a5

Please sign in to comment.