upstream: extend sftp-common.c:extend ls_file() to support supplied
user/group names; ok markus@ OpenBSD-Commit-ID: c70c70498b1fdcf158531117e405b6245863bfb0
This commit is contained in:
parent
74b77f7497
commit
488f6e1c58
|
@ -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) {
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -1161,7 +1161,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 */
|
||||
|
|
6
sftp.c
6
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>
|
||||
*
|
||||
|
@ -889,7 +889,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
|
||||
|
@ -1026,7 +1026,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 {
|
||||
|
|
Loading…
Reference in New Issue