Просмотр исходного кода

unetmsg: fix issuing requests without previously subscribing

Perform ACL check if not subscribed. Helps with one-shot requests.

Signed-off-by: Felix Fietkau <[email protected]>
Felix Fietkau 7 месяцев назад
Родитель
Сommit
6fcaf3d589

+ 5 - 2
package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-client.uc

@@ -72,8 +72,11 @@ function client_request(cl, req)
 		return core.handle_message(handle, data, true);
 	case "request":
 		handle = cl.subscribe[name];
-	    if (!handle)
-			return libubus.STATUS_INVALID_ARGUMENT;
+		if (!handle &&
+		    !core.acl_check("subscribe", cl.acl, [ name ]))
+			return libubus.STATUS_PERMISSION_DENIED;
+
+		handle ??= { client: cl.id };
 		return core.handle_request(handle, req, data, true);
 	}
 }

+ 1 - 0
package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd.uc

@@ -111,6 +111,7 @@ function handle_request(handle, req, data, remote)
 
 	for (let cur in handles) {
 		if (!cur || !cur.get_channel) {
+			cb();
 			continue;
 		}
 		let chan = cur.get_channel();