Skip to content

Commit

Permalink
Revert "Implement LogControl1 protocol for dynamic log level changes"
Browse files Browse the repository at this point in the history
After a long discussion, the polkit team decided to revert the
implementation of LogControl1 in polkit for the following reasons:
1. The authentication/authorization part of changing LogLevel needs to
   be implemented. Without it, any user can change log level via busctl.
   Issue: !507
2. Issue: !506
After all these issues are addressed, re-integration of the protocol can
be later reconsidered.
LogControl1 is not widely used so far, therefore no major damage will
be caused by postponing the integration of the protocol within polkit.

This reverts commit 79d84d0.
  • Loading branch information
jrybar-rh committed Oct 29, 2024
1 parent 8cf58ab commit d02649a
Showing 1 changed file with 8 additions and 115 deletions.
123 changes: 8 additions & 115 deletions src/polkitbackend/polkitbackendauthority.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ polkit_backend_authority_revoke_temporary_authorization_by_id (PolkitBackendAuth
typedef struct
{
guint authority_registration_id;
guint log_control_registration_id;

GDBusNodeInfo *introspection_info;

Expand All @@ -527,9 +526,6 @@ server_free (Server *server)
if (server->authority_registration_id > 0)
g_dbus_connection_unregister_object (server->connection, server->authority_registration_id);

if (server->log_control_registration_id > 0)
g_dbus_connection_unregister_object (server->connection, server->log_control_registration_id);

if (server->connection != NULL)
g_object_unref (server->connection);

Expand Down Expand Up @@ -654,17 +650,6 @@ static const gchar *server_introspection_data =
" <property type='s' name='BackendVersion' access='read'/>"
" <property type='u' name='BackendFeatures' access='read'/>"
" </interface>"
" <interface name='org.freedesktop.LogControl1'>"
" <property type='s' name='LogLevel' access='readwrite'>"
" <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='false'/>"
" </property>"
" <property type='s' name='LogTarget' access='readwrite'>"
" <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='false'/>"
" </property>"
" <property type='s' name='SyslogIdentifier' access='read'>"
" <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='false'/>"
" </property>"
" </interface>"
"</node>";

/* ---------------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -1364,95 +1349,22 @@ server_handle_get_property (GDBusConnection *connection,

result = NULL;

if (g_strcmp0 (interface_name, "org.freedesktop.PolicyKit1.Authority") == 0)
if (g_strcmp0 (property_name, "BackendName") == 0)
{
if (g_strcmp0 (property_name, "BackendName") == 0)
{
result = g_variant_new_string (polkit_backend_authority_get_name (server->authority));
}
else if (g_strcmp0 (property_name, "BackendVersion") == 0)
{
result = g_variant_new_string (polkit_backend_authority_get_version (server->authority));
}
else if (g_strcmp0 (property_name, "BackendFeatures") == 0)
{
result = g_variant_new_uint32 (polkit_backend_authority_get_features (server->authority));
}
else
g_assert_not_reached ();
result = g_variant_new_string (polkit_backend_authority_get_name (server->authority));
}
else if (g_strcmp0 (interface_name, "org.freedesktop.LogControl1") == 0)
else if (g_strcmp0 (property_name, "BackendVersion") == 0)
{
if (g_strcmp0 (property_name, "LogLevel") == 0)
{
switch (polkit_authority_log_level)
{
case LOG_LEVEL_EMERG:
result = g_variant_new_string ("emerg");
break;
case LOG_LEVEL_ALERT:
result = g_variant_new_string ("alert");
break;
case LOG_LEVEL_CRIT:
result = g_variant_new_string ("crit");
break;
case LOG_LEVEL_ERROR:
result = g_variant_new_string ("err");
break;
case LOG_LEVEL_WARNING:
result = g_variant_new_string ("warn");
break;
case LOG_LEVEL_NOTICE:
result = g_variant_new_string ("notice");
break;
case LOG_LEVEL_INFO:
result = g_variant_new_string ("info");
break;
case LOG_LEVEL_DEBUG:
result = g_variant_new_string ("debug");
break;
}
}
else if (g_strcmp0 (property_name, "LogTarget") == 0)
{
result = g_variant_new_string ("syslog");
}
else if (g_strcmp0 (property_name, "SyslogIdentifier") == 0)
{
result = g_variant_new_string ("polkitd");
}
else
g_assert_not_reached ();

result = g_variant_new_string (polkit_backend_authority_get_version (server->authority));
}

return result;
}

static gboolean
server_handle_set_property (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *property_name,
GVariant *value,
GError **error,
gpointer user_data)
{
if (g_strcmp0 (interface_name, "org.freedesktop.LogControl1") != 0)
return FALSE;

if (g_strcmp0 (property_name, "LogLevel") == 0)
else if (g_strcmp0 (property_name, "BackendFeatures") == 0)
{
const gchar *level;

g_variant_get (value, "&s", &level);
polkit_backend_authority_set_log_level (level);
result = g_variant_new_uint32 (polkit_backend_authority_get_features (server->authority));
}
else
return FALSE;
g_assert_not_reached ();

return TRUE;
return result;
}

/* ---------------------------------------------------------------------------------------------------- */
Expand All @@ -1464,13 +1376,6 @@ static const GDBusInterfaceVTable server_vtable =
NULL, /* server_handle_set_property */
};

static const GDBusInterfaceVTable logcontrol_vtable =
{
NULL, /* server_handle_method_call */
server_handle_get_property,
server_handle_set_property,
};

/**
* polkit_backend_authority_unregister:
* @registration_id: A #gpointer obtained from polkit_backend_authority_register().
Expand Down Expand Up @@ -1526,18 +1431,6 @@ polkit_backend_authority_register (PolkitBackendAuthority *authority,
goto error;
}

server->log_control_registration_id = g_dbus_connection_register_object (server->connection,
"/org/freedesktop/LogControl1",
g_dbus_node_info_lookup_interface (server->introspection_info, "org.freedesktop.LogControl1"),
&logcontrol_vtable,
server,
NULL,
error);
if (server->log_control_registration_id == 0)
{
goto error;
}

server->authority = g_object_ref (authority);

server->authority_changed_id = g_signal_connect (server->authority,
Expand Down

0 comments on commit d02649a

Please sign in to comment.