UTEMPTER(3)

πŸ“¦
version 1.2.3 Β· 2 versions
  • 1.2.3 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 15.1 Β· freebsd 14.5, freebsd 15.1
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– UTEMPTER(3) πŸ’–

okay bestie, pull up a chair, because we're about to talk about the utempter interface β€” that's section 3 of the manual, the library functions zone, and it's lowkey iconic. this is the little crew of functions that handles login records for pseudo-terminals, and honestly? they ate. ✨


🌸 NAME 🌸

utempter_add_record, utempter_remove_added_record, utempter_remove_record, utempter_set_helper β€” the utempter interface, aka the whole squad 🫢


✨ SYNOPSIS ✨

#include <utempter.h>

int
utempter_add_record(int fd, const char *host);

int
utempter_remove_added_record(void);

int
utempter_remove_record(int fd);

void
utempter_set_helper(const char *pathname);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea on each one of these queens:

  • utempter_add_record() β€” this one adds a login record to the database for the TTY that belongs to the pseudo-terminal master file descriptor fd. it uses the username that corresponds with the real user ID of the calling process, plus the optional hostname host. and the way it does this?? it spawns a privileged process to do the actual logging. main character move fr fr. πŸ‘‘
  • utempter_remove_record() β€” this babe marks the login session as closed for the TTY belonging to the pseudo-terminal master file descriptor fd. and yeah, same energy as before: it spawns a privileged process to perform the actual logging. πŸ’…
  • utempter_remove_added_record() β€” literally the same properties as the function we just talked about, except it uses an internally cached value of the file descriptor that was passed to the login functions. no fd argument needed, she remembers. πŸŽ€
  • utempter_set_helper() β€” this one changes the default helper path to the specified value. and listen, this is important: the pointer you pass to this function must remain valid all the time while the utempter interface is in use. like, all the time. no cap. don't let it dangle, bestie. 😭

⭐ RETURN VALUES ⭐

  • on error, zero is returned. πŸ’€
  • on success, a non-zero value is returned. πŸ”₯

(yes, that's the reverse of what your gut says. it's giving chaotic but we respect it.)


πŸ‘‘ NOTES πŸ‘‘

during execution of the privileged process spawned by these functions, the SIGCHLD signal handler will be temporarily set to the default action. so heads up on that, because your handler is gonna be on a lil break. πŸ™ˆ


🌈 SEE ALSO 🌈

go read those too, they're part of the extended universe. iykyk. πŸ¦‹


πŸ’œ HISTORY πŸ’œ

these functions appeared in ALT Linux Sisyphus in October 2001. vintage!! ancestral!! we love a legacy moment. 🌸


and that's the whole page, bestie β€” you're officially fluent in utempter. this lil masterpiece came from ALT Linux, dated November 4, 2010. slay, stay hydrated, and don't forget to keep that helper pointer valid. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from