]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: optimize time skew check
authorBingyin Zhang <zhangbingyin@cloudin.cn>
Thu, 14 Dec 2017 08:03:36 +0000 (16:03 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 6 Mar 2018 16:41:02 +0000 (17:41 +0100)
* Move query string check out of function is_time_skew_ok;

Signed-off-by: Bingyin Zhang <zhangbingyin@cloudin.cn>
(cherry picked from commit 2c97b0ce8378dedef9296bd57273c0b9f1c1f440)

src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index 9c7eabbaeeb1fa500eaaab77beb1b1c9366a71f2..b3e8d637b1b3d7bf2827fd3dbbe0fb4f755d4070 100644 (file)
@@ -3671,16 +3671,15 @@ namespace rgw {
 namespace auth {
 namespace s3 {
 
-bool AWSGeneralAbstractor::is_time_skew_ok(const utime_t& header_time,
-                                           const bool qsr) const
+bool AWSGeneralAbstractor::is_time_skew_ok(const utime_t& header_time) const
 {
   /* Check for time skew first. */
   const time_t req_sec = header_time.sec();
   time_t now;
   time(&now);
 
-  if ((req_sec < now - RGW_AUTH_GRACE_MINS * 60 ||
-       req_sec > now + RGW_AUTH_GRACE_MINS * 60) && !qsr) {
+  if (req_sec < now - RGW_AUTH_GRACE_MINS * 60 ||
+      req_sec > now + RGW_AUTH_GRACE_MINS * 60) {
     ldout(cct, 10) << "req_sec=" << req_sec << " now=" << now
                    << "; now - RGW_AUTH_GRACE_MINS="
                    << now - RGW_AUTH_GRACE_MINS * 60
@@ -3693,9 +3692,9 @@ bool AWSGeneralAbstractor::is_time_skew_ok(const utime_t& header_time,
                    << " req_time=" << header_time
                    << dendl;
     return false;
-  } else {
-    return true;
   }
+
+  return true;
 }
 
 
@@ -3968,7 +3967,7 @@ AWSGeneralAbstractor::get_auth_data_v2(const req_state* const s) const
   ldout(cct, 10) << "string_to_sign:\n"
                  << rgw::crypt_sanitize::auth{s,string_to_sign} << dendl;
 
-  if (! is_time_skew_ok(header_time, qsr)) {
+  if (!qsr && !is_time_skew_ok(header_time)) {
     throw -ERR_REQUEST_TIME_SKEWED;
   }
 
index d0aa098fa1b82fc74533aec9fb4f51fdfd5a2b19..a515303f985bb14f573efff8532070d13aba3023 100644 (file)
@@ -767,8 +767,7 @@ public:
 class AWSGeneralAbstractor : public AWSEngine::VersionAbstractor {
   CephContext* const cct;
 
-  bool is_time_skew_ok(const utime_t& header_time,
-                       const bool qsr) const;
+  bool is_time_skew_ok(const utime_t& header_time) const;
 
   virtual boost::optional<std::string>
   get_v4_canonical_headers(const req_info& info,