chiark / gitweb /
sd-bus: move common errors src/shared/bus-errors.h → src/libsystemd/sd-bus/bus-common...
[elogind.git] / src / libsystemd / sd-bus / bus-control.c
index a9a0c1ec1909a2199dd974509580320b1530f519..813c97f6501f6a022152f294b06739c718da131b 100644 (file)
@@ -405,11 +405,6 @@ static int bus_populate_creds_from_items(
                                 c->mask |= SD_BUS_CREDS_TID;
                         }
 
-                        if (mask & SD_BUS_CREDS_PID_STARTTIME && item->pids.starttime > 0) {
-                                c->pid_starttime = item->pids.starttime;
-                                c->mask |= SD_BUS_CREDS_PID_STARTTIME;
-                        }
-
                         break;
 
                 case KDBUS_ITEM_CREDS:
@@ -600,10 +595,11 @@ static int bus_populate_creds_from_items(
         return 0;
 }
 
-static int bus_get_name_creds_kdbus(
+int bus_get_name_creds_kdbus(
                 sd_bus *bus,
                 const char *name,
                 uint64_t mask,
+                bool allow_activator,
                 sd_bus_creds **creds) {
 
         _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
@@ -652,7 +648,7 @@ static int bus_get_name_creds_kdbus(
         conn_info = (struct kdbus_info *) ((uint8_t *) bus->kdbus_buffer + cmd->offset);
 
         /* Non-activated names are considered not available */
-        if (conn_info->flags & KDBUS_HELLO_ACTIVATOR) {
+        if (!allow_activator && (conn_info->flags & KDBUS_HELLO_ACTIVATOR)) {
                 if (name[0] == ':')
                         r = -ENXIO;
                 else
@@ -750,8 +746,7 @@ static int bus_get_name_creds_dbus1(
 
                 if ((mask & SD_BUS_CREDS_PID) ||
                     ((mask & SD_BUS_CREDS_AUGMENT) &&
-                     (mask & (SD_BUS_CREDS_PID_STARTTIME|
-                              SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
+                     (mask & (SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
                               SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
                               SD_BUS_CREDS_COMM|SD_BUS_CREDS_EXE|SD_BUS_CREDS_CMDLINE|
                               SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_CREDS_OWNER_UID|
@@ -875,7 +870,7 @@ _public_ int sd_bus_get_name_creds(
                 return -ENOTCONN;
 
         if (bus->is_kernel)
-                return bus_get_name_creds_kdbus(bus, name, mask, creds);
+                return bus_get_name_creds_kdbus(bus, name, mask, false, creds);
         else
                 return bus_get_name_creds_dbus1(bus, name, mask, creds);
 }
@@ -1179,6 +1174,10 @@ int bus_add_match_internal_kernel(
 
         assert(bus);
 
+        /* Monitor streams don't support matches, make this a NOP */
+        if (bus->hello_flags & KDBUS_HELLO_MONITOR)
+                return 0;
+
         bloom = alloca0(bus->bloom_size);
 
         sz = ALIGN8(offsetof(struct kdbus_cmd_match, items));
@@ -1391,6 +1390,10 @@ int bus_remove_match_internal_kernel(
 
         assert(bus);
 
+        /* Monitor streams don't support matches, make this a NOP */
+        if (bus->hello_flags & KDBUS_HELLO_MONITOR)
+                return 0;
+
         zero(m);
         m.size = offsetof(struct kdbus_cmd_match, items);
         m.cookie = cookie;