KRB5_GET_KRBHST(3)

πŸ’– KRB5_GET_KRBHST πŸ’–

okay bestie, welcome to the krb5_get_krbhst(3) page β€” it's a library functions manual situation and honestly? it's giving vintage. we're in the Kerberos 5 Library today and we're looking up KDC hosts like it's our job. πŸŽ€


✨ NAME ✨

krb5_get_krbhst, krb5_get_krb_admin_hst, krb5_get_krb_changepw_hst, krb5_get_krb524hst, krb5_free_krbhst β€” lookup Kerberos KDC hosts πŸ”πŸ‘‘


πŸ“š LIBRARY πŸ“š

Kerberos 5 Library (libkrb5, -lkrb5) β€” yeah she lives in libkrb5, link her with -lkrb5 and you're set 🫢


🌸 SYNOPSIS 🌸

#include <krb5.h>

krb5_error_code
krb5_get_krbhst(krb5_context context, const krb5_realm *realm,
    char ***hostlist);

krb5_error_code
krb5_get_krb_admin_hst(krb5_context context, const krb5_realm *realm,
    char ***hostlist);

krb5_error_code
krb5_get_krb_changepw_hst(krb5_context context, const krb5_realm *realm,
    char ***hostlist);

krb5_error_code
krb5_get_krb524hst(krb5_context context, const krb5_realm *realm,
    char ***hostlist);

krb5_error_code
krb5_free_krbhst(krb5_context context, char **hostlist);

πŸ’… DESCRIPTION πŸ’…

So these functions are the old API for getting a list of Kerberos hosts, which means they're basically cousins to the krb5_krbhst_init() functions. Similar vibe, different era. πŸ’«

But here's the tea: because these functions return all the hosts in one go, they might have to do more lookups than necessary. Not a scandal, just how it is. They stick around for compatibility reasons β€” legacy icon behaviour, no cap.

After you call one of these functions, hostlist is a NULL terminated list of strings pointing at the requested Kerberos hosts. So it's a whole list, terminated by NULL, pointing to the hosts you asked for. 🎯

And bestie, PLEASE free it with krb5_free_krbhst() when you're done with it. Memory leaks are not the vibe. πŸš«πŸ’§

🌈 EXAMPLES 🌈

This little cutie prints the KDCs of the realm β€œMY.REALM”. Periodt.

char **hosts, **p;
krb5_get_krbhst(context, "MY.REALM", &hosts);
for(p = hosts; *p; p++)
    printf("%s\n", *p);
krb5_free_krbhst(context, hosts);

look at her go πŸ¦‹ β€” grab the list, loop through it, print every single one, then clean up like a responsible main character.


πŸ‘€ SEE ALSO πŸ‘€


that's the whole page bestie, you ate that πŸ“βœ¨

this one's from the HEIMDAL source, dated April 24, 2005 β€” yeah she's an elder but she still serves πŸ’…πŸ‘‘

πŸ“¦ where this page comes from