S6-ACCESSRULES(7)
β¨ s6-accessrules(7) β¨
okay so bestie, welcome to the s6-accessrules page from section 7 of the manual β the one and only accessrules library interface π
πΈ NAME πΈ
s6-accessrules β the accessrules library interface π
π DESCRIPTION π
The functions and structures below are declared in the s6/accessrules.h header, and they're implemented in libs6.a or libs6.so. Periodt. π«Ά
π¦ General information π¦
s6-accessrules is an access control library, no cap. It looks up a key in a user-specified database, then returns a code depending on whether the database allows access (and in that case, extra info can be returned too), denies access, or just... doesn't contain the key at all π.
It's been designed so it's easy to extend to literally any database format and any key format β very main character energy, very flexible β¨.
π‘ Check the s6/accessrules.h header for the exact definitions, bestie.
π Data structures π
An s6_accessrules_result_t is a scalar that can have these values: S6_ACCESSRULES_ERROR, S6_ACCESSRULES_DENY, S6_ACCESSRULES_ALLOW or S6_ACCESSRULES_NOTFOUND. That's the whole vibe check β four possible outcomes π₯.
An s6_accessrules_params_t is a structure containing two strallocs[1], .env and .exec, used to return data contained in the database when a key has been allowed. How you interpret that data? Application-defined, so that's on you π.
β Function types β
π Backend lookups
An s6_accessrules_backend_func_t is the type of a function that takes a single key, looks it up in a database, and returns the result. Namely:
s6_accessrules_result_t f (char const *key, size_t keylen, void *handle, s6_accessrules_params_t *params)
f() looks up key key of length keylen in the database represented by handle, in an implementation-defined way. It returns a number that says the key has been allowed, denied or not found, or that an error occurred. If the key has been allowed, f stores additional information from the database into *params πΎ.
Two s6_accessrules_backend_func_t functions are natively implemented:
s6_accessrules_backend_fs()β takes achar const *handle and interprets it as a base directory to look upkeyunder, in the format understood bys6-accessrules-cdb-from-fs(8).s6_accessrules_backend_cdb()β takes astruct cdb *handle and looks upkeyin the CDB[2] it points to.handlemust already be mapped to a CDB file. Such a file can be built with thes6-accessrules-cdb-from-fs(8)utility.
ποΈ Frontend key checking
An s6_accessrules_keycheck_func_t is the type of a function that takes a user-level key, makes a list of corresponding backend-level keys, and calls an s6_accessrules_backend_func_t function until it finds a match. Namely:
s6_accessrules_result_t f (void const *key, void *handle, s6_accessrules_params_t *params, s6_accessrules_backend_func_t *backend)
f() derives a list of low-level keys to check from key. Then, for each key k of length klen in this list, it calls (*backend)(k, klen, handle, params), returning *backend's result if it is not S6_ACCESSRULES_NOTFOUND. If no match can be found in the whole list, f() finally returns S6_ACCESSRULES_NOTFOUND π.
Five s6_accessrules_keycheck_func_t functions are natively implemented β and these ones are iconic, let me walk you through π
s6_accessrules_keycheck_uidgid()β interpretskeyas a pointer to a structure containing an uiduand a gidg. The following checks are performed, in this order (i.e. subsequent checks are not performed if a match is found):- If
uis equal to the effective uid of the process, look for auid/selfmatch. - Look for a
uid/umatch. - If
gis equal to the effective gid of the process, look for agid/selfmatch. - Look for a
gid/gmatch. - Look for a
uid/defaultmatch.
- If
s6_accessrules_keycheck_reversedns()β interpretskeyas a string containing an FQDN. Then for each suffixkofkey, starting withkeyitself and ending withkey's TLD, it looks upreversedns/k. The final dot is excluded fromk. If no match can be found, the function checksreversedns/@and returns the result. For instance, ifkeyis "foo.bar.com", the following strings are looked up, in this order:reversedns/foo.bar.comreversedns/bar.comreversedns/comreversedns/@
s6_accessrules_keycheck_ip4()β interpretskeyas 4 network-byte-order characters containing an IPv4 address. Then for each netmaskmaskfrom 32 to 0, it constructs the IPv4 network prefixaddrcorresponding to that address, and looks upip4/addr_mask. For instance, ifkeyis"\300\250\001\007", representing the 192.168.1.7 address, the following strings are looked up, in this order:ip4/192.168.1.7_32ip4/192.168.1.6_31ip4/192.168.1.4_30ip4/192.168.1.0_29ip4/192.168.0.0_28ip4/192.168.0.0_27
and so on, down to:
ip4/192.0.0.0_3ip4/192.0.0.0_2ip4/128.0.0.0_1ip4/0.0.0.0_0
β οΈ Note that the ip4/0.0.0.0_0 string is a catch-all key that matches everything. Everything, bestie. π
s6_accessrules_keycheck_ip6()β interpretskeyas 16 network-byte-order characters containing an IPv6 address. Then for each netmaskmaskfrom 128 to 0, it constructs the IPv6 network prefixaddrcorresponding to that address, in canonical form, and looks upip6/addr_mask. For instance, ifkeyis"*\0\024P@\002\b\003\0\0\0\0\0\0\020\006", representing the 2a00:1450:4002:803::1006 address, the following strings are looked up, in this order:ip6/2a00:1450:4002:803::1006_128ip6/2a00:1450:4002:803::1006_127ip6/2a00:1450:4002:803::1004_126ip6/2a00:1450:4002:803::1000_125ip6/2a00:1450:4002:803::1000_124ip6/2a00:1450:4002:803::1000_123ip6/2a00:1450:4002:803::1000_122ip6/2a00:1450:4002:803::1000_121ip6/2a00:1450:4002:803::1000_120ip6/2a00:1450:4002:803::1000_119ip6/2a00:1450:4002:803::1000_118ip6/2a00:1450:4002:803::1000_117ip6/2a00:1450:4002:803::1000_116ip6/2a00:1450:4002:803::1000_115ip6/2a00:1450:4002:803::1000_114ip6/2a00:1450:4002:803::1000_113ip6/2a00:1450:4002:803::_112ip6/2a00:1450:4002:803::_111
and so on, down to:
ip6/2a00::_11ip6/2800::_10ip6/2800::_9ip6/2000::_8ip6/2000::_7ip6/2000::_6ip6/2000::_5ip6/2000::_4ip6/2000::_3ip6/::_2ip6/::_1ip6/::_0
β οΈ And note that the ip6/::_0 string is a catch-all key that matches everything too. Same energy, different address family π
s6_accessrules_keycheck_ip46()β interpretskeyas a pointer to anip46_t[3], and behaves either ass6_accessrules_keycheck_ip6()ors6_accessrules_keycheck_ip4(), depending on the type of address*keycontains. Versatile queen π
π Ready-to-use functions π
These functions are mostly macros; they're built by associating a frontend function with a backend function. Basically grab-and-go, we love convenience π
s6_accessrules_result_t s6_accessrules_uidgid_cdb(uid_t u, gid_t g, struct cdb *c, s6_accessrules_params_t *params)β Checks the*cCDB database for an authorization for uiduand gidg. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_uidgid_fs(uid_t u, gid_t g, char const *dir, s6_accessrules_params_t *params)β Checks thedirbase directory for an authorization for uiduand gidg. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_reversedns_cdb(char const *name, struct cdb *c, s6_accessrules_params_t *params)β Checks the*cCDB database for an authorization for thenameFQDN. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_reversedns_fs(char const *name, char const *dir, s6_accessrules_params_t *params)β Checks thedirbase directory for an authorization for thenameFQDN. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip4_cdb(char const *ip4, struct cdb *c, s6_accessrules_params_t *params)β Checks the*cCDB database for an authorization for theip4IPv4 address (4 network byte order characters). If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip4_fs(char const *ip4, char const *dir, s6_accessrules_params_t *params)β Checks thedirbase directory for an authorization for theip4IPv4 address (4 network byte order characters). If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip6_cdb(char const *ip6, struct cdb *c, s6_accessrules_params_t *params)β Checks the*cCDB database for an authorization for theip6IPv6 address (16 network byte order characters). If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip6_fs(char const *ip6, char const *dir, s6_accessrules_params_t *params)β Checks thedirbase directory for an authorization for theip6IPv6 address (16 network byte order characters). If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip46_cdb(ip46_t *ip, struct cdb *c, s6_accessrules_params_t *params)β Checks the*cCDB database for an authorization for theipIP address. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.s6_accessrules_result_t s6_accessrules_ip46_fs(ip46_t const *ip, char const *dir, s6_accessrules_params_t *params)β Checks thedirbase directory for an authorization for theipIP address. If the result isS6_ACCESSRULES_ALLOW, additional information may be stored intoparams.
π₯ SEE ALSO π₯
[1] https://skarnet.org/software/skalibs/libstddjb/stralloc.html
[3] https://skarnet.org/software/skalibs/libstddjb/ip46.html
This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/libs6/accessrules.html π§
π AUTHORS π
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port)
and that's the whole page bestie, no details skipped, we ate and left no crumbs π β¨ β cute little sign-off from Debian, dated September 29, 2021, page S6-ACCESSRULES(7), mwah π«Άπ
π¦ where this page comes from
- nixpkgs unstable: s6 2.15.1.0
- nixpkgs unstable: s6-man-pages 2.14.0.1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms