X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbus-proxyd%2Ftest-bus-policy.c;h=c9a027e8771bd9a4cd08e59fadf09b1199533b59;hb=5034c7bcdfc4493ed3c30722e9d897c8da78fede;hp=900e4d2b067e3d4bde308c4639d4603dc2afbe62;hpb=45f1b67a70a749ca14a7df256a177de74a3e73f6;p=elogind.git diff --git a/src/bus-proxyd/test-bus-policy.c b/src/bus-proxyd/test-bus-policy.c index 900e4d2b0..c9a027e87 100644 --- a/src/bus-proxyd/test-bus-policy.c +++ b/src/bus-proxyd/test-bus-policy.c @@ -36,7 +36,6 @@ #include "bus-internal.h" #include "bus-message.h" #include "bus-util.h" -#include "bus-internal.h" #include "build.h" #include "strv.h" #include "def.h" @@ -46,18 +45,17 @@ static int test_policy_load(Policy *p, const char *name) { - char *path; + _cleanup_free_ char *path = NULL; int r = 0; path = strjoin(TEST_DIR, "/bus-policy/", name, NULL); + assert_se(path); if (access(path, R_OK) == 0) policy_load(p, STRV_MAKE(path)); else r = -ENOENT; - free(path); - return r; } @@ -65,8 +63,6 @@ int main(int argc, char *argv[]) { Policy p = {}; struct ucred ucred = {}; - char **names_strv; - Hashmap *names_hash; /* Ownership tests */ assert_se(test_policy_load(&p, "ownerships.conf") == 0); @@ -95,32 +91,27 @@ int main(int argc, char *argv[]) { /* Signaltest */ assert_se(test_policy_load(&p, "signals.conf") == 0); - names_strv = STRV_MAKE("bli.bla.blubb"); ucred.uid = 0; - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_SIGNAL, NULL, "/an/object/path", NULL) == true); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == true); ucred.uid = 1; - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_SIGNAL, NULL, "/an/object/path", NULL) == false); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == false); policy_free(&p); /* Method calls */ assert_se(test_policy_load(&p, "methods.conf") == 0); - names_strv = STRV_MAKE("org.test.test1"); policy_dump(&p); ucred.uid = 0; - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_METHOD_CALL, "/an/object/path", "bli.bla.blubb", "Member") == false); - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_METHOD_CALL, "/an/object/path", "bli.bla.blubb", "Member") == false); - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_METHOD_CALL, "/an/object/path", "org.test.int1", "Member") == true); - assert_se(policy_check_send(&p, &ucred, names_strv, SD_BUS_MESSAGE_METHOD_CALL, "/an/object/path", "org.test.int2", "Member") == true); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int1", "Member") == true); + assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == true); - names_hash = hashmap_new(&string_hash_ops); - assert(names_hash != NULL); - assert_se(hashmap_put(names_hash, "org.test.test3", NULL) >= 0); - assert_se(policy_check_recv(&p, &ucred, names_hash, SD_BUS_MESSAGE_METHOD_CALL, "/an/object/path", "org.test.int3", "Member111") == true); + assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test3", "/an/object/path", "org.test.int3", "Member111") == true); policy_free(&p);