#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include "xlog.h"
+#include "conffile.h"
int verbose = 0;
char *usage="Usage: %s [-v] [-c || [-u|-g|-r key] || [-t timeout] key desc]";
#define DEFAULT_KEYRING "id_resolver"
#endif
+#ifndef PATH_IDMAPDCONF
+#define PATH_IDMAPDCONF "/etc/idmapd.conf"
+#endif
+
+static int keyring_clear(char *keyring);
#define UIDKEYS 0x1
#define GIDKEYS 0x2
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:
+ break;
+ }
+ }
if (rc < 0)
xlog_err("id_lookup: keyctl_instantiate failed: %m");
}
char buf[BUFSIZ];
key_serial_t key;
- xlog_syslog(0);
if (keyring == NULL)
keyring = DEFAULT_KEYRING;
if ((keymask & mask) == 0)
continue;
- if (strncmp(ptr+4, keystr, strlen(keystr)) != NULL)
+ if (strncmp(ptr+4, keystr, strlen(keystr)) != 0)
continue;
if (verbose) {
int timeout = 600;
key_serial_t key;
char *progname, *keystr = NULL;
- int clearring, keymask = 0;
+ int clearing = 0, keymask = 0;
/* Set the basename */
if ((progname = strrchr(argv[0], '/')) != NULL)
keystr = strdup(optarg);
break;
case 'c':
- clearring++;
+ clearing++;
break;
case 'v':
verbose++;
}
}
+ if (nfs4_init_name_mapping(PATH_IDMAPDCONF)) {
+ xlog_err("Unable to create name to user id mappings.");
+ return 1;
+ }
+ if (!verbose)
+ verbose = conf_get_num("General", "Verbosity", 0);
+
if (keystr) {
rc = key_revoke(keystr, keymask);
return rc;
}
- if (clearring) {
+ if (clearing) {
+ xlog_syslog(0);
rc = keyring_clear(DEFAULT_KEYRING);
return rc;
}
value = strtok(NULL, ":");
if (verbose) {
- xlog_warn("key: %ld type: %s value: %s timeout %ld",
+ xlog_warn("key: 0x%lx type: %s value: %s timeout %ld",
key, type, value, timeout);
}