summaryrefslogtreecommitdiff
path: root/sftp-int.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-int.c')
-rw-r--r--sftp-int.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/sftp-int.c b/sftp-int.c
index 6a2012910..04b67c969 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -25,7 +25,7 @@
25/* XXX: recursive operations */ 25/* XXX: recursive operations */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: sftp-int.c,v 1.49 2002/09/12 00:13:06 djm Exp $"); 28RCSID("$OpenBSD: sftp-int.c,v 1.50 2002/11/21 23:03:51 deraadt Exp $");
29 29
30#include "buffer.h" 30#include "buffer.h"
31#include "xmalloc.h" 31#include "xmalloc.h"
@@ -550,7 +550,7 @@ sdirent_comp(const void *aa, const void *bb)
550 SFTP_DIRENT *a = *(SFTP_DIRENT **)aa; 550 SFTP_DIRENT *a = *(SFTP_DIRENT **)aa;
551 SFTP_DIRENT *b = *(SFTP_DIRENT **)bb; 551 SFTP_DIRENT *b = *(SFTP_DIRENT **)bb;
552 552
553 return (strcmp(a->filename, b->filename)); 553 return (strcmp(a->filename, b->filename));
554} 554}
555 555
556/* sftp ls.1 replacement for directories */ 556/* sftp ls.1 replacement for directories */
@@ -563,7 +563,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
563 if ((n = do_readdir(conn, path, &d)) != 0) 563 if ((n = do_readdir(conn, path, &d)) != 0)
564 return (n); 564 return (n);
565 565
566 /* Count entries for sort */ 566 /* Count entries for sort */
567 for (n = 0; d[n] != NULL; n++) 567 for (n = 0; d[n] != NULL; n++)
568 ; 568 ;
569 569
@@ -571,7 +571,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
571 571
572 for (n = 0; d[n] != NULL; n++) { 572 for (n = 0; d[n] != NULL; n++) {
573 char *tmp, *fname; 573 char *tmp, *fname;
574 574
575 tmp = path_append(path, d[n]->filename); 575 tmp = path_append(path, d[n]->filename);
576 fname = path_strip(tmp, strip_path); 576 fname = path_strip(tmp, strip_path);
577 xfree(tmp); 577 xfree(tmp);
@@ -589,7 +589,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
589 /* XXX - multicolumn display would be nice here */ 589 /* XXX - multicolumn display would be nice here */
590 printf("%s\n", fname); 590 printf("%s\n", fname);
591 } 591 }
592 592
593 xfree(fname); 593 xfree(fname);
594 } 594 }
595 595
@@ -599,7 +599,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
599 599
600/* sftp ls.1 replacement which handles path globs */ 600/* sftp ls.1 replacement which handles path globs */
601static int 601static int
602do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, 602do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
603 int lflag) 603 int lflag)
604{ 604{
605 glob_t g; 605 glob_t g;
@@ -609,23 +609,23 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
609 609
610 memset(&g, 0, sizeof(g)); 610 memset(&g, 0, sizeof(g));
611 611
612 if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE, 612 if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,
613 NULL, &g)) { 613 NULL, &g)) {
614 error("Can't ls: \"%s\" not found", path); 614 error("Can't ls: \"%s\" not found", path);
615 return (-1); 615 return (-1);
616 } 616 }
617 617
618 /* 618 /*
619 * If the glob returns a single match, which is the same as the 619 * If the glob returns a single match, which is the same as the
620 * input glob, and it is a directory, then just list its contents 620 * input glob, and it is a directory, then just list its contents
621 */ 621 */
622 if (g.gl_pathc == 1 && 622 if (g.gl_pathc == 1 &&
623 strncmp(path, g.gl_pathv[0], strlen(g.gl_pathv[0]) - 1) == 0) { 623 strncmp(path, g.gl_pathv[0], strlen(g.gl_pathv[0]) - 1) == 0) {
624 if ((a = do_lstat(conn, path, 1)) == NULL) { 624 if ((a = do_lstat(conn, path, 1)) == NULL) {
625 globfree(&g); 625 globfree(&g);
626 return (-1); 626 return (-1);
627 } 627 }
628 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) && 628 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
629 S_ISDIR(a->perm)) { 629 S_ISDIR(a->perm)) {
630 globfree(&g); 630 globfree(&g);
631 return (do_ls_dir(conn, path, strip_path, lflag)); 631 return (do_ls_dir(conn, path, strip_path, lflag));
@@ -640,8 +640,8 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
640 if (lflag) { 640 if (lflag) {
641 /* 641 /*
642 * XXX: this is slow - 1 roundtrip per path 642 * XXX: this is slow - 1 roundtrip per path
643 * A solution to this is to fork glob() and 643 * A solution to this is to fork glob() and
644 * build a sftp specific version which keeps the 644 * build a sftp specific version which keeps the
645 * attribs (which currently get thrown away) 645 * attribs (which currently get thrown away)
646 * that the server returns as well as the filenames. 646 * that the server returns as well as the filenames.
647 */ 647 */
@@ -666,7 +666,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
666} 666}
667 667
668static int 668static int
669parse_args(const char **cpp, int *pflag, int *lflag, 669parse_args(const char **cpp, int *pflag, int *lflag,
670 unsigned long *n_arg, char **path1, char **path2) 670 unsigned long *n_arg, char **path1, char **path2)
671{ 671{
672 const char *cmd, *cp = *cpp; 672 const char *cmd, *cp = *cpp;
@@ -900,7 +900,7 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd)
900 do_globbed_ls(conn, *pwd, *pwd, lflag); 900 do_globbed_ls(conn, *pwd, *pwd, lflag);
901 break; 901 break;
902 } 902 }
903 903
904 /* Strip pwd off beginning of non-absolute paths */ 904 /* Strip pwd off beginning of non-absolute paths */
905 tmp = NULL; 905 tmp = NULL;
906 if (*path1 != '/') 906 if (*path1 != '/')