]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keyd.c
Make keyd command handling more consistent
[onak.git] / keyd.c
diff --git a/keyd.c b/keyd.c
index eab3b5495b951ecbe52b023829975b9b4e61a294..919b61b899a886609f29caebf86e841b725c9fce 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -125,7 +125,7 @@ int sock_init(const char *sockname)
 
 int sock_do(int fd)
 {
-       int      cmd = KEYD_CMD_UNKNOWN;
+       uint32_t cmd = KEYD_CMD_UNKNOWN;
        ssize_t  bytes = 0;
        ssize_t  count = 0;
        int      ret = 0;
@@ -152,6 +152,8 @@ int sock_do(int fd)
                case KEYD_CMD_VERSION:
                        cmd = KEYD_REPLY_OK;
                        write(fd, &cmd, sizeof(cmd));
+                       cmd = sizeof(keyd_version);
+                       write(fd, &cmd, sizeof(cmd));
                        write(fd, &keyd_version, sizeof(keyd_version));
                        break;
                case KEYD_CMD_GET:
@@ -311,6 +313,8 @@ int sock_do(int fd)
                        }
                        if (ret == 0) {
                                keyid = config.dbbackend->getfullkeyid(keyid);
+                               cmd = sizeof(keyid);
+                               write(fd, &cmd, sizeof(cmd));
                                write(fd, &keyid, sizeof(keyid));
                        }
                        break;
@@ -323,9 +327,14 @@ int sock_do(int fd)
                        write(fd, &bytes, sizeof(bytes));
                        break;
                case KEYD_CMD_CLOSE:
+                       cmd = KEYD_REPLY_OK;
+                       write(fd, &cmd, sizeof(cmd));
                        ret = 1;
                        break;
                case KEYD_CMD_QUIT:
+                       cmd = KEYD_REPLY_OK;
+                       write(fd, &cmd, sizeof(cmd));
+                       ret = 1;
                        trytocleanup();
                        break;
                default: