diff options
author | Benjamin Coddington <bcodding@redhat.com> | 2014-11-04 14:23:08 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2014-11-04 14:29:13 -0500 |
commit | e9932d8f6986ec4915bfc8c0b0631255ce2b80df (patch) | |
tree | 972d01ed816b1c8d52fa00a91aa67f766c0a671d | |
parent | 8f2e933aec15d06b0f1d95ea08c72e4d497f8dbf (diff) | |
download | nfs-utils-e9932d8f6986ec4915bfc8c0b0631255ce2b80df.tar.gz nfs-utils-e9932d8f6986ec4915bfc8c0b0631255ce2b80df.tar.xz nfs-utils-e9932d8f6986ec4915bfc8c0b0631255ce2b80df.zip |
nfsidmap: keyctl_invalidate kernel compatibility
Change the keyctl_invalidate call to use the syscall interface
directly so that when building with libkeyutils missing keyctl_invalidate
the build succeeds. Attempt to use _invalidate and fall back to
_revoke if the current kernel is missing _invalidate.
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | utils/nfsidmap/nfsidmap.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c index e0d31e7..96149cc 100644 --- a/utils/nfsidmap/nfsidmap.c +++ b/utils/nfsidmap/nfsidmap.c @@ -209,10 +209,23 @@ static int key_invalidate(char *keystr, int keymask) *(strchr(buf, ' ')) = '\0'; sscanf(buf, "%x", &key); - if (keyctl_invalidate(key) < 0) { - xlog_err("keyctl_invalidate(0x%x) failed: %m", key); - fclose(fp); - return 1; +/* older libkeyutils compatibility */ +#ifndef KEYCTL_INVALIDATE +#define KEYCTL_INVALIDATE 21 /* invalidate a key */ +#endif + if (keyctl(KEYCTL_INVALIDATE, key) < 0) { + if (errno != EOPNOTSUPP) { + xlog_err("keyctl_invalidate(0x%x) failed: %m", key); + fclose(fp); + return 1; + } else { + /* older kernel compatibility attempt: */ + if (keyctl_revoke(key) < 0) { + xlog_err("keyctl_revoke(0x%x) failed: %m", key); + fclose(fp); + return 1; + } + } } keymask &= ~mask; |