You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/09/09 19:30:51 UTC
[1/2] allura git commit: [#8127] don't error if somehow password
field isn't there to pop
Repository: allura
Updated Branches:
refs/heads/db/8127 [created] 6c39b8ad4
[#8127] don't error if somehow password field isn't there to pop
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/830b795d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/830b795d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/830b795d
Branch: refs/heads/db/8127
Commit: 830b795d4be578df16cfd229622935cbf24a1b8b
Parents: abc3b8e
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Sep 9 15:26:43 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Sep 9 15:29:58 2016 -0400
----------------------------------------------------------------------
Allura/allura/lib/decorators.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/830b795d/Allura/allura/lib/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index 7249e7c..70e5833 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -121,7 +121,7 @@ def reconfirm_auth(func, *args, **kwargs):
if AuthenticationProvider.get(request).validate_password(c.user, request.POST['password']):
session['auth-reconfirmed'] = datetime.utcnow()
session.save()
- kwargs.pop('password')
+ kwargs.pop('password', None)
else:
c.form_errors['password'] = 'Invalid password.'
[2/2] allura git commit: [#8127] set right perms for file,
with atomic ops
Posted by br...@apache.org.
[#8127] set right perms for file, with atomic ops
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6c39b8ad
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6c39b8ad
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6c39b8ad
Branch: refs/heads/db/8127
Commit: 6c39b8ad47fd4bcec9207f49971a60865a2fc2b5
Parents: 830b795
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Sep 9 15:26:46 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Sep 9 15:30:05 2016 -0400
----------------------------------------------------------------------
Allura/allura/lib/multifactor.py | 11 ++++++++++-
Allura/allura/lib/utils.py | 9 +++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6c39b8ad/Allura/allura/lib/multifactor.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/multifactor.py b/Allura/allura/lib/multifactor.py
index cfd6247..6bfe3c8 100644
--- a/Allura/allura/lib/multifactor.py
+++ b/Allura/allura/lib/multifactor.py
@@ -19,6 +19,7 @@ import os
import logging
import random
import string
+import tempfile
from collections import OrderedDict
from base64 import b32decode, b32encode
from time import time
@@ -37,6 +38,7 @@ import qrcode
from ming.odm import session
from allura.model.multifactor import RecoveryCode
+from allura.lib.utils import umask
log = logging.getLogger(__name__)
@@ -228,8 +230,15 @@ class GoogleAuthenticatorPamFilesystemMixin(object):
raise
def write_file(self, user, gaf):
- with open(self.config_file(user), 'w') as f:
+ conf_file = self.config_file(user)
+ # using a tmp file and rename is atomic, and how PAM module does it
+ # see `write_file_contents` in libpam/src/pam_google_authenticator.c
+ # 377 umask gives 400 permissions, which matches how the PAM module does it (600 would be fine too)
+ with umask(0o377), tempfile.NamedTemporaryFile(dir=os.path.dirname(conf_file),
+ prefix='tmp-allura-gauth-',
+ delete=False) as f:
f.write(gaf.dump())
+ os.rename(f.name, conf_file)
class GoogleAuthenticatorPamFilesystemTotpService(TotpService, GoogleAuthenticatorPamFilesystemMixin):
http://git-wip-us.apache.org/repos/asf/allura/blob/6c39b8ad/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 4ee7ca7..47352de 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -683,3 +683,12 @@ class JSONForExport(tg.jsonify.GenericJSON):
except TypeError:
return obj.__json__()
return super(JSONForExport, self).default(obj)
+
+
+@contextmanager
+def umask(new_mask):
+ cur_mask = os.umask(new_mask)
+ try:
+ yield
+ finally:
+ os.umask(cur_mask)