#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <pwd.h>
#include <grp.h>
#define DEFAULT_KEYRING "id_resolver"
#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) {
return rc;
}
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);
}