HOSTS_ACCESS(3)
π HOSTS_ACCESS(3) β the access control library, bestie edition π
okay so this is a page from the Library Functions Manual, and it's about hosts_access, hosts_ctl, request_init and request_set β the whole access-control-library friend group π«Ά. It's the HOSTS_ACCESS(3) manual, so like, section 3, library functions, you know the vibe. Let's get into it β¨
β¨ NAME β¨
hosts_access, hosts_ctl, request_init, request_set β access control library π
πΈ SYNOPSIS πΈ
#include <tcpd.h>
extern int allow_severity;
extern int deny_severity;
struct request_info *request_init(request, key, value, ..., 0)
struct request_info *request;
struct request_info *request_set(request, key, value, ..., 0)
struct request_info *request;
void fromhost(request)
struct request_info *request;
int hosts_access(request)
struct request_info *request;
int hosts_ctl(daemon, client_name, client_addr, client_user)
char *daemon;
char *client_name;
char *client_addr;
char *client_user;
π¦ DESCRIPTION π¦
so. the routines described in this doc are part of the libwrap.a library π. what they do is implement a rule-based access control language, and ngl the plot twist is that it can run optional shell commands whenever a rule fires π iconic behavior fr fr.
request_init() initializes a structure with information about a client request β¨. request_set() updates a request structure that's already been initialized. Both of these functions take a variable-length list of key-value pairs and return their first argument π«Ά. The argument lists are terminated with a zero key value. All string-valued arguments are copied. no cap. π
The expected keys (and their corresponding value types) are:
RQ_FILE(int) β the file descriptor that's associated with the request πRQ_CLIENT_NAME(char *) β the client host name πRQ_CLIENT_ADDR(char *) β a printable representation of the client network address πRQ_CLIENT_SIN(struct sockaddr_in *) β an internal representation of the client network address and port. Heads up: the contents of the structure are not copied β οΈRQ_SERVER_NAME(char *) β the hostname associated with the server endpoint address β¨RQ_SERVER_ADDR(char *) β a printable representation of the server endpoint address πΈRQ_SERVER_SIN(struct sockaddr_in *) β an internal representation of the server endpoint address and port. Same deal as before: the contents of the structure are not copied β οΈRQ_DAEMON(char *) β the name of the daemon process running on the server host πRQ_USER(char *) β the name of the user on whose behalf the client host makes the request π
hosts_access() consults the access control tables described in the hosts_access(5) manual page π. When internal endpoint information is available, host names and client user names are looked up on demand, using the request structure as a cache π§ β¨. hosts_access() returns zero if access should be denied π«. And important: fromhost() must be called before hosts_access() β like, that's not optional bestie, that's the order of operations π€
hosts_ctl() is a wrapper around the request_init() and hosts_access() routines, with a maybe-more-convenient interface π (though, lowkey, it does not pass on enough information to support automated client username lookups π). The client host address, client host name and username arguments should contain valid data or STRING_UNKNOWN. hosts_ctl() returns zero if access should be denied π«.
The allow_severity and deny_severity variables determine how accepted and rejected requests may be logged π. They must be provided by the caller, and they may be modified by rules in the access control tables π.
π DIAGNOSTICS π
Problems are reported via the syslog daemon π’. (so if something's going wrong, that's where the tea gets spilled.)
π SEE ALSO π
hosts_access(5)β format of the access control tables πhosts_options(5)β optional extensions to the base language β¨
π FILES π
/etc/hosts.allow,/etc/hosts.denyβ access control tables π
π BUGS π
hosts_access() uses the strtok() library function. This may interfere with other code that relies on strtok(). so yeah, watch out for that collision, it's giving messy π¬
π AUTHOR π
Wietse Venema (wietse@wzv.win.tue.nl) Department of Mathematics and Computing Science Eindhoven University of Technology Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands π·
okay and that's the whole page!! it came from the Library Functions Manual, section HOSTS_ACCESS(3) β yes that's the version/source tag and it's also literally the title, we love a self-referential queen π. thanks for reading bestie, go call fromhost() before hosts_access() or I will find out π
β¨π¦
π¦ where this page comes from
- debian bookworm: libwrap0-dev 7.6.q-32
- debian trixie: libwrap0-dev 7.6.q-36
- nixos 26.05: tcp-wrappers 7.6.q-36
- nixpkgs unstable: tcp-wrappers 7.6.q-36
- ubuntu jammy: libwrap0-dev 7.6.q-31build2
- ubuntu noble: libwrap0-dev 7.6.q-33
- ubuntu questing: libwrap0-dev 7.6.q-36build1
- ubuntu resolute: libwrap0-dev 7.6.q-36build2
- ubuntu stonking: libwrap0-dev 7.6.q-37
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms