]> the.earth.li Git - onak.git/blobdiff - keyd.c
Add support for v5 keys
[onak.git] / keyd.c
diff --git a/keyd.c b/keyd.c
index aa58b8a734edd3dc5b83e5e9cbdbb18dd68c821f..9994dea303b812588fe00ff9d18cec5424ce8668 100644 (file)
--- a/keyd.c
+++ b/keyd.c
  * 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 <https://www.gnu.org/licenses/>.
  */
 
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <inttypes.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -31,7 +32,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#include "config.h"
+#include "build-config.h"
 
 #ifdef HAVE_SYSTEMD
 #include <systemd/sd-daemon.h>
@@ -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);
@@ -607,7 +609,7 @@ int main(int argc, char *argv[])
 {
        int fd = -1, maxfd, i, clients[MAX_CLIENTS];
        fd_set rfds = { 0 }; /* Avoid scan-build false report for FD_SET */
-       char sockname[1024];
+       char sockname[100];
        char *configfile = NULL;
        bool foreground = false;
        int optchar;
@@ -653,7 +655,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) {