]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: optimize time skew check 19511/head
authorBingyin Zhang <zhangbingyin@cloudin.cn>
Thu, 14 Dec 2017 08:03:36 +0000 (16:03 +0800)
committerBingyin Zhang <zhangbingyin@cloudin.cn>
Thu, 14 Dec 2017 08:43:01 +0000 (16:43 +0800)
* Move query string check out of function is_time_skew_ok;

Signed-off-by: Bingyin Zhang <zhangbingyin@cloudin.cn>
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index 080c1180d92bc1e3e8c2c14440bd4998cbb5e006..dfd405d654d528f26e7d1b4ac0c82dcc5030ee9f 100644 (file)
@@ -3660,16 +3660,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
@@ -3682,9 +3681,9 @@ bool AWSGeneralAbstractor::is_time_skew_ok(const utime_t& header_time,
                    << " req_time=" << header_time
                    << dendl;
     return false;
-  } else {
-    return true;
   }
+
+  return true;
 }
 
 
@@ -3956,7 +3955,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 48130d6fcee82da166f26f921af10c4d352d60f2..10c8be185613c0c9bf25f6cae5e0845621e0b837 100644 (file)
@@ -766,8 +766,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,