As near as I can tell, the exit status of nfsidmap is supposed to be zero (success) or one (failure). The return value of id_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@xxxxxxxxxx> --- utils/nfsidmap/nfsidmap.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c index ed397c6..9881694 100644 --- a/utils/nfsidmap/nfsidmap.c +++ b/utils/nfsidmap/nfsidmap.c @@ -200,30 +200,33 @@ static int id_lookup(char *name_at_domain, key_serial_t key, int type) rc = nfs4_group_owner_to_gid(name_at_domain, &gid); sprintf(id, "%u", gid); } - if (rc < 0) + if (rc < 0) { xlog_errno(rc, "id_lookup: %s: failed: %m", (type == USER ? "nfs4_owner_to_uid" : "nfs4_group_owner_to_gid")); + return EXIT_FAILURE; + } - if (rc == 0) { - rc = keyctl_instantiate(key, id, strlen(id) + 1, 0); - if (rc < 0) { - switch(rc) { - case -EDQUOT: - case -ENFILE: - case -ENOMEM: - /* - * The keyring is full. Clear the keyring and try again - */ - rc = keyring_clear(DEFAULT_KEYRING); - if (rc == 0) - rc = keyctl_instantiate(key, id, strlen(id) + 1, 0); - break; - default: + rc = EXIT_SUCCESS; + if (keyctl_instantiate(key, id, strlen(id) + 1, 0)) { + switch (errno) { + case EDQUOT: + case ENFILE: + case ENOMEM: + /* + * The keyring is full. Clear the keyring and try again + */ + rc = keyring_clear(DEFAULT_KEYRING); + if (rc) break; + if (keyctl_instantiate(key, id, strlen(id) + 1, 0)) { + rc = EXIT_FAILURE; + xlog_err("id_lookup: keyctl_instantiate failed: %m"); } + break; + default: + rc = EXIT_FAILURE; + break; } - if (rc < 0) - xlog_err("id_lookup: keyctl_instantiate failed: %m"); } return rc; -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html