mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 00:48:29 +02:00
core: add defines for common authentication-related error messages
All D-Bus method call implementations use similar error messages when authenticating requests; add defines for them to ensure the same exact message is reused.
This commit is contained in:
parent
2d941dc95a
commit
4bd192a350
5 changed files with 26 additions and 22 deletions
|
|
@ -496,4 +496,8 @@ const char *nm_utils_parse_dns_domain (const char *domain, gboolean *is_routing)
|
|||
|
||||
#define NM_VPN_ROUTE_METRIC_DEFAULT 50
|
||||
|
||||
#define NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED "Unable to authenticate the request"
|
||||
#define NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN "Unable to determine UID of the request"
|
||||
#define NM_UTILS_ERROR_MSG_INSUFF_PRIV "Insufficient privileges"
|
||||
|
||||
#endif /* __NM_CORE_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -1223,7 +1223,7 @@ impl_manager_reload (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2434,7 +2434,7 @@ device_auth_request_cb (NMDevice *device,
|
|||
if (!subject) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Failed to get request UID.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2452,7 +2452,7 @@ device_auth_request_cb (NMDevice *device,
|
|||
if (!chain) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -5128,7 +5128,7 @@ validate_activation_request (NMManager *self,
|
|||
g_set_error_literal (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Failed to get request UID.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -5777,7 +5777,7 @@ impl_manager_deactivate_connection (NMDBusObject *obj,
|
|||
if (!subject) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Failed to get request UID.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -5793,7 +5793,7 @@ impl_manager_deactivate_connection (NMDBusObject *obj,
|
|||
if (!chain) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -6175,7 +6175,7 @@ impl_manager_enable (NMDBusObject *obj,
|
|||
if (!chain) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -6260,7 +6260,7 @@ impl_manager_get_permissions (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -6477,7 +6477,7 @@ impl_manager_check_connectivity (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal(invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -6919,7 +6919,7 @@ nm_manager_dbus_set_property_handle (NMDBusObject *obj,
|
|||
|
||||
subject = nm_auth_subject_new_unix_process_from_context (invocation);
|
||||
if (!subject) {
|
||||
error_message = "Could not determine request UID";
|
||||
error_message = NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN;
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
@ -7051,7 +7051,7 @@ impl_manager_checkpoint_create (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -7084,7 +7084,7 @@ impl_manager_checkpoint_destroy (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -7115,7 +7115,7 @@ impl_manager_checkpoint_rollback (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -7147,7 +7147,7 @@ impl_manager_checkpoint_adjust_rollback_timeout (NMDBusObject *obj,
|
|||
g_dbus_method_invocation_return_error_literal (invocation,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ agent_manager_register_with_capabilities (NMAgentManager *self,
|
|||
if (!subject) {
|
||||
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
|
||||
NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Unable to determine request sender and UID.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
goto done;
|
||||
}
|
||||
sender_uid = nm_auth_subject_get_unix_process_uid (subject);
|
||||
|
|
|
|||
|
|
@ -1235,7 +1235,7 @@ pk_auth_cb (NMAuthManager *auth_manager,
|
|||
} else if (nm_auth_call_result_eval (is_authorized, is_challenge, auth_error) != NM_AUTH_CALL_RESULT_YES) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Insufficient privileges");
|
||||
NM_UTILS_ERROR_MSG_INSUFF_PRIV);
|
||||
}
|
||||
|
||||
auth_data->callback (self,
|
||||
|
|
@ -1268,7 +1268,7 @@ _new_auth_subject (GDBusMethodInvocation *context, GError **error)
|
|||
g_set_error_literal (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Unable to determine UID of request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
}
|
||||
|
||||
return subject;
|
||||
|
|
|
|||
|
|
@ -2421,7 +2421,7 @@ pk_add_cb (NMAuthChain *chain,
|
|||
if (result != NM_AUTH_CALL_RESULT_YES) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Insufficient privileges.");
|
||||
NM_UTILS_ERROR_MSG_INSUFF_PRIV);
|
||||
} else {
|
||||
/* Authorized */
|
||||
connection = nm_auth_chain_get_data (chain, "connection");
|
||||
|
|
@ -2510,7 +2510,7 @@ nm_settings_add_connection_dbus (NMSettings *self,
|
|||
if (!chain) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Unable to authenticate the request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2594,7 +2594,7 @@ settings_add_connection_helper (NMSettings *self,
|
|||
g_dbus_method_invocation_return_error_literal (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Unable to determine UID of request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2935,7 +2935,7 @@ impl_settings_get_connection_by_uuid (NMDBusObject *obj,
|
|||
if (!subject) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Unable to determine UID of request.");
|
||||
NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -3282,7 +3282,7 @@ pk_hostname_cb (NMAuthChain *chain,
|
|||
if (result != NM_AUTH_CALL_RESULT_YES) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Insufficient privileges.");
|
||||
NM_UTILS_ERROR_MSG_INSUFF_PRIV);
|
||||
} else {
|
||||
hostname = nm_auth_chain_get_data (chain, "hostname");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue