KRB5_CREDS(3)

✨ KRB5_CREDS(3) ✨

okay bestie, welcome to KRB5_CREDS(3) β€” the Kerberos 5 credential handling functions, aka the page where we learn how to copy and yeet credentials πŸ’… no cap, it's giving "spreadsheet for your secret tickets" energy and honestly? iconic.


πŸŽ€ NAME πŸŽ€

krb5_creds, krb5_copy_creds, krb5_copy_creds_contents, krb5_free_creds, krb5_free_cred_contents β€” Kerberos 5 credential handling functions πŸ¦‹


πŸ“š LIBRARY πŸ“š

Kerberos 5 Library (libkrb5, -lkrb5) β€” yes you gotta link it, don't forget or the linker will simply not know you πŸ’€


🌸 SYNOPSIS 🌸

#include <krb5.h>

krb5_error_code
krb5_copy_creds(krb5_context context, const krb5_creds *incred,
    krb5_creds **outcred);

krb5_error_code
krb5_copy_creds_contents(krb5_context context, const krb5_creds *incred,
    krb5_creds *outcred);

krb5_error_code
krb5_free_creds(krb5_context context, krb5_creds *outcred);

krb5_error_code
krb5_free_cred_contents(krb5_context context, krb5_creds *cred);

four little functions, one big vibe check on your memory management 🫢


πŸ’– DESCRIPTION πŸ’–

so krb5_creds holds Kerberos credentials. that's the whole assignment. it's the lil container struct and it's lowkey carrying the entire plot:

typedef struct krb5_creds {
    krb5_principal      client;
    krb5_principal      server;
    krb5_keyblock       session;
    krb5_times          times;
    krb5_data           ticket;
    krb5_data           second_ticket;
    krb5_authdata       authdata;
    krb5_addresses      addresses;
    krb5_ticket_flags   flags;
} krb5_creds;

look at her. nine fields, zero notes. the way that she just sits there holding your client, your server, your session key, your times, your ticket, your second_ticket, your authdata, your addresses and your flags… main character energy fr fr πŸ‘‘


krb5_copy_creds() makes a copy of incred to outcred. and listen, bestie, outcred should be freed with krb5_free_creds() by the caller β€” that's you. you're the caller. the cleanup is your Roman empire now 🧹✨

krb5_copy_creds_contents() makes a copy of the content of incred to outcreds. and yeah, outcreds should be freed by the called with krb5_free_creds_contents(). (that's what the page says, verbatim β€” "the called", iconic typo, we don't gatekeep, we preserve 🫢 the intent is: whoever called this, frees with krb5_free_creds_contents().)

⚠️ note the difference okay?? krb5_copy_creds() copies into a freshly allocated outcred you free with krb5_free_creds(), while krb5_copy_creds_contents() copies into an existing outcreds you free with krb5_free_creds_contents(). mixing them up is a memory leak speedrun and we are NOT doing that πŸ’€

krb5_free_creds() frees the content of the cred structure and the structure itself. full send. everything goes. bye πŸ’…

krb5_free_cred_contents() frees the content of the cred structure. just the contents, bestie β€” the structure itself stays. it's giving "empty the bag but keep the bag" πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹

go read those too, iykyk πŸ“–


🌈 sign-off 🌈

and that's the page!! brought to you by HEIMDAL, dated May 1, 2006 β€” yes she's vintage, yes she still slays, we stan a legacy queen πŸ‘‘πŸ’–

now go free your creds, bestie. no leaks. periodt. ✨🫢

πŸ“¦ where this page comes from