Refer to processor via hydra and not charon.
[strongswan.git] / src / libcharon / plugins / smp / smp.c
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include <stdlib.h>
17
18 #include "smp.h"
19
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <sys/socket.h>
23 #include <sys/un.h>
24 #include <unistd.h>
25 #include <errno.h>
26 #include <signal.h>
27 #include <libxml/xmlreader.h>
28 #include <libxml/xmlwriter.h>
29
30 #include <library.h>
31 #include <hydra.h>
32 #include <daemon.h>
33 #include <threading/thread.h>
34 #include <processing/jobs/callback_job.h>
35
36
37 typedef struct private_smp_t private_smp_t;
38
39 /**
40 * Private data of an smp_t object.
41 */
42 struct private_smp_t {
43
44 /**
45 * Public part of smp_t object.
46 */
47 smp_t public;
48
49 /**
50 * XML unix socket fd
51 */
52 int socket;
53
54 /**
55 * job accepting stroke messages
56 */
57 callback_job_t *job;
58 };
59
60 ENUM(ike_sa_state_lower_names, IKE_CREATED, IKE_DELETING,
61 "created",
62 "connecting",
63 "established",
64 "rekeying",
65 "deleting",
66 );
67
68 /**
69 * write a bool into element
70 */
71 static void write_bool(xmlTextWriterPtr writer, char *element, bool val)
72 {
73 xmlTextWriterWriteElement(writer, element, val ? "true" : "false");
74 }
75
76 /**
77 * write a identification_t into element
78 */
79 static void write_id(xmlTextWriterPtr writer, char *element, identification_t *id)
80 {
81 xmlTextWriterStartElement(writer, element);
82 switch (id->get_type(id))
83 {
84 {
85 char *type = "";
86 while (TRUE)
87 {
88 case ID_ANY:
89 type = "any";
90 break;
91 case ID_IPV4_ADDR:
92 type = "ipv4";
93 break;
94 case ID_IPV6_ADDR:
95 type = "ipv6";
96 break;
97 case ID_FQDN:
98 type = "fqdn";
99 break;
100 case ID_RFC822_ADDR:
101 type = "email";
102 break;
103 case ID_DER_ASN1_DN:
104 type = "asn1dn";
105 break;
106 case ID_DER_ASN1_GN:
107 type = "asn1gn";
108 break;
109 }
110 xmlTextWriterWriteAttribute(writer, "type", type);
111 xmlTextWriterWriteFormatString(writer, "%Y", id);
112 break;
113 }
114 default:
115 /* TODO: base64 keyid */
116 xmlTextWriterWriteAttribute(writer, "type", "keyid");
117 break;
118 }
119 xmlTextWriterEndElement(writer);
120 }
121
122 /**
123 * write a host_t address into an element
124 */
125 static void write_address(xmlTextWriterPtr writer, char *element, host_t *host)
126 {
127 xmlTextWriterStartElement(writer, element);
128 xmlTextWriterWriteAttribute(writer, "type",
129 host->get_family(host) == AF_INET ? "ipv4" : "ipv6");
130 if (host->is_anyaddr(host))
131 { /* do not use %any for XML */
132 xmlTextWriterWriteFormatString(writer, "%s",
133 host->get_family(host) == AF_INET ? "0.0.0.0" : "::");
134 }
135 else
136 {
137 xmlTextWriterWriteFormatString(writer, "%H", host);
138 }
139 xmlTextWriterEndElement(writer);
140 }
141
142 /**
143 * write networks element
144 */
145 static void write_networks(xmlTextWriterPtr writer, char *element,
146 linked_list_t *list)
147 {
148 enumerator_t *enumerator;
149 traffic_selector_t *ts;
150
151 xmlTextWriterStartElement(writer, element);
152 enumerator = list->create_enumerator(list);
153 while (enumerator->enumerate(enumerator, (void**)&ts))
154 {
155 xmlTextWriterStartElement(writer, "network");
156 xmlTextWriterWriteAttribute(writer, "type",
157 ts->get_type(ts) == TS_IPV4_ADDR_RANGE ? "ipv4" : "ipv6");
158 xmlTextWriterWriteFormatString(writer, "%R", ts);
159 xmlTextWriterEndElement(writer);
160 }
161 enumerator->destroy(enumerator);
162 xmlTextWriterEndElement(writer);
163 }
164
165 /**
166 * write a childEnd
167 */
168 static void write_childend(xmlTextWriterPtr writer, child_sa_t *child, bool local)
169 {
170 linked_list_t *list;
171
172 xmlTextWriterWriteFormatElement(writer, "spi", "%lx",
173 htonl(child->get_spi(child, local)));
174 list = child->get_traffic_selectors(child, local);
175 write_networks(writer, "networks", list);
176 }
177
178 /**
179 * write a child_sa_t
180 */
181 static void write_child(xmlTextWriterPtr writer, child_sa_t *child)
182 {
183 child_cfg_t *config;
184
185 config = child->get_config(child);
186
187 xmlTextWriterStartElement(writer, "childsa");
188 xmlTextWriterWriteFormatElement(writer, "reqid", "%d",
189 child->get_reqid(child));
190 xmlTextWriterWriteFormatElement(writer, "childconfig", "%s",
191 config->get_name(config));
192 xmlTextWriterStartElement(writer, "local");
193 write_childend(writer, child, TRUE);
194 xmlTextWriterEndElement(writer);
195 xmlTextWriterStartElement(writer, "remote");
196 write_childend(writer, child, FALSE);
197 xmlTextWriterEndElement(writer);
198 xmlTextWriterEndElement(writer);
199 }
200
201 /**
202 * process a ikesalist query request message
203 */
204 static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer)
205 {
206 enumerator_t *enumerator;
207 ike_sa_t *ike_sa;
208
209 /* <ikesalist> */
210 xmlTextWriterStartElement(writer, "ikesalist");
211
212 enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
213 while (enumerator->enumerate(enumerator, &ike_sa))
214 {
215 ike_sa_id_t *id;
216 host_t *local, *remote;
217 iterator_t *children;
218 child_sa_t *child_sa;
219
220 id = ike_sa->get_id(ike_sa);
221
222 xmlTextWriterStartElement(writer, "ikesa");
223 xmlTextWriterWriteFormatElement(writer, "id", "%d",
224 ike_sa->get_unique_id(ike_sa));
225 xmlTextWriterWriteFormatElement(writer, "status", "%N",
226 ike_sa_state_lower_names, ike_sa->get_state(ike_sa));
227 xmlTextWriterWriteElement(writer, "role",
228 id->is_initiator(id) ? "initiator" : "responder");
229 xmlTextWriterWriteElement(writer, "peerconfig", ike_sa->get_name(ike_sa));
230
231 /* <local> */
232 local = ike_sa->get_my_host(ike_sa);
233 xmlTextWriterStartElement(writer, "local");
234 xmlTextWriterWriteFormatElement(writer, "spi", "%.16llx",
235 id->is_initiator(id) ? id->get_initiator_spi(id)
236 : id->get_responder_spi(id));
237 write_id(writer, "identification", ike_sa->get_my_id(ike_sa));
238 write_address(writer, "address", local);
239 xmlTextWriterWriteFormatElement(writer, "port", "%d",
240 local->get_port(local));
241 if (ike_sa->supports_extension(ike_sa, EXT_NATT))
242 {
243 write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_HERE));
244 }
245 xmlTextWriterEndElement(writer);
246 /* </local> */
247
248 /* <remote> */
249 remote = ike_sa->get_other_host(ike_sa);
250 xmlTextWriterStartElement(writer, "remote");
251 xmlTextWriterWriteFormatElement(writer, "spi", "%.16llx",
252 id->is_initiator(id) ? id->get_responder_spi(id)
253 : id->get_initiator_spi(id));
254 write_id(writer, "identification", ike_sa->get_other_id(ike_sa));
255 write_address(writer, "address", remote);
256 xmlTextWriterWriteFormatElement(writer, "port", "%d",
257 remote->get_port(remote));
258 if (ike_sa->supports_extension(ike_sa, EXT_NATT))
259 {
260 write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_THERE));
261 }
262 xmlTextWriterEndElement(writer);
263 /* </remote> */
264
265 /* <childsalist> */
266 xmlTextWriterStartElement(writer, "childsalist");
267 children = ike_sa->create_child_sa_iterator(ike_sa);
268 while (children->iterate(children, (void**)&child_sa))
269 {
270 write_child(writer, child_sa);
271 }
272 children->destroy(children);
273 /* </childsalist> */
274 xmlTextWriterEndElement(writer);
275
276 /* </ikesa> */
277 xmlTextWriterEndElement(writer);
278 }
279 enumerator->destroy(enumerator);
280
281 /* </ikesalist> */
282 xmlTextWriterEndElement(writer);
283 }
284
285 /**
286 * process a configlist query request message
287 */
288 static void request_query_config(xmlTextReaderPtr reader, xmlTextWriterPtr writer)
289 {
290 enumerator_t *enumerator;
291 peer_cfg_t *peer_cfg;
292
293 /* <configlist> */
294 xmlTextWriterStartElement(writer, "configlist");
295
296 enumerator = charon->backends->create_peer_cfg_enumerator(charon->backends,
297 NULL, NULL, NULL, NULL);
298 while (enumerator->enumerate(enumerator, &peer_cfg))
299 {
300 enumerator_t *children;
301 child_cfg_t *child_cfg;
302 ike_cfg_t *ike_cfg;
303 linked_list_t *list;
304
305 if (peer_cfg->get_ike_version(peer_cfg) != 2)
306 { /* only IKEv2 connections yet */
307 continue;
308 }
309
310 /* <peerconfig> */
311 xmlTextWriterStartElement(writer, "peerconfig");
312 xmlTextWriterWriteElement(writer, "name", peer_cfg->get_name(peer_cfg));
313
314 /* TODO: write auth_cfgs */
315
316 /* <ikeconfig> */
317 ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
318 xmlTextWriterStartElement(writer, "ikeconfig");
319 xmlTextWriterWriteElement(writer, "local", ike_cfg->get_my_addr(ike_cfg));
320 xmlTextWriterWriteElement(writer, "remote", ike_cfg->get_other_addr(ike_cfg));
321 xmlTextWriterEndElement(writer);
322 /* </ikeconfig> */
323
324 /* <childconfiglist> */
325 xmlTextWriterStartElement(writer, "childconfiglist");
326 children = peer_cfg->create_child_cfg_enumerator(peer_cfg);
327 while (children->enumerate(children, &child_cfg))
328 {
329 /* <childconfig> */
330 xmlTextWriterStartElement(writer, "childconfig");
331 xmlTextWriterWriteElement(writer, "name",
332 child_cfg->get_name(child_cfg));
333 list = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
334 write_networks(writer, "local", list);
335 list->destroy_offset(list, offsetof(traffic_selector_t, destroy));
336 list = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
337 write_networks(writer, "remote", list);
338 list->destroy_offset(list, offsetof(traffic_selector_t, destroy));
339 xmlTextWriterEndElement(writer);
340 /* </childconfig> */
341 }
342 children->destroy(children);
343 /* </childconfiglist> */
344 xmlTextWriterEndElement(writer);
345 /* </peerconfig> */
346 xmlTextWriterEndElement(writer);
347 }
348 enumerator->destroy(enumerator);
349 /* </configlist> */
350 xmlTextWriterEndElement(writer);
351 }
352
353 /**
354 * callback which logs to a XML writer
355 */
356 static bool xml_callback(xmlTextWriterPtr writer, debug_t group, level_t level,
357 ike_sa_t* ike_sa, char* format, va_list args)
358 {
359 if (level <= 1)
360 {
361 /* <item> */
362 xmlTextWriterStartElement(writer, "item");
363 xmlTextWriterWriteFormatAttribute(writer, "level", "%d", level);
364 xmlTextWriterWriteFormatAttribute(writer, "source", "%N", debug_names, group);
365 xmlTextWriterWriteFormatAttribute(writer, "thread", "%u", thread_current_id());
366 xmlTextWriterWriteVFormatString(writer, format, args);
367 xmlTextWriterEndElement(writer);
368 /* </item> */
369 }
370 return TRUE;
371 }
372
373 /**
374 * process a *terminate control request message
375 */
376 static void request_control_terminate(xmlTextReaderPtr reader,
377 xmlTextWriterPtr writer, bool ike)
378 {
379 if (xmlTextReaderRead(reader) &&
380 xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
381 {
382 const char *str;
383 u_int32_t id;
384 status_t status;
385
386 str = xmlTextReaderConstValue(reader);
387 if (str == NULL)
388 {
389 DBG1(DBG_CFG, "error parsing XML id string");
390 return;
391 }
392 id = atoi(str);
393 if (!id)
394 {
395 enumerator_t *enumerator;
396 ike_sa_t *ike_sa;
397
398 enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
399 while (enumerator->enumerate(enumerator, &ike_sa))
400 {
401 if (streq(str, ike_sa->get_name(ike_sa)))
402 {
403 ike = TRUE;
404 id = ike_sa->get_unique_id(ike_sa);
405 break;
406 }
407 }
408 enumerator->destroy(enumerator);
409 }
410 if (!id)
411 {
412 DBG1(DBG_CFG, "error parsing XML id string");
413 return;
414 }
415
416 DBG1(DBG_CFG, "terminating %s_SA %d", ike ? "IKE" : "CHILD", id);
417
418 /* <log> */
419 xmlTextWriterStartElement(writer, "log");
420 if (ike)
421 {
422 status = charon->controller->terminate_ike(
423 charon->controller, id,
424 (controller_cb_t)xml_callback, writer);
425 }
426 else
427 {
428 status = charon->controller->terminate_child(
429 charon->controller, id,
430 (controller_cb_t)xml_callback, writer);
431 }
432 /* </log> */
433 xmlTextWriterEndElement(writer);
434 xmlTextWriterWriteFormatElement(writer, "status", "%d", status);
435 }
436 }
437
438 /**
439 * process a *initiate control request message
440 */
441 static void request_control_initiate(xmlTextReaderPtr reader,
442 xmlTextWriterPtr writer, bool ike)
443 {
444 if (xmlTextReaderRead(reader) &&
445 xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
446 {
447 const char *str;
448 status_t status = FAILED;
449 peer_cfg_t *peer;
450 child_cfg_t *child = NULL;
451 enumerator_t *enumerator;
452
453 str = xmlTextReaderConstValue(reader);
454 if (str == NULL)
455 {
456 DBG1(DBG_CFG, "error parsing XML config name string");
457 return;
458 }
459 DBG1(DBG_CFG, "initiating %s_SA %s", ike ? "IKE" : "CHILD", str);
460
461 /* <log> */
462 xmlTextWriterStartElement(writer, "log");
463 peer = charon->backends->get_peer_cfg_by_name(charon->backends, (char*)str);
464 if (peer)
465 {
466 enumerator = peer->create_child_cfg_enumerator(peer);
467 if (ike)
468 {
469 if (!enumerator->enumerate(enumerator, &child))
470 {
471 child = NULL;
472 }
473 child->get_ref(child);
474 }
475 else
476 {
477 while (enumerator->enumerate(enumerator, &child))
478 {
479 if (streq(child->get_name(child), str))
480 {
481 child->get_ref(child);
482 break;
483 }
484 child = NULL;
485 }
486 }
487 enumerator->destroy(enumerator);
488 if (child)
489 {
490 status = charon->controller->initiate(charon->controller,
491 peer, child, (controller_cb_t)xml_callback,
492 writer);
493 }
494 else
495 {
496 peer->destroy(peer);
497 }
498 }
499 /* </log> */
500 xmlTextWriterEndElement(writer);
501 xmlTextWriterWriteFormatElement(writer, "status", "%d", status);
502 }
503 }
504
505 /**
506 * process a query request
507 */
508 static void request_query(xmlTextReaderPtr reader, xmlTextWriterPtr writer)
509 {
510 /* <query> */
511 xmlTextWriterStartElement(writer, "query");
512 while (xmlTextReaderRead(reader))
513 {
514 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT)
515 {
516 if (streq(xmlTextReaderConstName(reader), "ikesalist"))
517 {
518 request_query_ikesa(reader, writer);
519 break;
520 }
521 if (streq(xmlTextReaderConstName(reader), "configlist"))
522 {
523 request_query_config(reader, writer);
524 break;
525 }
526 }
527 }
528 /* </query> */
529 xmlTextWriterEndElement(writer);
530 }
531
532 /**
533 * process a control request
534 */
535 static void request_control(xmlTextReaderPtr reader, xmlTextWriterPtr writer)
536 {
537 /* <control> */
538 xmlTextWriterStartElement(writer, "control");
539 while (xmlTextReaderRead(reader))
540 {
541 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT)
542 {
543 if (streq(xmlTextReaderConstName(reader), "ikesaterminate"))
544 {
545 request_control_terminate(reader, writer, TRUE);
546 break;
547 }
548 if (streq(xmlTextReaderConstName(reader), "childsaterminate"))
549 {
550 request_control_terminate(reader, writer, FALSE);
551 break;
552 }
553 if (streq(xmlTextReaderConstName(reader), "ikesainitiate"))
554 {
555 request_control_initiate(reader, writer, TRUE);
556 break;
557 }
558 if (streq(xmlTextReaderConstName(reader), "childsainitiate"))
559 {
560 request_control_initiate(reader, writer, FALSE);
561 break;
562 }
563 }
564 }
565 /* </control> */
566 xmlTextWriterEndElement(writer);
567 }
568
569 /**
570 * process a request message
571 */
572 static void request(xmlTextReaderPtr reader, char *id, int fd)
573 {
574 xmlTextWriterPtr writer;
575
576 writer = xmlNewTextWriter(xmlOutputBufferCreateFd(fd, NULL));
577 if (writer == NULL)
578 {
579 DBG1(DBG_CFG, "opening SMP XML writer failed");
580 return;
581 }
582
583 xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
584 /* <message xmlns="http://www.strongswan.org/smp/1.0"
585 id="id" type="response"> */
586 xmlTextWriterStartElement(writer, "message");
587 xmlTextWriterWriteAttribute(writer, "xmlns",
588 "http://www.strongswan.org/smp/1.0");
589 xmlTextWriterWriteAttribute(writer, "id", id);
590 xmlTextWriterWriteAttribute(writer, "type", "response");
591
592 while (xmlTextReaderRead(reader))
593 {
594 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT)
595 {
596 if (streq(xmlTextReaderConstName(reader), "query"))
597 {
598 request_query(reader, writer);
599 break;
600 }
601 if (streq(xmlTextReaderConstName(reader), "control"))
602 {
603 request_control(reader, writer);
604 break;
605 }
606 }
607 }
608 /* </message> and close document */
609 xmlTextWriterEndDocument(writer);
610 xmlFreeTextWriter(writer);
611 }
612
613 /**
614 * cleanup helper function for open file descriptors
615 */
616 static void closefdp(int *fd)
617 {
618 close(*fd);
619 }
620
621 /**
622 * read from a opened connection and process it
623 */
624 static job_requeue_t process(int *fdp)
625 {
626 int fd = *fdp;
627 bool oldstate;
628 char buffer[4096];
629 size_t len;
630 xmlTextReaderPtr reader;
631 char *id = NULL, *type = NULL;
632
633 thread_cleanup_push((thread_cleanup_t)closefdp, (void*)&fd);
634 oldstate = thread_cancelability(TRUE);
635 len = read(fd, buffer, sizeof(buffer));
636 thread_cancelability(oldstate);
637 thread_cleanup_pop(FALSE);
638 if (len <= 0)
639 {
640 close(fd);
641 DBG2(DBG_CFG, "SMP XML connection closed");
642 return JOB_REQUEUE_NONE;
643 }
644 DBG3(DBG_CFG, "got XML request: %b", buffer, len);
645
646 reader = xmlReaderForMemory(buffer, len, NULL, NULL, 0);
647 if (reader == NULL)
648 {
649 DBG1(DBG_CFG, "opening SMP XML reader failed");
650 return JOB_REQUEUE_FAIR;;
651 }
652
653 /* read message type and id */
654 while (xmlTextReaderRead(reader))
655 {
656 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT &&
657 streq(xmlTextReaderConstName(reader), "message"))
658 {
659 id = xmlTextReaderGetAttribute(reader, "id");
660 type = xmlTextReaderGetAttribute(reader, "type");
661 break;
662 }
663 }
664
665 /* process message */
666 if (id && type)
667 {
668 if (streq(type, "request"))
669 {
670 request(reader, id, fd);
671 }
672 else
673 {
674 /* response(reader, id) */
675 }
676 }
677 xmlFreeTextReader(reader);
678 return JOB_REQUEUE_FAIR;;
679 }
680
681 /**
682 * accept from XML socket and create jobs to process connections
683 */
684 static job_requeue_t dispatch(private_smp_t *this)
685 {
686 struct sockaddr_un strokeaddr;
687 int fd, *fdp, strokeaddrlen = sizeof(strokeaddr);
688 callback_job_t *job;
689 bool oldstate;
690
691 /* wait for connections, but allow thread to terminate */
692 oldstate = thread_cancelability(TRUE);
693 fd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen);
694 thread_cancelability(oldstate);
695
696 if (fd < 0)
697 {
698 DBG1(DBG_CFG, "accepting SMP XML socket failed: %s", strerror(errno));
699 sleep(1);
700 return JOB_REQUEUE_FAIR;;
701 }
702
703 fdp = malloc_thing(int);
704 *fdp = fd;
705 job = callback_job_create((callback_job_cb_t)process, fdp, free, this->job);
706 hydra->processor->queue_job(hydra->processor, (job_t*)job);
707
708 return JOB_REQUEUE_DIRECT;
709 }
710
711 /**
712 * Implementation of itnerface_t.destroy.
713 */
714 static void destroy(private_smp_t *this)
715 {
716 this->job->cancel(this->job);
717 close(this->socket);
718 free(this);
719 }
720
721 /*
722 * Described in header file
723 */
724 plugin_t *smp_plugin_create()
725 {
726 struct sockaddr_un unix_addr = { AF_UNIX, IPSEC_PIDDIR "/charon.xml"};
727 private_smp_t *this = malloc_thing(private_smp_t);
728 mode_t old;
729
730 this->public.plugin.destroy = (void (*)(plugin_t*))destroy;
731
732 /* set up unix socket */
733 this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
734 if (this->socket == -1)
735 {
736 DBG1(DBG_CFG, "could not create XML socket");
737 free(this);
738 return NULL;
739 }
740
741 unlink(unix_addr.sun_path);
742 old = umask(~(S_IRWXU | S_IRWXG));
743 if (bind(this->socket, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0)
744 {
745 DBG1(DBG_CFG, "could not bind XML socket: %s", strerror(errno));
746 close(this->socket);
747 free(this);
748 return NULL;
749 }
750 umask(old);
751 if (chown(unix_addr.sun_path, charon->uid, charon->gid) != 0)
752 {
753 DBG1(DBG_CFG, "changing XML socket permissions failed: %s", strerror(errno));
754 }
755
756 if (listen(this->socket, 5) < 0)
757 {
758 DBG1(DBG_CFG, "could not listen on XML socket: %s", strerror(errno));
759 close(this->socket);
760 free(this);
761 return NULL;
762 }
763
764 this->job = callback_job_create((callback_job_cb_t)dispatch, this, NULL, NULL);
765 hydra->processor->queue_job(hydra->processor, (job_t*)this->job);
766
767 return &this->public.plugin;
768 }
769