Imported Upstream version 1.17
[platform/upstream/krb5.git] / src / tests / t_kdb_locking.py
1 # This is a regression test for
2 # https://bugzilla.redhat.com/show_bug.cgi?id=586032 .
3 #
4 # We start a KDC, remove the kadm5 lock file, use the KDC, re-create the
5 # kadm5 lock file, and use kadmin.local.  The kinit should fail, and the
6 # kadmin.local should succeed.
7
8
9 import os
10
11 from k5test import *
12
13 p = 'foo'
14 realm = K5Realm(create_user=False, bdb_only=True)
15 realm.addprinc(p, p)
16
17 kadm5_lock = os.path.join(realm.testdir, 'db.kadm5.lock')
18 if not os.path.exists(kadm5_lock):
19     fail('kadm5 lock file not created: ' + kadm5_lock)
20 os.unlink(kadm5_lock)
21
22 realm.kinit(p, p, [], expected_code=1,
23             expected_msg='A service is not available')
24
25 f = open(kadm5_lock, 'w')
26 f.close()
27
28 output = realm.run([kadminl, 'modprinc', '-allow_tix', p])
29 if 'Cannot lock database' in output:
30     fail('krb5kdc still holds a lock on the principal db')
31
32 success('KDB locking tests')