mirror of
https://github.com/samba-team/samba.git
synced 2025-10-24 15:33:20 +03:00
s3: libsmb: Add clistr_is_previous_version_path()
Looks for @GMT- token in pathname. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
This commit is contained in:
committed by
Uri Simchoni
parent
79c8b75671
commit
19696f3494
@@ -37,3 +37,31 @@ size_t clistr_pull_talloc(TALLOC_CTX *ctx,
|
||||
src_len,
|
||||
flags);
|
||||
}
|
||||
|
||||
bool clistr_is_previous_version_path(const char *path)
|
||||
{
|
||||
char *q;
|
||||
time_t timestamp;
|
||||
struct tm tm;
|
||||
const char *p = strstr_m(path, "@GMT-");
|
||||
|
||||
if (p == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (p > path && (p[-1] != '\\')) {
|
||||
return false;
|
||||
}
|
||||
q = strptime(p, GMT_FORMAT, &tm);
|
||||
if (q == NULL) {
|
||||
return false;
|
||||
}
|
||||
tm.tm_isdst = -1;
|
||||
timestamp = timegm(&tm);
|
||||
if (timestamp == (time_t)-1) {
|
||||
return false;
|
||||
}
|
||||
if (q[0] != '\0' && q[0] != '\\') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -868,6 +868,7 @@ size_t clistr_pull_talloc(TALLOC_CTX *ctx,
|
||||
const void *src,
|
||||
int src_len,
|
||||
int flags);
|
||||
bool clistr_is_previous_version_path(const char *path);
|
||||
|
||||
/* The following definitions come from libsmb/clitrans.c */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user