diff options
author | Martin Kosek <mkosek@redhat.com> | 2013-11-29 13:29:20 +0100 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-12-09 12:23:03 +0100 |
commit | 5b2ce3c5a57e8193ee1c6d23c4e79c3b2b62cb05 (patch) | |
tree | df42ec7606da1e9418d7eb7c3830a3f1dac9cd9f /ipapython | |
parent | 2877f5d8a11ebdd32c2007b26facab2073cf48ad (diff) | |
download | freeipa.git-5b2ce3c5a57e8193ee1c6d23c4e79c3b2b62cb05.tar.gz freeipa.git-5b2ce3c5a57e8193ee1c6d23c4e79c3b2b62cb05.tar.xz freeipa.git-5b2ce3c5a57e8193ee1c6d23c4e79c3b2b62cb05.zip |
Allow kernel keyring CCACHE when supported
Server and client installer should allow kernel keyring ccache when
supported.
https://fedorahosted.org/freeipa/ticket/4013
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/kernel_keyring.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ipapython/kernel_keyring.py b/ipapython/kernel_keyring.py index 547dd3de..d30531ca 100644 --- a/ipapython/kernel_keyring.py +++ b/ipapython/kernel_keyring.py @@ -17,6 +17,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +import os + from ipapython.ipautil import run # NOTE: Absolute path not required for keyctl since we reset the environment @@ -47,6 +49,21 @@ def get_real_key(key): raise ValueError('key %s not found' % key) return stdout.rstrip() +def get_persistent_key(key): + (stdout, stderr, rc) = run(['keyctl', 'get_persistent', KEYRING, key], raiseonerr=False) + if rc: + raise ValueError('persistent key %s not found' % key) + return stdout.rstrip() + +def is_persistent_keyring_supported(): + uid = os.geteuid() + try: + get_persistent_key(str(uid)) + except ValueError: + return False + + return True + def has_key(key): """ Returns True/False whether the key exists in the keyring. |