From: Volker Lendecke Date: Mon, 30 Mar 2020 19:43:51 +0000 (+0200) Subject: libsmb: Respect the full timeval for smbc_utimes() X-Git-Tag: ldb-2.2.0~943 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cfd0a8a738e39679aa7dab4580c2bcaf270c7616;p=thirdparty%2Fsamba.git libsmb: Respect the full timeval for smbc_utimes() Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/selftest/knownfail.d/libsmbclient.utimes b/selftest/knownfail.d/libsmbclient.utimes deleted file mode 100644 index 4b7db2eb5a0..00000000000 --- a/selftest/knownfail.d/libsmbclient.utimes +++ /dev/null @@ -1 +0,0 @@ -samba4.libsmbclient.utimes.* diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index fe236f41f0c..581dd6b9c1c 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -34,6 +34,7 @@ #include "../libcli/smb/smbXcli_base.h" #include "../libcli/security/security.h" #include "lib/util/tevent_ntstatus.h" +#include "lib/util/time_basic.h" /* * Routine to open a directory @@ -2047,8 +2048,7 @@ SMBC_utimes_ctx(SMBCCTX *context, char *password = NULL; char *workgroup = NULL; char *path = NULL; - time_t access_time; - time_t write_time; + struct timespec access_time, write_time; uint16_t port = 0; TALLOC_CTX *frame = talloc_stackframe(); bool ok; @@ -2067,31 +2067,19 @@ SMBC_utimes_ctx(SMBCCTX *context, } if (tbuf == NULL) { - access_time = write_time = time(NULL); + access_time = write_time = timespec_current(); } else { - access_time = tbuf[0].tv_sec; - write_time = tbuf[1].tv_sec; + access_time = convert_timeval_to_timespec(tbuf[0]); + write_time = convert_timeval_to_timespec(tbuf[1]); } if (DEBUGLVL(4)) { - char *p; - char atimebuf[32]; - char mtimebuf[32]; - - strncpy(atimebuf, ctime(&access_time), sizeof(atimebuf) - 1); - atimebuf[sizeof(atimebuf) - 1] = '\0'; - if ((p = strchr(atimebuf, '\n')) != NULL) { - *p = '\0'; - } - - strncpy(mtimebuf, ctime(&write_time), sizeof(mtimebuf) - 1); - mtimebuf[sizeof(mtimebuf) - 1] = '\0'; - if ((p = strchr(mtimebuf, '\n')) != NULL) { - *p = '\0'; - } + struct timeval_buf abuf, wbuf; dbgtext("smbc_utimes(%s, atime = %s mtime = %s)\n", - fname, atimebuf, mtimebuf); + fname, + timespec_string_buf(&access_time, false, &abuf), + timespec_string_buf(&write_time, false, &wbuf)); } if (SMBC_parse_path(frame, @@ -2132,8 +2120,8 @@ SMBC_utimes_ctx(SMBCCTX *context, srv, path, (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, - (struct timespec) { .tv_sec = access_time }, - (struct timespec) { .tv_sec = write_time }, + access_time, + write_time, (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, 0); if (!ok) {