summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c81
1 files changed, 42 insertions, 39 deletions
diff --git a/sftp.c b/sftp.c
index e1aa49d0f..66bd111b1 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.103 2008/07/13 22:16:03 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.107 2009/02/02 11:15:14 dtucker 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 *
@@ -207,36 +207,37 @@ cmd_interrupt(int signo)
207static void 207static void
208help(void) 208help(void)
209{ 209{
210 printf("Available commands:\n"); 210 printf("Available commands:\n"
211 printf("cd path Change remote directory to 'path'\n"); 211 "bye Quit sftp\n"
212 printf("lcd path Change local directory to 'path'\n"); 212 "cd path Change remote directory to 'path'\n"
213 printf("chgrp grp path Change group of file 'path' to 'grp'\n"); 213 "chgrp grp path Change group of file 'path' to 'grp'\n"
214 printf("chmod mode path Change permissions of file 'path' to 'mode'\n"); 214 "chmod mode path Change permissions of file 'path' to 'mode'\n"
215 printf("chown own path Change owner of file 'path' to 'own'\n"); 215 "chown own path Change owner of file 'path' to 'own'\n"
216 printf("df [path] Display statistics for current directory or\n"); 216 "df [-hi] [path] Display statistics for current directory or\n"
217 printf(" filesystem containing 'path'\n"); 217 " filesystem containing 'path'\n"
218 printf("help Display this help text\n"); 218 "exit Quit sftp\n"
219 printf("get remote-path [local-path] Download file\n"); 219 "get [-P] remote-path [local-path] Download file\n"
220 printf("lls [ls-options [path]] Display local directory listing\n"); 220 "help Display this help text\n"
221 printf("ln oldpath newpath Symlink remote file\n"); 221 "lcd path Change local directory to 'path'\n"
222 printf("lmkdir path Create local directory\n"); 222 "lls [ls-options [path]] Display local directory listing\n"
223 printf("lpwd Print local working directory\n"); 223 "lmkdir path Create local directory\n"
224 printf("ls [path] Display remote directory listing\n"); 224 "ln oldpath newpath Symlink remote file\n"
225 printf("lumask umask Set local umask to 'umask'\n"); 225 "lpwd Print local working directory\n"
226 printf("mkdir path Create remote directory\n"); 226 "ls [-1aflnrSt] [path] Display remote directory listing\n"
227 printf("progress Toggle display of progress meter\n"); 227 "lumask umask Set local umask to 'umask'\n"
228 printf("put local-path [remote-path] Upload file\n"); 228 "mkdir path Create remote directory\n"
229 printf("pwd Display remote working directory\n"); 229 "progress Toggle display of progress meter\n"
230 printf("exit Quit sftp\n"); 230 "put [-P] local-path [remote-path] Upload file\n"
231 printf("quit Quit sftp\n"); 231 "pwd Display remote working directory\n"
232 printf("rename oldpath newpath Rename remote file\n"); 232 "quit Quit sftp\n"
233 printf("rmdir path Remove remote directory\n"); 233 "rename oldpath newpath Rename remote file\n"
234 printf("rm path Delete remote file\n"); 234 "rm path Delete remote file\n"
235 printf("symlink oldpath newpath Symlink remote file\n"); 235 "rmdir path Remove remote directory\n"
236 printf("version Show SFTP version\n"); 236 "symlink oldpath newpath Symlink remote file\n"
237 printf("!command Execute 'command' in local shell\n"); 237 "version Show SFTP version\n"
238 printf("! Escape to local shell\n"); 238 "!command Execute 'command' in local shell\n"
239 printf("? Synonym for help\n"); 239 "! Escape to local shell\n"
240 "? Synonym for help\n");
240} 241}
241 242
242static void 243static void
@@ -1234,8 +1235,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1234 int err_abort) 1235 int err_abort)
1235{ 1236{
1236 char *path1, *path2, *tmp; 1237 char *path1, *path2, *tmp;
1237 int pflag, lflag, iflag, hflag, cmdnum, i; 1238 int pflag = 0, lflag = 0, iflag = 0, hflag = 0, cmdnum, i;
1238 unsigned long n_arg; 1239 unsigned long n_arg = 0;
1239 Attrib a, *aa; 1240 Attrib a, *aa;
1240 char path_buf[MAXPATHLEN]; 1241 char path_buf[MAXPATHLEN];
1241 int err = 0; 1242 int err = 0;
@@ -1386,17 +1387,19 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1386 remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); 1387 remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g);
1387 for (i = 0; g.gl_pathv[i] && !interrupted; i++) { 1388 for (i = 0; g.gl_pathv[i] && !interrupted; i++) {
1388 if (!(aa = do_stat(conn, g.gl_pathv[i], 0))) { 1389 if (!(aa = do_stat(conn, g.gl_pathv[i], 0))) {
1389 if (err != 0 && err_abort) 1390 if (err_abort) {
1391 err = -1;
1390 break; 1392 break;
1391 else 1393 } else
1392 continue; 1394 continue;
1393 } 1395 }
1394 if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) { 1396 if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) {
1395 error("Can't get current ownership of " 1397 error("Can't get current ownership of "
1396 "remote file \"%s\"", g.gl_pathv[i]); 1398 "remote file \"%s\"", g.gl_pathv[i]);
1397 if (err != 0 && err_abort) 1399 if (err_abort) {
1400 err = -1;
1398 break; 1401 break;
1399 else 1402 } else
1400 continue; 1403 continue;
1401 } 1404 }
1402 aa->flags &= SSH2_FILEXFER_ATTR_UIDGID; 1405 aa->flags &= SSH2_FILEXFER_ATTR_UIDGID;
@@ -1668,8 +1671,8 @@ usage(void)
1668 "usage: %s [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\n" 1671 "usage: %s [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\n"
1669 " [-o ssh_option] [-P sftp_server_path] [-R num_requests]\n" 1672 " [-o ssh_option] [-P sftp_server_path] [-R num_requests]\n"
1670 " [-S program] [-s subsystem | sftp_server] host\n" 1673 " [-S program] [-s subsystem | sftp_server] host\n"
1671 " %s [[user@]host[:file [file]]]\n" 1674 " %s [user@]host[:file ...]\n"
1672 " %s [[user@]host[:dir[/]]]\n" 1675 " %s [user@]host[:dir[/]]\n"
1673 " %s -b batchfile [user@]host\n", __progname, __progname, __progname, __progname); 1676 " %s -b batchfile [user@]host\n", __progname, __progname, __progname, __progname);
1674 exit(1); 1677 exit(1);
1675} 1678}