mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-24 11:12:14 +01:00
Avoid stale ~/.osc_cookiejar file
Always clear the cookiejar, if ~/.oscrc's mtime is "greater" than ~/.osc_cookiejar's mtime. This fixes issue #86.
This commit is contained in:
parent
25ccfde43c
commit
05ad9efae3
@ -560,7 +560,7 @@ def _build_opener(apiurl):
|
|||||||
return opener
|
return opener
|
||||||
|
|
||||||
|
|
||||||
def init_basicauth(config):
|
def init_basicauth(config, config_mtime):
|
||||||
"""initialize urllib2 with the credentials for Basic Authentication"""
|
"""initialize urllib2 with the credentials for Basic Authentication"""
|
||||||
|
|
||||||
def filterhdrs(meth, ishdr, *hdrs):
|
def filterhdrs(meth, ishdr, *hdrs):
|
||||||
@ -613,6 +613,9 @@ def init_basicauth(config):
|
|||||||
cookiejar = LWPCookieJar(cookie_file)
|
cookiejar = LWPCookieJar(cookie_file)
|
||||||
try:
|
try:
|
||||||
cookiejar.load(ignore_discard=True)
|
cookiejar.load(ignore_discard=True)
|
||||||
|
if int(round(config_mtime)) > int(os.stat(cookie_file).st_mtime):
|
||||||
|
cookiejar.clear()
|
||||||
|
cookiejar.save()
|
||||||
except IOError:
|
except IOError:
|
||||||
try:
|
try:
|
||||||
fd = os.open(cookie_file, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o600)
|
fd = os.open(cookie_file, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o600)
|
||||||
@ -1026,7 +1029,7 @@ def get_config(override_conffile=None,
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
# finally, initialize urllib2 for to use the credentials for Basic Authentication
|
# finally, initialize urllib2 for to use the credentials for Basic Authentication
|
||||||
init_basicauth(config)
|
init_basicauth(config, os.stat(conffile).st_mtime)
|
||||||
|
|
||||||
|
|
||||||
# vim: sw=4 et
|
# vim: sw=4 et
|
||||||
|
Loading…
x
Reference in New Issue
Block a user