HESIOD(3)

πŸ’– HESIOD(3) πŸ’–

Library Functions Manual ✨ the passwd-info edition ✨

okay bestie, welcome to the library-functions manual for HESIOD, and specifically the girlies that fetch your passwd info. pull up a chair, grab a strawberry πŸ“, we're doing this.


✨ NAME ✨

hesiod_getpwnam</prouple>, hesiod_getpwuid, hesiod_free_passwd β€” Hesiod functions for retrieving passwd information πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <hesiod.h>

struct passwd *hesiod_getpwnam(void *context, const char *name)
struct passwd *hesiod_getpwuid(void *context, uid_t uid)
void hesiod_free_passwd(void *context, struct passwd *pw)

and to actually link the thing:

cc file.c -lhesiod

no cap, that's the whole vibe. 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

so this little family of functions lets you retrieve passwd database information using Hesiod. iconic behavior honestly.

before you can look anything up, you need an initialized Hesiod context β€” go check hesiod(3) for the deets on that, i'm not gonna re-explain her whole lore here. πŸ™ˆ

you can look up passwd info in two ways, and it's giving options:

  • by name β€” using hesiod_getpwnam
  • by uid β€” using hesiod_getpwuid

the info comes back in the same format as getpwnam or getpwuid would give you. same format, same energy. ✨

⚠️ listen to me bestie: it is the caller's responsibility to call hesiod_free_passwd with the returned passwd entry to free the resources used by the passwd entry. that's your job, not hers. don't ghost it or you're leaking memory and that's not the aesthetic. πŸ’€

the actual queries, explained πŸ”

Hesiod queries for passwd information are made using the passwd or uid Hesiod type, and the Hesiod name you pass is either the username or the decimal representation of the uid. yep, just the number, decimal, as a name. slay.

the corresponding records should be a colon-separated list of fields, giving, in order:

  1. the username
  2. the encrypted password
  3. the uid
  4. the gid
  5. GECOS information
  6. the home directory
  7. the shell of the user

seven fields, colon-separated, in that exact order. it's giving /etc/passwd but make it Hesiod. πŸ‘‘


🌈 RETURN VALUES 🌈

on failure, hesiod_getpwnam and hesiod_getpwuid return NULL and set the global variable errno to indicate the error. so if you get nothing back, check errno, she's telling you what went wrong. 🫢


πŸ’€ ERRORS πŸ’€

these calls may fail for any of the reasons the routine hesiod_resolve may fail. that's it, that's the list. go read up on hesiod_resolve if you want the full tea. β˜•


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! this one came from the Library Functions Manual, and it's stamped 30 November 1996 β€” a true vintage icon, ahead of her time fr fr. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

now go free your passwd entries. i'm literally begging you. mwah. πŸ’‹