# Copyright (C) 2010 by the Massachusetts Institute of Technology.1# All rights reserved.23# Export of this software from the United States of America may4# require a specific license from the United States Government.5# It is the responsibility of any person or organization contemplating6# export to obtain such a license before exporting.7#8# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and9# distribute this software and its documentation for any purpose and10# without fee is hereby granted, provided that the above copyright11# notice appear in all copies and that both that copyright notice and12# this permission notice appear in supporting documentation, and that13# the name of M.I.T. not be used in advertising or publicity pertaining14# to distribution of the software without specific, written prior15# permission. Furthermore if you modify this software you must label16# your software as modified software and not distribute it in such a17# fashion that it might be confused with the original M.I.T. software.18# M.I.T. makes no representations about the suitability of19# this software for any purpose. It is provided "as is" without express20# or implied warranty.2122# Invoked by the testrealm target in the top-level Makefile. Creates23# a test realm and spawns a shell pointing at it, for convenience of24# manual testing. If a numeric argument is present after options,25# creates that many fully connected test realms and point the shell at26# the first one.2728from k5test import *2930# A list of directories containing programs in the build tree.31progpaths = [32'kdc',33os.path.join('kadmin', 'server'),34os.path.join('kadmin', 'cli'),35os.path.join('kadmin', 'dbutil'),36os.path.join('kadmin', 'ktutil'),37os.path.join('clients', 'kdestroy'),38os.path.join('clients', 'kinit'),39os.path.join('clients', 'klist'),40os.path.join('clients', 'kpasswd'),41os.path.join('clients', 'ksu'),42os.path.join('clients', 'kvno'),43os.path.join('clients', 'kswitch'),44'kprop'45]4647# Add program directories to the beginning of PATH.48def supplement_path(env):49# Construct prefixes; these will end in a trailing separator.50path_prefix = manpath_prefix = ''51for dir in progpaths:52path_prefix += os.path.join(buildtop, dir) + os.pathsep5354# Assume PATH exists in env for simplicity.55env['PATH'] = path_prefix + env['PATH']5657if args:58realms = cross_realms(int(args[0]), start_kadmind=True)59realm = realms[0]60else:61realm = K5Realm(start_kadmind=True)62env = realm.env.copy()63supplement_path(env)6465pwfilename = os.path.join('testdir', 'passwords')66pwfile = open(pwfilename, 'w')67pwfile.write('user: %s\nadmin: %s\n' % (password('user'), password('admin')))68pwfile.close()6970print()71print('Realm files are in %s' % realm.testdir)72print('KRB5_CONFIG is %s' % env['KRB5_CONFIG'])73print('KRB5_KDC_PROFILE is %s' % env['KRB5_KDC_PROFILE'])74print('KRB5CCNAME is %s' % env['KRB5CCNAME'])75print('KRB5_KTNAME is %s' % env['KRB5_KTNAME'])76print('KRB5RCACHEDIR is %s' % env['KRB5RCACHEDIR'])77print('Password for user is %s (see also %s)' % (password('user'), pwfilename))78print('Password for admin is %s' % password('admin'))79print()8081subprocess.call([os.getenv('SHELL')], env=env)82success('Create test krb5 realm.')838485