return parse_rfc850(s, t) || parse_asctime(s, t) || parse_rfc1123(s, t) || parse_rfc1123_alt(s,t);
}
-bool parse_iso8601(const char *s, struct tm *t)
+bool parse_iso8601(const char *s, struct tm *t, bool extended_format)
{
memset(t, 0, sizeof(*t));
- const char *p = strptime(s, "%Y-%m-%dT%T", t);
+ const char *p;
+
+ if (!s)
+ s = "";
+
+ if (extended_format)
+ p = strptime(s, "%Y-%m-%dT%T", t);
+ else
+ p = strptime(s, "%Y%m%dT%H%M%S", t);
if (!p) {
dout(0) << "parse_iso8601 failed" << dendl;
return false;
/** time parsing */
extern int parse_time(const char *time_str, time_t *time);
extern bool parse_rfc2616(const char *s, struct tm *t);
-extern bool parse_iso8601(const char *s, struct tm *t);
+extern bool parse_iso8601(const char *s, struct tm *t, bool extended_format = true);
extern string rgw_trim_whitespace(const string& src);
extern string rgw_trim_quotes(const string& val);
/* grab date */
const char *d = s->info.env->get("HTTP_X_AMZ_DATE");
- s->aws4_auth->date = d ? d : "";
- if (s->aws4_auth->date.empty()) {
+ struct tm t;
+ if (!parse_iso8601(d, &t, false)) {
dout(10) << "error reading date via http_x_amz_date" << dendl;
- return -EINVAL;
+ return -EACCES;
}
-
+ s->aws4_auth->date = d;
}
/* AKIAIVKTAZLOCF43WNQD/AAAAMMDD/region/host/aws4_request */