xref: /freebsd/crypto/krb5/src/tests/t_kdb_locking.py (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
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
9import os
10
11from k5test import *
12
13p = 'foo'
14realm = K5Realm(create_user=False, bdb_only=True)
15realm.addprinc(p, p)
16
17kadm5_lock = os.path.join(realm.testdir, 'db.kadm5.lock')
18if not os.path.exists(kadm5_lock):
19    fail('kadm5 lock file not created: ' + kadm5_lock)
20os.unlink(kadm5_lock)
21
22realm.kinit(p, p, [], expected_code=1,
23            expected_msg='A service is not available')
24
25f = open(kadm5_lock, 'w')
26f.close()
27
28output = realm.run([kadminl, 'modprinc', '-allow_tix', p])
29if 'Cannot lock database' in output:
30    fail('krb5kdc still holds a lock on the principal db')
31
32success('KDB locking tests')
33