NACK - creating a macro just to save ~15 chars?? really?
On 06/28/2012 12:10 PM, Nikola Pajkovsky wrote:
I'm getting be lazy, so I did only rename of that loong function by define Signed-off-by: Nikola Pajkovsky <[email protected]> --- src/dbus/abrt-dbus.c | 10 +++++----- src/dbus/abrt-polkit.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c index 0322e64..b02b3cc 100644 --- a/src/dbus/abrt-dbus.c +++ b/src/dbus/abrt-dbus.c @@ -407,7 +407,7 @@ static void handle_method_call(GDBusConnection *connection, */ if (caller_uid != 0) { - if (polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") == PolkitYes) + if (polkit_chk_auth_dname(caller, "getall") == PolkitYes) caller_uid = 0; } @@ -436,7 +436,7 @@ static void handle_method_call(GDBusConnection *connection, return; } - if (polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") != PolkitYes) + if (polkit_chk_auth_dname(caller, "getall") != PolkitYes) { VERB1 log("not authorized"); g_dbus_method_invocation_return_dbus_error(invocation, @@ -509,7 +509,7 @@ static void handle_method_call(GDBusConnection *connection, if (!dir_accessible_by_uid(problem_dir, caller_uid)) { - if (polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") != PolkitYes) + if (polkit_chk_auth_dname(caller, "getall") != PolkitYes) { VERB1 log("not authorized"); g_dbus_method_invocation_return_dbus_error(invocation, @@ -583,7 +583,7 @@ static void handle_method_call(GDBusConnection *connection, const char *dir_name = (const char*)l->data; if (!dir_accessible_by_uid(dir_name, caller_uid)) { - if (polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") != PolkitYes) + if (polkit_chk_auth_dname(caller, "getall") != PolkitYes) { // if user didn't provide correct credentials, just move to the next dir continue; } @@ -607,7 +607,7 @@ static void handle_method_call(GDBusConnection *connection, g_variant_get(parameters, "(ssxxb)", &element, &value, ×tamp_from, ×tamp_to, &all); - if (all && polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") == PolkitYes) + if (all && polkit_chk_auth_dname(caller, "getall") == PolkitYes) caller_uid = 0; response = get_problem_dirs_for_element_in_time(caller_uid, element, value, timestamp_from, diff --git a/src/dbus/abrt-polkit.h b/src/dbus/abrt-polkit.h index 0f6eb1e..f7d66a3 100644 --- a/src/dbus/abrt-polkit.h +++ b/src/dbus/abrt-polkit.h @@ -33,6 +33,9 @@ typedef enum { PolkitChallenge = 0x03 } PolkitResult; +#define polkit_chk_auth_dname(dbus_name, action) \ + polkit_check_authorization_dname(dbus_name, ABRT_DBUS_NAME"." #action) + PolkitResult polkit_check_authorization_dname(const char *dbus_name, const char *action_id); PolkitResult polkit_check_authorization_pid(pid_t pid, const char *action_id);
