From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH 1/2] nfsidmap: Added Error Logging
Date: Thu, 10 Nov 2011 15:26:24 -0500 [thread overview]
Message-ID: <1320956785-18004-2-git-send-email-steved@redhat.com> (raw)
In-Reply-To: <1320956785-18004-1-git-send-email-steved@redhat.com>
Since this binary is being called by the kernel,
errors need to be logged to the syslog for
help in debugging problems.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/nfsidmap/Makefile.am | 2 +-
utils/nfsidmap/nfsidmap.c | 34 ++++++++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/utils/nfsidmap/Makefile.am b/utils/nfsidmap/Makefile.am
index f837b91..037aa79 100644
--- a/utils/nfsidmap/Makefile.am
+++ b/utils/nfsidmap/Makefile.am
@@ -4,6 +4,6 @@ man8_MANS = nfsidmap.man
sbin_PROGRAMS = nfsidmap
nfsidmap_SOURCES = nfsidmap.c
-nfsidmap_LDADD = -lnfsidmap -lkeyutils
+nfsidmap_LDADD = -lnfsidmap -lkeyutils ../../support/nfs/libnfs.a
MAINTAINERCLEANFILES = Makefile.in
diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c
index 2d87381..134d9bc 100644
--- a/utils/nfsidmap/nfsidmap.c
+++ b/utils/nfsidmap/nfsidmap.c
@@ -10,6 +10,7 @@
#include <nfsidmap.h>
#include <syslog.h>
+#include "xlog.h"
/* gcc nfsidmap.c -o nfsidmap -l nfsidmap -l keyutils */
@@ -36,9 +37,15 @@ 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)
+ xlog_err("id_lookup: %s: failed: %m",
+ (type == USER ? "nfs4_owner_to_uid" : "nfs4_group_owner_to_gid"));
- if (rc == 0)
+ if (rc == 0) {
rc = keyctl_instantiate(key, id, strlen(id) + 1, 0);
+ if (rc < 0)
+ xlog_err("id_lookup: keyctl_instantiate failed: %m");
+ }
return rc;
}
@@ -57,6 +64,7 @@ int name_lookup(char *id, key_serial_t key, int type)
rc = nfs4_get_default_domain(NULL, domain, NFS4_MAX_DOMAIN_LEN);
if (rc != 0) {
rc = -1;
+ xlog_err("name_lookup: nfs4_get_default_domain failed: %m");
goto out;
}
@@ -67,10 +75,15 @@ 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)
+ xlog_err("name_lookup: %s: failed: %m",
+ (type == USER ? "nfs4_uid_to_name" : "nfs4_gid_to_name"));
- if (rc == 0)
+ if (rc == 0) {
rc = keyctl_instantiate(key, &name, strlen(name), 0);
-
+ if (rc < 0)
+ xlog_err("name_lookup: keyctl_instantiate failed: %m");
+ }
out:
return rc;
}
@@ -83,9 +96,22 @@ int main(int argc, char **argv)
int rc = 1;
int timeout = 600;
key_serial_t key;
+ char *progname;
+
+ /* Set the basename */
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
- if (argc < 3)
+ xlog_open(progname);
+ xlog_syslog(1);
+ xlog_stderr(0);
+
+ if (argc < 3) {
+ xlog_err("Bad arg count. Check /etc/request-key.conf");
return 1;
+ }
arg = malloc(sizeof(char) * strlen(argv[2]) + 1);
strcpy(arg, argv[2]);
--
1.7.6.4
next prev parent reply other threads:[~2011-11-10 20:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 20:26 [PATCH 0/2] nfsidmap: Added error logging and verbosity flag Steve Dickson
2011-11-10 20:26 ` Steve Dickson [this message]
2011-11-10 20:26 ` [PATCH 2/2] nfsidmap: Added -v flag Steve Dickson
2011-11-10 21:11 ` Jim Rees
2011-11-10 21:25 ` Steve Dickson
2011-11-11 0:23 ` Jim Rees
2011-11-11 14:55 ` Steve Dickson
2011-11-10 21:19 ` Bryan Schumaker
2011-11-10 21:27 ` Steve Dickson
-- strict thread matches above, loose matches on Subject: below --
2011-11-12 15:55 [PATCH 0/2] Added error logging and verbosity flag (ver #2) Steve Dickson
2011-11-12 15:55 ` [PATCH 1/2] nfsidmap: Added Error Logging 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=1320956785-18004-2-git-send-email-steved@redhat.com \
--to=steved@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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