diff -Nru swauth-1.0.4/debian/changelog swauth-1.0.4/debian/changelog --- swauth-1.0.4/debian/changelog 2013-09-19 16:41:19.000000000 +0000 +++ swauth-1.0.4/debian/changelog 2016-06-09 03:10:53.000000000 +0000 @@ -1,8 +1,18 @@ -swauth (1.0.4-0ubuntu1~cloud0) precise-havana; urgency=low +swauth (1.0.4-0ubuntu1.14.04.1~cloud0) precise-icehouse; urgency=medium * New update for the Ubuntu Cloud Archive. - -- Chuck Short Thu, 19 Sep 2013 12:41:19 -0400 + -- Openstack Ubuntu Testing Bot Thu, 09 Jun 2016 03:10:53 +0000 + +swauth (1.0.4-0ubuntu1.14.04.1) trusty; urgency=medium + + * Use correct timeout parameter (LP: #1582475) + - d/p/0001-Fixed-to-work-with-newer-Swift.patch: backported a patch + from upstream to use either the timeout or time parameter to the + Swift memcache client implementation depending on the version of + Swift installed. + + -- Billy Olsen Tue, 07 Jun 2016 16:53:12 +0200 swauth (1.0.4-0ubuntu1) quantal; urgency=low diff -Nru swauth-1.0.4/debian/patches/0001-Fixed-to-work-with-newer-Swift.patch swauth-1.0.4/debian/patches/0001-Fixed-to-work-with-newer-Swift.patch --- swauth-1.0.4/debian/patches/0001-Fixed-to-work-with-newer-Swift.patch 1970-01-01 00:00:00.000000000 +0000 +++ swauth-1.0.4/debian/patches/0001-Fixed-to-work-with-newer-Swift.patch 2016-06-07 14:53:10.000000000 +0000 @@ -0,0 +1,198 @@ +From 6bd58deadbd3dab59dc542d907a67e69b66aa9ff Mon Sep 17 00:00:00 2001 +From: gholt +Date: Wed, 24 Apr 2013 07:32:32 +0000 +Subject: [PATCH 1/1] Fixed to work with newer Swift + +This cherry-pick checks the version of Swift and determines +whether to use the timeout or the time parameter for calls +to the swift.common.memcache client. + +(cherry picked from commit c44b5b64489c1721cf05992b14e53b0c8a4e325e) +--- + swauth/middleware.py | 42 +++++++++++++++++----- + swauth/swift_version.py | 71 +++++++++++++++++++++++++++++++++++++ + test_swauth/unit/test_middleware.py | 6 ++-- + 3 files changed, 107 insertions(+), 12 deletions(-) + create mode 100644 swauth/swift_version.py + +diff --git a/swauth/middleware.py b/swauth/middleware.py +index 399fa5c..e7a070d 100644 +--- a/swauth/middleware.py ++++ b/swauth/middleware.py +@@ -39,9 +39,12 @@ from swift.common.utils import cache_from_env, get_logger, get_remote_client, \ + split_path, TRUE_VALUES, urlparse + from swift.common.wsgi import make_pre_authed_request + ++from swauth import swift_version + import swauth.authtypes + + ++MEMCACHE_TIME = swift_version.newer_than('1.7.7-dev') ++ + + class Swauth(object): + """ +@@ -302,9 +305,14 @@ class Swauth(object): + expires_from_now = float(resp.getheader('x-auth-ttl')) + groups = resp.getheader('x-auth-groups') + if memcache_client: +- memcache_client.set(memcache_key, +- (time() + expires_from_now, groups), +- timeout=expires_from_now) ++ if MEMCACHE_TIME: ++ memcache_client.set( ++ memcache_key, (time() + expires_from_now, groups), ++ time=expires_from_now) ++ else: ++ memcache_client.set( ++ memcache_key, (time() + expires_from_now, groups), ++ timeout=expires_from_now) + else: + path = quote('/v1/%s/.token_%s/%s' % + (self.auth_account, token[-1], token)) +@@ -323,9 +331,16 @@ class Swauth(object): + groups.append(detail['account_id']) + groups = ','.join(groups) + if memcache_client: +- memcache_client.set(memcache_key, +- (detail['expires'], groups), +- timeout=float(detail['expires'] - time())) ++ if MEMCACHE_TIME: ++ memcache_client.set( ++ memcache_key, ++ (detail['expires'], groups), ++ time=float(detail['expires'] - time())) ++ else: ++ memcache_client.set( ++ memcache_key, ++ (detail['expires'], groups), ++ timeout=float(detail['expires'] - time())) + return groups + + def authorize(self, req): +@@ -1312,9 +1327,18 @@ class Swauth(object): + if not memcache_client: + raise Exception( + 'No memcache set up; required for Swauth middleware') +- memcache_client.set(memcache_key, (self.itoken_expires, +- '.auth,.reseller_admin,%s.auth' % self.reseller_prefix), +- timeout=self.token_life) ++ if MEMCACHE_TIME: ++ memcache_client.set( ++ memcache_key, ++ (self.itoken_expires, ++ '.auth,.reseller_admin,%s.auth' % self.reseller_prefix), ++ time=self.token_life) ++ else: ++ memcache_client.set( ++ memcache_key, ++ (self.itoken_expires, ++ '.auth,.reseller_admin,%s.auth' % self.reseller_prefix), ++ timeout=self.token_life) + return self.itoken + + def get_admin_detail(self, req): +diff --git a/swauth/swift_version.py b/swauth/swift_version.py +new file mode 100644 +index 0000000..cabe284 +--- /dev/null ++++ b/swauth/swift_version.py +@@ -0,0 +1,71 @@ ++import swift ++ ++ ++MAJOR = None ++MINOR = None ++REVISION = None ++FINAL = None ++ ++ ++def parse(value): ++ parts = value.split('.') ++ if parts[-1].endswith('-dev'): ++ final = False ++ parts[-1] = parts[-1][:-4] ++ else: ++ final = True ++ major = int(parts.pop(0)) ++ minor = int(parts.pop(0)) ++ if parts: ++ revision = int(parts.pop(0)) ++ else: ++ revision = 0 ++ return major, minor, revision, final ++ ++ ++def newer_than(value): ++ global MAJOR, MINOR, REVISION, FINAL ++ major, minor, revision, final = parse(value) ++ if MAJOR is None: ++ MAJOR, MINOR, REVISION, FINAL = parse(swift.__version__) ++ if MAJOR < major: ++ return False ++ elif MAJOR == major: ++ if MINOR < minor: ++ return False ++ elif MINOR == minor: ++ if REVISION < revision: ++ return False ++ elif REVISION == revision: ++ if not FINAL or final: ++ return False ++ return True ++ ++ ++def run_tests(): ++ global MAJOR, MINOR, REVISION, FINAL ++ MAJOR, MINOR, REVISION, FINAL = parse('1.3') ++ assert(newer_than('1.2')) ++ assert(newer_than('1.2.9')) ++ assert(newer_than('1.3-dev')) ++ assert(newer_than('1.3.0-dev')) ++ assert(not newer_than('1.3')) ++ assert(not newer_than('1.3.0')) ++ assert(not newer_than('1.3.1-dev')) ++ assert(not newer_than('1.3.1')) ++ assert(not newer_than('1.4')) ++ assert(not newer_than('2.0')) ++ MAJOR, MINOR, REVISION, FINAL = parse('1.7.7-dev') ++ assert(newer_than('1.6')) ++ assert(newer_than('1.7')) ++ assert(newer_than('1.7.6-dev')) ++ assert(newer_than('1.7.6')) ++ assert(not newer_than('1.7.7')) ++ assert(not newer_than('1.7.8-dev')) ++ assert(not newer_than('1.7.8')) ++ assert(not newer_than('1.8.0')) ++ assert(not newer_than('2.0')) ++ ++ ++if __name__ == '__main__': ++ run_tests() +diff --git a/test_swauth/unit/test_middleware.py b/test_swauth/unit/test_middleware.py +index 8f8bd7b..761ac00 100644 +--- a/test_swauth/unit/test_middleware.py ++++ b/test_swauth/unit/test_middleware.py +@@ -35,16 +35,16 @@ class FakeMemcache(object): + def get(self, key): + return self.store.get(key) + +- def set(self, key, value, timeout=0): ++ def set(self, key, value, timeout=0, time=0): + self.store[key] = value + return True + +- def incr(self, key, timeout=0): ++ def incr(self, key, timeout=0, time=0): + self.store[key] = self.store.setdefault(key, 0) + 1 + return self.store[key] + + @contextmanager +- def soft_lock(self, key, timeout=0, retries=5): ++ def soft_lock(self, key, timeout=0, retries=5, time=0): + yield True + + def delete(self, key): +-- +2.7.4 + diff -Nru swauth-1.0.4/debian/patches/series swauth-1.0.4/debian/patches/series --- swauth-1.0.4/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ swauth-1.0.4/debian/patches/series 2016-06-07 14:53:10.000000000 +0000 @@ -0,0 +1 @@ +0001-Fixed-to-work-with-newer-Swift.patch