summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-07-02 22:31:49 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-28 15:47:37 +1000
commitf2ccff7b06a2ad762103f98a736f37da94d7cfdd (patch)
tree0c43173607f12b2d467ed6c047fde92beed78da6
parentde209587f9ddbe19d321753bb8f160ce19eb4517 (diff)
downloadsamba-f2ccff7b06a2ad762103f98a736f37da94d7cfdd.tar.gz
samba-f2ccff7b06a2ad762103f98a736f37da94d7cfdd.tar.bz2
samba-f2ccff7b06a2ad762103f98a736f37da94d7cfdd.zip
s3-vfs: Try to be consistent about localtime vs GMT handling in vfs_shadow_copy2
With the ability to handle times a abolute time_t values since 1970 this becomes more important to get absolutly correct. Andrew Bartlett
-rw-r--r--source3/modules/vfs_shadow_copy2.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index 227453d277..7c42052af7 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -150,27 +150,34 @@ static char *shadow_copy2_insert_string(TALLOC_CTX *mem_ctx,
{
const char *fmt;
struct tm snap_tm;
- fstring gmt;
- size_t gmt_len;
+ fstring snaptime_string;
+ size_t snaptime_len;
- if (localtime_r(&snapshot, &snap_tm) == 0) {
- DEBUG(10, ("gmtime_r failed\n"));
- return NULL;
- }
fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
"format", GMT_FORMAT);
if (lp_parm_bool(SNUM(handle->conn), "shadow", "sscanf", false)) {
- gmt_len = snprintf(gmt, sizeof(gmt), fmt,
+ snaptime_len = snprintf(snaptime_string, sizeof(snaptime_string), fmt,
(unsigned long)snapshot);
- if (gmt_len == 0) {
+ if (snaptime_len <= 0) {
DEBUG(10, ("snprintf failed\n"));
return NULL;
}
} else {
- gmt_len = strftime(gmt, sizeof(gmt), fmt,
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", false)) {
+ if (localtime_r(&snapshot, &snap_tm) == 0) {
+ DEBUG(10, ("gmtime_r failed\n"));
+ return NULL;
+ }
+ } else {
+ if (gmtime_r(&snapshot, &snap_tm) == 0) {
+ DEBUG(10, ("gmtime_r failed\n"));
+ return NULL;
+ }
+ }
+ snaptime_len = strftime(snaptime_string, sizeof(snaptime_string), fmt,
&snap_tm);
- if (gmt_len == 0) {
+ if (snaptime_len == 0) {
DEBUG(10, ("strftime failed\n"));
return NULL;
}
@@ -179,7 +186,7 @@ static char *shadow_copy2_insert_string(TALLOC_CTX *mem_ctx,
lp_parm_const_string(
SNUM(handle->conn), "shadow", "snapdir",
".snapshots"),
- gmt);
+ snaptime_string);
}
static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
@@ -207,7 +214,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
goto no_snapshot;
}
tm.tm_isdst = -1;
- timestamp = mktime(&tm);
+ timestamp = timegm(&tm);
if (timestamp == (time_t)-1) {
goto no_snapshot;
}