aboutsummaryrefslogtreecommitdiff
path: root/src/tests
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/tests
parentae027dd69fc80cca549c9198d10afad389f30873 (diff)
downloadkrb5-94da4584645475272abec6259d1666e34bd59594.zip
krb5-94da4584645475272abec6259d1666e34bd59594.tar.gz
krb5-94da4584645475272abec6259d1666e34bd59594.tar.bz2
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/tests')
-rw-r--r--src/tests/t_ccache.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tests/t_ccache.py b/src/tests/t_ccache.py
index eedd29a..dd20e11 100644
--- a/src/tests/t_ccache.py
+++ b/src/tests/t_ccache.py
@@ -85,13 +85,20 @@ def collection_test(realm, ccname):
collection_test(realm, '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 realm.testdir as the collection name to avoid conflicts with
# other build trees.
cname = realm.testdir
+ col_ringname = '_krb_' + cname
- realm.run([keyctl, 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
collection_test(realm, 'KEYRING:session:' + cname)
- realm.run([keyctl, 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
# Test legacy keyring cache linkage.
realm.env['KRB5CCNAME'] = 'KEYRING:' + cname
@@ -108,12 +115,10 @@ if test_keyring:
# Remove the collection keyring. When the collection is
# reinitialized, the legacy cache should reappear inside it
# automatically as the primary cache.
- out = realm.run([keyctl, 'purge', 'keyring', '_krb_' + cname])
- if 'purged 1 keys' not in out:
- fail('Could not purge collection keyring')
+ cleanup_keyring('@s', col_ringname)
out = realm.run([klist])
if realm.user_princ not in out:
- fail('Cannot see legacy cache after purging collection')
+ fail('Cannot see legacy cache after removing collection')
coll_id = realm.run([keyctl, 'search', '@s', 'keyring', '_krb_' + cname])
out = realm.run([keyctl, 'list', coll_id.strip()])
if (id.strip() + ':') not in out:
@@ -121,8 +126,7 @@ if test_keyring:
# Destroy the cache and check that it is unlinked from the session keyring.
realm.run([kdestroy])
realm.run([keyctl, 'search', '@s', 'keyring', cname], expected_code=1)
- # Clean up the collection key.
- realm.run([keyctl, 'purge', 'keyring', '_krb_' + cname])
+ cleanup_keyring('@s', col_ringname)
# Test parameter expansion in default_ccache_name
realm.stop()