diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-09-19 10:41:58 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-09-19 20:49:13 +1000 |
commit | 488f6e1c582212c2374a4bf8cd1b703d2e70fb8b (patch) | |
tree | d5f1d8e0dd2a49e53b78726c22800a24f21cd283 /sftp-common.c | |
parent | 74b77f7497dba3a58315c8f308883de448078057 (diff) | |
download | openssh-git-488f6e1c582212c2374a4bf8cd1b703d2e70fb8b.tar.gz |
upstream: extend sftp-common.c:extend ls_file() to support supplied
user/group names; ok markus@
OpenBSD-Commit-ID: c70c70498b1fdcf158531117e405b6245863bfb0
Diffstat (limited to 'sftp-common.c')
-rw-r--r-- | sftp-common.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sftp-common.c b/sftp-common.c index 3ad57673..50f1bbaf 100644 --- a/sftp-common.c +++ b/sftp-common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-common.c,v 1.32 2020/10/18 11:32:02 djm Exp $ */ +/* $OpenBSD: sftp-common.c,v 1.33 2022/09/19 10:41:58 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Damien Miller. All rights reserved. @@ -212,21 +212,25 @@ fx2txt(int status) * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh */ char * -ls_file(const char *name, const struct stat *st, int remote, int si_units) +ls_file(const char *name, const struct stat *st, int remote, int si_units, + const char *user, const char *group) { int ulen, glen, sz = 0; struct tm *ltime = localtime(&st->st_mtime); - const char *user, *group; char buf[1024], lc[8], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; char sbuf[FMT_SCALED_STRSIZE]; time_t now; strmode(st->st_mode, mode); if (remote) { - snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid); - user = ubuf; - snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid); - group = gbuf; + if (user == NULL) { + snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid); + user = ubuf; + } + if (group == NULL) { + snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid); + group = gbuf; + } strlcpy(lc, "?", sizeof(lc)); } else { user = user_from_uid(st->st_uid, 0); |