From 91723dca0ee9bf68b0147dcf233274cd93f911c8 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Thu, 10 Mar 2022 21:07:10 -0500 Subject: Render something on errors --- assets/error.html | 5 +++++ assets/post.html | 8 ++++---- assets/static/css/default.css | 2 +- conf/clog.conf | 3 ++- src/clog.c | 24 ++++++++++++++++++------ 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 assets/error.html diff --git a/assets/error.html b/assets/error.html new file mode 100644 index 0000000..789988a --- /dev/null +++ b/assets/error.html @@ -0,0 +1,5 @@ + +
+

%s

+
+ diff --git a/assets/post.html b/assets/post.html index 8b105aa..a199fd6 100644 --- a/assets/post.html +++ b/assets/post.html @@ -1,13 +1,13 @@ - +

%s

-%s +%s
%s -
+

- + diff --git a/assets/static/css/default.css b/assets/static/css/default.css index 3db6da0..c6dcf9a 100644 --- a/assets/static/css/default.css +++ b/assets/static/css/default.css @@ -102,7 +102,7 @@ body { opacity: 0.5; padding: 1px; font-size: 40pt; - height: 0.9em; + /* height: 0.9em; */ text-shadow: 0.0em 0.0em 0.2em rgb(230,230,255); } diff --git a/conf/clog.conf b/conf/clog.conf index c22fc73..a45a039 100644 --- a/conf/clog.conf +++ b/conf/clog.conf @@ -9,7 +9,8 @@ load ./clog.so init workers 4 -seccomp_tracing no +# seccomp_tracing no +seccomp_tracing yes domain * { attach notls diff --git a/src/clog.c b/src/clog.c index 36f0a96..9364a2f 100644 --- a/src/clog.c +++ b/src/clog.c @@ -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); -- cgit v1.2.3