1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 #include <microhttpd.h>
11 #include "sd-daemon.h"
12 #include "sd-journal.h"
14 #include "alloc-util.h"
18 #include "hostname-util.h"
20 #include "logs-show.h"
21 #include "main-func.h"
22 #include "microhttpd-util.h"
24 #include "parse-util.h"
25 #include "pretty-print.h"
27 #include "tmpfile-util.h"
30 #define JOURNAL_WAIT_TIMEOUT (10*USEC_PER_SEC)
32 static char *arg_key_pem
= NULL
;
33 static char *arg_cert_pem
= NULL
;
34 static char *arg_trust_pem
= NULL
;
35 static const char *arg_directory
= NULL
;
37 STATIC_DESTRUCTOR_REGISTER(arg_key_pem
, freep
);
38 STATIC_DESTRUCTOR_REGISTER(arg_cert_pem
, freep
);
39 STATIC_DESTRUCTOR_REGISTER(arg_trust_pem
, freep
);
41 typedef struct RequestMeta
{
54 int argument_parse_error
;
63 static const char* const mime_types
[_OUTPUT_MODE_MAX
] = {
64 [OUTPUT_SHORT
] = "text/plain",
65 [OUTPUT_JSON
] = "application/json",
66 [OUTPUT_JSON_SSE
] = "text/event-stream",
67 [OUTPUT_JSON_SEQ
] = "application/json-seq",
68 [OUTPUT_EXPORT
] = "application/vnd.fdo.journal",
71 static RequestMeta
*request_meta(void **connection_cls
) {
74 assert(connection_cls
);
76 return *connection_cls
;
78 m
= new0(RequestMeta
, 1);
86 static void request_meta_free(
88 struct MHD_Connection
*connection
,
89 void **connection_cls
,
90 enum MHD_RequestTerminationCode toe
) {
92 RequestMeta
*m
= *connection_cls
;
97 sd_journal_close(m
->journal
);
105 static int open_journal(RequestMeta
*m
) {
112 return sd_journal_open_directory(&m
->journal
, arg_directory
, 0);
114 return sd_journal_open(&m
->journal
, SD_JOURNAL_LOCAL_ONLY
|SD_JOURNAL_SYSTEM
);
117 static int request_meta_ensure_tmp(RequestMeta
*m
) {
125 fd
= open_tmpfile_unlinkable("/tmp", O_RDWR
|O_CLOEXEC
);
129 m
->tmp
= fdopen(fd
, "w+");
139 static ssize_t
request_reader_entries(
145 RequestMeta
*m
= cls
;
152 assert(pos
>= m
->delta
);
156 while (pos
>= m
->size
) {
159 /* End of this entry, so let's serialize the next
162 if (m
->n_entries_set
&&
164 return MHD_CONTENT_READER_END_OF_STREAM
;
167 r
= sd_journal_previous_skip(m
->journal
, (uint64_t) -m
->n_skip
+ 1);
168 else if (m
->n_skip
> 0)
169 r
= sd_journal_next_skip(m
->journal
, (uint64_t) m
->n_skip
+ 1);
171 r
= sd_journal_next(m
->journal
);
174 log_error_errno(r
, "Failed to advance journal pointer: %m");
175 return MHD_CONTENT_READER_END_WITH_ERROR
;
179 r
= sd_journal_wait(m
->journal
, (uint64_t) JOURNAL_WAIT_TIMEOUT
);
181 log_error_errno(r
, "Couldn't wait for journal event: %m");
182 return MHD_CONTENT_READER_END_WITH_ERROR
;
184 if (r
== SD_JOURNAL_NOP
)
190 return MHD_CONTENT_READER_END_OF_STREAM
;
196 r
= sd_journal_test_cursor(m
->journal
, m
->cursor
);
198 log_error_errno(r
, "Failed to test cursor: %m");
199 return MHD_CONTENT_READER_END_WITH_ERROR
;
203 return MHD_CONTENT_READER_END_OF_STREAM
;
209 if (m
->n_entries_set
)
214 r
= request_meta_ensure_tmp(m
);
216 log_error_errno(r
, "Failed to create temporary file: %m");
217 return MHD_CONTENT_READER_END_WITH_ERROR
;
220 r
= show_journal_entry(m
->tmp
, m
->journal
, m
->mode
, 0, OUTPUT_FULL_WIDTH
,
223 log_error_errno(r
, "Failed to serialize item: %m");
224 return MHD_CONTENT_READER_END_WITH_ERROR
;
228 if (sz
== (off_t
) -1) {
229 log_error_errno(errno
, "Failed to retrieve file position: %m");
230 return MHD_CONTENT_READER_END_WITH_ERROR
;
233 m
->size
= (uint64_t) sz
;
236 if (m
->tmp
== NULL
&& m
->follow
)
239 if (fseeko(m
->tmp
, pos
, SEEK_SET
) < 0) {
240 log_error_errno(errno
, "Failed to seek to position: %m");
241 return MHD_CONTENT_READER_END_WITH_ERROR
;
251 k
= fread(buf
, 1, n
, m
->tmp
);
253 log_error("Failed to read from file: %s", errno
? strerror(errno
) : "Premature EOF");
254 return MHD_CONTENT_READER_END_WITH_ERROR
;
260 static int request_parse_accept(
262 struct MHD_Connection
*connection
) {
269 header
= MHD_lookup_connection_value(connection
, MHD_HEADER_KIND
, "Accept");
273 if (streq(header
, mime_types
[OUTPUT_JSON
]))
274 m
->mode
= OUTPUT_JSON
;
275 else if (streq(header
, mime_types
[OUTPUT_JSON_SSE
]))
276 m
->mode
= OUTPUT_JSON_SSE
;
277 else if (streq(header
, mime_types
[OUTPUT_JSON_SEQ
]))
278 m
->mode
= OUTPUT_JSON_SEQ
;
279 else if (streq(header
, mime_types
[OUTPUT_EXPORT
]))
280 m
->mode
= OUTPUT_EXPORT
;
282 m
->mode
= OUTPUT_SHORT
;
287 static int request_parse_range(
289 struct MHD_Connection
*connection
) {
291 const char *range
, *colon
, *colon2
;
297 range
= MHD_lookup_connection_value(connection
, MHD_HEADER_KIND
, "Range");
301 if (!startswith(range
, "entries="))
305 range
+= strspn(range
, WHITESPACE
);
307 colon
= strchr(range
, ':');
309 m
->cursor
= strdup(range
);
313 colon2
= strchr(colon
+ 1, ':');
315 _cleanup_free_
char *t
;
317 t
= strndup(colon
+ 1, colon2
- colon
- 1);
321 r
= safe_atoi64(t
, &m
->n_skip
);
326 p
= (colon2
? colon2
: colon
) + 1;
328 r
= safe_atou64(p
, &m
->n_entries
);
332 if (m
->n_entries
<= 0)
335 m
->n_entries_set
= true;
338 m
->cursor
= strndup(range
, colon
- range
);
344 m
->cursor
[strcspn(m
->cursor
, WHITESPACE
)] = 0;
345 if (isempty(m
->cursor
))
346 m
->cursor
= mfree(m
->cursor
);
351 static int request_parse_arguments_iterator(
353 enum MHD_ValueKind kind
,
357 RequestMeta
*m
= cls
;
358 _cleanup_free_
char *p
= NULL
;
364 m
->argument_parse_error
= -EINVAL
;
368 if (streq(key
, "follow")) {
369 if (isempty(value
)) {
374 r
= parse_boolean(value
);
376 m
->argument_parse_error
= r
;
384 if (streq(key
, "discrete")) {
385 if (isempty(value
)) {
390 r
= parse_boolean(value
);
392 m
->argument_parse_error
= r
;
400 if (streq(key
, "boot")) {
404 r
= parse_boolean(value
);
406 m
->argument_parse_error
= r
;
412 char match
[9 + 32 + 1] = "_BOOT_ID=";
415 r
= sd_id128_get_boot(&bid
);
417 log_error_errno(r
, "Failed to get boot ID: %m");
421 sd_id128_to_string(bid
, match
+ 9);
422 r
= sd_journal_add_match(m
->journal
, match
, sizeof(match
)-1);
424 m
->argument_parse_error
= r
;
432 p
= strjoin(key
, "=", strempty(value
));
434 m
->argument_parse_error
= log_oom();
438 r
= sd_journal_add_match(m
->journal
, p
, 0);
440 m
->argument_parse_error
= r
;
447 static int request_parse_arguments(
449 struct MHD_Connection
*connection
) {
454 m
->argument_parse_error
= 0;
455 MHD_get_connection_values(connection
, MHD_GET_ARGUMENT_KIND
, request_parse_arguments_iterator
, m
);
457 return m
->argument_parse_error
;
460 static int request_handler_entries(
461 struct MHD_Connection
*connection
,
462 void *connection_cls
) {
464 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
465 RequestMeta
*m
= connection_cls
;
473 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
475 if (request_parse_accept(m
, connection
) < 0)
476 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Accept header.");
478 if (request_parse_range(m
, connection
) < 0)
479 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Range header.");
481 if (request_parse_arguments(m
, connection
) < 0)
482 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse URL arguments.");
486 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Discrete seeks require a cursor specification.");
489 m
->n_entries_set
= true;
493 r
= sd_journal_seek_cursor(m
->journal
, m
->cursor
);
494 else if (m
->n_skip
>= 0)
495 r
= sd_journal_seek_head(m
->journal
);
496 else if (m
->n_skip
< 0)
497 r
= sd_journal_seek_tail(m
->journal
);
499 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to seek in journal.");
501 response
= MHD_create_response_from_callback(MHD_SIZE_UNKNOWN
, 4*1024, request_reader_entries
, m
, NULL
);
503 return respond_oom(connection
);
505 MHD_add_response_header(response
, "Content-Type", mime_types
[m
->mode
]);
506 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
509 static int output_field(FILE *f
, OutputMode m
, const char *d
, size_t l
) {
513 eq
= memchr(d
, '=', l
);
517 j
= l
- (eq
- d
+ 1);
519 if (m
== OUTPUT_JSON
) {
520 fprintf(f
, "{ \"%.*s\" : ", (int) (eq
- d
), d
);
521 json_escape(f
, eq
+1, j
, OUTPUT_FULL_WIDTH
);
524 fwrite(eq
+1, 1, j
, f
);
531 static ssize_t
request_reader_fields(
537 RequestMeta
*m
= cls
;
544 assert(pos
>= m
->delta
);
548 while (pos
>= m
->size
) {
553 /* End of this field, so let's serialize the next
556 if (m
->n_fields_set
&&
558 return MHD_CONTENT_READER_END_OF_STREAM
;
560 r
= sd_journal_enumerate_unique(m
->journal
, &d
, &l
);
562 log_error_errno(r
, "Failed to advance field index: %m");
563 return MHD_CONTENT_READER_END_WITH_ERROR
;
565 return MHD_CONTENT_READER_END_OF_STREAM
;
573 r
= request_meta_ensure_tmp(m
);
575 log_error_errno(r
, "Failed to create temporary file: %m");
576 return MHD_CONTENT_READER_END_WITH_ERROR
;
579 r
= output_field(m
->tmp
, m
->mode
, d
, l
);
581 log_error_errno(r
, "Failed to serialize item: %m");
582 return MHD_CONTENT_READER_END_WITH_ERROR
;
586 if (sz
== (off_t
) -1) {
587 log_error_errno(errno
, "Failed to retrieve file position: %m");
588 return MHD_CONTENT_READER_END_WITH_ERROR
;
591 m
->size
= (uint64_t) sz
;
594 if (fseeko(m
->tmp
, pos
, SEEK_SET
) < 0) {
595 log_error_errno(errno
, "Failed to seek to position: %m");
596 return MHD_CONTENT_READER_END_WITH_ERROR
;
604 k
= fread(buf
, 1, n
, m
->tmp
);
606 log_error("Failed to read from file: %s", errno
? strerror(errno
) : "Premature EOF");
607 return MHD_CONTENT_READER_END_WITH_ERROR
;
613 static int request_handler_fields(
614 struct MHD_Connection
*connection
,
616 void *connection_cls
) {
618 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
619 RequestMeta
*m
= connection_cls
;
627 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
629 if (request_parse_accept(m
, connection
) < 0)
630 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Accept header.");
632 r
= sd_journal_query_unique(m
->journal
, field
);
634 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to query unique fields.");
636 response
= MHD_create_response_from_callback(MHD_SIZE_UNKNOWN
, 4*1024, request_reader_fields
, m
, NULL
);
638 return respond_oom(connection
);
640 MHD_add_response_header(response
, "Content-Type", mime_types
[m
->mode
== OUTPUT_JSON
? OUTPUT_JSON
: OUTPUT_SHORT
]);
641 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
644 static int request_handler_redirect(
645 struct MHD_Connection
*connection
,
646 const char *target
) {
649 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
654 if (asprintf(&page
, "<html><body>Please continue to the <a href=\"%s\">journal browser</a>.</body></html>", target
) < 0)
655 return respond_oom(connection
);
657 response
= MHD_create_response_from_buffer(strlen(page
), page
, MHD_RESPMEM_MUST_FREE
);
660 return respond_oom(connection
);
663 MHD_add_response_header(response
, "Content-Type", "text/html");
664 MHD_add_response_header(response
, "Location", target
);
665 return MHD_queue_response(connection
, MHD_HTTP_MOVED_PERMANENTLY
, response
);
668 static int request_handler_file(
669 struct MHD_Connection
*connection
,
671 const char *mime_type
) {
673 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
674 _cleanup_close_
int fd
= -1;
681 fd
= open(path
, O_RDONLY
|O_CLOEXEC
);
683 return mhd_respondf(connection
, errno
, MHD_HTTP_NOT_FOUND
, "Failed to open file %s: %m", path
);
685 if (fstat(fd
, &st
) < 0)
686 return mhd_respondf(connection
, errno
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to stat file: %m");
688 response
= MHD_create_response_from_fd_at_offset64(st
.st_size
, fd
, 0);
690 return respond_oom(connection
);
693 MHD_add_response_header(response
, "Content-Type", mime_type
);
694 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
697 static int get_virtualization(char **v
) {
698 _cleanup_(sd_bus_unrefp
) sd_bus
*bus
= NULL
;
702 r
= sd_bus_default_system(&bus
);
706 r
= sd_bus_get_property_string(
708 "org.freedesktop.systemd1",
709 "/org/freedesktop/systemd1",
710 "org.freedesktop.systemd1.Manager",
727 static int request_handler_machine(
728 struct MHD_Connection
*connection
,
729 void *connection_cls
) {
731 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
732 RequestMeta
*m
= connection_cls
;
734 _cleanup_free_
char* hostname
= NULL
, *os_name
= NULL
;
735 uint64_t cutoff_from
= 0, cutoff_to
= 0, usage
= 0;
737 _cleanup_free_
char *v
= NULL
, *json
= NULL
;
744 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
746 r
= sd_id128_get_machine(&mid
);
748 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine machine ID: %m");
750 r
= sd_id128_get_boot(&bid
);
752 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine boot ID: %m");
754 hostname
= gethostname_malloc();
756 return respond_oom(connection
);
758 r
= sd_journal_get_usage(m
->journal
, &usage
);
760 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine disk usage: %m");
762 r
= sd_journal_get_cutoff_realtime_usec(m
->journal
, &cutoff_from
, &cutoff_to
);
764 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine disk usage: %m");
766 (void) parse_os_release(NULL
, "PRETTY_NAME", &os_name
, NULL
);
767 (void) get_virtualization(&v
);
770 "{ \"machine_id\" : \"" SD_ID128_FORMAT_STR
"\","
771 "\"boot_id\" : \"" SD_ID128_FORMAT_STR
"\","
772 "\"hostname\" : \"%s\","
773 "\"os_pretty_name\" : \"%s\","
774 "\"virtualization\" : \"%s\","
775 "\"usage\" : \"%"PRIu64
"\","
776 "\"cutoff_from_realtime\" : \"%"PRIu64
"\","
777 "\"cutoff_to_realtime\" : \"%"PRIu64
"\" }\n",
778 SD_ID128_FORMAT_VAL(mid
),
779 SD_ID128_FORMAT_VAL(bid
),
780 hostname_cleanup(hostname
),
781 os_name
? os_name
: "Linux",
787 return respond_oom(connection
);
789 response
= MHD_create_response_from_buffer(strlen(json
), json
, MHD_RESPMEM_MUST_FREE
);
791 return respond_oom(connection
);
794 MHD_add_response_header(response
, "Content-Type", "application/json");
795 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
798 static int request_handler(
800 struct MHD_Connection
*connection
,
804 const char *upload_data
,
805 size_t *upload_data_size
,
806 void **connection_cls
) {
810 assert(connection_cls
);
814 if (!streq(method
, "GET"))
815 return mhd_respond(connection
, MHD_HTTP_NOT_ACCEPTABLE
, "Unsupported method.");
817 if (!*connection_cls
) {
818 if (!request_meta(connection_cls
))
819 return respond_oom(connection
);
824 r
= check_permissions(connection
, &code
, NULL
);
830 return request_handler_redirect(connection
, "/browse");
832 if (streq(url
, "/entries"))
833 return request_handler_entries(connection
, *connection_cls
);
835 if (startswith(url
, "/fields/"))
836 return request_handler_fields(connection
, url
+ 8, *connection_cls
);
838 if (streq(url
, "/browse"))
839 return request_handler_file(connection
, DOCUMENT_ROOT
"/browse.html", "text/html");
841 if (streq(url
, "/machine"))
842 return request_handler_machine(connection
, *connection_cls
);
844 return mhd_respond(connection
, MHD_HTTP_NOT_FOUND
, "Not found.");
847 static int help(void) {
848 _cleanup_free_
char *link
= NULL
;
851 r
= terminal_urlify_man("systemd-journal-gatewayd.service", "8", &link
);
855 printf("%s [OPTIONS...] ...\n\n"
856 "HTTP server for journal events.\n\n"
857 " -h --help Show this help\n"
858 " --version Show package version\n"
859 " --cert=CERT.PEM Server certificate in PEM format\n"
860 " --key=KEY.PEM Server key in PEM format\n"
861 " --trust=CERT.PEM Certificate authority certificate in PEM format\n"
862 " -D --directory=PATH Serve journal files in directory\n"
863 "\nSee the %s for details.\n"
864 , program_invocation_short_name
871 static int parse_argv(int argc
, char *argv
[]) {
881 static const struct option options
[] = {
882 { "help", no_argument
, NULL
, 'h' },
883 { "version", no_argument
, NULL
, ARG_VERSION
},
884 { "key", required_argument
, NULL
, ARG_KEY
},
885 { "cert", required_argument
, NULL
, ARG_CERT
},
886 { "trust", required_argument
, NULL
, ARG_TRUST
},
887 { "directory", required_argument
, NULL
, 'D' },
894 while ((c
= getopt_long(argc
, argv
, "hD:", options
, NULL
)) >= 0)
906 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
907 "Key file specified twice");
908 r
= read_full_file(optarg
, &arg_key_pem
, NULL
);
910 return log_error_errno(r
, "Failed to read key file: %m");
916 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
917 "Certificate file specified twice");
918 r
= read_full_file(optarg
, &arg_cert_pem
, NULL
);
920 return log_error_errno(r
, "Failed to read certificate file: %m");
921 assert(arg_cert_pem
);
927 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
928 "CA certificate file specified twice");
929 r
= read_full_file(optarg
, &arg_trust_pem
, NULL
);
931 return log_error_errno(r
, "Failed to read CA certificate file: %m");
932 assert(arg_trust_pem
);
935 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
936 "Option --trust is not available.");
939 arg_directory
= optarg
;
946 assert_not_reached("Unhandled option");
950 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
951 "This program does not take arguments.");
953 if (!!arg_key_pem
!= !!arg_cert_pem
)
954 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
955 "Certificate and key files must be specified together");
957 if (arg_trust_pem
&& !arg_key_pem
)
958 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
959 "CA certificate can only be used with certificate file");
964 static int run(int argc
, char *argv
[]) {
965 _cleanup_(MHD_stop_daemonp
) struct MHD_Daemon
*d
= NULL
;
966 struct MHD_OptionItem opts
[] = {
967 { MHD_OPTION_NOTIFY_COMPLETED
,
968 (intptr_t) request_meta_free
, NULL
},
969 { MHD_OPTION_EXTERNAL_LOGGER
,
970 (intptr_t) microhttpd_logger
, NULL
},
971 { MHD_OPTION_END
, 0, NULL
},
972 { MHD_OPTION_END
, 0, NULL
},
973 { MHD_OPTION_END
, 0, NULL
},
974 { MHD_OPTION_END
, 0, NULL
},
975 { MHD_OPTION_END
, 0, NULL
},
979 /* We force MHD_USE_ITC here, in order to make sure
980 * libmicrohttpd doesn't use shutdown() on our listening
981 * socket, which would break socket re-activation. See
983 * https://lists.gnu.org/archive/html/libmicrohttpd/2015-09/msg00014.html
984 * https://github.com/systemd/systemd/pull/1286
991 MHD_USE_POLL_INTERNAL_THREAD
|
992 MHD_USE_THREAD_PER_CONNECTION
;
997 r
= parse_argv(argc
, argv
);
1003 r
= setup_gnutls_logger(NULL
);
1007 n
= sd_listen_fds(1);
1009 return log_error_errno(n
, "Failed to determine passed sockets: %m");
1011 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "Can't listen on more than one socket.");
1014 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1015 { MHD_OPTION_LISTEN_SOCKET
, SD_LISTEN_FDS_START
};
1018 assert(arg_cert_pem
);
1019 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1020 { MHD_OPTION_HTTPS_MEM_KEY
, 0, arg_key_pem
};
1021 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1022 { MHD_OPTION_HTTPS_MEM_CERT
, 0, arg_cert_pem
};
1023 flags
|= MHD_USE_TLS
;
1026 if (arg_trust_pem
) {
1027 assert(flags
& MHD_USE_TLS
);
1028 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1029 { MHD_OPTION_HTTPS_MEM_TRUST
, 0, arg_trust_pem
};
1032 d
= MHD_start_daemon(flags
, 19531,
1034 request_handler
, NULL
,
1035 MHD_OPTION_ARRAY
, opts
,
1038 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "Failed to start daemon!");
1045 DEFINE_MAIN_FUNCTION(run
);