summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/sftp.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2013-08-08 05:04:04 +0000
committerDamien Miller <djm@cvs.openbsd.org>2013-08-08 05:04:04 +0000
commit7cf32228659ba80d262268ace29e1600d3235f8f (patch)
tree189eedd41298213910d6c9eec09a0e0dbe52431b /usr.bin/ssh/sftp.c
parent1f16d9914c08f4feaf802393454911b5b6514b18 (diff)
add a "-l" flag for the rename command to force it to use the silly
standard SSH_FXP_RENAME command instead of the POSIX-rename- like posix-rename@openssh.com extension. intended for use in regress tests, so no documentation.
Diffstat (limited to 'usr.bin/ssh/sftp.c')
-rw-r--r--usr.bin/ssh/sftp.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index 90bb03c516e..ffb3a682b87 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.151 2013/08/08 04:52:04 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.152 2013/08/08 05:04:03 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -394,6 +394,30 @@ parse_link_flags(const char *cmd, char **argv, int argc, int *sflag)
}
static int
+parse_rename_flags(const char *cmd, char **argv, int argc, int *lflag)
+{
+ extern int opterr, optind, optopt, optreset;
+ int ch;
+
+ optind = optreset = 1;
+ opterr = 0;
+
+ *lflag = 0;
+ while ((ch = getopt(argc, argv, "l")) != -1) {
+ switch (ch) {
+ case 'l':
+ *lflag = 1;
+ break;
+ default:
+ error("%s: Invalid flag -%c", cmd, optopt);
+ return -1;
+ }
+ }
+
+ return optind;
+}
+
+static int
parse_ls_flags(char **argv, int argc, int *lflag)
{
extern int opterr, optind, optopt, optreset;
@@ -1189,8 +1213,13 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
case I_LINK:
if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1)
return -1;
- case I_SYMLINK:
+ goto parse_two_paths;
case I_RENAME:
+ if ((optidx = parse_rename_flags(cmd, argv, argc, lflag)) == -1)
+ return -1;
+ goto parse_two_paths;
+ case I_SYMLINK:
+ parse_two_paths:
if (argc - optidx < 2) {
error("You must specify two paths after a %s "
"command.", cmd);
@@ -1332,7 +1361,7 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
case I_RENAME:
path1 = make_absolute(path1, *pwd);
path2 = make_absolute(path2, *pwd);
- err = do_rename(conn, path1, path2);
+ err = do_rename(conn, path1, path2, lflag);
break;
case I_SYMLINK:
sflag = 1;