483b06
From 1e37dbe2c41ff0339873cd2347cb90c39a59d8ed Mon Sep 17 00:00:00 2001
483b06
From: Simo Sorce <simo@redhat.com>
483b06
Date: Mon, 5 Jun 2017 09:50:22 -0400
483b06
Subject: [PATCH] Add code to be able to set default kinit lifetime
483b06
483b06
This is done by setting the kinit_lifetime option in default.conf
483b06
to a value that can be passed in with the -l option syntax of kinit.
483b06
483b06
https://pagure.io/freeipa/issue/7001
483b06
483b06
Signed-off-by: Simo Sorce <simo@redhat.com>
483b06
Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
483b06
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
483b06
---
483b06
 ipalib/constants.py     | 1 +
483b06
 ipalib/install/kinit.py | 5 ++++-
483b06
 ipaserver/rpcserver.py  | 3 ++-
483b06
 pylint_plugins.py       | 1 +
483b06
 4 files changed, 8 insertions(+), 2 deletions(-)
483b06
483b06
diff --git a/ipalib/constants.py b/ipalib/constants.py
483b06
index f8a194c1f559db9aeffef058578d700cde41fd0b..5adff97fbd6ad8ab4cfa5322481be2d9056f925a 100644
483b06
--- a/ipalib/constants.py
483b06
+++ b/ipalib/constants.py
483b06
@@ -153,6 +153,7 @@ DEFAULT_CONFIG = (
483b06
     ('session_auth_duration', '20 minutes'),
483b06
     # How a session expiration is computed, see SessionManager.set_session_expiration_time()
483b06
     ('session_duration_type', 'inactivity_timeout'),
483b06
+    ('kinit_lifetime', None),
483b06
 
483b06
     # Debugging:
483b06
     ('verbose', 0),
483b06
diff --git a/ipalib/install/kinit.py b/ipalib/install/kinit.py
483b06
index 73471f103eabfe39580c8fbd0665157f635fa5c5..91ea5132aa1cb1e192af46b4896d55670e375f7a 100644
483b06
--- a/ipalib/install/kinit.py
483b06
+++ b/ipalib/install/kinit.py
483b06
@@ -63,7 +63,7 @@ def kinit_keytab(principal, keytab, ccache_name, config=None, attempts=1):
483b06
 
483b06
 def kinit_password(principal, password, ccache_name, config=None,
483b06
                    armor_ccache_name=None, canonicalize=False,
483b06
-                   enterprise=False):
483b06
+                   enterprise=False, lifetime=None):
483b06
     """
483b06
     perform interactive kinit as principal using password. If using FAST for
483b06
     web-based authentication, use armor_ccache_path to specify http service
483b06
@@ -76,6 +76,9 @@ def kinit_password(principal, password, ccache_name, config=None,
483b06
                           % armor_ccache_name)
483b06
         args.extend(['-T', armor_ccache_name])
483b06
 
483b06
+    if lifetime:
483b06
+        args.extend(['-l', lifetime])
483b06
+
483b06
     if canonicalize:
483b06
         root_logger.debug("Requesting principal canonicalization")
483b06
         args.append('-C')
483b06
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
483b06
index 32f286148bbdf294f941116b4bdca85714a52837..2990df25985eab63d4bcfc8edf7f2b12da3e9832 100644
483b06
--- a/ipaserver/rpcserver.py
483b06
+++ b/ipaserver/rpcserver.py
483b06
@@ -969,7 +969,8 @@ class login_password(Backend, KerberosSession):
483b06
                 password,
483b06
                 ccache_name,
483b06
                 armor_ccache_name=armor_path,
483b06
-                enterprise=True)
483b06
+                enterprise=True,
483b06
+                lifetime=self.api.env.kinit_lifetime)
483b06
 
483b06
             if armor_path:
483b06
                 self.debug('Cleanup the armor ccache')
483b06
diff --git a/pylint_plugins.py b/pylint_plugins.py
483b06
index db80efeba8824eb221d988bb494400da173675a9..550f269b308b6c5b21cb13404040aa0934381f0e 100644
483b06
--- a/pylint_plugins.py
483b06
+++ b/pylint_plugins.py
483b06
@@ -67,6 +67,7 @@ fake_api_env = {'env': [
483b06
     'realm',
483b06
     'session_auth_duration',
483b06
     'session_duration_type',
483b06
+    'kinit_lifetime',
483b06
 ]}
483b06
 
483b06
 # this is due ipaserver.rpcserver.KerberosSession where api is undefined
483b06
-- 
483b06
2.9.4
483b06