summaryrefslogtreecommitdiff
path: root/ubus.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-01-26 15:14:55 +0100
committerJo-Philipp Wich <jow@openwrt.org>2013-01-26 15:14:55 +0100
commitd241c560bf2cd84a4cb497eaa3fe131a7c193293 (patch)
treec53abf7bba9deccd96b396ee019f504bfdabc80c /ubus.c
parentac7670faba12e23b8ec7e866dcfe1d98d3921b40 (diff)
ubus: use a default sid if authentication is disabled
Diffstat (limited to 'ubus.c')
-rw-r--r--ubus.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/ubus.c b/ubus.c
index 3a21fc7..79e077a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -35,6 +35,7 @@ static struct ubus_context *ctx;
static struct blob_buf buf;
#define UH_UBUS_MAX_POST_SIZE 4096
+#define UH_UBUS_DEFAULT_SID "00000000000000000000000000000000"
enum {
RPC_JSONRPC,
@@ -449,15 +450,21 @@ static void uh_ubus_handle_request(struct client *cl, char *url, struct path_inf
blob_buf_init(&buf, 0);
- url += strlen(conf.ubus_prefix);
- while (*url == '/')
- url++;
+ if (conf.ubus_noauth) {
+ sid = UH_UBUS_DEFAULT_SID;
+ }
+ else {
+ url += strlen(conf.ubus_prefix);
+ while (*url == '/')
+ url++;
- sep = strchr(url, '/');
- if (sep)
- *sep = 0;
+ sep = strchr(url, '/');
+ if (sep)
+ *sep = 0;
+
+ sid = url;
+ }
- sid = url;
if (strlen(sid) != 32 ||
cl->request.method != UH_HTTP_MSG_POST)
return ops->client_error(cl, 400, "Bad Request", "Invalid Request");