/* Maximum number of clients we're prepared to accept at once */
#define MAX_CLIENTS 16
-#ifdef HAVE_SYSTEMD
static bool using_socket_activation = false;
-#endif
static struct keyd_stats *stats;
if (ret != -1) {
ret = listen(fd, 5);
- if (ret == -1) {
- close(fd);
- fd = -1;
- }
+ }
+
+ if (ret == -1) {
+ logthing(LOGTHING_ERROR,
+ "Couldn't open socket to listen on: %s (%d)",
+ strerror(errno),
+ errno);
+ close(fd);
+ fd = -1;
}
#ifdef HAVE_SYSTEMD
}
}
}
break;
+ case KEYD_CMD_GET:
+ if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
+ ret = 1;
+ }
+ if (ret == 0) {
+ if ((read(fd, &bytes, 1) != 1) ||
+ (bytes > MAX_FINGERPRINT_LEN)) {
+ ret = 1;
+ } else {
+ fingerprint.length = bytes;
+ bytes = read(fd, fingerprint.fp,
+ fingerprint.length);
+ if (bytes != fingerprint.length) {
+ ret = 1;
+ }
+ }
+ }
+ if (ret == 0) {
+ logthing(LOGTHING_INFO,
+ "Fetching by fingerprint"
+ ", result: %d",
+ dbctx->fetch_key(dbctx,
+ &fingerprint,
+ &key, false));
+ if (key != NULL) {
+ keyd_write_key(fd, key);
+ free_publickey(key);
+ key = NULL;
+ } else {
+ if (!keyd_write_size(fd, 0)) {
+ ret = 1;
+ }
+ }
+ }
+ break;
case KEYD_CMD_GET_ID:
if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
ret = 1;
}
}
break;
-
case KEYD_CMD_GET_TEXT:
if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
ret = 1;
dbctx = config.dbinit(config.backend, false);
- logthing(LOGTHING_NOTICE, "Accepting connections.");
+ logthing(LOGTHING_NOTICE, "Accepting connections%s",
+ using_socket_activation ? " (via systemd)" : "");
while (!cleanup() && select(maxfd + 1, &rfds, NULL, NULL, NULL) != -1) {
/*
* Deal with existing clients first; if we're at our
free(stats);
+ logthing(LOGTHING_NOTICE, "Exiting");
cleanuplogthing();
cleanupconfig();