core: make nm_auth_get_caller_uid() error description non-const

For consistency with the next commit, so we don't need to remember
when to free the description or not.
This commit is contained in:
Dan Williams
2010-11-18 13:47:04 -06:00
parent c3c9d93b1d
commit eccca738aa
5 changed files with 17 additions and 11 deletions

View File

@@ -327,7 +327,7 @@ gboolean
nm_auth_get_caller_uid (DBusGMethodInvocation *context,
NMDBusManager *dbus_mgr,
gulong *out_uid,
const char **out_error_desc)
char **out_error_desc)
{
DBusConnection *connection;
char *sender = NULL;
@@ -348,14 +348,14 @@ nm_auth_get_caller_uid (DBusGMethodInvocation *context,
sender = dbus_g_method_get_sender (context);
if (!sender) {
if (out_error_desc)
*out_error_desc = "Could not determine D-Bus requestor";
*out_error_desc = g_strdup ("Could not determine D-Bus requestor");
goto out;
}
connection = nm_dbus_manager_get_dbus_connection (dbus_mgr);
if (!connection) {
if (out_error_desc)
*out_error_desc = "Could not get the D-Bus system bus";
*out_error_desc = g_strdup ("Could not get the D-Bus system bus");
goto out;
}
@@ -364,7 +364,7 @@ nm_auth_get_caller_uid (DBusGMethodInvocation *context,
*out_uid = dbus_bus_get_unix_user (connection, sender, &dbus_error);
if (dbus_error_is_set (&dbus_error)) {
if (out_error_desc)
*out_error_desc = "Could not determine the user ID of the requestor";
*out_error_desc = g_strdup_printf ("Could not determine the user ID of the requestor");
dbus_error_free (&dbus_error);
*out_uid = G_MAXULONG;
} else

View File

@@ -89,7 +89,7 @@ void nm_auth_chain_unref (NMAuthChain *chain);
gboolean nm_auth_get_caller_uid (DBusGMethodInvocation *context,
NMDBusManager *dbus_mgr,
gulong *out_uid,
const char **out_error_desc);
char **out_error_desc);
#endif /* NM_MANAGER_AUTH_H */

View File

@@ -685,7 +685,7 @@ static void
pending_activation_check_authorized (PendingActivation *pending,
NMDBusManager *dbus_mgr)
{
const char *error_desc = NULL;
char *error_desc = NULL;
gulong sender_uid = G_MAXULONG;
GError *error;
@@ -701,6 +701,7 @@ pending_activation_check_authorized (PendingActivation *pending,
error_desc);
pending->callback (pending, error);
g_error_free (error);
g_free (error_desc);
return;
}
@@ -1225,7 +1226,7 @@ manager_device_disconnect_request (NMDevice *device,
NMActRequest *req;
GError *error = NULL;
gulong sender_uid = G_MAXULONG;
const char *error_desc = NULL;
char *error_desc = NULL;
req = nm_device_get_act_request (device);
if (!req) {
@@ -1249,6 +1250,7 @@ manager_device_disconnect_request (NMDevice *device,
error_desc);
dbus_g_method_return_error (context, error);
g_error_free (error);
g_free (error_desc);
return;
}
@@ -2225,7 +2227,7 @@ impl_manager_deactivate_connection (NMManager *self,
GSList *iter;
NMAuthChain *chain;
gulong sender_uid = G_MAXULONG;
const char *error_desc = NULL;
char *error_desc = NULL;
/* Check for device connections first */
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
@@ -2267,6 +2269,7 @@ impl_manager_deactivate_connection (NMManager *self,
error_desc);
dbus_g_method_return_error (context, error);
g_error_free (error);
g_free (error_desc);
return;
}
@@ -2599,7 +2602,7 @@ impl_manager_enable (NMManager *self,
NMAuthChain *chain;
GError *error = NULL;
gulong sender_uid = G_MAXULONG;
const char *error_desc = NULL;
char *error_desc = NULL;
g_return_if_fail (NM_IS_MANAGER (self));
@@ -2620,6 +2623,7 @@ impl_manager_enable (NMManager *self,
error_desc);
dbus_g_method_return_error (context, error);
g_error_free (error);
g_free (error_desc);
return;
}

View File

@@ -808,7 +808,7 @@ pk_add_cb (NMAuthChain *chain,
NMConnection *connection;
NMSysconfigConnection *added;
gulong caller_uid = G_MAXULONG;
const char *error_desc = NULL;
char *error_desc = NULL;
priv->auths = g_slist_remove (priv->auths, chain);
@@ -839,6 +839,7 @@ pk_add_cb (NMAuthChain *chain,
NM_SETTINGS_ERROR_NOT_PRIVILEGED,
"Unable to determine UID of request: %s.",
error_desc ? error_desc : "(unknown)");
g_free (error_desc);
goto done;
}

View File

@@ -629,7 +629,7 @@ auth_start (NMSysconfigConnection *self,
gulong sender_uid = G_MAXULONG;
GError *error = NULL;
char *sender;
const char *error_desc = NULL;
char *error_desc = NULL;
PolkitSubject *subject;
/* Get the caller's UID */
@@ -637,6 +637,7 @@ auth_start (NMSysconfigConnection *self,
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
error_desc);
g_free (error);
goto error;
}