From patchwork Fri Oct 23 01:01:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1386482 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=IXysuZPo; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=OECJRw/v; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHQw21qG4z9sSn for ; Fri, 23 Oct 2020 12:03:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=uZQwmGwGQGMb9qaBmiitG/4I9UbtFKiybEAfuIwqeuI=; b=IXysuZPokpIwp/ZgMu5+snASBJ FaDRWZWzuHdiItaALSuEC7USKXMt6n5A7LBc2O2QaGnH7n5gER2uAWFaFKCuzEFTcDAYbxHRZXZeL OhYphpdyfxl9EOl2EwDwOfB0Q1s8v1o3Nf5rdatjg2VCttUu85Wit/1KEBwYI+Mc4V98H9OIPcvo7 +Uo/YFu6Y2FdTrvszuE/V4FawaX34QoXBqp8TqK9YXNrg/ZCEAb97IZTJZNkx5tl0nTRgbWB9XPDH /8d9nQsS0e7EA+O1uWex/uOCYSmVY00q1hFZoccZZBjFKPTg7cNLu5R7LvUJlCB/9SrWcUPL38dlk HdZY9mmA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVlTD-0007ya-FG; Fri, 23 Oct 2020 01:02:15 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVlTB-0007y1-HL for openwrt-devel@lists.openwrt.org; Fri, 23 Oct 2020 01:02:14 +0000 Received: by mail-wr1-x441.google.com with SMTP id h5so5938728wrv.7 for ; Thu, 22 Oct 2020 18:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n2zrv4NVdnbsnaFC8/LuuTEMd03Yi7e9Cgau0UWUhGU=; b=OECJRw/vAT6lWsjvcFvvUX2Dlwiq3R32YKMVGyeHh0P/3a366Phi5jTnILRUDoRIJ8 1DnxJ9T1gynCzb+/5a6xvSPjpOpTpSQ69z8dtx/ZPUWBxYxJwDTKjXAJPqc0LzAapYH2 QNXoxuqx+FS3rTCavQsxY5c8W924qrEZwyh6RFAV7EI7BOIxR1q61VVQoSZP7GYCh5gw biXefdqp+zBdXo8RPgGCQXZl7G4pxegIfQVIpzfphJTA2ucF4dtR96iATwouBWBSbenf k6ONi22dVNz4jsC/wqW0GC+itZQBni3tyCwAqZEOc+FgGgDAOnd9MvG+GAg/PvUbpkZX naxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n2zrv4NVdnbsnaFC8/LuuTEMd03Yi7e9Cgau0UWUhGU=; b=Jypk4lGsc0w2hCjEW+9eXfRiFi5ohULh0zxHTRZtPaDD66eQk02ODsB3NfoeqRecTI hBmRMB3wASVhuE0wrCl3mfnJyyzh0MIJIUpNr0gJB6yfJ1gGvPp+oOtWDAW83jKH9i1W qeE4jmqsvlwzroakefl8JGg2yEbSjPJRcCj9Ph+KrdFDtzE+5FUEhDCEQPIZQLgdxZPW oI38a5YJD6dMJx9jyObv4wx4iA92VVQjWvPjo6TOjjsf/N8fcCDuq0RK1yK7QB/qY2gf hyrwLbFxF9E8tYkS2Eadp9go1WgGcSomQ3TwLvZ8ERM0wDTEur33jpf0Cbh8dY+kN+6H YT3Q== X-Gm-Message-State: AOAM53321ovKm87QbTcPBdkhJ/iC4GD+t2HQm8Oetu1uSxj6YBJtJP0Y GnHtLTYhXULSlXn8y4tDb5hBWIV5gGR/c7vb X-Google-Smtp-Source: ABdhPJwSbve3Cks13Qf/yTWCwC3zwiQPZ6jvnJwdf+EENUPZvSgtwXw6jUsk0rmpxH4p1hFEki0Xrg== X-Received: by 2002:a5d:5743:: with SMTP id q3mr5142032wrw.167.1603414931793; Thu, 22 Oct 2020 18:02:11 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id c14sm6837054wrv.12.2020.10.22.18.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 18:02:01 -0700 (PDT) From: Ansuel Smith To: openwrt-devel@lists.openwrt.org Subject: [PATCH] ubusd_acl: add support for wildcard in methods Date: Fri, 23 Oct 2020 03:01:55 +0200 Message-Id: <20201023010155.16357-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201022_210213_611391_2E501A90 X-CRM114-Status: GOOD ( 14.16 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ansuel Smith Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add support for wildcard in methods to permiss access to all methods defined by the object. This can be usefull for process that run as non-root user and needs to access ubus method. Signed-off-by: Ansuel Smith --- ubusd_acl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ubusd_acl.c b/ubusd_acl.c index e426a4a..e050e2c 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -147,12 +147,16 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj, case UBUS_ACL_ACCESS: if (acl->methods) { struct blob_attr *cur; + char *cur_method; size_t rem; blobmsg_for_each_attr(cur, acl->methods, rem) - if (blobmsg_type(cur) == BLOBMSG_TYPE_STRING) - if (!strcmp(method, blobmsg_get_string(cur))) + if (blobmsg_type(cur) == BLOBMSG_TYPE_STRING) { + cur_method = blobmsg_get_string(cur); + + if (!strcmp(method, cur_method) || !strcmp("*", cur_method)) return 0; + } } break; }