1# Copyright (C) 2010 by the Massachusetts Institute of Technology. 2# All rights reserved. 3 4# Export of this software from the United States of America may 5# require a specific license from the United States Government. 6# It is the responsibility of any person or organization contemplating 7# export to obtain such a license before exporting. 8# 9# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 10# distribute this software and its documentation for any purpose and 11# without fee is hereby granted, provided that the above copyright 12# notice appear in all copies and that both that copyright notice and 13# this permission notice appear in supporting documentation, and that 14# the name of M.I.T. not be used in advertising or publicity pertaining 15# to distribution of the software without specific, written prior 16# permission. Furthermore if you modify this software you must label 17# your software as modified software and not distribute it in such a 18# fashion that it might be confused with the original M.I.T. software. 19# M.I.T. makes no representations about the suitability of 20# this software for any purpose. It is provided "as is" without express 21# or implied warranty. 22 23# Invoked by the testrealm target in the top-level Makefile. Creates 24# a test realm and spawns a shell pointing at it, for convenience of 25# manual testing. If a numeric argument is present after options, 26# creates that many fully connected test realms and point the shell at 27# the first one. 28 29from k5test import * 30 31# A list of directories containing programs in the build tree. 32progpaths = [ 33 'kdc', 34 os.path.join('kadmin', 'server'), 35 os.path.join('kadmin', 'cli'), 36 os.path.join('kadmin', 'dbutil'), 37 os.path.join('kadmin', 'ktutil'), 38 os.path.join('clients', 'kdestroy'), 39 os.path.join('clients', 'kinit'), 40 os.path.join('clients', 'klist'), 41 os.path.join('clients', 'kpasswd'), 42 os.path.join('clients', 'ksu'), 43 os.path.join('clients', 'kvno'), 44 os.path.join('clients', 'kswitch'), 45 'kprop' 46] 47 48# Add program directories to the beginning of PATH. 49def supplement_path(env): 50 # Construct prefixes; these will end in a trailing separator. 51 path_prefix = manpath_prefix = '' 52 for dir in progpaths: 53 path_prefix += os.path.join(buildtop, dir) + os.pathsep 54 55 # Assume PATH exists in env for simplicity. 56 env['PATH'] = path_prefix + env['PATH'] 57 58if args: 59 realms = cross_realms(int(args[0]), start_kadmind=True) 60 realm = realms[0] 61else: 62 realm = K5Realm(start_kadmind=True) 63env = realm.env.copy() 64supplement_path(env) 65 66pwfilename = os.path.join('testdir', 'passwords') 67pwfile = open(pwfilename, 'w') 68pwfile.write('user: %s\nadmin: %s\n' % (password('user'), password('admin'))) 69pwfile.close() 70 71print() 72print('Realm files are in %s' % realm.testdir) 73print('KRB5_CONFIG is %s' % env['KRB5_CONFIG']) 74print('KRB5_KDC_PROFILE is %s' % env['KRB5_KDC_PROFILE']) 75print('KRB5CCNAME is %s' % env['KRB5CCNAME']) 76print('KRB5_KTNAME is %s' % env['KRB5_KTNAME']) 77print('KRB5RCACHEDIR is %s' % env['KRB5RCACHEDIR']) 78print('Password for user is %s (see also %s)' % (password('user'), pwfilename)) 79print('Password for admin is %s' % password('admin')) 80print() 81 82subprocess.call([os.getenv('SHELL')], env=env) 83success('Create test krb5 realm.') 84