krb5_support(3)

🌸 NAME 🌸

krb5_support β€” Heimdal Kerberos 5 support functions πŸ’–

Okay so hi bestie!! 🫢 Welcome to krb5_support(3), the support-functions corner of the Heimdal Kerberos 5 library. This page is packed, and it's giving very much "the glue that holds everything together" energy. ✨


✨ SYNOPSIS ✨

πŸŽ€ Data Structures

  • struct krb5plugin_an2ln_ftable_desc β€” the description of the krb5_aname_to_lname(3) plugin facility.
  • struct krb5plugin_db_ftable_desc β€” the description of the krb5 DB plugin facility.
  • struct krb5plugin_kuserok_ftable_desc β€” the description of the krb5_kuserok(3) plugin facility.

🌈 Functions

Lowkey a whole friend group of functions, no cap. Here they all are, verbatim, because names are sacred:

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_acl_match_string
    (krb5_context context, const char *string, const char *format,...)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_acl_match_file
    (krb5_context context, const char *file, const char *format,...)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_aname_to_localname
    (krb5_context context, krb5_const_principal aname, size_t lnsize,
    char *lname)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
    krb5_config_parse_file_multi (krb5_context context, const char
    *fname, krb5_config_section **res)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_config_file_free
    (krb5_context context, krb5_config_section *s)
KRB5_LIB_FUNCTION const krb5_config_binding *KRB5_LIB_CALL
    krb5_config_get_list (krb5_context context, const
    krb5_config_section *c,...)
KRB5_LIB_FUNCTION const krb5_config_binding *KRB5_LIB_CALL
    krb5_config_vget_list (krb5_context context, const
    krb5_config_section *c, va_list args)
KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL krb5_config_get_string
    (krb5_context context, const krb5_config_section *c,...)
KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL krb5_config_vget_string
    (krb5_context context, const krb5_config_section *c, va_list args)
KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL
    krb5_config_vget_string_default (krb5_context context, const
    krb5_config_section *c, const char *def_value, va_list args)
KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL
    krb5_config_get_string_default (krb5_context context, const
    krb5_config_section *c, const char *def_value,...)
KRB5_LIB_FUNCTION char **KRB5_LIB_CALL krb5_config_vget_strings
    (krb5_context context, const krb5_config_section *c, va_list args)
KRB5_LIB_FUNCTION char **KRB5_LIB_CALL krb5_config_get_strings
    (krb5_context context, const krb5_config_section *c,...)
KRB5_LIB_FUNCTION void KRB5_LIB_CALL krb5_config_free_strings (char
    **strings)
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
    krb5_config_vget_bool_default (krb5_context context, const
    krb5_config_section *c, krb5_boolean def_value, va_list args)
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_vget_bool
    (krb5_context context, const krb5_config_section *c, va_list args)
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
    krb5_config_get_bool_default (krb5_context context, const
    krb5_config_section *c, krb5_boolean def_value,...)
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_get_bool
    (krb5_context context, const krb5_config_section *c,...)
KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_vget_time_default
    (krb5_context context, const krb5_config_section *c, int def_value,
    va_list args)
KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_vget_time (krb5_context
    context, const krb5_config_section *c, va_list args)
KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_get_time_default
    (krb5_context context, const krb5_config_section *c, int
    def_value,...)
KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_get_time (krb5_context
    context, const krb5_config_section *c,...)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_expand_hostname
    (krb5_context context, const char *orig_hostname, char
    **new_hostname)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
    krb5_expand_hostname_realms (krb5_context context, const char
    *orig_hostname, char **new_hostname, char ***realms)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_free_host_realm
    (krb5_context context, krb5_realm *realmlist)
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_kuserok (krb5_context
    context, krb5_principal principal, const char *luser)
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_plugin_register
    (krb5_context context, enum krb5_plugin_type type, const char *name,
    void *symbol)

πŸ’œ Detailed Description πŸ’œ

Not me checking this section and finding it's just… vibes. 🫠 There's no extra prose here in the original β€” the whole story lives down in the Function Documentation, so let's go, bestie. πŸ’…


πŸ“– Function Documentation πŸ“–

πŸ“ krb5_acl_match_file

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_acl_match_file
    (krb5_context context, const char *file, const char *format, ...)

So krb5_acl_match_file takes an ACL format and matches it against each line in a file, doing that via krb5_acl_match_string(). πŸŽ€ And the cutest little detail: lines starting with # are treated like comments and ignored. Periodt.

Parameters:

  • context β€” Kerberos 5 context.
  • file β€” file with acl listed in the file.
  • format β€” format to match.
  • ... β€” parameter to format string.

Returns:

Return an error code or 0.

See also:

krb5_acl_match_string


πŸ¦‹ krb5_acl_match_string

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_acl_match_string
    (krb5_context context, const char *string, const char *format, ...)

krb5_acl_match_string matches an ACL format against a string. ✨

The ACL format has three format specifiers: s, f, and r. Each specifier will retrieve one argument from the variable arguments, either for matching or for storing data. The input string is split up using ' ' (space) and '\t' (tab) as a delimiter; multiple ' ' and '\t' in a row are considered to be the same. πŸ”₯

List of format specifiers:

  • s β€” Matches a string using strcmp(3) (case sensitive).
  • f β€” Matches the string with fnmatch(3). Theflags argument (the last argument) passed to the fnmatch function is 0.
  • r β€” Returns a copy of the string in the char ** passed in; the copy must be freed with free(3). There is no need to free(3) the string on error: the function will clean up and set the pointer to NULL. πŸ™ˆ

Parameters:

  • context β€” Kerberos 5 context
  • string β€” string to match with
  • format β€” format to match
  • ... β€” parameter to format string

Returns:

Return an error code or 0.

And here's the example, verbatim, because it ate:

char *s;

ret = krb5_acl_match_string(context, "foo", "s", "foo");
if (ret)
    krb5_errx(context, 1, "acl didn't match");
ret = krb5_acl_match_string(context, "foo foo baz/kaka",
    "ss", "foo", &s, "foo/\*");
if (ret) {
    // no need to free(s) on error
    assert(s == NULL);
    krb5_errx(context, 1, "acl didn't match");
}
free(s);

See also:

krb5_acl_match_file


πŸŽ€ krb5_aname_to_localname

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_aname_to_localname
    (krb5_context context, krb5_const_principal aname, size_t lnsize, char *lname)

Map a principal name to a local username. πŸ’«

Returns 0 on success, KRB5_NO_LOCALNAME if no mapping was found, or some Kerberos or system error.

Inputs:

Parameters:

  • context β€” A krb5_context
  • aname β€” A principal name
  • lnsize β€” The size of the buffer into which the username will be written
  • lname β€” The buffer into which the username will be written

🌸 krb5_config_file_free

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_config_file_free
    (krb5_context context, krb5_config_section *s)

Free a configuration file section β€” aka the result of krb5_config_parse_file() and krb5_config_parse_file_multi(). Cleanup queen behavior, honestly. 🧹

Parameters:

  • context β€” A Kerberos 5 context
  • s β€” the configuration section to free

Returns:

returns 0 on successes, otherwise an error code, see krb5_get_error_message()


πŸ’– krb5_config_free_strings

KRB5_LIB_FUNCTION void KRB5_LIB_CALL krb5_config_free_strings (char **strings)

Free the resulting strings from krb5_config-get_strings() and krb5_config_vget_strings(). You have to do this, bestie β€” no leaking on my watch. πŸ’€

Parameters:

  • strings β€” strings to free

πŸ“ krb5_config_get_bool

KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_get_bool
    (krb5_context context, const krb5_config_section *c, ...)

Like krb5_config_get_bool() but with a va_list list of configuration selection. (Yes, fr fr, that's what it says β€” iconic copy-paste energy, we keep it exactly.) πŸ™ˆ

Configuration value to a boolean value, where yes/true and any non-zero number means TRUE and other value is FALSE.

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • ... β€” a list of names, terminated with NULL.

Returns:

TRUE or FALSE


✨ krb5_config_get_bool_default

KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_get_bool_default
    (krb5_context context, const krb5_config_section *c, krb5_boolean def_value, ...)

krb5_config_get_bool_default() will convert the configuration option value to a boolean value, where yes/true and any non-zero number means TRUE and other value is FALSE. πŸ”₯

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • ... β€” a list of names, terminated with NULL.

Returns:

TRUE or FALSE


🌈 krb5_config_get_list

KRB5_LIB_FUNCTION const krb5_config_binding *KRB5_LIB_CALL
    krb5_config_get_list (krb5_context context, const krb5_config_section *c, ...)

Get a list of configuration binding list for more processing. πŸ’…

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • ... β€” a list of names, terminated with NULL.

Returns:

NULL if configuration list is not found, a list otherwise


πŸ¦‹ krb5_config_get_string

KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL krb5_config_get_string
    (krb5_context context, const krb5_config_section *c, ...)

Returns a 'const char *' to a string in the configuration database. ⚠️ Heads up bestie: the string may not be valid after a reload of the configuration database, so a caller should make a local copy if it needs to keep the string. Don't be caught holding a stale pointer, that's not the vibe. 😭

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • ... β€” a list of names, terminated with NULL.

Returns:

NULL if configuration string not found, a string otherwise


🌸 krb5_config_get_string_default

KRB5_LIB_FUNCTION const char *KRB5_LIB_CALL krb5_config_get_string_default
    (krb5_context context, const krb5_config_section *c, const char *def_value, ...)

Like krb5_config_get_string(), but instead of returning NULL, instead return a default value. Glow-up behavior. ✨

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • ... β€” a list of names, terminated with NULL.

Returns:

a configuration string


πŸŽ€ krb5_config_get_strings

KRB5_LIB_FUNCTION char **KRB5_LIB_CALL krb5_config_get_strings
    (krb5_context context, const krb5_config_section *c, ...)

Get a list of configuration strings, free the result with krb5_config_free_strings(). 🫢

okay so back to that function we were just on β€” its params are giving:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • ... β€” a list of names, terminated with NULL.

And it returns TRUE or FALSE. periodt. πŸ’…


krb5_config_get_time ⏳✨

KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_get_time (krb5_context context, const krb5_config_section * c,  ...)

This one gets the time from the configuration file using a relative time, for example: 1h30s. So like, you can say 1h30s and it just gets it. Lowkey iconic. πŸ•°οΈ

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • ... β€” a list of names, terminated with NULL.

Returns:

  • parsed the time or -1 on error

krb5_config_get_time_default 🌸

KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_get_time_default (krb5_context context, const krb5_config_section * c, int def_value, ...)

Get the time from the configuration file using a relative time, for example: 1h30s. (Same vibe as above but with a default, bestie.)

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • ... β€” a list of names, terminated with NULL.

Returns:

  • parsed the time (or def_value on parse error)

krb5_config_parse_file_multi πŸ“‚

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_config_parse_file_multi (krb5_context context, const char * fname, krb5_config_section ** res)

Parse a configuration file and add the result into res. This interface can be used to parse several configuration files into one resulting krb5_config_section by calling it repeatably. So you can stack them like leggings under a skirt. πŸ§…

Parameters:

  • context β€” a Kerberos 5 context.
  • fname β€” a file name to a Kerberos configuration file
  • res β€” the returned result, must be free with krb5_free_config_files().

Returns:

  • Return an error code or 0, see krb5_get_error_message().
If the fname starts with '~/' parse configuration file in the current users home directory. The behavior can be disabled and enabled by calling krb5_set_home_dir_access().

krb5_config_vget_bool βœ…

KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_vget_bool (krb5_context context, const krb5_config_section * c, va_list args)

krb5_config_get_bool() will convert the configuration option value to a boolean value, where yes/true and any non-zero number means TRUE and other value is FALSE. So basically if it's not yes, true, or a non-zero number, it's a no. 🚫

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • args β€” a va_list of arguments

Returns:

  • TRUE or FALSE

krb5_config_vget_bool_default πŸŽ€

KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_config_vget_bool_default (krb5_context context, const krb5_config_section * c, krb5_boolean def_value, va_list args)

Like krb5_config_get_bool_default() but with a va_list list of configuration selection.

Configuration value to a boolean value, where yes/true and any non-zero number means TRUE and other value is FALSE. Same rules as above, but you get a default if nothing's found.

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • args β€” a va_list of arguments

Returns:

  • TRUE or FALSE

krb5_config_vget_list πŸ“‹

KRB5_LIB_FUNCTION const krb5_config_binding* KRB5_LIB_CALL krb5_config_vget_list (krb5_context context, const krb5_config_section * c, va_list args)

Get a list of configuration binding list for more processing. It's giving "here's the list, go off." πŸ’…

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • args β€” a va_list of arguments

Returns:

  • NULL if configuration list is not found, a list otherwise

krb5_config_vget_string 🧡

KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL krb5_config_vget_string (krb5_context context, const krb5_config_section * c, va_list args)

Like krb5_config_get_string(), but uses a va_list instead of .... So it's the same but with extra steps. 😌

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • args β€” a va_list of arguments

Returns:

  • NULL if configuration string not found, a string otherwise

krb5_config_vget_string_default 🌈

KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL krb5_config_vget_string_default (krb5_context context, const krb5_config_section * c, const char * def_value, va_list args)

Like krb5_config_vget_string(), but instead of returning NULL, instead return a default value. So you never get NULL, you get your little default. 🍼

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • args β€” a va_list of arguments

Returns:

  • a configuration string

krb5_config_vget_strings πŸ“

KRB5_LIB_FUNCTION char** KRB5_LIB_CALL krb5_config_vget_strings (krb5_context context, const krb5_config_section * c, va_list args)

Get a list of configuration strings, free the result with krb5_config_free_strings(). Don't forget to free, bestie, or it's a leak. πŸ’€

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • args β€” a va_list of arguments

Returns:

  • TRUE or FALSE

krb5_config_vget_time ⏰

KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_vget_time (krb5_context context, const krb5_config_section * c, va_list args)

Get the time from the configuration file using a relative time, for example: 1h30s. Same as the non-v version but with va_list. πŸ•

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • args β€” a va_list of arguments

Returns:

  • parsed the time or -1 on error

krb5_config_vget_time_default πŸ’œ

KRB5_LIB_FUNCTION int KRB5_LIB_CALL krb5_config_vget_time_default (krb5_context context, const krb5_config_section * c, int def_value, va_list args)

Get the time from the configuration file using a relative time.

Like krb5_config_get_time_default() but with a va_list list of configuration selection.

Parameters:

  • context β€” A Kerberos 5 context.
  • c β€” a configuration section, or NULL to use the section from context
  • def_value β€” the default value to return if no configuration found in the database.
  • args β€” a va_list of arguments

Returns:

  • parsed the time (or def_value on parse error)

krb5_expand_hostname 🏠

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_expand_hostname (krb5_context context, const char * orig_hostname, char ** new_hostname)

krb5_expand_hostname() tries to make orig_hostname into a more canonical one in the newly allocated space returned in new_hostname. It's like glow-up for hostnames. ✨

Parameters:

  • context β€” a Keberos context
  • orig_hostname β€” hostname to canonicalise.
  • new_hostname β€” output hostname, caller must free hostname with krb5_xfree().

Returns:

  • Return an error code or 0, see krb5_get_error_message().

krb5_expand_hostname_realms πŸ‘‘

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_expand_hostname_realms (krb5_context context, const char * orig_hostname, char ** new_hostname, char *** realms)

krb5_expand_hostname_realms() expands orig_hostname to a name we believe to be a hostname in newly allocated space in new_hostname and return the realms new_hostname is believed to belong to in realms. So it's the hostname glow-up plus the realms it belongs to. πŸ’«

Parameters:

  • context β€” a Keberos context
  • orig_hostname β€” hostname to canonicalise.
  • new_hostname β€” output hostname, caller must free hostname with krb5_xfree().
  • realms β€” output possible realms, is an array that is terminated with NULL. Caller must free with krb5_free_host_realm().

Returns:

  • Return an error code or 0, see krb5_get_error_message().

krb5_free_host_realm πŸ—‘οΈ

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_free_host_realm (krb5_context context, krb5_realm * realmlist)

Free all memory allocated by realmlist. It's the cleanup queen. 🧹

Parameters:

  • context β€” A Kerberos 5 context.
  • realmlist β€” realmlist to free, NULL is ok

Returns:

  • a Kerberos error code, always 0.

krb5_kuserok πŸ”

KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL krb5_kuserok (krb5_context context, krb5_principal principal, const char * luser)

This function takes the name of a local user and checks if principal is allowed to log in as that user.

The user may have a ~/.k5login file listing principals that are allowed to login as that user. If that file does not exist, all principals with only one component that is identical to the username, and a realm considered local, are allowed access.

The .k5login file must contain one principal per line, be owned by user and not be writable by group or other (but must be readable by anyone).

Note that if the file exists, no implicit access rights are given to user@LOCALREALM.

Optionally, a set of files may be put in ~/.k5login.d (a directory), in which case they will all be checked in the same manner as .k5login. The files may be called anything, but files starting with a hash (#) , or ending with a tilde (~) are ignored. Subdirectories are not traversed. Note that this directory may not be checked by other Kerberos implementations.

If no configuration file exists, match user against local domains, ie luser@LOCAL-REALMS-IN-CONFIGURATION-FILES.

Parameters:

  • context β€” Kerberos 5 context.
  • principal β€” principal to check if allowed to login
  • luser β€” local user id

Returns:

  • returns TRUE if access should be granted, FALSE otherwise.

krb5_plugin_register 🧩

KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL krb5_plugin_register (krb5_context context, enum krb5_plugin_type type, const char * name, void * symbol)

Register a plugin symbol name of specific type. Plug it in, plug it in. πŸ”Œ

Parameters:

  • context β€” a Keberos context
  • type β€” type of plugin symbol
  • name β€” name of plugin symbol
  • symbol β€” a pointer to the named symbol

Returns:

  • In case of error a non zero error com_err error is returned and the Kerberos error string is set.

✨ Author ✨

Generated automatically by Doxygen for Heimdal Kerberos 5 library from the source code. So it's a robot, not a person. Beep boop. πŸ€–


Anyways, that's the whole vibe. This page is from Heimdal Kerberos 5 library, version 7.8.0, dated Tue Nov 15 2022, and it's krb5_support(3). Stay slay, bestie. πŸ’–βœ¨

πŸ“¦ where this page comes from