X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;ds=inline;f=keyd.c;h=ddd1366a9bb7c94b56b6d31fc7b181005ae2c663;hb=a94e29c9a3763f96b1c773f0818b97e4fd0777b0;hp=7fb7eab2c8daad616a3ffed950ccb87fa869913e;hpb=2458360e75aa46091f60c16e041c07bffe2edefb;p=onak.git
diff --git a/keyd.c b/keyd.c
index 7fb7eab..ddd1366 100644
--- a/keyd.c
+++ b/keyd.c
@@ -13,14 +13,15 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see .
*/
#include
#include
#include
+#include
#include
+#include
#include
#include
#include
@@ -31,7 +32,7 @@
#include
#include
-#include "config.h"
+#include "build-config.h"
#ifdef HAVE_SYSTEMD
#include
@@ -47,7 +48,6 @@
#include "mem.h"
#include "onak-conf.h"
#include "parsekey.h"
-#include "version.h"
/* Maximum number of clients we're prepared to accept at once */
#define MAX_CLIENTS 16
@@ -397,6 +397,7 @@ static int sock_do(struct onak_dbctx *dbctx, int fd)
}
break;
case KEYD_CMD_STORE:
+ case KEYD_CMD_UPDATE:
if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
ret = 1;
}
@@ -427,7 +428,8 @@ static int sock_do(struct onak_dbctx *dbctx, int fd)
&packets,
0);
parse_keys(packets, &key);
- dbctx->store_key(dbctx, key, false, false);
+ dbctx->store_key(dbctx, key, false,
+ (cmd == KEYD_CMD_UPDATE));
free_packet_list(packets);
packets = NULL;
free_publickey(key);
@@ -442,8 +444,9 @@ static int sock_do(struct onak_dbctx *dbctx, int fd)
ret = 1;
}
if (ret == 0) {
- bytes = read(fd, &keyid, sizeof(keyid));
- if (bytes != sizeof(keyid)) {
+ bytes = read(fd, &fingerprint,
+ sizeof(fingerprint));
+ if (bytes != sizeof(fingerprint)) {
ret = 1;
}
}
@@ -453,32 +456,7 @@ static int sock_do(struct onak_dbctx *dbctx, int fd)
", result: %d",
keyid,
dbctx->delete_key(dbctx,
- keyid, false));
- }
- break;
- case KEYD_CMD_GETFULLKEYID:
- if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
- ret = 1;
- }
- if (ret == 0) {
- bytes = read(fd, &keyid, sizeof(keyid));
- if (bytes != sizeof(keyid)) {
- ret = 1;
- }
- }
- if (ret == 0) {
- keyid = dbctx->getfullkeyid(dbctx, keyid);
- cmd = sizeof(keyid);
- bytes = write(fd, &cmd, sizeof(cmd));
- if (bytes != sizeof(cmd)) {
- ret = 1;
- }
- }
- if (ret == 0) {
- bytes = write(fd, &keyid, sizeof(keyid));
- if (bytes != sizeof(keyid)) {
- ret = 1;
- }
+ &fingerprint, false));
}
break;
case KEYD_CMD_KEYITER:
@@ -606,8 +584,8 @@ static void usage(void)
int main(int argc, char *argv[])
{
int fd = -1, maxfd, i, clients[MAX_CLIENTS];
- fd_set rfds;
- char sockname[1024];
+ fd_set rfds = { 0 }; /* Avoid scan-build false report for FD_SET */
+ char sockname[100];
char *configfile = NULL;
bool foreground = false;
int optchar;
@@ -653,7 +631,8 @@ int main(int argc, char *argv[])
}
stats->started = time(NULL);
- snprintf(sockname, 1023, "%s/%s", config.sock_dir, KEYD_SOCKET);
+ snprintf(sockname, sizeof(sockname) - 1, "%s/%s",
+ config.sock_dir, KEYD_SOCKET);
fd = sock_init(sockname);
if (fd != -1) {