From: Ralph Boehme Date: Fri, 1 May 2020 14:30:28 +0000 (+0200) Subject: smbd: print twrp in smb_fname_str_dbg() X-Git-Tag: ldb-2.2.0~682 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6b0c3d1ec6205b6279596615b0ff0710d613e2a;p=thirdparty%2Fsamba.git smbd: print twrp in smb_fname_str_dbg() This looses precision by going from NTTIME to time_t, but GMT_FORMAT only has seconds granularity anyway and @GMT token as defined by MS-SMB2 as well. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 6ab5d26a7ab..00a5fcda997 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -136,6 +136,11 @@ struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx, const char *smb_fname_str_dbg(const struct smb_filename *smb_fname) { char *fname = NULL; + time_t t; + struct tm tm; + struct tm *ptm = NULL; + fstring tstr; + ssize_t slen; NTSTATUS status; if (smb_fname == NULL) { @@ -145,6 +150,28 @@ const char *smb_fname_str_dbg(const struct smb_filename *smb_fname) if (!NT_STATUS_IS_OK(status)) { return ""; } + if (smb_fname->twrp == 0) { + return fname; + } + + t = nt_time_to_unix(smb_fname->twrp); + ptm = gmtime_r(&t, &tm); + if (ptm == NULL) { + return ""; + } + + slen = strftime(tstr, sizeof(tstr), GMT_FORMAT, &tm); + if (slen == 0) { + return ""; + } + + fname = talloc_asprintf(talloc_tos(), + "%s {%s}", + fname, + tstr); + if (fname == NULL) { + return ""; + } return fname; }