From: djm Date: Tue, 30 Apr 2024 06:23:51 +0000 (+0000) Subject: fix home-directory extension implementation, it always returned X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6ebf38efb5423ff2f408dd61142b665cf211ac82;p=openbsd fix home-directory extension implementation, it always returned the current user's home directory contrary to the spec. Patch from Jakub Jelen via GHPR477 --- diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index 51258d9e801..b45abefd95d 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/sftp-server.c @@ -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. * @@ -1673,14 +1673,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);