summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ssh/sftp-common.c18
-rw-r--r--usr.bin/ssh/sftp-common.h5
-rw-r--r--usr.bin/ssh/sftp-server.c5
-rw-r--r--usr.bin/ssh/sftp.c6
4 files changed, 20 insertions, 14 deletions
diff --git a/usr.bin/ssh/sftp-common.c b/usr.bin/ssh/sftp-common.c
index a315470840c..82d6fd1dcb5 100644
--- a/usr.bin/ssh/sftp-common.c
+++ b/usr.bin/ssh/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.
@@ -207,21 +207,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);
diff --git a/usr.bin/ssh/sftp-common.h b/usr.bin/ssh/sftp-common.h
index 2e778a9ca0b..421a78f7882 100644
--- a/usr.bin/ssh/sftp-common.h
+++ b/usr.bin/ssh/sftp-common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-common.h,v 1.12 2015/01/14 13:54:13 djm Exp $ */
+/* $OpenBSD: sftp-common.h,v 1.13 2022/09/19 10:41:58 djm Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -47,6 +47,7 @@ void stat_to_attrib(const struct stat *, Attrib *);
void attrib_to_stat(const Attrib *, struct stat *);
int decode_attrib(struct sshbuf *, Attrib *);
int encode_attrib(struct sshbuf *, const Attrib *);
-char *ls_file(const char *, const struct stat *, int, int);
+char *ls_file(const char *, const struct stat *, int, int,
+ const char *, const char *);
const char *fx2txt(int);
diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c
index 566a95ebddc..2da879fcf28 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.143 2022/09/19 10:40:52 djm Exp $ */
+/* $OpenBSD: sftp-server.c,v 1.144 2022/09/19 10:41:58 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@@ -1139,7 +1139,8 @@ process_readdir(u_int32_t id)
continue;
stat_to_attrib(&st, &(stats[count].attrib));
stats[count].name = xstrdup(dp->d_name);
- stats[count].long_name = ls_file(dp->d_name, &st, 0, 0);
+ stats[count].long_name = ls_file(dp->d_name, &st,
+ 0, 0, NULL, NULL);
count++;
/* send up to 100 entries in one message */
/* XXX check packet size instead */
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index c4e63af7e3a..7bb529b7462 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.220 2022/09/16 03:33:14 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.221 2022/09/19 10:41:58 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -868,7 +868,7 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
memset(&sb, 0, sizeof(sb));
attrib_to_stat(&d[n]->a, &sb);
lname = ls_file(fname, &sb, 1,
- (lflag & LS_SI_UNITS));
+ (lflag & LS_SI_UNITS), NULL, NULL);
mprintf("%s\n", lname);
free(lname);
} else
@@ -999,7 +999,7 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
continue;
}
lname = ls_file(fname, g.gl_statv[i], 1,
- (lflag & LS_SI_UNITS));
+ (lflag & LS_SI_UNITS), NULL, NULL);
mprintf("%s\n", lname);
free(lname);
} else {