Skip to content

Commit

Permalink
sftp-server: Fix home-directory extension to match the specification
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakuje committed Mar 26, 2024
1 parent edcff77 commit 233414b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sftp-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,14 +1706,16 @@ process_extended_home_directory(u_int32_t id)
fatal_fr(r, "parse");

debug3("request %u: home-directory \"%s\"", id, username);
if ((user_pw = getpwnam(username)) == NULL) {
if (username[0] != '\0') {
user_pw = pw;
} else if ((user_pw = getpwnam(username)) == NULL) {
send_status(id, SSH2_FX_FAILURE);
goto out;
}

verbose("home-directory \"%s\"", pw->pw_dir);
verbose("home-directory \"%s\"", user_pw->pw_dir);
attrib_clear(&s.attrib);
s.name = s.long_name = pw->pw_dir;
s.name = s.long_name = user_pw->pw_dir;
send_names(id, 1, &s);
out:
free(username);
Expand Down

0 comments on commit 233414b

Please sign in to comment.