From nobody Sat Nov 25 12:19:58 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ScrWy4vQDz52Y1Y for ; Sat, 25 Nov 2023 12:19:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ScrWy3TFhz4l3K for ; Sat, 25 Nov 2023 12:19:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700914798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kldGrXV2K8aDvgzDEn0nkYM2S4/fdnTu/yXm8SZHEqs=; b=gtq5Ph0DNrmerAqDwr75WnHdPwRMz7DYJvz7uNcBnUP+aEeVhCaGW/wuajQZpFMEdK8gf9 kGl5VgHt+wfNGnXJkeA6rSdmKCUF5BYR0UDWx5uf640XFo+DI+QXe+5FCwHzPqvZ0KE4q+ zAVRlJcT4EXXuXXjZSeYBo7EelLauxWHPguoyzA1JFHTBcNImBoK0pKTZvSNONccdfxgDs 2C8rsSfPfQ37i4qrefjsjb2GgJfe9DRRMPeo+mDvI4m39vxhTZPPiJAw6vsUsfU4bBWdze 6QX2g61QmvQ0OeCGD8dUbHxyS+ZLNKWmhYWaoAU5zqikNyCA/96UsWRJEbn1Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700914798; a=rsa-sha256; cv=none; b=ZqPY3ywT6WI4mAFFtVBeVbJhngjkuTMV5OyPaCcKDQDJxFoarF8AZ5rxGa+2jvPP44vLSs LAs7UaxPZ++R90olRppJzJ/Ciz2NvGdLkvy/VZhDBxgHXrMpnsflo2Aec+97g3XIYC/PQR udYYYaeHXvh/gL8YvcHJMee2NFqE51lqP9k6j6yYdbdC0EYMhXyZRCkdQOLCMZUNutT0na acrphZwEsl4tQAB74vhTwzmRKccLGat4ER6h9m9gA/iytI7cMRQGu2WHT0zOT1CZFnV4h9 sE8rqor24y+M5PQoQb4dT4Puv1TUViw87m1SoGoS0h1emG8SSGMWsl1AiJKxpA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ScrWy2TCrz1RTl for ; Sat, 25 Nov 2023 12:19:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 3APCJwmv012402 for ; Sat, 25 Nov 2023 12:19:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 3APCJwA8012401 for bugs@FreeBSD.org; Sat, 25 Nov 2023 12:19:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 275330] Capsicum should have "static" initializer as well Date: Sat, 25 Nov 2023 12:19:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: vini.ipsmaker@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D275330 Bug ID: 275330 Summary: Capsicum should have "static" initializer as well Product: Base System Version: 14.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: vini.ipsmaker@gmail.com I recently wrote Lua bindings for Capsicum and faced two inconveniences with the API. First problem is related to initalization. I'm using gperf to translate a string known only at runtime (whatever the Lua code is trying to do) to a cap_rights_t. Something like: cap_rights_t values[N] =3D { CAP_READ, // HASH("CAP_READ") =3D 0 CAP_WRITE, // HASH("CAP_WRITE") =3D 0 // ... }; However there are several holes in this table that are used whenever the known-at-runtime-string doesn't point to a valid capability and I need to initialize them to a default value. Other APIs such as POSIX threads solve this problem by offering a macro (PTHREAD_MUTEX_INITIALIZER) that can be used to initialize the variable ins= tead of calling a function. It'd be very helpful if Capsicum offered a macro CAP_RIGHTS_INITIALIZER in = the same fashion. That'd solve half of my problems with Capsicum's API. The second problem I'm facing is a lack of a function to check whether cap_rights_t is empty. Right now I have to do this: cap_rights_t all_rights; cap_rights_init(&all_rights); CAP_ALL(&all_rights); //< I don't even know whether CAP_ALL() is part of the intended public API cap_rights_t complement =3D all_rights; cap_rights_remove(&complement, &flag); //< flag is what I want to know whet= her is empty if (cap_rights_contains(&complement, &all_rights)) { // ... } That's *very* inconvenient (and inefficient). Can we have cap_rights_is_empty(flag)? That'd solve the other half of my problems with = the API. --=20 You are receiving this mail because: You are the assignee for the bug.=