OpenVAS Scanner 23.23.1
nasl_krb5.c File Reference
#include "nasl_krb5.h"
#include "../misc/openvas-krb5.h"
#include "nasl_debug.h"
#include "nasl_func.h"
#include "nasl_global_ctxt.h"
#include "nasl_lex_ctxt.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include <stdio.h>

Macros

#define NASL_PRINT_KRB_ERROR(lexic, credential, result)
#define SET_SLICE_FROM_LEX_OR_ENV(lexic, slice, name, env_name)
#define PERROR_SET_SLICE_FROM_LEX_OR_ENV(lexic, slice, name, env_name)

Functions

static OKrb5Credential build_krb5_credential (lex_ctxt *lexic)
tree_cellnasl_okrb5_find_kdc (lex_ctxt *lexic)
 Returns the defined KDC of a given Realm.
tree_cellnasl_okrb5_add_realm (lex_ctxt *lexic)
 Adds the given KDC to the given Realm.
tree_cellnasl_okrb5_is_success (lex_ctxt *lexic)
 Returns 1 if the krb5 function was successful 0 otherwise.
tree_cellnasl_okrb5_is_failure (lex_ctxt *lexic)
 Returns 0 if the krb5 function was successful and 1 if it failed.
tree_cellnasl_okrb5_gss_init (lex_ctxt *lexic)
tree_cellnasl_okrb5_gss_prepare_context (lex_ctxt *lexic)
tree_cellnasl_okrb5_gss_update_context (lex_ctxt *lexic)
void nasl_okrb5_clean (void)
tree_cellnasl_okrb5_gss_update_context_needs_more (lex_ctxt *lexic)
static tree_cellokrb5_slice_to_tree_cell (struct OKrb5Slice *slice)
tree_cellnasl_okrb5_gss_update_context_out (lex_ctxt *lexic)
tree_cellnasl_okrb5_gss_session_key_context (lex_ctxt *lexic)
tree_cellnasl_okrb5_error_code_to_string (lex_ctxt *lexic)

Variables

static OKrb5ErrorCode last_okrb5_result
static struct OKrb5GSSContextcached_gss_context = NULL
static struct OKrb5Sliceto_application = NULL
static bool gss_update_context_more = false

Macro Definition Documentation

◆ NASL_PRINT_KRB_ERROR

#define NASL_PRINT_KRB_ERROR ( lexic,
credential,
result )
Value:
do \
{ \
char *error_str = okrb5_error_code_to_string (result); \
nasl_perror ( \
lexic, "%s[config_path: '%s' realm: '%s' user: '%s'] => %s (%d)", \
__func__, credential.config_path.data, credential.realm.data, \
credential.user.user.data, error_str, result); \
free (error_str); \
} \
while (0)
char * okrb5_error_code_to_string(const OKrb5ErrorCode code)
Definition openvas-krb5.c:600

◆ PERROR_SET_SLICE_FROM_LEX_OR_ENV

#define PERROR_SET_SLICE_FROM_LEX_OR_ENV ( lexic,
slice,
name,
env_name )
Value:
do \
{ \
SET_SLICE_FROM_LEX_OR_ENV (lexic, slice, name, env_name); \
if (slice.len == 0) \
{ \
nasl_perror (lexic, "Expected %s or env variable %s", name, \
env_name); \
} \
} \
while (0)
const char * name
Definition nasl_init.c:436

◆ SET_SLICE_FROM_LEX_OR_ENV

#define SET_SLICE_FROM_LEX_OR_ENV ( lexic,
slice,
name,
env_name )
Value:
do \
{ \
okrb5_set_slice_from_str (slice, get_str_var_by_name (lexic, name)); \
if (slice.len == 0) \
{ \
okrb5_set_slice_from_str (slice, getenv (env_name)); \
} \
} \
while (0)
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1118

Function Documentation

◆ build_krb5_credential()

OKrb5Credential build_krb5_credential ( lex_ctxt * lexic)
static

◆ nasl_okrb5_add_realm()

tree_cell * nasl_okrb5_add_realm ( lex_ctxt * lexic)

Adds the given KDC to the given Realm.

This function returns 0 on success. To retrieve a human readable error message, the function okrb5_result can be used.

The nasl function has three optional parameter:

  • realm: The realm for which the KDC should be returned. If the realm is not defined, then the env parameter KRB5_REALM is used.
  • kdc: The realm for which the KDC should be returned. If the realm is not defined, then the env parameter KRB5_KDC is used.
  • config_path: The path to the krb5.conf file. If the path is not defined, then the env parameter KRB5_CONFIG is used.

This function should only be used for debug purposes.

Parameters
[in]lexicNASL lexer.
Returns
lex cell containing a number indicating success or failure.

◆ nasl_okrb5_clean()

void nasl_okrb5_clean ( void )

◆ nasl_okrb5_error_code_to_string()

tree_cell * nasl_okrb5_error_code_to_string ( lex_ctxt * lexic)

◆ nasl_okrb5_find_kdc()

tree_cell * nasl_okrb5_find_kdc ( lex_ctxt * lexic)

Returns the defined KDC of a given Realm.

This function returns the KDC of a given Realm. The Realm is defined in the krb5.conf file. If there is no KDC for the given Realm, the function returns NULL within the tree_cell to the script.

The nasl function has two optional parameter:

  • realm: The realm for which the KDC should be returned. If the realm is not defined, then the env parameter KRB5_REALM is used.
  • config_path: The path to the krb5.conf file. If the path is not defined, then the env parameter KRB5_CONFIG is used.

This function should only be used for debug purposes.

Parameters
[in]lexicNASL lexer.
Returns
lex cell containing the KDC as a string.

◆ nasl_okrb5_gss_init()

tree_cell * nasl_okrb5_gss_init ( lex_ctxt * lexic)

◆ nasl_okrb5_gss_prepare_context()

tree_cell * nasl_okrb5_gss_prepare_context ( lex_ctxt * lexic)

◆ nasl_okrb5_gss_session_key_context()

tree_cell * nasl_okrb5_gss_session_key_context ( lex_ctxt * lexic)

◆ nasl_okrb5_gss_update_context()

tree_cell * nasl_okrb5_gss_update_context ( lex_ctxt * lexic)

◆ nasl_okrb5_gss_update_context_needs_more()

tree_cell * nasl_okrb5_gss_update_context_needs_more ( lex_ctxt * lexic)

◆ nasl_okrb5_gss_update_context_out()

tree_cell * nasl_okrb5_gss_update_context_out ( lex_ctxt * lexic)

◆ nasl_okrb5_is_failure()

tree_cell * nasl_okrb5_is_failure ( lex_ctxt * lexic)

Returns 0 if the krb5 function was successful and 1 if it failed.

The nasl function has one optional parameter:

  • retval: the return value of the krb5 function. If the value is not defined, the return value of the last krb5 function is used.
Parameters
[in]lexicNASL lexer.
Returns
lex cell containing a number indicating success.

◆ nasl_okrb5_is_success()

tree_cell * nasl_okrb5_is_success ( lex_ctxt * lexic)

Returns 1 if the krb5 function was successful 0 otherwise.

The nasl function has one optional parameter:

  • retval: the return value of the krb5 function. If the value is not defined, the return value of the last krb5 function is used.
Parameters
[in]lexicNASL lexer.
Returns
lex cell containing a number indicating success.

◆ okrb5_slice_to_tree_cell()

tree_cell * okrb5_slice_to_tree_cell ( struct OKrb5Slice * slice)
inlinestatic

Variable Documentation

◆ cached_gss_context

struct OKrb5GSSContext* cached_gss_context = NULL
static

◆ gss_update_context_more

bool gss_update_context_more = false
static

◆ last_okrb5_result

OKrb5ErrorCode last_okrb5_result
static

◆ to_application

struct OKrb5Slice* to_application = NULL
static