Skip to content

Commit

Permalink
upstream: fix home-directory extension implementation, it always
Browse files Browse the repository at this point in the history
returned the current user's home directory contrary to the spec.

Patch from Jakub Jelen via GHPR477

OpenBSD-Commit-ID: 5afd775eab7f9cbe222d7fbae4c793de6c3b3d28
  • Loading branch information
djmdjm committed Apr 30, 2024
1 parent 14e2b16 commit 385ecb3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sftp-server.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: sftp-server.c,v 1.147 2023/04/12 08:53:54 jsg Exp $ */
/* $OpenBSD: sftp-server.c,v 1.148 2024/04/30 06:23:51 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
Expand Down 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 385ecb3

Please sign in to comment.