Skip to content

Commit

Permalink
Prep k5test.py for iprop (add start_kpropd(), ...)
Browse files Browse the repository at this point in the history
Add a start_kpropd() method to K5Realm and make start_kadmind() use the
kadmind -p, -K, and -F options.

ticket: 7378
  • Loading branch information
nicowilliams authored and greghudson committed Oct 8, 2012
1 parent e419711 commit 3c5745e
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions src/util/k5test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
- port0 is used in the default krb5.conf for the KDC
- port1 is used in the default krb5.conf for kadmind
- port2 is used in the default krb5.conf for kpasswd
- port3 is the return value of realm.server_port()
- port3 is used in the default krb5.conf for kpropd
- port4 is used in the default krb5.conf for iprop (in kadmind)
- port5 is the return value of realm.server_port()
* kdc_conf={...}: kdc.conf options, expressed as a nested dictionary,
to be merged with the default kdc.conf settings. The top level keys
Expand All @@ -121,6 +123,8 @@
* start_kadmind=True: Start kadmind.
* start_kpropd=True: Start kpropd.
* get_creds=False: Don't get user credentials.
Scripts may use the following functions and variables:
Expand Down Expand Up @@ -247,6 +251,9 @@
* realm.start_kadmind(): Start a kadmind with the realm's master KDC
environment. Errors if a kadmind is already running.
* realm.start_kpropd(): Start a kpropd with the realm's slave KDC
environment. Errors if a kpropd is already running.
* realm.stop_kadmind(): Stop the kadmind process. Errors if no
kadmind is running.
Expand Down Expand Up @@ -697,7 +704,8 @@ class K5Realm(object):
def __init__(self, realm='KRBTEST.COM', portbase=61000, testdir='testdir',
krb5_conf=None, kdc_conf=None, create_kdb=True,
krbtgt_keysalt=None, create_user=True, get_creds=True,
create_host=True, start_kdc=True, start_kadmind=False):
create_host=True, start_kdc=True, start_kadmind=False,
start_kpropd=False):
global hostname, _default_krb5_conf, _default_kdc_conf

self.realm = realm
Expand All @@ -716,6 +724,7 @@ def __init__(self, realm='KRBTEST.COM', portbase=61000, testdir='testdir',
self._kdc_conf = _cfg_merge(_default_kdc_conf, kdc_conf)
self._kdc_proc = None
self._kadmind_proc = None
self._kpropd_proc = None

self._create_empty_dir()
self._create_krb5_conf('client')
Expand Down Expand Up @@ -747,6 +756,8 @@ def __init__(self, realm='KRBTEST.COM', portbase=61000, testdir='testdir',
self.start_kdc()
if start_kadmind and create_kdb:
self.start_kadmind()
if start_kpropd and create_kdb:
self.start_kpropd()
if get_creds and create_kdb and create_user and start_kdc:
self.kinit(self.user_princ, password('user'))
self.klist(self.user_princ)
Expand Down Expand Up @@ -842,6 +853,8 @@ def _make_env(self, type, has_kdc_conf):
env['KRB5_KTNAME'] = self.keytab
env['KRB5_CLIENT_KTNAME'] = self.client_keytab
env['KRB5RCACHEDIR'] = self.testdir
env['KPROPD_PORT'] = str(self.portbase + 3)
env['KPROP_PORT'] = str(self.portbase + 3)
return env

def run_as_client(self, args, **keywords):
Expand All @@ -857,7 +870,7 @@ def run_as_slave(self, args, **keywords):
return _run_cmd(args, self.env_slave, **keywords)

def server_port(self):
return self.portbase + 3
return self.portbase + 5

def start_server(self, args, sentinel):
return _start_daemon(args, self.env_server, sentinel)
Expand Down Expand Up @@ -886,19 +899,41 @@ def stop_kdc(self):
def start_kadmind(self):
global krb5kdc
assert(self._kadmind_proc is None)
self._kadmind_proc = _start_daemon([kadmind, '-nofork', '-W'],
self.env_master, 'starting...')
dump_path = os.path.join(self.testdir, 'master-dump')
self._kadmind_proc = _start_daemon([kadmind, '-nofork', '-W',
'-p', kdb5_util, '-K', kprop,
'-F', dump_path],
self.env_master, 'starting...')

def stop_kadmind(self):
assert(self._kadmind_proc is not None)
stop_daemon(self._kadmind_proc)
self._kadmind_proc = None

def start_kpropd(self):
global krb5kdc
assert(self._kpropd_proc is None)
slavedump_path = os.path.join(self.testdir, 'incoming-slave-datatrans')
kpropdacl_path = os.path.join(self.testdir, 'kpropd-acl')
self._kpropd_proc = _start_daemon([kpropd, '-D', '-P',
str(self.portbase + 3),
'-f', slavedump_path,
'-p', kdb5_util,
'-a', kpropdacl_path],
self.env_slave, 'ready')

def stop_kpropd(self):
assert(self._kpropd_proc is not None)
stop_daemon(self._kpropd_proc)
self._kpropd_proc = None

def stop(self):
if self._kdc_proc:
self.stop_kdc()
if self._kadmind_proc:
self.stop_kadmind()
if self._kpropd_proc:
self.stop_kpropd()

def addprinc(self, princname, password=None):
if password:
Expand Down Expand Up @@ -1063,7 +1098,8 @@ def cross_realms(num, xtgts=None, args=None, **keywords):
'all' : {
'realms' : {
'$realm' : {
'database_module' : 'foo_db2'
'database_module' : 'foo_db2',
'iprop_port' : '$port4'
}
},
'dbmodules' : {
Expand Down

0 comments on commit 3c5745e

Please sign in to comment.