From patchwork Mon Nov 3 17:12:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 5218481 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D59B9F380 for ; Mon, 3 Nov 2014 17:12:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7D272015A for ; Mon, 3 Nov 2014 17:12:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF3AB20136 for ; Mon, 3 Nov 2014 17:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbaKCRMd (ORCPT ); Mon, 3 Nov 2014 12:12:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752128AbaKCRMd (ORCPT ); Mon, 3 Nov 2014 12:12:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA3HCU7B018131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 3 Nov 2014 12:12:31 -0500 Received: from bcodding-csb.redhat.com (vpn-50-102.rdu2.redhat.com [10.10.50.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA3HCUVg001639; Mon, 3 Nov 2014 12:12:30 -0500 Received: by bcodding-csb.redhat.com (Postfix, from userid 24008) id 2ECFD83F88; Mon, 3 Nov 2014 12:12:30 -0500 (EST) From: Benjamin Coddington To: linux-nfs@vger.kernel.org Cc: chuck.lever@oracle.com Subject: [PATCH v2] nfsidmap: keyctl_invalidate kernel compatibility Date: Mon, 3 Nov 2014 12:12:30 -0500 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;