chiark / gitweb /
bus: minor fixes
[elogind.git] / src / libsystemd-bus / bus-message.c
index e0fb1f41db0a8b762604a2af9fca61314fdfc8c3..721dafe38b800c761b635856ac03631fe5ca7390 100644 (file)
@@ -3555,8 +3555,10 @@ int bus_message_parse_fields(sd_bus_message *m) {
 }
 
 int bus_message_seal(sd_bus_message *m, uint64_t serial) {
-        int r;
+        struct bus_body_part *part;
         size_t l, a;
+        unsigned i;
+        int r;
 
         assert(m);
 
@@ -3566,6 +3568,9 @@ int bus_message_seal(sd_bus_message *m, uint64_t serial) {
         if (m->n_containers > 0)
                 return -EBADMSG;
 
+        if (m->poisoned)
+                return -ESTALE;
+
         /* If there's a non-trivial signature set, then add it in here */
         if (!isempty(m->root_container.signature)) {
                 r = message_append_field_signature(m, SD_BUS_MESSAGE_HEADER_SIGNATURE, m->root_container.signature, NULL);
@@ -3595,6 +3600,10 @@ int bus_message_seal(sd_bus_message *m, uint64_t serial) {
                 m->header->fields_size -= a;
         }
 
+        for (i = 0, part = &m->body; i < m->n_body_parts; i++, part = part->next)
+                if (part->memfd >= 0 && part->sealed)
+                        ioctl(part->memfd, KDBUS_CMD_MEMFD_SEAL_SET, 1);
+
         m->header->serial = serial;
         m->sealed = true;