diff options
Diffstat (limited to 'src/clog.c')
-rw-r--r-- | src/clog.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -13,7 +13,9 @@ #include "../lib/md4c/src/md4c-html.c" KORE_SECCOMP_FILTER("clog", - KORE_SYSCALL_ALLOW(getdents64) + KORE_SYSCALL_ALLOW(getdents64), + KORE_SYSCALL_ALLOW(sendmmsg), + KORE_SYSCALL_ALLOW(uname) ) int init(int); @@ -68,6 +70,9 @@ render_posts(struct http_request *req, const char *resource) // Post attributes/query results. char *id, *title, *created_at, *body; + // Start writing HTML. + kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); + // Setup SQL kore_pgsql_init(&sql); @@ -76,16 +81,18 @@ render_posts(struct http_request *req, const char *resource) // kore_pgsql_register()). We also say we will perform a synchronous // query (KORE_PGSQL_SYNC). err = kore_pgsql_setup(&sql, database, KORE_PGSQL_SYNC); - kore_log(LOG_ERR, "kore_pgsql_setup: %d", err); + kore_log(LOG_DEBUG, "kore_pgsql_setup: %d", err); if (!err) { + kore_buf_appendf( + resp_buf, + (const char *) asset_error_html, + "There was an error processing the request." + ); kore_pgsql_logerror(&sql); goto out; } - // Start writing HTML. - kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); - // Query for posts, check for error. if (!resource) { // Query all posts. @@ -107,6 +114,11 @@ render_posts(struct http_request *req, const char *resource) ); } if (!err) { + kore_buf_appendf( + resp_buf, + (const char *) asset_error_html, + "There was an error processing the request." + ); kore_pgsql_logerror(&sql); goto out; } @@ -118,7 +130,7 @@ render_posts(struct http_request *req, const char *resource) title = kore_pgsql_getvalue(&sql, row, 1); created_at = kore_pgsql_getvalue(&sql, row, 2); body = kore_pgsql_getvalue(&sql, row, 3); - kore_log(LOG_NOTICE, "id: '%s'; title '%s'", id, title); + kore_log(LOG_DEBUG, "id: '%s'; title '%s'", id, title); // Allocate a buffer to render the markdown as HTML into. struct kore_buf *html_buf = kore_buf_alloc(0); |