Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(
manage_resources.c
manage_report_configs.c
manage_report_formats.c
manage_roles.c
manage_runtime_flags.c
manage_authentication.c
manage_settings.c
Expand Down Expand Up @@ -216,6 +217,7 @@ set(
manage_sql_configs.c
manage_sql_report_configs.c
manage_sql_report_formats.c
manage_sql_roles.c
manage_sql_tickets.c
manage_sql_tls_certificates.c
manage_sql_nvts_osp.c
Expand Down Expand Up @@ -675,6 +677,7 @@ set(
"${CMAKE_CURRENT_SOURCE_DIR}/manage_preferences.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_runtime_flags.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_report_formats.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_roles.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_authentication.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_agent_installers.c"
Expand All @@ -688,6 +691,7 @@ set(
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_oci_image_targets.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_port_lists.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_report_formats.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_roles.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_secinfo.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_tickets.c"
"${CMAKE_CURRENT_SOURCE_DIR}/manage_sql_tls_certificates.c"
Expand Down
1 change: 1 addition & 0 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#include "manage_port_lists.h"
#include "manage_report_configs.h"
#include "manage_report_formats.h"
#include "manage_roles.h"
#include "manage_runtime_flags.h"
#include "manage_tls_certificates.h"
#include "sql.h"
Expand Down
1 change: 1 addition & 0 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
#include "manage_sql_secinfo.h"
#include "manage_authentication.h"
#include "manage_runtime_flags.h"
#include "manage_roles.h"
#include "manage_scan_queue.h"
#include "gmpd.h"
#include "utils.h"
Expand Down
9 changes: 0 additions & 9 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -2948,9 +2948,6 @@ delete_permissions_cache_for_user (user_t);

/* Roles. */

int
manage_get_roles (GSList *, const db_conn_info_t *, int);

int
init_role_iterator (iterator_t *, get_data_t *);

Expand All @@ -2969,12 +2966,6 @@ role_uuid (role_t);
gchar *
role_users (role_t);

int
trash_role_in_use (role_t);

int
role_in_use (role_t);

int
trash_role_writable (role_t);

Expand Down
38 changes: 38 additions & 0 deletions src/manage_roles.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Copyright (C) 2026 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

#include "manage_roles.h"

#undef G_LOG_DOMAIN
/**
* @brief GLib log domain.
*/
#define G_LOG_DOMAIN "md manage"

/**
* @brief Check whether a role is in use.
*
* @param[in] role Role.
*
* @return 1 yes, 0 no.
*/
int
role_in_use (role_t role)
{
return 0;
}

/**
* @brief Check whether a trashcan role is in use.
*
* @param[in] role Role.
*
* @return 1 yes, 0 no.
*/
int
trash_role_in_use (role_t role)
{
return 0;
}
22 changes: 22 additions & 0 deletions src/manage_roles.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright (C) 2026 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

#ifndef _GVMD_MANAGE_ROLES_H
#define _GVMD_MANAGE_ROLES_H

#include "manage_get.h"
#include "manage_resources.h"
#include "sql.h" // Sadly, for db_conn_info_t

int
manage_get_roles (GSList *, const db_conn_info_t *, int);

int
trash_role_in_use (role_t);

int
role_in_use (role_t);

#endif /* not _GVMD_MANAGE_ROLES_H */
64 changes: 1 addition & 63 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "manage_groups.h"
#include "manage_port_lists.h"
#include "manage_report_formats.h"
#include "manage_roles.h"
#include "manage_runtime_flags.h"
#include "manage_sql_credential_stores.h"
#include "manage_sql_copy.h"
Expand Down Expand Up @@ -35104,43 +35105,6 @@ clean_feed_role_permissions (const char *type,

/* Roles. */

/**
* @brief List roles.
*
* @param[in] log_config Log configuration.
* @param[in] database Location of manage database.
* @param[in] verbose Whether to print UUID.
*
* @return 0 success, -1 error.
*/
int
manage_get_roles (GSList *log_config, const db_conn_info_t *database,
int verbose)
{
iterator_t roles;
int ret;

g_info (" Getting roles.");

ret = manage_option_setup (log_config, database,
0 /* avoid_db_check_inserts */);
if (ret)
return ret;

init_iterator (&roles, "SELECT name, uuid FROM roles;");
while (next (&roles))
if (verbose)
printf ("%s %s\n", iterator_string (&roles, 0), iterator_string (&roles, 1));
else
printf ("%s\n", iterator_string (&roles, 0));

cleanup_iterator (&roles);

manage_option_cleanup ();

return 0;
}

/**
* @brief Create a role from an existing role.
*
Expand Down Expand Up @@ -35560,32 +35524,6 @@ trash_role_writable (role_t role)
return 1;
}

/**
* @brief Check whether a role is in use.
*
* @param[in] role Role.
*
* @return 1 yes, 0 no.
*/
int
role_in_use (role_t role)
{
return 0;
}

/**
* @brief Check whether a trashcan role is in use.
*
* @param[in] role Role.
*
* @return 1 yes, 0 no.
*/
int
trash_role_in_use (role_t role)
{
return 0;
}

/**
* @brief Modify a role.
*
Expand Down
53 changes: 53 additions & 0 deletions src/manage_sql_roles.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* Copyright (C) 2026 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

#include "manage_roles.h"
#include "manage_acl.h"
#include "manage_sql.h"
#include "sql.h"

/**
* @file
* @brief GVM management layer: Roles SQL
*
* The Roles SQL for the GVM management layer.
*/

/**
* @brief List roles.
*
* @param[in] log_config Log configuration.
* @param[in] database Location of manage database.
* @param[in] verbose Whether to print UUID.
*
* @return 0 success, -1 error.
*/
int
manage_get_roles (GSList *log_config, const db_conn_info_t *database,
int verbose)
{
iterator_t roles;
int ret;

g_info (" Getting roles.");

ret = manage_option_setup (log_config, database,
0 /* avoid_db_check_inserts */);
if (ret)
return ret;

init_iterator (&roles, "SELECT name, uuid FROM roles;");
while (next (&roles))
if (verbose)
printf ("%s %s\n", iterator_string (&roles, 0), iterator_string (&roles, 1));
else
printf ("%s\n", iterator_string (&roles, 0));

cleanup_iterator (&roles);

manage_option_cleanup ();

return 0;
}
Loading