summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-12-20 15:19:06 -0500
committerGreg Hudson <ghudson@mit.edu>2013-12-20 23:10:03 -0500
commit94da4584645475272abec6259d1666e34bd59594 (patch)
tree1f7b73a28cf77a2e325824aec4d085c46517502c /src/lib/krb5
parentae027dd69fc80cca549c9198d10afad389f30873 (diff)
downloadkrb5-94da4584645475272abec6259d1666e34bd59594.tar.gz
krb5-94da4584645475272abec6259d1666e34bd59594.tar.xz
krb5-94da4584645475272abec6259d1666e34bd59594.zip
Avoid keyctl purge in keyring ccache tests
keyctl purge was added in keyutils 1.5 (released in March 2011). Use keyctl unlink to clean up keys instead, as it is more universal. ticket: 7810 target_version: 1.12.1 tags: pullup
Diffstat (limited to 'src/lib/krb5')
-rw-r--r--src/lib/krb5/ccache/t_cccol.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/lib/krb5/ccache/t_cccol.py b/src/lib/krb5/ccache/t_cccol.py
index e762625662..e6d715cbaf 100644
--- a/src/lib/krb5/ccache/t_cccol.py
+++ b/src/lib/krb5/ccache/t_cccol.py
@@ -11,30 +11,33 @@ test_keyring = (keyctl is not None and
# Run the collection test program against each collection-enabled type.
realm.run(['./t_cccol', 'DIR:' + os.path.join(realm.testdir, 'cc')])
if test_keyring:
+ def cleanup_keyring(anchor, name):
+ out = realm.run(['keyctl', 'list', anchor])
+ if ('keyring: ' + name + '\n') in out:
+ keyid = realm.run(['keyctl', 'search', anchor, 'keyring', name])
+ realm.run(['keyctl', 'unlink', keyid.strip(), anchor])
+
# Use the test directory as the collection name to avoid colliding
# with other build trees.
cname = realm.testdir
+ col_ringname = '_krb_' + cname
# Remove any keys left behind by previous failed test runs.
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
- realm.run(['keyctl', 'purge', 'keyring', cname])
- out = realm.run(['keyctl', 'list', '@u'])
- if ('keyring: _krb_' + cname + '\n') in out:
- id = realm.run(['keyctl', 'search', '@u', 'keyring', '_krb_' + cname])
- realm.run(['keyctl', 'unlink', id.strip(), '@u'])
+ cleanup_keyring('@s', cname)
+ cleanup_keyring('@s', col_ringname)
+ cleanup_keyring('@u', col_ringname)
# Run test program over each subtype, cleaning up as we go. Don't
# test the persistent subtype, since it supports only one
# collection and might be in actual use.
realm.run(['./t_cccol', 'KEYRING:' + cname])
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
realm.run(['./t_cccol', 'KEYRING:legacy:' + cname])
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
realm.run(['./t_cccol', 'KEYRING:session:' + cname])
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
realm.run(['./t_cccol', 'KEYRING:user:' + cname])
- id = realm.run(['keyctl', 'search', '@u', 'keyring', '_krb_' + cname])
- realm.run(['keyctl', 'unlink', id.strip(), '@u'])
+ cleanup_keyring('@u', col_ringname)
realm.run(['./t_cccol', 'KEYRING:process:abcd'])
realm.run(['./t_cccol', 'KEYRING:thread:abcd'])
@@ -57,8 +60,7 @@ realm.kinit('alice', password('alice'), flags=['-c', dalice])
realm.kinit('bob', password('bob'), flags=['-c', dbob])
if test_keyring:
- cname = realm.testdir
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
krccname = 'KEYRING:session:' + cname
kruser = '%s:tkt1' % krccname
kralice = '%s:tkt2' % krccname
@@ -105,7 +107,7 @@ realm.run(['./t_cccursor', realm.ccache, 'CONTENT'])
realm.run(['./t_cccursor', mfoo, 'CONTENT'], expected_code=1)
if test_keyring:
realm.run(['./t_cccursor', krccname, 'CONTENT'])
- realm.run(['keyctl', 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
# Make sure FILE doesn't yield a nonexistent default cache.
realm.run([kdestroy])