summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/sftp.c b/sftp.c
index ff4d63d5c..cb9b967ed 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.164 2014/07/09 01:45:10 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.170 2015/01/20 23:14:00 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -17,6 +17,7 @@
17 17
18#include "includes.h" 18#include "includes.h"
19 19
20#include <sys/param.h> /* MIN MAX */
20#include <sys/types.h> 21#include <sys/types.h>
21#include <sys/ioctl.h> 22#include <sys/ioctl.h>
22#ifdef HAVE_SYS_STAT_H 23#ifdef HAVE_SYS_STAT_H
@@ -46,6 +47,7 @@
46#else 47#else
47typedef void EditLine; 48typedef void EditLine;
48#endif 49#endif
50#include <limits.h>
49#include <signal.h> 51#include <signal.h>
50#include <stdlib.h> 52#include <stdlib.h>
51#include <stdio.h> 53#include <stdio.h>
@@ -63,7 +65,8 @@ typedef void EditLine;
63#include "misc.h" 65#include "misc.h"
64 66
65#include "sftp.h" 67#include "sftp.h"
66#include "buffer.h" 68#include "ssherr.h"
69#include "sshbuf.h"
67#include "sftp-common.h" 70#include "sftp-common.h"
68#include "sftp-client.h" 71#include "sftp-client.h"
69 72
@@ -202,7 +205,7 @@ static const struct CMD cmds[] = {
202 { "quit", I_QUIT, NOARGS }, 205 { "quit", I_QUIT, NOARGS },
203 { "reget", I_REGET, REMOTE }, 206 { "reget", I_REGET, REMOTE },
204 { "rename", I_RENAME, REMOTE }, 207 { "rename", I_RENAME, REMOTE },
205 { "reput", I_REPUT, LOCAL }, 208 { "reput", I_REPUT, LOCAL },
206 { "rm", I_RM, REMOTE }, 209 { "rm", I_RM, REMOTE },
207 { "rmdir", I_RMDIR, REMOTE }, 210 { "rmdir", I_RMDIR, REMOTE },
208 { "symlink", I_SYMLINK, REMOTE }, 211 { "symlink", I_SYMLINK, REMOTE },
@@ -250,9 +253,9 @@ help(void)
250 "df [-hi] [path] Display statistics for current directory or\n" 253 "df [-hi] [path] Display statistics for current directory or\n"
251 " filesystem containing 'path'\n" 254 " filesystem containing 'path'\n"
252 "exit Quit sftp\n" 255 "exit Quit sftp\n"
253 "get [-Ppr] remote [local] Download file\n" 256 "get [-afPpRr] remote [local] Download file\n"
254 "reget remote [local] Resume download file\n" 257 "reget [-fPpRr] remote [local] Resume download file\n"
255 "reput [local] remote Resume upload file\n" 258 "reput [-fPpRr] [local] remote Resume upload file\n"
256 "help Display this help text\n" 259 "help Display this help text\n"
257 "lcd path Change local directory to 'path'\n" 260 "lcd path Change local directory to 'path'\n"
258 "lls [ls-options [path]] Display local directory listing\n" 261 "lls [ls-options [path]] Display local directory listing\n"
@@ -263,7 +266,7 @@ help(void)
263 "lumask umask Set local umask to 'umask'\n" 266 "lumask umask Set local umask to 'umask'\n"
264 "mkdir path Create remote directory\n" 267 "mkdir path Create remote directory\n"
265 "progress Toggle display of progress meter\n" 268 "progress Toggle display of progress meter\n"
266 "put [-Ppr] local [remote] Upload file\n" 269 "put [-afPpRr] local [remote] Upload file\n"
267 "pwd Display remote working directory\n" 270 "pwd Display remote working directory\n"
268 "quit Quit sftp\n" 271 "quit Quit sftp\n"
269 "rename oldpath newpath Rename remote file\n" 272 "rename oldpath newpath Rename remote file\n"
@@ -1400,7 +1403,7 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1400 int cmdnum, i; 1403 int cmdnum, i;
1401 unsigned long n_arg = 0; 1404 unsigned long n_arg = 0;
1402 Attrib a, *aa; 1405 Attrib a, *aa;
1403 char path_buf[MAXPATHLEN]; 1406 char path_buf[PATH_MAX];
1404 int err = 0; 1407 int err = 0;
1405 glob_t g; 1408 glob_t g;
1406 1409
@@ -1519,6 +1522,9 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1519 err = do_df(conn, path1, hflag, iflag); 1522 err = do_df(conn, path1, hflag, iflag);
1520 break; 1523 break;
1521 case I_LCHDIR: 1524 case I_LCHDIR:
1525 tmp = tilde_expand_filename(path1, getuid());
1526 free(path1);
1527 path1 = tmp;
1522 if (chdir(path1) == -1) { 1528 if (chdir(path1) == -1) {
1523 error("Couldn't change local directory to " 1529 error("Couldn't change local directory to "
1524 "\"%s\": %s", path1, strerror(errno)); 1530 "\"%s\": %s", path1, strerror(errno));
@@ -2081,8 +2087,8 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
2081 free(dir); 2087 free(dir);
2082 } 2088 }
2083 2089
2084 setlinebuf(stdout); 2090 setvbuf(stdout, NULL, _IOLBF, 0);
2085 setlinebuf(infile); 2091 setvbuf(infile, NULL, _IOLBF, 0);
2086 2092
2087 interactive = !batchmode && isatty(STDIN_FILENO); 2093 interactive = !batchmode && isatty(STDIN_FILENO);
2088 err = 0; 2094 err = 0;