chiark / gitweb /
sd-bus: update to current kernel version, by splitting off the extended KDBUS_ITEM_PI...
[elogind.git] / src / bus-proxyd / bus-proxyd.c
index d6607edfd6513ed10852a0789ed02684a8a1316f..32c82422211f4fd6493a4969833103ec9e71e71a 100644 (file)
@@ -412,8 +412,6 @@ static int get_creds_by_name(sd_bus *bus, const char *name, uint64_t mask, sd_bu
         assert(name);
         assert(_creds);
 
-        assert_return(service_name_is_valid(name), -EINVAL);
-
         r = sd_bus_get_name_creds(bus, name, mask, &c);
         if (r == -ESRCH || r == -ENXIO)
                 return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", name);
@@ -444,29 +442,6 @@ static int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, s
         return get_creds_by_name(bus, name, mask, _creds, error);
 }
 
-static int peer_is_privileged(sd_bus *bus, sd_bus_message *m) {
-        _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
-        uid_t uid;
-        int r;
-
-        r = get_creds_by_message(bus, m, SD_BUS_CREDS_UID, &creds, NULL);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_creds_get_uid(creds, &uid);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_creds_has_effective_cap(creds, CAP_SYS_ADMIN);
-        if (r > 0)
-                return true;
-
-        if (uid == getuid())
-                return true;
-
-        return false;
-}
-
 static int process_policy(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred) {
         int r;
         char **name;
@@ -792,9 +767,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(arg0))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 r = sd_bus_get_name_creds(a, arg0, 0, NULL);
                 if (r == -ESRCH || r == -ENXIO) {
                         sd_bus_error_setf(&error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Could not get owners of name '%s': no such name.", arg0);
@@ -853,9 +825,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 if (streq(name, "org.freedesktop.DBus"))
                         return synthetic_reply_method_return(m, "b", true);
 
@@ -872,9 +841,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
-
                 r = sd_bus_release_name(a, name);
                 if (r < 0) {
                         if (r == -ESRCH)
@@ -908,8 +874,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (policy && !policy_check_own(policy, ucred, name))
                         return synthetic_reply_method_errno(m, -EPERM, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
                 if ((flags & ~(BUS_NAME_ALLOW_REPLACEMENT|BUS_NAME_REPLACE_EXISTING|BUS_NAME_DO_NOT_QUEUE)) != 0)
                         return synthetic_reply_method_errno(m, -EINVAL, NULL);
 
@@ -950,8 +914,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
-                if (!service_name_is_valid(name))
-                        return synthetic_reply_method_errno(m, -EINVAL, NULL);
                 if (flags != 0)
                         return synthetic_reply_method_errno(m, -EINVAL, NULL);
 
@@ -981,9 +943,6 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 _cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
                 _cleanup_strv_free_ char **args = NULL;
 
-                if (!peer_is_privileged(a, m))
-                        return synthetic_reply_method_errno(m, -EPERM, NULL);
-
                 r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{ss}");
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
@@ -1283,9 +1242,17 @@ int main(int argc, char *argv[]) {
         }
 
         if (ucred.pid > 0) {
-                a->fake_creds.pid = ucred.pid;
+                a->fake_pids.pid = ucred.pid;
+                a->fake_pids_valid = true;
+
                 a->fake_creds.uid = ucred.uid;
+                a->fake_creds.euid = (uid_t) -1;
+                a->fake_creds.suid = (uid_t) -1;
+                a->fake_creds.fsuid = (uid_t) -1;
                 a->fake_creds.gid = ucred.gid;
+                a->fake_creds.egid = (gid_t) -1;
+                a->fake_creds.sgid = (gid_t) -1;
+                a->fake_creds.fsgid = (gid_t) -1;
                 a->fake_creds_valid = true;
         }
 
@@ -1478,8 +1445,10 @@ int main(int argc, char *argv[]) {
 
                         assert_se(sd_bus_creds_get_uid(bus_creds, &uid) == 0);
 
+/*
                         if (uid == 0 || uid != ucred.uid)
                                 p = &policy;
+*/
 
                         /* We officially got EOF, let's quit */
                         if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {