summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-06-01 03:33:53 +0000
committerDamien Miller <djm@mindrot.org>2018-06-01 13:35:59 +1000
commit9c935dd9bf05628826ad2495d3e8bdf3d3271c21 (patch)
tree35ccf63e51d3daf2fa927b843d813295e41e96e6 /sftp-server.c
parentd8748b91d1d6c108c0c260ed41fa55f37b9ef34b (diff)
upstream: make UID available as a %-expansion everywhere that the
username is available currently. In the client this is via %i, in the server %U (since %i was already used in the client in some places for this, but used for something different in the server); bz#2870, ok dtucker@ OpenBSD-Commit-ID: c7e912b0213713316cb55db194b3a6415b3d4b95
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sftp-server.c b/sftp-server.c
index df0fb506..ab1b063f 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-server.c,v 1.111 2017/04/04 00:24:56 djm Exp $ */
+/* $OpenBSD: sftp-server.c,v 1.112 2018/06/01 03:33:53 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@@ -1503,7 +1503,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
int i, r, in, out, max, ch, skipargs = 0, log_stderr = 0;
ssize_t len, olen, set_size;
SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
- char *cp, *homedir = NULL, buf[4*4096];
+ char *cp, *homedir = NULL, uidstr[32], buf[4*4096];
long mask;
extern char *optarg;
@@ -1554,8 +1554,10 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
break;
case 'd':
cp = tilde_expand_filename(optarg, user_pw->pw_uid);
+ snprintf(uidstr, sizeof(uidstr), "%llu",
+ (unsigned long long)pw->pw_uid);
homedir = percent_expand(cp, "d", user_pw->pw_dir,
- "u", user_pw->pw_name, (char *)NULL);
+ "u", user_pw->pw_name, "U", uidstr, (char *)NULL);
free(cp);
break;
case 'p':