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, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <sys/types.h>
26 #include "keystructs.h"
29 #include "onak-conf.h"
33 int fd_putchar(void *ctx, size_t count, void *c)
35 fwrite(c, sizeof(char), count, ctx);
41 * sendkeysync - Send a key sync mail to our peers.
42 * keys: The list of keys to send.
44 * Takes a list of keys and sends out a keysync mail to all our peers.
46 int sendkeysync(struct openpgp_publickey *keys)
49 struct ll *cursite = NULL;
50 struct openpgp_packet_list *packets = NULL;
51 struct openpgp_packet_list *list_end = NULL;
53 if (config.syncsites != NULL &&
54 (fd=popen(config.mta, "w")) != NULL) {
55 fprintf(fd, "From: %s\n", config.adminemail);
58 for (cursite = config.syncsites; cursite != NULL;
59 cursite = cursite->next) {
60 fprintf(fd, "%s", (char *) cursite->object);
61 if (cursite->next != NULL) {
67 fprintf(fd, "Subject: incremental\n");
68 fprintf(fd, "X-Keyserver-Sent: %s\n", config.thissite);
69 fprintf(fd, "Precedence: list\n");
70 fprintf(fd, "MIME-Version: 1.0\n");
71 fprintf(fd, "Content-Type: application/pgp-keys\n\n");
73 flatten_publickey(keys,
76 armor_openpgp_stream(fd_putchar,
79 free_packet_list(packets);