summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-12-01 09:01:20 +0100
committerJeremy Allison <jra@samba.org>2019-12-06 00:17:36 +0000
commitc6beb71813c015fddda02190e8093c335a2de411 (patch)
treee7cf2b2456fa823089215d6a612a179a121d2e68 /source3/client
parent1b9c31ef6ae8ffe1ee052b34d5013032cd37838a (diff)
downloadsamba-c6beb71813c015fddda02190e8093c335a2de411.tar.gz
smbclient: use cli_setpathinfo_ext() in utimes command
This allows correct processing of sentinel date values. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index ccbfba0b53f..cca88bd7893 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -39,6 +39,7 @@
#include "libsmb/nmblib.h"
#include "include/ntioctl.h"
#include "../libcli/smb/smbXcli_base.h"
+#include "lib/util/time_basic.h"
#ifndef REGISTER
#define REGISTER 0
@@ -5189,16 +5190,22 @@ static int cmd_show_connect( void )
*
* Update the file times with the ones provided.
*/
-static int set_remote_times(const char *filename, time_t create_time,
- time_t access_time, time_t write_time,
- time_t change_time)
+static int set_remote_times(const char *filename,
+ struct timespec *create_time,
+ struct timespec *access_time,
+ struct timespec *write_time,
+ struct timespec *change_time)
{
extern struct cli_state *cli;
NTSTATUS status;
- status = cli_setpathinfo_basic(cli, filename, create_time,
- access_time, write_time,
- change_time, -1);
+ status = cli_setpathinfo_ext(cli,
+ filename,
+ create_time,
+ access_time,
+ write_time,
+ change_time,
+ -1);
if (!NT_STATUS_IS_OK(status)) {
d_printf("cli_setpathinfo_basic failed: %s\n",
nt_errstr(status));
@@ -5219,7 +5226,8 @@ static int cmd_utimes(void)
const extern char *cmd_ptr;
char *buf;
char *fname = NULL;
- time_t times[4] = {0, 0, 0, 0};
+ struct timespec times[4] = {{0}};
+ struct timeval_buf tbuf[4];
int time_count = 0;
int err = 0;
bool ok;
@@ -5256,10 +5264,11 @@ static int cmd_utimes(void)
time_count < 4) {
const char *s = buf;
struct tm tm = {0,};
+ time_t t;
char *ret;
if (strlen(s) == 2 && strcmp(s, "-1") == 0) {
- times[time_count] = 0;
+ times[time_count] = make_omit_timespec();
time_count++;
continue;
} else {
@@ -5278,7 +5287,8 @@ static int cmd_utimes(void)
}
/* Convert tm to a time_t */
- times[time_count] = mktime(&tm);
+ t = mktime(&tm);
+ times[time_count] = (struct timespec){.tv_sec = t};
time_count++;
}
@@ -5293,12 +5303,12 @@ static int cmd_utimes(void)
}
DEBUG(10, ("times\nCreate: %sAccess: %s Write: %sChange: %s\n",
- talloc_strdup(ctx, ctime(&times[0])),
- talloc_strdup(ctx, ctime(&times[1])),
- talloc_strdup(ctx, ctime(&times[2])),
- talloc_strdup(ctx, ctime(&times[3]))));
+ timespec_string_buf(&times[0], false, &tbuf[0]),
+ timespec_string_buf(&times[1], false, &tbuf[1]),
+ timespec_string_buf(&times[2], false, &tbuf[2]),
+ timespec_string_buf(&times[3], false, &tbuf[3])));
- set_remote_times(fname, times[0], times[1], times[2], times[3]);
+ set_remote_times(fname, &times[0], &times[1], &times[2], &times[3]);
out:
talloc_free(ctx);
return err;