From: Jo-Philipp Wich Date: Sat, 26 Jan 2013 14:14:55 +0000 (+0100) Subject: ubus: use a default sid if authentication is disabled X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d241c560bf2cd84a4cb497eaa3fe131a7c193293;p=project%2Fuhttpd.git ubus: use a default sid if authentication is disabled --- 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");