1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 #include <microhttpd.h>
13 #include "sd-daemon.h"
14 #include "sd-journal.h"
16 #include "alloc-util.h"
20 #include "hostname-util.h"
22 #include "logs-show.h"
23 #include "main-func.h"
24 #include "microhttpd-util.h"
26 #include "parse-util.h"
27 #include "pretty-print.h"
29 #include "tmpfile-util.h"
32 #define JOURNAL_WAIT_TIMEOUT (10*USEC_PER_SEC)
34 static char *arg_key_pem
= NULL
;
35 static char *arg_cert_pem
= NULL
;
36 static char *arg_trust_pem
= NULL
;
37 static const char *arg_directory
= NULL
;
39 STATIC_DESTRUCTOR_REGISTER(arg_key_pem
, freep
);
40 STATIC_DESTRUCTOR_REGISTER(arg_cert_pem
, freep
);
41 STATIC_DESTRUCTOR_REGISTER(arg_trust_pem
, freep
);
43 typedef struct RequestMeta
{
56 int argument_parse_error
;
65 static const char* const mime_types
[_OUTPUT_MODE_MAX
] = {
66 [OUTPUT_SHORT
] = "text/plain",
67 [OUTPUT_JSON
] = "application/json",
68 [OUTPUT_JSON_SSE
] = "text/event-stream",
69 [OUTPUT_JSON_SEQ
] = "application/json-seq",
70 [OUTPUT_EXPORT
] = "application/vnd.fdo.journal",
73 static RequestMeta
*request_meta(void **connection_cls
) {
76 assert(connection_cls
);
78 return *connection_cls
;
80 m
= new0(RequestMeta
, 1);
88 static void request_meta_free(
90 struct MHD_Connection
*connection
,
91 void **connection_cls
,
92 enum MHD_RequestTerminationCode toe
) {
94 RequestMeta
*m
= *connection_cls
;
99 sd_journal_close(m
->journal
);
107 static int open_journal(RequestMeta
*m
) {
114 return sd_journal_open_directory(&m
->journal
, arg_directory
, 0);
116 return sd_journal_open(&m
->journal
, SD_JOURNAL_LOCAL_ONLY
|SD_JOURNAL_SYSTEM
);
119 static int request_meta_ensure_tmp(RequestMeta
*m
) {
127 fd
= open_tmpfile_unlinkable("/tmp", O_RDWR
|O_CLOEXEC
);
131 m
->tmp
= fdopen(fd
, "w+");
141 static ssize_t
request_reader_entries(
147 RequestMeta
*m
= cls
;
154 assert(pos
>= m
->delta
);
158 while (pos
>= m
->size
) {
161 /* End of this entry, so let's serialize the next
164 if (m
->n_entries_set
&&
166 return MHD_CONTENT_READER_END_OF_STREAM
;
169 r
= sd_journal_previous_skip(m
->journal
, (uint64_t) -m
->n_skip
+ 1);
170 else if (m
->n_skip
> 0)
171 r
= sd_journal_next_skip(m
->journal
, (uint64_t) m
->n_skip
+ 1);
173 r
= sd_journal_next(m
->journal
);
176 log_error_errno(r
, "Failed to advance journal pointer: %m");
177 return MHD_CONTENT_READER_END_WITH_ERROR
;
181 r
= sd_journal_wait(m
->journal
, (uint64_t) JOURNAL_WAIT_TIMEOUT
);
183 log_error_errno(r
, "Couldn't wait for journal event: %m");
184 return MHD_CONTENT_READER_END_WITH_ERROR
;
186 if (r
== SD_JOURNAL_NOP
)
192 return MHD_CONTENT_READER_END_OF_STREAM
;
198 r
= sd_journal_test_cursor(m
->journal
, m
->cursor
);
200 log_error_errno(r
, "Failed to test cursor: %m");
201 return MHD_CONTENT_READER_END_WITH_ERROR
;
205 return MHD_CONTENT_READER_END_OF_STREAM
;
211 if (m
->n_entries_set
)
216 r
= request_meta_ensure_tmp(m
);
218 log_error_errno(r
, "Failed to create temporary file: %m");
219 return MHD_CONTENT_READER_END_WITH_ERROR
;
222 r
= show_journal_entry(m
->tmp
, m
->journal
, m
->mode
, 0, OUTPUT_FULL_WIDTH
,
225 log_error_errno(r
, "Failed to serialize item: %m");
226 return MHD_CONTENT_READER_END_WITH_ERROR
;
230 if (sz
== (off_t
) -1) {
231 log_error_errno(errno
, "Failed to retrieve file position: %m");
232 return MHD_CONTENT_READER_END_WITH_ERROR
;
235 m
->size
= (uint64_t) sz
;
238 if (m
->tmp
== NULL
&& m
->follow
)
241 if (fseeko(m
->tmp
, pos
, SEEK_SET
) < 0) {
242 log_error_errno(errno
, "Failed to seek to position: %m");
243 return MHD_CONTENT_READER_END_WITH_ERROR
;
253 k
= fread(buf
, 1, n
, m
->tmp
);
255 log_error("Failed to read from file: %s", errno
? strerror(errno
) : "Premature EOF");
256 return MHD_CONTENT_READER_END_WITH_ERROR
;
262 static int request_parse_accept(
264 struct MHD_Connection
*connection
) {
271 header
= MHD_lookup_connection_value(connection
, MHD_HEADER_KIND
, "Accept");
275 if (streq(header
, mime_types
[OUTPUT_JSON
]))
276 m
->mode
= OUTPUT_JSON
;
277 else if (streq(header
, mime_types
[OUTPUT_JSON_SSE
]))
278 m
->mode
= OUTPUT_JSON_SSE
;
279 else if (streq(header
, mime_types
[OUTPUT_JSON_SEQ
]))
280 m
->mode
= OUTPUT_JSON_SEQ
;
281 else if (streq(header
, mime_types
[OUTPUT_EXPORT
]))
282 m
->mode
= OUTPUT_EXPORT
;
284 m
->mode
= OUTPUT_SHORT
;
289 static int request_parse_range(
291 struct MHD_Connection
*connection
) {
293 const char *range
, *colon
, *colon2
;
299 range
= MHD_lookup_connection_value(connection
, MHD_HEADER_KIND
, "Range");
303 if (!startswith(range
, "entries="))
307 range
+= strspn(range
, WHITESPACE
);
309 colon
= strchr(range
, ':');
311 m
->cursor
= strdup(range
);
315 colon2
= strchr(colon
+ 1, ':');
317 _cleanup_free_
char *t
;
319 t
= strndup(colon
+ 1, colon2
- colon
- 1);
323 r
= safe_atoi64(t
, &m
->n_skip
);
328 p
= (colon2
? colon2
: colon
) + 1;
330 r
= safe_atou64(p
, &m
->n_entries
);
334 if (m
->n_entries
<= 0)
337 m
->n_entries_set
= true;
340 m
->cursor
= strndup(range
, colon
- range
);
346 m
->cursor
[strcspn(m
->cursor
, WHITESPACE
)] = 0;
347 if (isempty(m
->cursor
))
348 m
->cursor
= mfree(m
->cursor
);
353 static int request_parse_arguments_iterator(
355 enum MHD_ValueKind kind
,
359 RequestMeta
*m
= cls
;
360 _cleanup_free_
char *p
= NULL
;
366 m
->argument_parse_error
= -EINVAL
;
370 if (streq(key
, "follow")) {
371 if (isempty(value
)) {
376 r
= parse_boolean(value
);
378 m
->argument_parse_error
= r
;
386 if (streq(key
, "discrete")) {
387 if (isempty(value
)) {
392 r
= parse_boolean(value
);
394 m
->argument_parse_error
= r
;
402 if (streq(key
, "boot")) {
406 r
= parse_boolean(value
);
408 m
->argument_parse_error
= r
;
414 char match
[9 + 32 + 1] = "_BOOT_ID=";
417 r
= sd_id128_get_boot(&bid
);
419 log_error_errno(r
, "Failed to get boot ID: %m");
423 sd_id128_to_string(bid
, match
+ 9);
424 r
= sd_journal_add_match(m
->journal
, match
, sizeof(match
)-1);
426 m
->argument_parse_error
= r
;
434 p
= strjoin(key
, "=", strempty(value
));
436 m
->argument_parse_error
= log_oom();
440 r
= sd_journal_add_match(m
->journal
, p
, 0);
442 m
->argument_parse_error
= r
;
449 static int request_parse_arguments(
451 struct MHD_Connection
*connection
) {
456 m
->argument_parse_error
= 0;
457 MHD_get_connection_values(connection
, MHD_GET_ARGUMENT_KIND
, request_parse_arguments_iterator
, m
);
459 return m
->argument_parse_error
;
462 static int request_handler_entries(
463 struct MHD_Connection
*connection
,
464 void *connection_cls
) {
466 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
467 RequestMeta
*m
= connection_cls
;
475 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
477 if (request_parse_accept(m
, connection
) < 0)
478 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Accept header.");
480 if (request_parse_range(m
, connection
) < 0)
481 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Range header.");
483 if (request_parse_arguments(m
, connection
) < 0)
484 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse URL arguments.");
488 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Discrete seeks require a cursor specification.");
491 m
->n_entries_set
= true;
495 r
= sd_journal_seek_cursor(m
->journal
, m
->cursor
);
496 else if (m
->n_skip
>= 0)
497 r
= sd_journal_seek_head(m
->journal
);
498 else if (m
->n_skip
< 0)
499 r
= sd_journal_seek_tail(m
->journal
);
501 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to seek in journal.");
503 response
= MHD_create_response_from_callback(MHD_SIZE_UNKNOWN
, 4*1024, request_reader_entries
, m
, NULL
);
505 return respond_oom(connection
);
507 MHD_add_response_header(response
, "Content-Type", mime_types
[m
->mode
]);
508 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
511 static int output_field(FILE *f
, OutputMode m
, const char *d
, size_t l
) {
515 eq
= memchr(d
, '=', l
);
519 j
= l
- (eq
- d
+ 1);
521 if (m
== OUTPUT_JSON
) {
522 fprintf(f
, "{ \"%.*s\" : ", (int) (eq
- d
), d
);
523 json_escape(f
, eq
+1, j
, OUTPUT_FULL_WIDTH
);
526 fwrite(eq
+1, 1, j
, f
);
533 static ssize_t
request_reader_fields(
539 RequestMeta
*m
= cls
;
546 assert(pos
>= m
->delta
);
550 while (pos
>= m
->size
) {
555 /* End of this field, so let's serialize the next
558 if (m
->n_fields_set
&&
560 return MHD_CONTENT_READER_END_OF_STREAM
;
562 r
= sd_journal_enumerate_unique(m
->journal
, &d
, &l
);
564 log_error_errno(r
, "Failed to advance field index: %m");
565 return MHD_CONTENT_READER_END_WITH_ERROR
;
567 return MHD_CONTENT_READER_END_OF_STREAM
;
575 r
= request_meta_ensure_tmp(m
);
577 log_error_errno(r
, "Failed to create temporary file: %m");
578 return MHD_CONTENT_READER_END_WITH_ERROR
;
581 r
= output_field(m
->tmp
, m
->mode
, d
, l
);
583 log_error_errno(r
, "Failed to serialize item: %m");
584 return MHD_CONTENT_READER_END_WITH_ERROR
;
588 if (sz
== (off_t
) -1) {
589 log_error_errno(errno
, "Failed to retrieve file position: %m");
590 return MHD_CONTENT_READER_END_WITH_ERROR
;
593 m
->size
= (uint64_t) sz
;
596 if (fseeko(m
->tmp
, pos
, SEEK_SET
) < 0) {
597 log_error_errno(errno
, "Failed to seek to position: %m");
598 return MHD_CONTENT_READER_END_WITH_ERROR
;
606 k
= fread(buf
, 1, n
, m
->tmp
);
608 log_error("Failed to read from file: %s", errno
? strerror(errno
) : "Premature EOF");
609 return MHD_CONTENT_READER_END_WITH_ERROR
;
615 static int request_handler_fields(
616 struct MHD_Connection
*connection
,
618 void *connection_cls
) {
620 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
621 RequestMeta
*m
= connection_cls
;
629 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
631 if (request_parse_accept(m
, connection
) < 0)
632 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to parse Accept header.");
634 r
= sd_journal_query_unique(m
->journal
, field
);
636 return mhd_respond(connection
, MHD_HTTP_BAD_REQUEST
, "Failed to query unique fields.");
638 response
= MHD_create_response_from_callback(MHD_SIZE_UNKNOWN
, 4*1024, request_reader_fields
, m
, NULL
);
640 return respond_oom(connection
);
642 MHD_add_response_header(response
, "Content-Type", mime_types
[m
->mode
== OUTPUT_JSON
? OUTPUT_JSON
: OUTPUT_SHORT
]);
643 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
646 static int request_handler_redirect(
647 struct MHD_Connection
*connection
,
648 const char *target
) {
651 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
656 if (asprintf(&page
, "<html><body>Please continue to the <a href=\"%s\">journal browser</a>.</body></html>", target
) < 0)
657 return respond_oom(connection
);
659 response
= MHD_create_response_from_buffer(strlen(page
), page
, MHD_RESPMEM_MUST_FREE
);
662 return respond_oom(connection
);
665 MHD_add_response_header(response
, "Content-Type", "text/html");
666 MHD_add_response_header(response
, "Location", target
);
667 return MHD_queue_response(connection
, MHD_HTTP_MOVED_PERMANENTLY
, response
);
670 static int request_handler_file(
671 struct MHD_Connection
*connection
,
673 const char *mime_type
) {
675 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
676 _cleanup_close_
int fd
= -1;
683 fd
= open(path
, O_RDONLY
|O_CLOEXEC
);
685 return mhd_respondf(connection
, errno
, MHD_HTTP_NOT_FOUND
, "Failed to open file %s: %m", path
);
687 if (fstat(fd
, &st
) < 0)
688 return mhd_respondf(connection
, errno
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to stat file: %m");
690 response
= MHD_create_response_from_fd_at_offset64(st
.st_size
, fd
, 0);
692 return respond_oom(connection
);
695 MHD_add_response_header(response
, "Content-Type", mime_type
);
696 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
699 static int get_virtualization(char **v
) {
700 _cleanup_(sd_bus_unrefp
) sd_bus
*bus
= NULL
;
704 r
= sd_bus_default_system(&bus
);
708 r
= sd_bus_get_property_string(
710 "org.freedesktop.systemd1",
711 "/org/freedesktop/systemd1",
712 "org.freedesktop.systemd1.Manager",
729 static int request_handler_machine(
730 struct MHD_Connection
*connection
,
731 void *connection_cls
) {
733 _cleanup_(MHD_destroy_responsep
) struct MHD_Response
*response
= NULL
;
734 RequestMeta
*m
= connection_cls
;
736 _cleanup_free_
char* hostname
= NULL
, *os_name
= NULL
;
737 uint64_t cutoff_from
= 0, cutoff_to
= 0, usage
= 0;
739 _cleanup_free_
char *v
= NULL
, *json
= NULL
;
746 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to open journal: %m");
748 r
= sd_id128_get_machine(&mid
);
750 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine machine ID: %m");
752 r
= sd_id128_get_boot(&bid
);
754 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine boot ID: %m");
756 hostname
= gethostname_malloc();
758 return respond_oom(connection
);
760 r
= sd_journal_get_usage(m
->journal
, &usage
);
762 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine disk usage: %m");
764 r
= sd_journal_get_cutoff_realtime_usec(m
->journal
, &cutoff_from
, &cutoff_to
);
766 return mhd_respondf(connection
, r
, MHD_HTTP_INTERNAL_SERVER_ERROR
, "Failed to determine disk usage: %m");
768 (void) parse_os_release(NULL
, "PRETTY_NAME", &os_name
, NULL
);
769 (void) get_virtualization(&v
);
772 "{ \"machine_id\" : \"" SD_ID128_FORMAT_STR
"\","
773 "\"boot_id\" : \"" SD_ID128_FORMAT_STR
"\","
774 "\"hostname\" : \"%s\","
775 "\"os_pretty_name\" : \"%s\","
776 "\"virtualization\" : \"%s\","
777 "\"usage\" : \"%"PRIu64
"\","
778 "\"cutoff_from_realtime\" : \"%"PRIu64
"\","
779 "\"cutoff_to_realtime\" : \"%"PRIu64
"\" }\n",
780 SD_ID128_FORMAT_VAL(mid
),
781 SD_ID128_FORMAT_VAL(bid
),
782 hostname_cleanup(hostname
),
783 os_name
? os_name
: "Linux",
789 return respond_oom(connection
);
791 response
= MHD_create_response_from_buffer(strlen(json
), json
, MHD_RESPMEM_MUST_FREE
);
793 return respond_oom(connection
);
796 MHD_add_response_header(response
, "Content-Type", "application/json");
797 return MHD_queue_response(connection
, MHD_HTTP_OK
, response
);
800 static int request_handler(
802 struct MHD_Connection
*connection
,
806 const char *upload_data
,
807 size_t *upload_data_size
,
808 void **connection_cls
) {
812 assert(connection_cls
);
816 if (!streq(method
, "GET"))
817 return mhd_respond(connection
, MHD_HTTP_NOT_ACCEPTABLE
, "Unsupported method.");
819 if (!*connection_cls
) {
820 if (!request_meta(connection_cls
))
821 return respond_oom(connection
);
826 r
= check_permissions(connection
, &code
, NULL
);
832 return request_handler_redirect(connection
, "/browse");
834 if (streq(url
, "/entries"))
835 return request_handler_entries(connection
, *connection_cls
);
837 if (startswith(url
, "/fields/"))
838 return request_handler_fields(connection
, url
+ 8, *connection_cls
);
840 if (streq(url
, "/browse"))
841 return request_handler_file(connection
, DOCUMENT_ROOT
"/browse.html", "text/html");
843 if (streq(url
, "/machine"))
844 return request_handler_machine(connection
, *connection_cls
);
846 return mhd_respond(connection
, MHD_HTTP_NOT_FOUND
, "Not found.");
849 static int help(void) {
850 _cleanup_free_
char *link
= NULL
;
853 r
= terminal_urlify_man("systemd-journal-gatewayd.service", "8", &link
);
857 printf("%s [OPTIONS...] ...\n\n"
858 "HTTP server for journal events.\n\n"
859 " -h --help Show this help\n"
860 " --version Show package version\n"
861 " --cert=CERT.PEM Server certificate in PEM format\n"
862 " --key=KEY.PEM Server key in PEM format\n"
863 " --trust=CERT.PEM Certificate authority certificate in PEM format\n"
864 " -D --directory=PATH Serve journal files in directory\n"
865 "\nSee the %s for details.\n"
866 , program_invocation_short_name
873 static int parse_argv(int argc
, char *argv
[]) {
883 static const struct option options
[] = {
884 { "help", no_argument
, NULL
, 'h' },
885 { "version", no_argument
, NULL
, ARG_VERSION
},
886 { "key", required_argument
, NULL
, ARG_KEY
},
887 { "cert", required_argument
, NULL
, ARG_CERT
},
888 { "trust", required_argument
, NULL
, ARG_TRUST
},
889 { "directory", required_argument
, NULL
, 'D' },
896 while ((c
= getopt_long(argc
, argv
, "hD:", options
, NULL
)) >= 0)
908 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
909 "Key file specified twice");
910 r
= read_full_file(optarg
, &arg_key_pem
, NULL
);
912 return log_error_errno(r
, "Failed to read key file: %m");
918 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
919 "Certificate file specified twice");
920 r
= read_full_file(optarg
, &arg_cert_pem
, NULL
);
922 return log_error_errno(r
, "Failed to read certificate file: %m");
923 assert(arg_cert_pem
);
929 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
930 "CA certificate file specified twice");
931 r
= read_full_file(optarg
, &arg_trust_pem
, NULL
);
933 return log_error_errno(r
, "Failed to read CA certificate file: %m");
934 assert(arg_trust_pem
);
937 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
938 "Option --trust is not available.");
941 arg_directory
= optarg
;
948 assert_not_reached("Unhandled option");
952 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
953 "This program does not take arguments.");
955 if (!!arg_key_pem
!= !!arg_cert_pem
)
956 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
957 "Certificate and key files must be specified together");
959 if (arg_trust_pem
&& !arg_key_pem
)
960 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
961 "CA certificate can only be used with certificate file");
966 static int run(int argc
, char *argv
[]) {
967 _cleanup_(MHD_stop_daemonp
) struct MHD_Daemon
*d
= NULL
;
968 struct MHD_OptionItem opts
[] = {
969 { MHD_OPTION_NOTIFY_COMPLETED
,
970 (intptr_t) request_meta_free
, NULL
},
971 { MHD_OPTION_EXTERNAL_LOGGER
,
972 (intptr_t) microhttpd_logger
, NULL
},
973 { MHD_OPTION_END
, 0, NULL
},
974 { MHD_OPTION_END
, 0, NULL
},
975 { MHD_OPTION_END
, 0, NULL
},
976 { MHD_OPTION_END
, 0, NULL
},
977 { MHD_OPTION_END
, 0, NULL
},
981 /* We force MHD_USE_ITC here, in order to make sure
982 * libmicrohttpd doesn't use shutdown() on our listening
983 * socket, which would break socket re-activation. See
985 * https://lists.gnu.org/archive/html/libmicrohttpd/2015-09/msg00014.html
986 * https://github.com/systemd/systemd/pull/1286
993 MHD_USE_POLL_INTERNAL_THREAD
|
994 MHD_USE_THREAD_PER_CONNECTION
;
999 r
= parse_argv(argc
, argv
);
1005 r
= setup_gnutls_logger(NULL
);
1009 n
= sd_listen_fds(1);
1011 return log_error_errno(n
, "Failed to determine passed sockets: %m");
1013 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "Can't listen on more than one socket.");
1016 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1017 { MHD_OPTION_LISTEN_SOCKET
, SD_LISTEN_FDS_START
};
1020 assert(arg_cert_pem
);
1021 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1022 { MHD_OPTION_HTTPS_MEM_KEY
, 0, arg_key_pem
};
1023 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1024 { MHD_OPTION_HTTPS_MEM_CERT
, 0, arg_cert_pem
};
1025 flags
|= MHD_USE_TLS
;
1028 if (arg_trust_pem
) {
1029 assert(flags
& MHD_USE_TLS
);
1030 opts
[opts_pos
++] = (struct MHD_OptionItem
)
1031 { MHD_OPTION_HTTPS_MEM_TRUST
, 0, arg_trust_pem
};
1034 d
= MHD_start_daemon(flags
, 19531,
1036 request_handler
, NULL
,
1037 MHD_OPTION_ARRAY
, opts
,
1040 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "Failed to start daemon!");
1047 DEFINE_MAIN_FUNCTION(run
);