diff options
author | Uri Simchoni <uri@samba.org> | 2017-03-21 23:26:05 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2017-03-28 17:45:19 +0200 |
commit | 3ccb427ace78f828792f9c8f3cc1478ae38301b1 (patch) | |
tree | 02479347bc4afdd8bbde71df36f6883c58bd7032 /source3/client/client.c | |
parent | 200dbca238772b64e7c055d82d985045f92f6bcb (diff) | |
download | samba-3ccb427ace78f828792f9c8f3cc1478ae38301b1.tar.gz |
smbclient: add -f option to rename command
This option causes the rename to request that the
destination file / directory be replaced if it exists.
Supported only in SMB2 and higher protocol.
Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/client/client.c')
-rw-r--r-- | source3/client/client.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 78945f92c2b..d2ebea0ad39 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3833,10 +3833,11 @@ static int cmd_rename(void) char *targetsrc; char *targetdest; NTSTATUS status; + bool replace = false; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) { - d_printf("rename <src> <dest>\n"); + d_printf("rename <src> <dest> [-f]\n"); return 1; } @@ -3856,6 +3857,11 @@ static int cmd_rename(void) return 1; } + if (next_token_talloc(ctx, &cmd_ptr, &buf, NULL) && + strcsequal(buf, "-f")) { + replace = true; + } + status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetsrc); if (!NT_STATUS_IS_OK(status)) { @@ -3870,7 +3876,7 @@ static int cmd_rename(void) return 1; } - status = cli_rename(targetcli, targetsrc, targetdest, false); + status = cli_rename(targetcli, targetsrc, targetdest, replace); if (!NT_STATUS_IS_OK(status)) { d_printf("%s renaming files %s -> %s \n", nt_errstr(status), |