HOSTS_ACCESS(3)

πŸ“¦
version 7.6.q Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 🌈


πŸŽ€ 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 πŸ’…βœ¨πŸ¦‹