1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

clitar: restore mtime on files

The documentation for smbclient states that when extracting a tar
archive:

  Restored files have their creation times (mtime) set to the
  date saved in the tar file.

However this behaviour was lost in commit 2945596011cc ("clitar.c: fresh
new compilable file.").

Add a call to cli_setatr() to set both the mtime and the mode of files
after they have been extracted.

Signed-off-by: Steven Price <steven@ecrips.co.uk>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Jan 27 19:26:03 UTC 2021 on sn-devel-184
This commit is contained in:
Steven Price 2020-10-24 11:56:09 +01:00 committed by Volker Lendecke
parent 9883ac4593
commit 1e47c04aad

View File

@ -1126,7 +1126,9 @@ static int tar_send_file(struct tar *t, struct archive_entry *entry)
uint16_t remote_fd = (uint16_t) -1;
int err = 0;
int flags = O_RDWR | O_CREAT | O_TRUNC;
mode_t mode = archive_entry_filetype(entry);
mode_t filetype = archive_entry_filetype(entry);
mode_t mode = archive_entry_mode(entry);
time_t mtime = archive_entry_mtime(entry);
int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
if (ctx == NULL) {
@ -1156,7 +1158,7 @@ static int tar_send_file(struct tar *t, struct archive_entry *entry)
goto out;
}
if (mode != AE_IFREG && mode != AE_IFDIR) {
if (filetype != AE_IFREG && filetype != AE_IFDIR) {
d_printf("Skipping non-dir & non-regular file %s\n", full_path);
goto out;
}
@ -1167,7 +1169,7 @@ static int tar_send_file(struct tar *t, struct archive_entry *entry)
goto out;
}
if (mode == AE_IFDIR) {
if (filetype == AE_IFDIR) {
goto out;
}
@ -1215,6 +1217,13 @@ close_out:
err = 1;
}
status = cli_setatr(cli, full_path, mode, mtime);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Error setting attributes on remote file %s: %s\n",
full_path, nt_errstr(status));
err = 1;
}
out:
talloc_free(ctx);
return err;