From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f174.google.com ([209.85.223.174]:32870 "EHLO mail-io0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698AbbLBVXH (ORCPT ); Wed, 2 Dec 2015 16:23:07 -0500 Received: by iouu10 with SMTP id u10so61599920iou.0 for ; Wed, 02 Dec 2015 13:23:05 -0800 (PST) Subject: [PATCH] nfsidmap: keyring_clear() should succeed if id_resolver keyring not found From: Chuck Lever To: SteveD@redhat.com Cc: linux-nfs@vger.kernel.org Date: Wed, 02 Dec 2015 16:23:04 -0500 Message-ID: <20151202212304.5640.52063.stgit@manet.1015granger.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sender: linux-nfs-owner@vger.kernel.org List-ID: root#nfsvmb10:~# nfsidmap -c nfsidmap: 'id_resolver' keyring was not found. root#nfsvmb10:~# echo $? 1 If the id_resolver keyring doesn't exist, the kernel has no cached idmap information to expunge. AFAIK it's not an error. If nfsidmap is run by a non-privileged user, the id_resolver keyring is never visible. IMO that should be reported, but the error message should report the privilege problem, not the missing keyring. Reported-by: Amy Shi Fixes: 69aa69e7de80 ('nfsidmap: Allow keys to be cleared from the ') Signed-off-by: Chuck Lever --- utils/nfsidmap/nfsidmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c index 507193b..15b4a51 100644 --- a/utils/nfsidmap/nfsidmap.c +++ b/utils/nfsidmap/nfsidmap.c @@ -80,8 +80,9 @@ static int keyring_clear(const char *keyring) key = find_key_by_type_and_desc("keyring", keyring, 0); if (key == -1) { - xlog_err("'%s' keyring was not found.", keyring); - return EXIT_FAILURE; + if (verbose) + xlog_warn("'%s' keyring was not found.", keyring); + return EXIT_SUCCESS; } if (keyctl_clear(key) < 0) { @@ -89,10 +90,9 @@ static int keyring_clear(const char *keyring) (unsigned int)key); return EXIT_FAILURE; } - + if (verbose) xlog_warn("'%s' cleared", keyring); - return EXIT_SUCCESS; } @@ -404,6 +404,11 @@ int main(int argc, char **argv) } } + if (geteuid() != 0) { + xlog_err("Must be run as root."); + return EXIT_FAILURE; + } + if ((rc = nfs4_init_name_mapping(PATH_IDMAPDCONF))) { xlog_errno(rc, "Unable to create name to user id mappings."); return EXIT_FAILURE;