summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-10-23 12:23:07 +0200
committerThomas Haller <thaller@redhat.com>2020-10-23 12:23:08 +0200
commitad18612c3644e7797bc173077bfc8731b0b5fd97 (patch)
tree335f94c7793a1bb47c68420abe3ec561d856fa2e
parentb6a18e059302117157971e7c5f551fc40d864e89 (diff)
core: remove error checking for nm_auth_chain_new_subject() which cannot fail
nm_auth_chain_new_subject() cannot return %NULL, so these checks are only noise. Also, there are already calls that correctly rely on the fact that this function cannot fail. We use glib, where memory allocation by definition cannot fail. That means, a lot of functions simply cannot fail in our code base. This is a very nice property (to have an functions that cannot fail), so don't add error checking that is not useful.
-rw-r--r--src/nm-manager.c17
-rw-r--r--src/settings/nm-settings.c8
2 files changed, 0 insertions, 25 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index ec5ca6ef0..9a97c43f1 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2495,16 +2495,7 @@ nm_manager_device_auth_request(NMManager * self,
&error))
goto fail_on_idle;
- /* Validate the request */
chain = nm_auth_chain_new_subject(subject, context, device_auth_done_cb, self);
- if (!chain) {
- g_set_error(&error,
- NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_PERMISSION_DENIED,
- NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
- goto fail_on_idle;
- }
-
if (cancellable)
nm_auth_chain_set_cancellable(chain, cancellable);
@@ -6033,15 +6024,7 @@ impl_manager_deactivate_connection(NMDBusObject * obj,
&error))
goto done;
- /* Validate the user request */
chain = nm_auth_chain_new_subject(subject, invocation, deactivate_net_auth_done_cb, self);
- if (!chain) {
- error = g_error_new_literal(NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_PERMISSION_DENIED,
- NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
- goto done;
- }
-
c_list_link_tail(&priv->auth_lst_head, nm_auth_chain_parent_lst_list(chain));
nm_auth_chain_set_data(chain, "path", g_strdup(active_path), g_free);
nm_auth_chain_add_call(chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 6b9d50834..8b0b2c0dd 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -2521,17 +2521,9 @@ nm_settings_add_connection_dbus(NMSettings * self,
else
perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM;
- /* Validate the user request */
chain = nm_auth_chain_new_subject(subject, context, pk_add_cb, self);
- if (!chain) {
- error = g_error_new_literal(NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_PERMISSION_DENIED,
- NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
- goto done;
- }
c_list_link_tail(&priv->auth_lst_head, nm_auth_chain_parent_lst_list(chain));
-
nm_auth_chain_set_data(chain, "perm", (gpointer) perm, NULL);
nm_auth_chain_set_data(chain, "connection", g_object_ref(connection), g_object_unref);
nm_auth_chain_set_data(chain, "callback", callback, NULL);