chiark / gitweb /
bus-proxyd: enforce policy for Hello messages
authorDaniel Mack <daniel@zonque.org>
Wed, 24 Sep 2014 15:18:35 +0000 (17:18 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 11 Nov 2014 13:14:01 +0000 (14:14 +0100)
src/bus-proxyd/bus-proxyd.c

index aaa79243cf8d2b435852b6a1e3730427557e6977..a6554aba3b8da00ab2fb70c02f595106b573ac8e 100644 (file)
@@ -997,7 +997,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m) {
         }
 }
 
-static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hello) {
+static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred, bool *got_hello) {
         _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
         bool is_hello;
         int r;
@@ -1029,6 +1029,11 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell
                 return -EIO;
         }
 
+        if (!policy_check_hello(policy, ucred)) {
+                log_error("Policy denied HELLO");
+                return -EPERM;
+        }
+
         *got_hello = true;
 
         if (!a->is_kernel)
@@ -1418,7 +1423,7 @@ int main(int argc, char *argv[]) {
                                 goto finish;
                         }
 
-                        k = process_hello(a, b, m, &got_hello);
+                        k = process_hello(a, b, m, &policy, &ucred, &got_hello);
                         if (k < 0) {
                                 r = k;
                                 log_error("Failed to process HELLO: %s", strerror(-r));