Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure superadmins can edit themselves #2633

Merged
merged 4 commits into from
Dec 16, 2020
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added option for "Start Task" event upon "New SecInfo arrived" condition in alerts dialog [#2418](https://github.com/greenbone/gsa/pull/2418)

### Changed
- Disable clone icon for superadmins [#2633](https://github.com/greenbone/gsa/pull/2633)
- Ensure superadmins can edit themselves [#2633](https://github.com/greenbone/gsa/pull/2633)
- Disable clone icon for superadmins [#2634](https://github.com/greenbone/gsa/pull/2634)
- Allow äüöÄÜÖß in form validation rule for "name" [#2586](https://github.com/greenbone/gsa/pull/2586)
- Show "Filter x matches at least y results" condition to task events in alert dialog [#2580](https://github.com/greenbone/gsa/pull/2580)
- Always send sort=name with delta report request filters [#2570](https://github.com/greenbone/gsa/pull/2570)
Expand Down
13 changes: 9 additions & 4 deletions gsad/src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14410,6 +14410,7 @@ save_user_gmp (gvm_connection_t *connection, credentials_t *credentials,
entity_t entity;
GString *command, *group_elements, *role_elements;
params_t *groups, *roles;
user_t *current_user;

/* List of hosts user has/lacks access rights. */
hosts = params_value (params, "access_hosts");
Expand Down Expand Up @@ -14456,7 +14457,11 @@ save_user_gmp (gvm_connection_t *connection, credentials_t *credentials,
g_string_append (command, buf);
g_free (buf);

if (login)
current_user = credentials_get_user (credentials);

if (login
/* gvmd forbids users from modifying their own names. */
&& strcmp (login, user_get_username (current_user)))
{
buf = g_markup_printf_escaped ("<new_name>%s</new_name>", login);
g_string_append (command, buf);
Expand Down Expand Up @@ -14517,7 +14522,9 @@ save_user_gmp (gvm_connection_t *connection, credentials_t *credentials,
params_iterator_init (&iter, roles);
while (params_iterator_next (&iter, &name, &param))
{
if (param->value && strcmp (param->value, "--"))
if (param->value && strcmp (param->value, "--")
/* Skip "Super Admin" which may not be added to a user. */
&& strcmp (param->value, "9c5a6ec6-6fe2-11e4-8cb6-406186ea4fc5"))
g_string_append_printf (role_elements, "<role id=\"%s\"/>",
param->value ? param->value : "");
}
Expand All @@ -14541,8 +14548,6 @@ save_user_gmp (gvm_connection_t *connection, credentials_t *credentials,
command->str);
g_string_free (command, TRUE);

user_t *current_user = credentials_get_user (credentials);

switch (ret)
{
case 0:
Expand Down