# This file is part of elogind.
+# SPDX-License-Identifier: LGPL-2.1+
#
# elogind is free software; you can redistribute it and/or modify it
+#
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@rootlibdir@
-includedir=@includedir@/elogind
+includedir=@includedir@
Name: elogind
Description: elogind Library
/***
+ SPDX-License-Identifier: LGPL-2.1+
+
This file is part of systemd.
systemd is free software; you can redistribute it and/or modify it
sd_listen_fds_with_names;
} LIBSYSTEMD_226;
-/*
- * These methods are not needed by elogind.
- * LIBSYSTEMD_229 {
- * global:
- * sd_journal_has_runtime_files;
- * sd_journal_has_persistent_files;
- * sd_journal_enumerate_fields;
- * sd_journal_restart_fields;
- * } LIBSYSTEMD_227;
-*/
-/*
- * These methods are not needed by elogind.
- * LIBSYSTEMD_230 {
- * global:
- * sd_journal_open_directory_fd;
- * sd_journal_open_files_fd;
- * } LIBSYSTEMD_229;
-*/
-
+/** if 0 /// UNNEEDED by elogind
+ * LIBSYSTEMD_229 {
+ * global:
+ * sd_journal_has_runtime_files;
+ * sd_journal_has_persistent_files;
+ * sd_journal_enumerate_fields;
+ * sd_journal_restart_fields;
+ * } LIBSYSTEMD_227;
+ *
+ * LIBSYSTEMD_230 {
+ * global:
+ * sd_journal_open_directory_fd;
+ * sd_journal_open_files_fd;
+ * } LIBSYSTEMD_229;
+ endif **/
LIBSYSTEMD_231 {
global:
sd_event_get_iteration;
+/** if 0 /// Previous blocks unused by elogind
+ * } LIBSYSTEMD_230;
+ * else **/
} LIBSYSTEMD_227;
+/** endif **/
LIBSYSTEMD_232 {
global:
global:
sd_bus_message_appendv;
} LIBSYSTEMD_233;
+
+LIBSYSTEMD_236 {
+global:
+ sd_bus_message_new;
+ sd_bus_message_seal;
+} LIBSYSTEMD_234;
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <stdio_ext.h>
+
#include "bus-internal.h"
#include "bus-introspect.h"
#include "bus-protocol.h"
if (!i->f)
return -ENOMEM;
- fputs_unlocked(BUS_INTROSPECT_DOCTYPE
- "<node>\n", i->f);
+ (void) __fsetlocking(i->f, FSETLOCKING_BYCALLER);
+
+ fputs(BUS_INTROSPECT_DOCTYPE
+ "<node>\n", i->f);
return 0;
}
int introspect_write_default_interfaces(struct introspect *i, bool object_manager) {
assert(i);
- fputs_unlocked(BUS_INTROSPECT_INTERFACE_PEER
- BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
- BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
+ fputs(BUS_INTROSPECT_INTERFACE_PEER
+ BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
+ BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
if (object_manager)
- fputs_unlocked(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
+ fputs(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
return 0;
}
static void introspect_write_flags(struct introspect *i, int type, int flags) {
if (flags & SD_BUS_VTABLE_DEPRECATED)
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
if (type == _SD_BUS_VTABLE_METHOD && (flags & SD_BUS_VTABLE_METHOD_NO_REPLY))
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f);
if (IN_SET(type, _SD_BUS_VTABLE_PROPERTY, _SD_BUS_VTABLE_WRITABLE_PROPERTY)) {
if (flags & SD_BUS_VTABLE_PROPERTY_EXPLICIT)
- fputs_unlocked(" <annotation name=\"org.freedesktop.systemd1.Explicit\" value=\"true\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.elogind1.Explicit\" value=\"true\"/>\n", i->f);
if (flags & SD_BUS_VTABLE_PROPERTY_CONST)
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f);
else if (flags & SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION)
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f);
else if (!(flags & SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE))
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f);
}
if (!i->trusted &&
IN_SET(type, _SD_BUS_VTABLE_METHOD, _SD_BUS_VTABLE_WRITABLE_PROPERTY) &&
!(flags & SD_BUS_VTABLE_UNPRIVILEGED))
- fputs_unlocked(" <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.elogind1.Privileged\" value=\"true\"/>\n", i->f);
}
static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) {
if (direction)
fprintf(i->f, " direction=\"%s\"/>\n", direction);
else
- fputs_unlocked("/>\n", i->f);
+ fputs("/>\n", i->f);
signature += l;
}
case _SD_BUS_VTABLE_START:
if (v->flags & SD_BUS_VTABLE_DEPRECATED)
- fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
+ fputs(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
break;
case _SD_BUS_VTABLE_METHOD:
introspect_write_arguments(i, strempty(v->x.method.signature), "in");
introspect_write_arguments(i, strempty(v->x.method.result), "out");
introspect_write_flags(i, v->type, v->flags);
- fputs_unlocked(" </method>\n", i->f);
+ fputs(" </method>\n", i->f);
break;
case _SD_BUS_VTABLE_PROPERTY:
v->x.property.signature,
v->type == _SD_BUS_VTABLE_WRITABLE_PROPERTY ? "readwrite" : "read");
introspect_write_flags(i, v->type, v->flags);
- fputs_unlocked(" </property>\n", i->f);
+ fputs(" </property>\n", i->f);
break;
case _SD_BUS_VTABLE_SIGNAL:
fprintf(i->f, " <signal name=\"%s\">\n", v->x.signal.member);
introspect_write_arguments(i, strempty(v->x.signal.signature), NULL);
introspect_write_flags(i, v->type, v->flags);
- fputs_unlocked(" </signal>\n", i->f);
+ fputs(" </signal>\n", i->f);
break;
}
assert(m);
assert(reply);
- fputs_unlocked("</node>\n", i->f);
+ fputs("</node>\n", i->f);
r = fflush_and_check(i->f);
if (r < 0)
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+//#include <stdio_ext.h>
+
#include "alloc-util.h"
#include "bus-internal.h"
#include "bus-match.h"
if (!f)
return NULL;
+ __fsetlocking(f, FSETLOCKING_BYCALLER);
+
for (i = 0; i < n_components; i++) {
char buf[32];
if (i != 0)
- fputc_unlocked(',', f);
+ fputc(',', f);
- fputs_unlocked(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f);
- fputc_unlocked('=', f);
- fputc_unlocked('\'', f);
+ fputs(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f);
+ fputc('=', f);
+ fputc('\'', f);
if (components[i].type == BUS_MATCH_MESSAGE_TYPE)
- fputs_unlocked(bus_message_type_to_string(components[i].value_u8), f);
+ fputs(bus_message_type_to_string(components[i].value_u8), f);
else
- fputs_unlocked(components[i].value_str, f);
+ fputs(components[i].value_str, f);
- fputc_unlocked('\'', f);
+ fputc('\'', f);
}
r = fflush_and_check(f);
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
return r;
}
-static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
- sd_bus_message *m;
+_public_ int sd_bus_message_new(
+ sd_bus *bus,
+ sd_bus_message **m,
+ uint8_t type) {
- assert(bus);
+ sd_bus_message *t;
- m = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(struct bus_header));
- if (!m)
- return NULL;
+ assert_return(bus, -ENOTCONN);
+ assert_return(bus->state != BUS_UNSET, -ENOTCONN);
+ assert_return(m, -EINVAL);
+ assert_return(type < _SD_BUS_MESSAGE_TYPE_MAX, -EINVAL);
- m->n_ref = 1;
- m->header = (struct bus_header*) ((uint8_t*) m + ALIGN(sizeof(struct sd_bus_message)));
- m->header->endian = BUS_NATIVE_ENDIAN;
- m->header->type = type;
- m->header->version = bus->message_version;
- m->allow_fds = bus->can_fds || !IN_SET(bus->state, BUS_HELLO, BUS_RUNNING);
- m->root_container.need_offsets = BUS_MESSAGE_IS_GVARIANT(m);
- m->bus = sd_bus_ref(bus);
+ t = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(struct bus_header));
+ if (!t)
+ return -ENOMEM;
+
+ t->n_ref = 1;
+ t->header = (struct bus_header*) ((uint8_t*) t + ALIGN(sizeof(struct sd_bus_message)));
+ t->header->endian = BUS_NATIVE_ENDIAN;
+ t->header->type = type;
+ t->header->version = bus->message_version;
+ t->allow_fds = bus->can_fds || !IN_SET(bus->state, BUS_HELLO, BUS_RUNNING);
+ t->root_container.need_offsets = BUS_MESSAGE_IS_GVARIANT(t);
+ t->bus = sd_bus_ref(bus);
if (bus->allow_interactive_authorization)
- m->header->flags |= BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION;
+ t->header->flags |= BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION;
- return m;
+ *m = t;
+ return 0;
}
_public_ int sd_bus_message_new_signal(
assert_return(member_name_is_valid(member), -EINVAL);
assert_return(m, -EINVAL);
- t = message_new(bus, SD_BUS_MESSAGE_SIGNAL);
- if (!t)
+ r = sd_bus_message_new(bus, &t, SD_BUS_MESSAGE_SIGNAL);
+ if (r < 0)
return -ENOMEM;
+ assert(t);
+
t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
r = message_append_field_string(t, BUS_MESSAGE_HEADER_PATH, SD_BUS_TYPE_OBJECT_PATH, path, &t->path);
assert_return(member_name_is_valid(member), -EINVAL);
assert_return(m, -EINVAL);
- t = message_new(bus, SD_BUS_MESSAGE_METHOD_CALL);
- if (!t)
+ r = sd_bus_message_new(bus, &t, SD_BUS_MESSAGE_METHOD_CALL);
+ if (r < 0)
return -ENOMEM;
+ assert(t);
+
r = message_append_field_string(t, BUS_MESSAGE_HEADER_PATH, SD_BUS_TYPE_OBJECT_PATH, path, &t->path);
if (r < 0)
goto fail;
sd_bus_message **m) {
sd_bus_message *t;
+ uint64_t cookie;
int r;
assert_return(call, -EINVAL);
assert_return(call->bus->state != BUS_UNSET, -ENOTCONN);
assert_return(m, -EINVAL);
- t = message_new(call->bus, type);
- if (!t)
+ cookie = BUS_MESSAGE_COOKIE(call);
+ if (cookie == 0)
+ return -EOPNOTSUPP;
+
+ r = sd_bus_message_new(call->bus, &t, type);
+ if (r < 0)
return -ENOMEM;
- t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
- t->reply_cookie = BUS_MESSAGE_COOKIE(call);
- if (t->reply_cookie == 0)
- return -EOPNOTSUPP;
+ assert(t);
+ t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
+ t->reply_cookie = cookie;
r = message_append_reply_cookie(t, t->reply_cookie);
if (r < 0)
goto fail;
assert(sd_bus_error_is_set(e));
assert(m);
- t = message_new(bus, SD_BUS_MESSAGE_METHOD_ERROR);
- if (!t)
+ r = sd_bus_message_new(bus, &t, SD_BUS_MESSAGE_METHOD_ERROR);
+ if (r < 0)
return -ENOMEM;
+ assert(t);
+
t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
t->reply_cookie = cookie;
return 0;
}
-int bus_message_seal(sd_bus_message *m, uint64_t cookie, usec_t timeout) {
+_public_ int sd_bus_message_seal(sd_bus_message *m, uint64_t cookie, uint64_t timeout_usec) {
struct bus_body_part *part;
size_t a;
unsigned i;
int r;
- assert(m);
+ assert_return(m, -EINVAL);
if (m->sealed)
return -EPERM;
else
m->header->dbus1.serial = (uint32_t) cookie;
- m->timeout = m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED ? 0 : timeout;
+ m->timeout = m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED ? 0 : timeout_usec;
/* Add padding at the end of the fields part, since we know
* the body needs to start at an 8 byte alignment. We made
case SD_BUS_MESSAGE_METHOD_RETURN:
case SD_BUS_MESSAGE_METHOD_ERROR:
- n = message_new(bus, (*m)->header->type);
- if (!n)
+ r = sd_bus_message_new(bus, &n, (*m)->header->type);
+ if (r < 0)
return -ENOMEM;
+ assert(n);
+
n->reply_cookie = (*m)->reply_cookie;
r = message_append_reply_cookie(n, n->reply_cookie);
if (timeout == 0 && !((*m)->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED))
timeout = BUS_DEFAULT_TIMEOUT;
- r = bus_message_seal(n, BUS_MESSAGE_COOKIE(*m), timeout);
+ r = sd_bus_message_seal(n, BUS_MESSAGE_COOKIE(*m), timeout);
if (r < 0)
return r;
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
return m->header->version == 2;
}
-int bus_message_seal(sd_bus_message *m, uint64_t serial, usec_t timeout);
#if 0 /// UNNEEDED by elogind
int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
#endif // 0
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
if (!streq_ptr(previous_interface, c->interface)) {
if (previous_interface)
- fputs_unlocked(" </interface>\n", intro.f);
+ fputs(" </interface>\n", intro.f);
fprintf(intro.f, " <interface name=\"%s\">\n", c->interface);
}
}
if (previous_interface)
- fputs_unlocked(" </interface>\n", intro.f);
+ fputs(" </interface>\n", intro.f);
if (empty) {
/* Nothing?, let's see if we exist at all, and if not
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
if (f)
b->can_fds =
- (f - e == strlen("\r\nAGREE_UNIX_FD")) &&
- memcmp(e + 2, "AGREE_UNIX_FD", strlen("AGREE_UNIX_FD")) == 0;
+ (f - e == STRLEN("\r\nAGREE_UNIX_FD")) &&
+ memcmp(e + 2, "AGREE_UNIX_FD",
+ STRLEN("AGREE_UNIX_FD")) == 0;
b->rbuffer_size -= (start - (char*) b->rbuffer);
memmove(b->rbuffer, start, b->rbuffer_size);
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
({ \
char *_x; \
size_t _l = strlen(name); \
- _x = alloca(strlen(MATCH_PREFIX)+_l+strlen(MATCH_SUFFIX)+1); \
+ _x = alloca(STRLEN(MATCH_PREFIX)+_l+STRLEN(MATCH_SUFFIX)+1); \
strcpy(stpcpy(stpcpy(_x, MATCH_PREFIX), name), MATCH_SUFFIX); \
_x; \
})
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
if (timeout == 0)
timeout = BUS_DEFAULT_TIMEOUT;
- return bus_message_seal(m, ++b->cookie, timeout);
+ return sd_bus_message_seal(m, ++b->cookie, timeout);
}
static int bus_remarshal_message(sd_bus *b, sd_bus_message **m) {
* pick a fixed, artificial one. We use (uint32_t) -1 rather
* than (uint64_t) -1 since dbus1 only had 32bit identifiers,
* even though kdbus can do 64bit. */
- return bus_message_seal(m, 0xFFFFFFFFULL, 0);
+ return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
}
static int bus_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call, size_t *idx) {
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
assert_se(sd_bus_message_new_signal(bus, &m, "/foo/bar", "bar.x", "waldo") >= 0);
assert_se(sd_bus_message_append(m, "ssssas", "one", "two", "/prefix/three", "prefix.four", 3, "pi", "pa", "po") >= 0);
- assert_se(bus_message_seal(m, 1, 0) >= 0);
+ assert_se(sd_bus_message_seal(m, 1, 0) >= 0);
zero(mask);
assert_se(bus_match_run(NULL, &root, m) == 0);
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.