Greenbone Security Assistant  8.0.0
gsad_gmp_auth.h File Reference

Authentication GMP. More...

#include <glib.h>
Include dependency graph for gsad_gmp_auth.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int authenticate_gmp (const gchar *, const gchar *, gchar **, gchar **, gchar **, gchar **, gchar **, gchar **)
 Check authentication credentials. More...
 

Detailed Description

Authentication GMP.

Definition in file gsad_gmp_auth.h.

Function Documentation

◆ authenticate_gmp()

int authenticate_gmp ( const gchar *  username,
const gchar *  password,
gchar **  role,
gchar **  timezone,
gchar **  severity,
gchar **  capabilities,
gchar **  language,
gchar **  pw_warning 
)

Check authentication credentials.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[out]roleRole.
[out]timezoneTimezone.
[out]severitySeverity class.
[out]capabilitiesCapabilities of manager.
[out]languageUser Interface Language, or NULL.
[out]pw_warningPassword warning message, NULL if password is OK.
Returns
0 if valid, 1 failed, 2 manager down, -1 error.

Definition at line 19273 of file gsad_gmp.c.

19276 {
19277  gvm_connection_t connection;
19278  int auth;
19279  gmp_authenticate_info_opts_t auth_opts;
19280 
19281  if (gvm_connection_open (&connection, manager_address, manager_port))
19282  {
19283  g_debug ("%s failed to acquire socket!\n", __FUNCTION__);
19284  return 2;
19285  }
19286 
19287  auth_opts = gmp_authenticate_info_opts_defaults;
19288  auth_opts.username = username;
19289  auth_opts.password = password;
19290  auth_opts.role = role;
19291  auth_opts.severity = severity;
19292  auth_opts.timezone = timezone;
19293  auth_opts.pw_warning = pw_warning;
19294 
19295  auth = gmp_authenticate_info_ext_c (&connection, auth_opts);
19296  if (auth == 0)
19297  {
19298  entity_t entity;
19299  const char *status;
19300  char first;
19301  gchar *response;
19302  int ret;
19303 
19304  /* Get language setting. */
19305 
19306  ret = setting_get_value (
19307  &connection, "6765549a-934e-11e3-b358-406186ea4fc5", language, NULL);
19308 
19309  switch (ret)
19310  {
19311  case 0:
19312  break;
19313  case 1:
19314  case 2:
19315  gvm_connection_close (&connection);
19316  return 2;
19317  default:
19318  gvm_connection_close (&connection);
19319  return -1;
19320  }
19321 
19322  /* Request help. */
19323 
19324  ret = gvm_connection_sendf (&connection,
19325  "<help format=\"XML\" type=\"brief\"/>");
19326  if (ret)
19327  {
19328  gvm_connection_close (&connection);
19329  return 2;
19330  }
19331 
19332  /* Read the response. */
19333 
19334  entity = NULL;
19335  if (read_entity_and_text_c (&connection, &entity, &response))
19336  {
19337  gvm_connection_close (&connection);
19338  return 2;
19339  }
19340 
19341  /* Check the response. */
19342 
19343  status = entity_attribute (entity, "status");
19344  if (status == NULL || strlen (status) == 0)
19345  {
19346  g_free (response);
19347  free_entity (entity);
19348  return -1;
19349  }
19350  first = status[0];
19351  free_entity (entity);
19352  if (first == '2')
19353  {
19354  *capabilities = response;
19355  }
19356  else
19357  {
19358  gvm_connection_close (&connection);
19359  g_free (response);
19360  return -1;
19361  }
19362 
19363  gvm_connection_close (&connection);
19364  return 0;
19365  }
19366  else
19367  {
19368  gvm_connection_close (&connection);
19369  return 1;
19370  }
19371 }
static int setting_get_value(gvm_connection_t *connection, const char *setting_id, gchar **value, cmd_response_data_t *response_data)
Get a setting by UUID for the current user of an GMP connection.
Definition: gsad_gmp.c:888
int manager_port
The port the manager is on.
Definition: gsad_gmp.c:140
int gvm_connection_open(gvm_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_gmp.c:19235
gchar * manager_address
The address the manager is on.
Definition: gsad_gmp.c:135

References gvm_connection_open(), manager_address, manager_port, and setting_get_value().

Referenced by login().

Here is the call graph for this function:
Here is the caller graph for this function: