+
+int session_send_lock_all(Manager *m, bool lock) {
+ Session *session;
+ Iterator i;
+ int r = 0;
+
+ assert(m);
+
+ HASHMAP_FOREACH(session, m->sessions, i) {
+ int k;
+
+ k = session_send_lock(session, lock);
+ if (k < 0)
+ r = k;
+ }
+
+ return r;
+}
+
+int session_send_create_reply(Session *s, DBusError *error) {
+ _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+
+ assert(s);
+
+ if (!s->create_message)
+ return 0;
+
+ if (error) {
+ DBusError buffer;
+
+ dbus_error_init(&buffer);
+
+ if (!dbus_error_is_set(error)) {
+ dbus_set_error_const(&buffer, DBUS_ERROR_INVALID_ARGS, "Invalid Arguments");
+ error = &buffer;
+ }
+
+ reply = dbus_message_new_error(s->create_message, error->name, error->message);
+ dbus_error_free(&buffer);
+
+ if (!reply)
+ return log_oom();
+ } else {
+ _cleanup_close_ int fifo_fd = -1;
+ _cleanup_free_ char *path = NULL;
+ const char *cseat;
+ uint32_t vtnr;
+ dbus_bool_t exists;
+
+ fifo_fd = session_create_fifo(s);
+ if (fifo_fd < 0) {
+ log_error("Failed to create fifo: %s", strerror(-fifo_fd));
+ return fifo_fd;
+ }
+
+ path = session_bus_path(s);
+ if (!path)
+ return log_oom();
+
+ reply = dbus_message_new_method_return(s->create_message);
+ if (!reply)
+ return log_oom();
+
+ cseat = s->seat ? s->seat->id : "";
+ vtnr = s->vtnr;
+ exists = false;
+
+ if (!dbus_message_append_args(
+ reply,
+ DBUS_TYPE_STRING, &s->id,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_STRING, &s->user->runtime_path,
+ DBUS_TYPE_UNIX_FD, &fifo_fd,
+ DBUS_TYPE_STRING, &cseat,
+ DBUS_TYPE_UINT32, &vtnr,
+ DBUS_TYPE_BOOLEAN, &exists,
+ DBUS_TYPE_INVALID))
+ return log_oom();
+ }
+
+ if (!dbus_connection_send(s->manager->bus, reply, NULL))
+ return log_oom();
+
+ dbus_message_unref(s->create_message);
+ s->create_message = NULL;
+
+ return 0;
+}