chiark / gitweb /
journal-upload: HTTPS support
[elogind.git] / src / journal-remote / journal-remote.c
index 9db4692a28b3d8585a761eb6d1df3021eb9f8691..437e0b05d1f9d1fc503d73b934ab0c95e4d3267e 100644 (file)
@@ -412,25 +412,28 @@ static int process_http_upload(
                 log_info("Received %zu bytes", *upload_data_size);
 
                 r = push_data(source, upload_data, *upload_data_size);
-                if (r < 0) {
-                        log_error("Failed to store received data of size %zu: %s",
-                                  *upload_data_size, strerror(-r));
+                if (r < 0)
                         return mhd_respond_oom(connection);
-                }
+
                 *upload_data_size = 0;
         } else
                 finished = true;
 
         while (true) {
                 r = process_source(source, &server->writer, arg_compress, arg_seal);
-                if (r == -E2BIG)
-                        log_warning("Entry too big, skipped");
-                else if (r == -EAGAIN || r == -EWOULDBLOCK)
+                if (r == -EAGAIN || r == -EWOULDBLOCK)
                         break;
                 else if (r < 0) {
                         log_warning("Failed to process data for connection %p", connection);
-                        return mhd_respondf(connection, MHD_HTTP_UNPROCESSABLE_ENTITY,
-                                            "Processing failed: %s", strerror(-r));
+                        if (r == -E2BIG)
+                                return mhd_respondf(connection,
+                                                    MHD_HTTP_REQUEST_ENTITY_TOO_LARGE,
+                                                    "Entry is too large, maximum is %u bytes.\n",
+                                                    DATA_SIZE_MAX);
+                        else
+                                return mhd_respondf(connection,
+                                                    MHD_HTTP_UNPROCESSABLE_ENTITY,
+                                                    "Processing failed: %s.", strerror(-r));
                 }
         }
 
@@ -958,7 +961,7 @@ static int dispatch_raw_connection_event(sd_event_source *event,
  **********************************************************************
  **********************************************************************/
 
-static int help(void) {
+static void help(void) {
         printf("%s [OPTIONS...] {FILE|-}...\n\n"
                "Write external journal events to a journal file.\n\n"
                "Options:\n"
@@ -980,8 +983,6 @@ static int help(void) {
                "\n"
                "Note: file descriptors from sd_listen_fds() will be consumed, too.\n"
                , program_invocation_short_name);
-
-        return 0;
 }
 
 static int parse_argv(int argc, char *argv[]) {
@@ -1200,7 +1201,7 @@ static int parse_argv(int argc, char *argv[]) {
                 }
 
         if (arg_listen_https && !(key_pem && cert_pem)) {
-                log_error("Options --key and --cert must be used when https sources are specified");
+                log_error("Options --key and --cert must be used when using HTTPS.");
                 return -EINVAL;
         }
 
@@ -1239,7 +1240,6 @@ int main(int argc, char **argv) {
         RemoteServer s = {};
         int r, r2;
 
-        log_set_max_level(LOG_DEBUG);
         log_show_color(true);
         log_parse_environment();