summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2013-11-29 13:29:20 +0100
committerPetr Viktorin <pviktori@redhat.com>2013-12-09 12:21:22 +0100
commit9677308caa78ed722570aea32f21334b8c27bad3 (patch)
treec0725324e5347b7f00cae94528932211f9fba39c /ipapython
parentb6540e88d88470f6566507e442f521214c5a74dc (diff)
downloadfreeipa-9677308caa78ed722570aea32f21334b8c27bad3.tar.gz
freeipa-9677308caa78ed722570aea32f21334b8c27bad3.tar.xz
freeipa-9677308caa78ed722570aea32f21334b8c27bad3.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.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ipapython/kernel_keyring.py b/ipapython/kernel_keyring.py
index 547dd3de6..d30531cab 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.