[phodav: 1/2] server: forbid PUT method on a read-only shared folder
- From: Marc-André Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [phodav: 1/2] server: forbid PUT method on a read-only shared folder
- Date: Tue, 19 Apr 2022 13:20:25 +0000 (UTC)
commit 580572afefd6316284c6f5c2c25801344c3f5f9c
Author: SnipFoo <snip herbesfolles org>
Date: Wed Mar 16 16:25:31 2022 +0100
server: forbid PUT method on a read-only shared folder
Also, add debug messages for the PUT method similar to those
used for the other methods.
libphodav/phodav-method-put.c | 11 +++++++++++
libphodav/phodav-priv.h | 1 +
libphodav/phodav-server.c | 6 ++++++
3 files changed, 18 insertions(+)
---
diff --git a/libphodav/phodav-method-put.c b/libphodav/phodav-method-put.c
index 4715d06..785996b 100644
--- a/libphodav/phodav-method-put.c
+++ b/libphodav/phodav-method-put.c
@@ -97,6 +97,16 @@ phodav_method_put (PathHandler *handler, SoupMessage *msg, const gchar *path, GE
GFileOutputStream *output = NULL;
gint status;
+ g_debug ("%s %s HTTP/1.%d %s %s", msg->method, path, soup_message_get_http_version (msg),
+ soup_message_headers_get_one (msg->request_headers, "X-Litmus") ? : "",
+ soup_message_headers_get_one (msg->request_headers, "X-Litmus-Second") ? : "");
+
+ if (handler_get_readonly(handler))
+ {
+ status = SOUP_STATUS_FORBIDDEN;
+ goto end;
+ }
+
status = phodav_check_if (handler, msg, path, &submitted);
if (status != SOUP_STATUS_OK)
goto end;
@@ -115,4 +125,5 @@ phodav_method_put (PathHandler *handler, SoupMessage *msg, const gchar *path, GE
end:
soup_message_set_status (msg, status);
g_clear_object (&file);
+ g_debug (" -> %d %s\n", msg->status_code, msg->reason_phrase);
}
diff --git a/libphodav/phodav-priv.h b/libphodav/phodav-priv.h
index 1957ead..aee60d1 100644
--- a/libphodav/phodav-priv.h
+++ b/libphodav/phodav-priv.h
@@ -76,6 +76,7 @@ typedef gboolean (* PathCb) (const gchar *key,
GFile * handler_get_file (PathHandler *handler);
GCancellable * handler_get_cancellable (PathHandler *handler);
PhodavServer * handler_get_server (PathHandler *handler);
+gboolean handler_get_readonly (PathHandler *handler);
gboolean server_foreach_parent_path (PhodavServer *server,
const gchar *path,
diff --git a/libphodav/phodav-server.c b/libphodav/phodav-server.c
index d08cd78..b648ca9 100644
--- a/libphodav/phodav-server.c
+++ b/libphodav/phodav-server.c
@@ -120,6 +120,12 @@ handler_get_cancellable (PathHandler *handler)
return handler->self->cancellable;
}
+gboolean G_GNUC_PURE
+handler_get_readonly (PathHandler *handler)
+{
+ return handler->self->readonly;
+}
+
static PathHandler *
path_handler_new (PhodavServer *self, GFile *file)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]