chiark / gitweb /
journal-gatewayd: minor cleanup
[elogind.git] / src / journal / journal-gatewayd.c
index 1d0559f..63d9744 100644 (file)
@@ -237,7 +237,7 @@ static ssize_t request_reader_entries(
                         m->tmp = tmpfile();
                         if (!m->tmp) {
                                 log_error("Failed to create temporary file: %m");
-                                return MHD_CONTENT_READER_END_WITH_ERROR;;
+                                return MHD_CONTENT_READER_END_WITH_ERROR;
                         }
                 }
 
@@ -328,14 +328,13 @@ static int request_parse_range(
 
                 colon2 = strchr(colon + 1, ':');
                 if (colon2) {
-                        char *t;
+                        char _cleanup_free_ *t;
 
                         t = strndup(colon + 1, colon2 - colon - 1);
                         if (!t)
                                 return -ENOMEM;
 
                         r = safe_atoi64(t, &m->n_skip);
-                        free(t);
                         if (r < 0)
                                 return r;
                 }
@@ -416,6 +415,38 @@ static int request_parse_arguments_iterator(
                 return MHD_YES;
         }
 
+        if (streq(key, "boot")) {
+                if (isempty(value))
+                        r = true;
+                else {
+                        r = parse_boolean(value);
+                        if (r < 0) {
+                                m->argument_parse_error = r;
+                                return MHD_NO;
+                        }
+                }
+
+                if (r) {
+                        char match[9 + 32 + 1] = "_BOOT_ID=";
+                        sd_id128_t bid;
+
+                        r = sd_id128_get_boot(&bid);
+                        if (r < 0) {
+                                log_error("Failed to get boot ID: %s", strerror(-r));
+                                return MHD_NO;
+                        }
+
+                        sd_id128_to_string(bid, match + 9);
+                        r = sd_journal_add_match(m->journal, match, sizeof(match)-1);
+                        if (r < 0) {
+                                m->argument_parse_error = r;
+                                return MHD_NO;
+                        }
+                }
+
+                return MHD_YES;
+        }
+
         p = strjoin(key, "=", strempty(value), NULL);
         if (!p) {
                 m->argument_parse_error = log_oom();
@@ -571,7 +602,7 @@ static ssize_t request_reader_fields(
                         m->tmp = tmpfile();
                         if (!m->tmp) {
                                 log_error("Failed to create temporary file: %m");
-                                return MHD_CONTENT_READER_END_WITH_ERROR;;
+                                return MHD_CONTENT_READER_END_WITH_ERROR;
                         }
                 }