2 * sendsync.c - Routines to send a key sync mail.
4 * Copyright 1999, 2002, 2005, 2011 Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <https://www.gnu.org/licenses/>.
21 #include <sys/types.h>
25 #include "keystructs.h"
28 #include "onak-conf.h"
32 int fd_putchar(void *ctx, size_t count, void *c)
34 fwrite(c, sizeof(char), count, ctx);
40 * sendkeysync - Send a key sync mail to our peers.
41 * keys: The list of keys to send.
43 * Takes a list of keys and sends out a keysync mail to all our peers.
45 int sendkeysync(struct openpgp_publickey *keys)
48 struct ll *cursite = NULL;
49 struct openpgp_packet_list *packets = NULL;
50 struct openpgp_packet_list *list_end = NULL;
52 if (config.syncsites != NULL &&
53 (fd=popen(config.mta, "w")) != NULL) {
54 fprintf(fd, "From: %s\n", config.adminemail);
57 for (cursite = config.syncsites; cursite != NULL;
58 cursite = cursite->next) {
59 fprintf(fd, "%s", (char *) cursite->object);
60 if (cursite->next != NULL) {
66 fprintf(fd, "Subject: incremental\n");
67 fprintf(fd, "X-Keyserver-Sent: %s\n", config.thissite);
68 fprintf(fd, "Precedence: list\n");
69 fprintf(fd, "MIME-Version: 1.0\n");
70 fprintf(fd, "Content-Type: application/pgp-keys\n\n");
72 flatten_publickey(keys,
75 armor_openpgp_stream(fd_putchar,
78 free_packet_list(packets);