[Python-modules-commits] [python-keyring] 01/04: Import python-keyring_5.7.orig.tar.gz

Dmitry Shachnev mitya57 at moszumanska.debian.org
Mon Dec 7 07:02:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch master
in repository python-keyring.

commit 3baec8e16b8182086a7135b7b6f1b2a376d68588
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Mon Dec 7 09:50:09 2015 +0300

    Import python-keyring_5.7.orig.tar.gz
---
 .hgtags                      |  1 +
 CHANGES.rst                  |  9 +++++
 CONTRIBUTORS.txt             | 25 -------------
 PKG-INFO                     | 44 +++++++++++++++++++----
 README.rst                   | 33 ++++++++++++++----
 keyring.egg-info/PKG-INFO    | 44 +++++++++++++++++++----
 keyring.egg-info/SOURCES.txt |  1 -
 keyring/backends/Gnome.py    | 13 +++++--
 keyring/backends/OS_X.py     | 83 +++++++++++++++++++++++++++++++++-----------
 keyring/tests/test_core.py   | 14 +++-----
 setup.cfg                    |  2 +-
 11 files changed, 188 insertions(+), 81 deletions(-)

diff --git a/.hgtags b/.hgtags
index 8e7cbfc..9277354 100644
--- a/.hgtags
+++ b/.hgtags
@@ -81,3 +81,4 @@ ec350f6cd8328edc404e6cbfd489b657cf7a2dea 5.3
 25fc5b1f44a2a5acf5f314f47b4df1486dae767a 5.5
 41a4a8009d2336bfebe221e735a642d0740651e6 5.5.1
 155b7078a68c14f4a8158e1154fd5c050acbcf2a 5.6
+b627f03618585eeb8df1d7403ac3637ece06d644 5.7
diff --git a/CHANGES.rst b/CHANGES.rst
index 2e573f7..d472446 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -3,6 +3,15 @@ CHANGES
 =======
 
 ---
+5.7
+---
+
+* Issue #177: Resolve default keyring name on Gnome using the API.
+* Issue #145: Add workaround for password exposure through
+  process status for most passwords containing simple
+  characters.
+
+---
 5.6
 ---
 
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
deleted file mode 100644
index 65ee685..0000000
--- a/CONTRIBUTORS.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-------------
-Contributors
-------------
-
-* Kang Zhang
-* Tarek Ziadé
-* Marcin Kasperski
-* Steve Borho
-* Michael Gruenewald
-* Jason R. Coombs
-* Benji York
-* Jonathan Ballet
-* Gary Poster
-* Patrick Mezard
-* Jérôme Laheurte
-* Jake Basile
-* Jelmer Vernooij
-* André Sintzoff
-* Thomas Kluyver
-* Sebastian Ramacher
-* Robert Leftwich
-* Kyle Stark
-* Daniel Holth
-* Manuel de la Peña
-* Dmitry Shachnev
diff --git a/PKG-INFO b/PKG-INFO
index d638a9e..b5e2358 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: keyring
-Version: 5.6
+Version: 5.7
 Summary: Store and access your passwords safely.
 Home-page: http://bitbucket.org/kang/python-keyring-lib
 Author: Jason R. Coombs
@@ -63,6 +63,30 @@ Description: =======================================
             >>> keyring.get_password("system", "username")
             'password'
         
+        Command-line Utility
+        ====================
+        
+        Keyring supplies a ``keyring`` command which is installed with the
+        package. After installing keyring in most environments, the
+        command should be available for setting, getting, and deleting
+        passwords. For more information on usage, invoke with no arguments
+        or with ``--help`` as so::
+        
+            $ keyring --help
+            $ keyring set system username
+            Password for 'username' in 'system':
+            $ keyring get system username
+            password
+        
+        The command-line functionality is also exposed as an executable
+        package, suitable for invoking from Python like so::
+        
+            $ python -m keyring --help
+            $ python -m keyring set system username
+            Password for 'username' in 'system':
+            $ python -m keyring get system username
+            password
+        
         --------------------------
         Configure your keyring lib
         --------------------------
@@ -267,9 +291,9 @@ Description: =======================================
         
             python bin/test --help
         
-        -------
-        Credits
-        -------
+        ----------
+        Background
+        ----------
         
         The project was based on Tarek Ziade's idea in `this post`_. Kang Zhang
         initially carried it out as a `Google Summer of Code`_ project, and Tarek
@@ -277,14 +301,20 @@ Description: =======================================
         
         .. _this post: http://tarekziade.wordpress.com/2009/03/27/pycon-hallway-session-1-a-keyring-library-for-python/
         .. _Google Summer of Code: http://socghop.appspot.com/
-        
-        See CONTRIBUTORS.txt for a complete list of contributors.
-        
         =======
         CHANGES
         =======
         
         ---
+        5.7
+        ---
+        
+        * Issue #177: Resolve default keyring name on Gnome using the API.
+        * Issue #145: Add workaround for password exposure through
+          process status for most passwords containing simple
+          characters.
+        
+        ---
         5.6
         ---
         
diff --git a/README.rst b/README.rst
index 5d1b4cd..29f4628 100644
--- a/README.rst
+++ b/README.rst
@@ -55,6 +55,30 @@ and `keyring.get_password`:
     >>> keyring.get_password("system", "username")
     'password'
 
+Command-line Utility
+====================
+
+Keyring supplies a ``keyring`` command which is installed with the
+package. After installing keyring in most environments, the
+command should be available for setting, getting, and deleting
+passwords. For more information on usage, invoke with no arguments
+or with ``--help`` as so::
+
+    $ keyring --help
+    $ keyring set system username
+    Password for 'username' in 'system':
+    $ keyring get system username
+    password
+
+The command-line functionality is also exposed as an executable
+package, suitable for invoking from Python like so::
+
+    $ python -m keyring --help
+    $ python -m keyring set system username
+    Password for 'username' in 'system':
+    $ python -m keyring get system username
+    password
+
 --------------------------
 Configure your keyring lib
 --------------------------
@@ -259,9 +283,9 @@ For more information about the options that the script provides do execute::
 
     python bin/test --help
 
--------
-Credits
--------
+----------
+Background
+----------
 
 The project was based on Tarek Ziade's idea in `this post`_. Kang Zhang
 initially carried it out as a `Google Summer of Code`_ project, and Tarek
@@ -269,6 +293,3 @@ mentored Kang on this project.
 
 .. _this post: http://tarekziade.wordpress.com/2009/03/27/pycon-hallway-session-1-a-keyring-library-for-python/
 .. _Google Summer of Code: http://socghop.appspot.com/
-
-See CONTRIBUTORS.txt for a complete list of contributors.
-
diff --git a/keyring.egg-info/PKG-INFO b/keyring.egg-info/PKG-INFO
index d638a9e..b5e2358 100644
--- a/keyring.egg-info/PKG-INFO
+++ b/keyring.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: keyring
-Version: 5.6
+Version: 5.7
 Summary: Store and access your passwords safely.
 Home-page: http://bitbucket.org/kang/python-keyring-lib
 Author: Jason R. Coombs
@@ -63,6 +63,30 @@ Description: =======================================
             >>> keyring.get_password("system", "username")
             'password'
         
+        Command-line Utility
+        ====================
+        
+        Keyring supplies a ``keyring`` command which is installed with the
+        package. After installing keyring in most environments, the
+        command should be available for setting, getting, and deleting
+        passwords. For more information on usage, invoke with no arguments
+        or with ``--help`` as so::
+        
+            $ keyring --help
+            $ keyring set system username
+            Password for 'username' in 'system':
+            $ keyring get system username
+            password
+        
+        The command-line functionality is also exposed as an executable
+        package, suitable for invoking from Python like so::
+        
+            $ python -m keyring --help
+            $ python -m keyring set system username
+            Password for 'username' in 'system':
+            $ python -m keyring get system username
+            password
+        
         --------------------------
         Configure your keyring lib
         --------------------------
@@ -267,9 +291,9 @@ Description: =======================================
         
             python bin/test --help
         
-        -------
-        Credits
-        -------
+        ----------
+        Background
+        ----------
         
         The project was based on Tarek Ziade's idea in `this post`_. Kang Zhang
         initially carried it out as a `Google Summer of Code`_ project, and Tarek
@@ -277,14 +301,20 @@ Description: =======================================
         
         .. _this post: http://tarekziade.wordpress.com/2009/03/27/pycon-hallway-session-1-a-keyring-library-for-python/
         .. _Google Summer of Code: http://socghop.appspot.com/
-        
-        See CONTRIBUTORS.txt for a complete list of contributors.
-        
         =======
         CHANGES
         =======
         
         ---
+        5.7
+        ---
+        
+        * Issue #177: Resolve default keyring name on Gnome using the API.
+        * Issue #145: Add workaround for password exposure through
+          process status for most passwords containing simple
+          characters.
+        
+        ---
         5.6
         ---
         
diff --git a/keyring.egg-info/SOURCES.txt b/keyring.egg-info/SOURCES.txt
index b265771..8f31762 100644
--- a/keyring.egg-info/SOURCES.txt
+++ b/keyring.egg-info/SOURCES.txt
@@ -2,7 +2,6 @@
 .hgtags
 .travis.yml
 CHANGES.rst
-CONTRIBUTORS.txt
 README.rst
 buildout.cfg
 hook-keyring.backend.py
diff --git a/keyring/backends/Gnome.py b/keyring/backends/Gnome.py
index 5264e99..49f3f81 100644
--- a/keyring/backends/Gnome.py
+++ b/keyring/backends/Gnome.py
@@ -16,9 +16,11 @@ from ..py27compat import unicode_str
 class Keyring(KeyringBackend):
     """Gnome Keyring"""
 
-    # Name of the keyring to store the passwords in.
-    # Use None for the default keyring.
     KEYRING_NAME = None
+    """
+    Name of the keyring in which to store the passwords.
+    Use None for the default keyring.
+    """
 
     requisite_vars = [
         'DISPLAY',
@@ -35,6 +37,11 @@ class Keyring(KeyringBackend):
             raise RuntimeError("Requisite environment vars are not present")
         return int(cls.has_requisite_vars())
 
+    @property
+    def keyring_name(self):
+        system_default = GnomeKeyring.get_default_keyring_sync()[1]
+        return self.KEYRING_NAME or system_default
+
     @classmethod
     def has_requisite_vars(cls):
         """
@@ -86,7 +93,7 @@ class Keyring(KeyringBackend):
         GnomeKeyring.Attribute.list_append_string(attrs, 'service', service)
         GnomeKeyring.Attribute.list_append_string(attrs, 'application', 'python-keyring')
         result = GnomeKeyring.item_create_sync(
-            self.KEYRING_NAME, GnomeKeyring.ItemType.NETWORK_PASSWORD,
+            self.keyring_name, GnomeKeyring.ItemType.NETWORK_PASSWORD,
             "Password for '%s' on '%s'" % (username, service),
             attrs, password, True)[0]
         if result == GnomeKeyring.Result.CANCELLED:
diff --git a/keyring/backends/OS_X.py b/keyring/backends/OS_X.py
index 1f8d940..f4f7472 100644
--- a/keyring/backends/OS_X.py
+++ b/keyring/backends/OS_X.py
@@ -2,6 +2,7 @@ import platform
 import subprocess
 import re
 import binascii
+import functools
 
 from ..backend import KeyringBackend
 from ..errors import PasswordSetError
@@ -41,26 +42,62 @@ class Keyring(KeyringBackend):
     def set_password(self, service, username, password):
         if username is None:
             username = ''
-        set_error = PasswordSetError("Can't store password in keychain")
         try:
-            # set up the call for security.
-            cmd = [
-                'security',
-                SecurityCommand('add', self.store),
-                '-a', username,
-                '-s', service,
-                '-w', password,
-                '-U',
-            ]
-            call = subprocess.Popen(cmd, stderr=subprocess.PIPE,
-                stdout=subprocess.PIPE)
-            stdoutdata, stderrdata = call.communicate()
-            code = call.returncode
-            # check return code.
-            if code is not 0:
-                raise set_error
-        except:
-            raise set_error
+            # This two-step process is a stop-gap measure until a ctypes
+            # implementation can be created. Fall back to the
+            # command-line version when the username/service/password
+            # strings contain characters (escapes, newlines, etc.) that
+            # the interactive security session can't handle.
+            interactive_call = functools.partial(self._interactive_set,
+                service, username, password)
+            direct_call = functools.partial(self._direct_set,
+                service, username, password)
+            code = interactive_call() and direct_call()
+            # check return code
+            if code:
+                raise Exception()
+        except Exception:
+            raise PasswordSetError("Can't store password in keychain")
+
+    def _interactive_set(self, service, username, password):
+        """
+        Call the security command, supplying parameters through
+        the input stream to avoid revealing the password in the
+        process status.
+        """
+        cmd = [
+            'security',
+            '-i'
+        ]
+        security_cmd = "{} -a '{}' -s '{}' -p '{}' -U\n".format(
+            SecurityCommand('add', self.store),
+            username, service, password)
+        call = subprocess.Popen(
+            cmd,
+            stdin=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            stdout=subprocess.PIPE)
+        stdoutdata, stderrdata = call.communicate(
+            security_cmd.encode('utf-8'))
+        return call.returncode
+
+    def _direct_set(self, service, username, password):
+        """
+        Call the security command, supplying the parameters on
+        the command line.
+        """
+        cmd = [
+            'security',
+            SecurityCommand('add', self.store),
+            '-a', username,
+            '-s', service,
+            '-w', password,
+            '-U',
+        ]
+        call = subprocess.Popen(
+            cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+        stdoutdata, stderrdata = call.communicate()
+        return call.returncode
 
     def get_password(self, service, username):
         if username is None:
@@ -74,7 +111,9 @@ class Keyring(KeyringBackend):
                 '-a', username,
                 '-s', service,
             ]
-            call = subprocess.Popen(cmd, stderr=subprocess.PIPE,
+            call = subprocess.Popen(
+                cmd,
+                stderr=subprocess.PIPE,
                 stdout=subprocess.PIPE)
             stdoutdata, stderrdata = call.communicate()
             code = call.returncode
@@ -112,7 +151,9 @@ class Keyring(KeyringBackend):
                 '-s', service,
             ]
             # set up the call for security.
-            call = subprocess.Popen(cmd, stderr=subprocess.PIPE,
+            call = subprocess.Popen(
+                cmd,
+                stderr=subprocess.PIPE,
                 stdout=subprocess.PIPE)
             stdoutdata, stderrdata = call.communicate()
             code = call.returncode
diff --git a/keyring/tests/test_core.py b/keyring/tests/test_core.py
index 242a3b9..c4a99cf 100644
--- a/keyring/tests/test_core.py
+++ b/keyring/tests/test_core.py
@@ -1,9 +1,3 @@
-"""
-test_core.py
-
-Created by Kang Zhang on 2009-08-09
-"""
-
 from __future__ import with_statement
 
 import os
@@ -27,7 +21,7 @@ def config_filename(tmpdir):
         yield str(filename)
 
 
-class TestKeyring(keyring.backend.KeyringBackend):
+class ATestKeyring(keyring.backend.KeyringBackend):
     """A faked keyring for test.
     """
     def __init__(self):
@@ -50,7 +44,7 @@ class TestKeyring(keyring.backend.KeyringBackend):
             raise errors.PasswordDeleteError("not set")
 
 
-class TestKeyring2(TestKeyring):
+class AnotherTestKeyring(ATestKeyring):
     """Another faked keyring for test.
     """
     def get_password(self, service, username):
@@ -86,7 +80,7 @@ class TestCore:
     def test_set_keyring_in_runtime(self):
         """Test the function of set keyring in runtime.
         """
-        keyring.core.set_keyring(TestKeyring())
+        keyring.core.set_keyring(ATestKeyring())
 
         keyring.core.set_password("test", "user", "password")
         assert keyring.core.get_password("test", "user") == PASSWORD_TEXT
@@ -101,7 +95,7 @@ class TestCore:
                 # the path for the user created keyring
                 "keyring-path= %s\n" % os.path.dirname(os.path.abspath(__file__)),
                 # the name of the keyring class
-                "default-keyring=test_core.TestKeyring2\n",
+                "default-keyring=test_core.AnotherTestKeyring\n",
                 ])
 
         # init the keyring lib, the lib will automaticlly load the
diff --git a/setup.cfg b/setup.cfg
index 80eb663..e551c0f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,7 +3,7 @@ release = sdist upload
 test = pytest
 
 [egg_info]
+tag_build = 
 tag_date = 0
 tag_svn_revision = 0
-tag_build = 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-keyring.git



More information about the Python-modules-commits mailing list