diff options
author | Holger Macht <holger@homac.de> | 2006-10-26 17:04:44 +0200 |
---|---|---|
committer | Holger Macht <holger@homac.de> | 2006-10-26 17:04:44 +0200 |
commit | ad6be7e3e12b629ea60d581b614c948416d4f776 (patch) | |
tree | 366cd0280b089358ca6e5955a67413dd240e0070 | |
parent | 6cea793bf43584d0a8e5e98cbe6cc1e00ea8b192 (diff) |
catch error if call to PolicyKit failed
-rw-r--r-- | liblazy/liblazy_polkit.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/liblazy/liblazy_polkit.c b/liblazy/liblazy_polkit.c index 3bfd4c6..1742fd0 100644 --- a/liblazy/liblazy_polkit.c +++ b/liblazy/liblazy_polkit.c @@ -42,7 +42,7 @@ int liblazy_polkit_is_user_allowed_by_name(char *user, DBusConnection *dbus_connection; const char *unique_name; int is_allowed; - int ret = 0; + int error = 0; dbus_error_init(&dbus_error); @@ -60,22 +60,25 @@ int liblazy_polkit_is_user_allowed_by_name(char *user, if (ressource == NULL) ressource = ""; - ret = liblazy_dbus_system_send_method_call(DBUS_POLKIT_SERVICE, - DBUS_POLKIT_PATH, - DBUS_POLKIT_INTERFACE, - "IsUserPrivileged", - &reply, - DBUS_TYPE_STRING, &unique_name, - DBUS_TYPE_STRING, &user, - DBUS_TYPE_STRING, &privilege, - DBUS_TYPE_STRING, &ressource, - DBUS_TYPE_INVALID); + error = liblazy_dbus_system_send_method_call(DBUS_POLKIT_SERVICE, + DBUS_POLKIT_PATH, + DBUS_POLKIT_INTERFACE, + "IsUserPrivileged", + &reply, + DBUS_TYPE_STRING, &unique_name, + DBUS_TYPE_STRING, &user, + DBUS_TYPE_STRING, &privilege, + DBUS_TYPE_STRING, &ressource, + DBUS_TYPE_INVALID); - ret = liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_BOOLEAN, - &is_allowed, 0); + if (error) + return error; + + error = liblazy_dbus_message_get_basic_arg(reply, DBUS_TYPE_BOOLEAN, + &is_allowed, 0); dbus_message_unref(reply); - if (ret) - return ret; + if (error) + return error; return is_allowed; } |