- djm@cvs.openbsd.org 2004/06/20 18:53:39

[sftp.c]
     make "ls -l" listings print user/group names, add "ls -n" to show uid/gid
     (like /bin/ls); idea & ok markus@
This commit is contained in:
Darren Tucker 2004-06-22 12:30:53 +10:00
parent 365433f883
commit b215c5d8fe
2 changed files with 29 additions and 14 deletions

View File

@ -3,6 +3,10 @@
- djm@cvs.openbsd.org 2004/06/20 17:36:59 - djm@cvs.openbsd.org 2004/06/20 17:36:59
[ssh.c] [ssh.c]
filter passed env vars at slave in connection sharing case; ok markus@ filter passed env vars at slave in connection sharing case; ok markus@
- djm@cvs.openbsd.org 2004/06/20 18:53:39
[sftp.c]
make "ls -l" listings print user/group names, add "ls -n" to show uid/gid
(like /bin/ls); idea & ok markus@
20040620 20040620
- (tim) [configure.ac Makefile.in] Only change TEST_SHELL on broken platforms. - (tim) [configure.ac Makefile.in] Only change TEST_SHELL on broken platforms.
@ -1325,4 +1329,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
$Id: ChangeLog,v 1.3418 2004/06/22 02:29:23 dtucker Exp $ $Id: ChangeLog,v 1.3419 2004/06/22 02:30:53 dtucker Exp $

37
sftp.c
View File

@ -16,7 +16,7 @@
#include "includes.h" #include "includes.h"
RCSID("$OpenBSD: sftp.c,v 1.49 2004/06/18 06:13:25 dtucker Exp $"); RCSID("$OpenBSD: sftp.c,v 1.50 2004/06/20 18:53:39 djm Exp $");
#include "buffer.h" #include "buffer.h"
#include "xmalloc.h" #include "xmalloc.h"
@ -61,9 +61,11 @@ char *__progname;
/* Separators for interactive commands */ /* Separators for interactive commands */
#define WHITESPACE " \t\r\n" #define WHITESPACE " \t\r\n"
/* Define what type of ls view (0 - multi-column) */ /* Define what type of ls view */
#define LONG_VIEW 1 /* Full view ala ls -l */ #define LONG_VIEW 1 /* Full view ala ls -l */
#define SHORT_VIEW 2 /* Single row view ala ls -1 */ #define SHORT_VIEW 2 /* Single row view ala ls -1 */
#define NUMERIC_VIEW 4 /* Long view with numeric uid/gid */
#define VIEW_FLAGS (LONG_VIEW|SHORT_VIEW|NUMERIC_VIEW)
/* Commands for interactive mode */ /* Commands for interactive mode */
#define I_CHDIR 1 #define I_CHDIR 1
@ -339,10 +341,16 @@ parse_ls_flags(const char **cpp, int *lflag)
for(; strchr(WHITESPACE, *cp) == NULL; cp++) { for(; strchr(WHITESPACE, *cp) == NULL; cp++) {
switch (*cp) { switch (*cp) {
case 'l': case 'l':
*lflag = LONG_VIEW; *lflag &= ~VIEW_FLAGS;
*lflag |= LONG_VIEW;
break; break;
case '1': case '1':
*lflag = SHORT_VIEW; *lflag &= ~VIEW_FLAGS;
*lflag |= SHORT_VIEW;
break;
case 'n':
*lflag &= ~VIEW_FLAGS;
*lflag |= NUMERIC_VIEW|LONG_VIEW;
break; break;
default: default:
error("Invalid flag -%c", *cp); error("Invalid flag -%c", *cp);
@ -650,14 +658,17 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
xfree(tmp); xfree(tmp);
if (lflag & LONG_VIEW) { if (lflag & LONG_VIEW) {
char *lname; if (lflag & NUMERIC_VIEW) {
struct stat sb; char *lname;
struct stat sb;
memset(&sb, 0, sizeof(sb)); memset(&sb, 0, sizeof(sb));
attrib_to_stat(&d[n]->a, &sb); attrib_to_stat(&d[n]->a, &sb);
lname = ls_file(fname, &sb, 1); lname = ls_file(fname, &sb, 1);
printf("%s\n", lname); printf("%s\n", lname);
xfree(lname); xfree(lname);
} else
printf("%s\n", d[n]->longname);
} else { } else {
printf("%-*s", colspace, fname); printf("%-*s", colspace, fname);
if (c >= columns) { if (c >= columns) {