From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v2 5/6] nfsidmap: Fix error handling in name_lookup()
Date: Wed, 05 Aug 2015 10:46:12 -0400 [thread overview]
Message-ID: <20150805144612.13266.17288.stgit@manet.1015granger.net> (raw)
In-Reply-To: <20150805143258.13266.92369.stgit@manet.1015granger.net>
As near as I can tell, the exit status of nfsidmap is supposed to be
zero (success) or one (failure).
The return value of name_lookup() becomes the exit status, so it
should return only zero or one.
The libnfsidmap calls return a signed integer, either 0 or negative
errno values. These have to be translated to an exit status.
libkeyutils calls return a signed long, either 0 or -1. These also
have to be translated to an exit status.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/nfsidmap/nfsidmap.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c
index 9468c08..dbfac9b 100644
--- a/utils/nfsidmap/nfsidmap.c
+++ b/utils/nfsidmap/nfsidmap.c
@@ -235,7 +235,7 @@ static int id_lookup(char *name_at_domain, key_serial_t key, int type)
/*
* Find the name@domain string from either a user or group id
*/
-int name_lookup(char *id, key_serial_t key, int type)
+static int name_lookup(char *id, key_serial_t key, int type)
{
char name[IDMAP_NAMESZ];
char domain[NFS4_MAX_DOMAIN_LEN];
@@ -244,11 +244,10 @@ int name_lookup(char *id, key_serial_t key, int type)
int rc;
rc = nfs4_get_default_domain(NULL, domain, NFS4_MAX_DOMAIN_LEN);
- if (rc != 0) {
+ if (rc) {
xlog_errno(rc,
"name_lookup: nfs4_get_default_domain failed: %m");
- rc = -1;
- goto out;
+ return EXIT_FAILURE;
}
if (type == USER) {
@@ -258,16 +257,18 @@ int name_lookup(char *id, key_serial_t key, int type)
gid = atoi(id);
rc = nfs4_gid_to_name(gid, domain, name, IDMAP_NAMESZ);
}
- if (rc < 0)
+ if (rc) {
xlog_errno(rc, "name_lookup: %s: failed: %m",
(type == USER ? "nfs4_uid_to_name" : "nfs4_gid_to_name"));
+ return EXIT_FAILURE;
+ }
- if (rc == 0) {
- rc = keyctl_instantiate(key, &name, strlen(name), 0);
- if (rc < 0)
- xlog_err("name_lookup: keyctl_instantiate failed: %m");
+ rc = EXIT_SUCCESS;
+ if (keyctl_instantiate(key, &name, strlen(name), 0)) {
+ rc = EXIT_FAILURE;
+ xlog_err("name_lookup: keyctl_instantiate failed: %m");
}
-out:
+
return rc;
}
next prev parent reply other threads:[~2015-08-05 14:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 14:45 [PATCH v2 0/6] nfsidmap enhancements Chuck Lever
2015-08-05 14:45 ` [PATCH v2 1/6] nfsidmap: Display the effective NFSv4 domain name Chuck Lever
2015-08-05 14:45 ` [PATCH v2 2/6] nfsidmap: Use find_key_by_type_and_desc() if available Chuck Lever
2015-08-05 14:45 ` [PATCH v2 3/6] nfsidmap: List cached ID mapping results Chuck Lever
2015-08-05 14:46 ` [PATCH v2 4/6] nfsidmap: Fix error handling in id_lookup() Chuck Lever
2015-08-05 14:46 ` Chuck Lever [this message]
2015-08-05 14:46 ` [PATCH v2 6/6] nfsidmap: Clean up other exit status cases Chuck Lever
2015-09-16 19:08 ` [PATCH v2 0/6] nfsidmap enhancements Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150805144612.13266.17288.stgit@manet.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).