diff options
author | Damien Miller <djm@mindrot.org> | 2013-08-21 02:41:15 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-08-21 02:41:15 +1000 |
commit | c7dba12bf95eb1d69711881a153cc286c1987663 (patch) | |
tree | a91e31b8edac374ff5e1b9e671b8f411ae313ad0 /sftp.c | |
parent | 034f27a0c09e69fe3589045b41f03f6e345b63f5 (diff) |
- djm@cvs.openbsd.org 2013/08/08 05:04:03
[sftp-client.c sftp-client.h sftp.c]
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 'sftp.c')
-rw-r--r-- | sftp.c | 35 |
1 files changed, 32 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.151 2013/08/08 04:52:04 djm Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.152 2013/08/08 05:04:03 djm 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 | * |
@@ -415,6 +415,30 @@ parse_link_flags(const char *cmd, char **argv, int argc, int *sflag) | |||
415 | } | 415 | } |
416 | 416 | ||
417 | static int | 417 | static int |
418 | parse_rename_flags(const char *cmd, char **argv, int argc, int *lflag) | ||
419 | { | ||
420 | extern int opterr, optind, optopt, optreset; | ||
421 | int ch; | ||
422 | |||
423 | optind = optreset = 1; | ||
424 | opterr = 0; | ||
425 | |||
426 | *lflag = 0; | ||
427 | while ((ch = getopt(argc, argv, "l")) != -1) { | ||
428 | switch (ch) { | ||
429 | case 'l': | ||
430 | *lflag = 1; | ||
431 | break; | ||
432 | default: | ||
433 | error("%s: Invalid flag -%c", cmd, optopt); | ||
434 | return -1; | ||
435 | } | ||
436 | } | ||
437 | |||
438 | return optind; | ||
439 | } | ||
440 | |||
441 | static int | ||
418 | parse_ls_flags(char **argv, int argc, int *lflag) | 442 | parse_ls_flags(char **argv, int argc, int *lflag) |
419 | { | 443 | { |
420 | extern int opterr, optind, optopt, optreset; | 444 | extern int opterr, optind, optopt, optreset; |
@@ -1210,8 +1234,13 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag, | |||
1210 | case I_LINK: | 1234 | case I_LINK: |
1211 | if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1) | 1235 | if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1) |
1212 | return -1; | 1236 | return -1; |
1213 | case I_SYMLINK: | 1237 | goto parse_two_paths; |
1214 | case I_RENAME: | 1238 | case I_RENAME: |
1239 | if ((optidx = parse_rename_flags(cmd, argv, argc, lflag)) == -1) | ||
1240 | return -1; | ||
1241 | goto parse_two_paths; | ||
1242 | case I_SYMLINK: | ||
1243 | parse_two_paths: | ||
1215 | if (argc - optidx < 2) { | 1244 | if (argc - optidx < 2) { |
1216 | error("You must specify two paths after a %s " | 1245 | error("You must specify two paths after a %s " |
1217 | "command.", cmd); | 1246 | "command.", cmd); |
@@ -1353,7 +1382,7 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd, | |||
1353 | case I_RENAME: | 1382 | case I_RENAME: |
1354 | path1 = make_absolute(path1, *pwd); | 1383 | path1 = make_absolute(path1, *pwd); |
1355 | path2 = make_absolute(path2, *pwd); | 1384 | path2 = make_absolute(path2, *pwd); |
1356 | err = do_rename(conn, path1, path2); | 1385 | err = do_rename(conn, path1, path2, lflag); |
1357 | break; | 1386 | break; |
1358 | case I_SYMLINK: | 1387 | case I_SYMLINK: |
1359 | sflag = 1; | 1388 | sflag = 1; |