mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-29 21:50:11 +01:00
bus_context_log_and_set_error: add and use
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810 Reviewed-by: Philip Withnall
This commit is contained in:
parent
c6e024834b
commit
652a324fb6
4 changed files with 39 additions and 25 deletions
|
|
@ -1478,11 +1478,8 @@ pending_activation_timed_out (void *data)
|
|||
|
||||
dbus_error_init (&error);
|
||||
|
||||
dbus_set_error (&error, DBUS_ERROR_TIMED_OUT,
|
||||
"Activation of %s timed out",
|
||||
pending_activation->service_name);
|
||||
bus_context_log (pending_activation->activation->context,
|
||||
DBUS_SYSTEM_LOG_INFO,
|
||||
bus_context_log_and_set_error (pending_activation->activation->context,
|
||||
DBUS_SYSTEM_LOG_INFO, &error, DBUS_ERROR_TIMED_OUT,
|
||||
"Failed to activate service '%s': timed out",
|
||||
pending_activation->service_name);
|
||||
|
||||
|
|
|
|||
23
bus/bus.c
23
bus/bus.c
|
|
@ -1394,6 +1394,29 @@ bus_context_log_literal (BusContext *context,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bus_context_log_and_set_error (BusContext *context,
|
||||
DBusSystemLogSeverity severity,
|
||||
DBusError *error,
|
||||
const char *name,
|
||||
const char *msg,
|
||||
...)
|
||||
{
|
||||
DBusError stack_error = DBUS_ERROR_INIT;
|
||||
va_list args;
|
||||
|
||||
va_start (args, msg);
|
||||
_dbus_set_error_valist (&stack_error, name, msg, args);
|
||||
va_end (args);
|
||||
|
||||
/* If we hit OOM while setting the error, this will syslog "out of memory"
|
||||
* which is itself an indication that something is seriously wrong */
|
||||
bus_context_log_literal (context, DBUS_SYSTEM_LOG_SECURITY,
|
||||
stack_error.message);
|
||||
|
||||
dbus_move_error (&stack_error, error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Log something about a message, usually that it was rejected.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -124,6 +124,12 @@ void bus_context_log (BusContext
|
|||
void bus_context_log_literal (BusContext *context,
|
||||
DBusSystemLogSeverity severity,
|
||||
const char *msg);
|
||||
void bus_context_log_and_set_error (BusContext *context,
|
||||
DBusSystemLogSeverity severity,
|
||||
DBusError *error,
|
||||
const char *name,
|
||||
const char *msg,
|
||||
...) _DBUS_GNUC_PRINTF (5, 6);
|
||||
dbus_bool_t bus_context_check_security_policy (BusContext *context,
|
||||
BusTransaction *transaction,
|
||||
DBusConnection *sender,
|
||||
|
|
|
|||
28
bus/driver.c
28
bus/driver.c
|
|
@ -106,14 +106,8 @@ bus_driver_check_caller_is_privileged (DBusConnection *connection,
|
|||
{
|
||||
const char *method = dbus_message_get_member (message);
|
||||
|
||||
/* Yes this repetition is pretty horrible, but there's no
|
||||
* bus_context_log_valist() or dbus_set_error_valist() or
|
||||
* bus_context_log_literal() or dbus_set_error_literal().
|
||||
*/
|
||||
bus_context_log (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY,
|
||||
"rejected attempt to call %s by unknown uid", method);
|
||||
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
|
||||
bus_context_log_and_set_error (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY, error, DBUS_ERROR_ACCESS_DENIED,
|
||||
"rejected attempt to call %s by unknown uid", method);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -133,10 +127,8 @@ bus_driver_check_caller_is_privileged (DBusConnection *connection,
|
|||
{
|
||||
const char *method = dbus_message_get_member (message);
|
||||
|
||||
bus_context_log (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY,
|
||||
"rejected attempt to call %s by uid %lu", method, uid);
|
||||
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
|
||||
bus_context_log_and_set_error (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY, error, DBUS_ERROR_ACCESS_DENIED,
|
||||
"rejected attempt to call %s by uid %lu", method, uid);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -150,10 +142,8 @@ bus_driver_check_caller_is_privileged (DBusConnection *connection,
|
|||
{
|
||||
const char *method = dbus_message_get_member (message);
|
||||
|
||||
bus_context_log (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY,
|
||||
"rejected attempt to call %s by unknown uid", method);
|
||||
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
|
||||
bus_context_log_and_set_error (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY, error, DBUS_ERROR_ACCESS_DENIED,
|
||||
"rejected attempt to call %s by unknown uid", method);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -162,10 +152,8 @@ bus_driver_check_caller_is_privileged (DBusConnection *connection,
|
|||
{
|
||||
const char *method = dbus_message_get_member (message);
|
||||
|
||||
bus_context_log (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY,
|
||||
"rejected attempt to call %s by uid %s", method, windows_sid);
|
||||
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
|
||||
bus_context_log_and_set_error (bus_transaction_get_context (transaction),
|
||||
DBUS_SYSTEM_LOG_SECURITY, error, DBUS_ERROR_ACCESS_DENIED,
|
||||
"rejected attempt to call %s by uid %s", method, windows_sid);
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue