summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CODING_STYLE28
-rw-r--r--Makefile-man.am12
-rw-r--r--Makefile.am863
-rw-r--r--NEWS84
-rw-r--r--README421
-rw-r--r--TODO27
-rwxr-xr-xautogen.sh22
-rw-r--r--configure.ac81
l---------docs/gtk-doc.make1
-rw-r--r--factory/etc/pam.d/system-auth2
-rw-r--r--m4/gtk-doc.m488
-rw-r--r--man/custom-html.xsl3
-rw-r--r--man/elogind.conf.xml (renamed from man/logind.conf.xml)31
-rw-r--r--man/loginctl.xml14
-rw-r--r--man/pam_elogind.xml6
-rw-r--r--man/sd_is_fifo.xml200
-rw-r--r--shell-completion/zsh/_elogind-inhibit33
-rw-r--r--src/basic/.gitignore16
l---------src/basic/Makefile (renamed from src/shared/Makefile)0
-rw-r--r--src/basic/audit.c (renamed from src/shared/audit.c)0
-rw-r--r--src/basic/audit.h (renamed from src/shared/audit.h)0
-rw-r--r--src/basic/btrfs-util.h88
-rw-r--r--src/basic/build.h157
-rw-r--r--src/basic/bus-label.c (renamed from src/shared/bus-label.c)0
-rw-r--r--src/basic/bus-label.h (renamed from src/shared/bus-label.h)0
-rw-r--r--src/basic/calendarspec.h (renamed from src/shared/calendarspec.h)0
-rw-r--r--src/basic/capability.c (renamed from src/shared/capability.c)3
-rw-r--r--src/basic/capability.h (renamed from src/shared/capability.h)4
-rw-r--r--src/basic/cgroup-util.c (renamed from src/shared/cgroup-util.c)535
-rw-r--r--src/basic/cgroup-util.h (renamed from src/shared/cgroup-util.h)19
-rw-r--r--src/basic/conf-files.c (renamed from src/shared/conf-files.c)0
-rw-r--r--src/basic/conf-files.h (renamed from src/shared/conf-files.h)0
-rw-r--r--src/basic/def.h (renamed from src/shared/def.h)2
-rw-r--r--src/basic/device-nodes.h (renamed from src/shared/device-nodes.h)0
-rw-r--r--src/basic/env-util.h (renamed from src/shared/env-util.h)0
-rw-r--r--src/basic/errno-list.c (renamed from src/shared/errno-list.c)3
-rw-r--r--src/basic/errno-list.h (renamed from src/shared/errno-list.h)2
-rw-r--r--src/basic/exit-status.h (renamed from src/shared/exit-status.h)0
-rw-r--r--src/basic/fdset.h (renamed from src/shared/fdset.h)8
-rw-r--r--src/basic/fileio-label.c (renamed from src/shared/fileio-label.c)3
-rw-r--r--src/basic/fileio-label.h (renamed from src/shared/fileio-label.h)6
-rw-r--r--src/basic/fileio.c (renamed from src/shared/fileio.c)6
-rw-r--r--src/basic/fileio.h (renamed from src/shared/fileio.h)4
-rw-r--r--src/basic/gunicode.c (renamed from src/shared/gunicode.c)0
-rw-r--r--src/basic/gunicode.h (renamed from src/shared/gunicode.h)0
-rw-r--r--src/basic/hashmap.c (renamed from src/shared/hashmap.c)15
-rw-r--r--src/basic/hashmap.h (renamed from src/shared/hashmap.h)3
-rw-r--r--src/basic/hostname-util.c (renamed from src/shared/hostname-util.c)0
-rw-r--r--src/basic/hostname-util.h (renamed from src/shared/hostname-util.h)0
-rw-r--r--src/basic/ioprio.h (renamed from src/shared/ioprio.h)0
-rw-r--r--src/basic/label.c (renamed from src/shared/label.c)0
-rw-r--r--src/basic/label.h (renamed from src/shared/label.h)0
-rw-r--r--src/basic/list.h (renamed from src/shared/list.h)0
-rw-r--r--src/basic/log.c (renamed from src/shared/log.c)0
-rw-r--r--src/basic/log.h (renamed from src/shared/log.h)0
-rw-r--r--src/basic/login-util.c (renamed from src/shared/login-shared.c)2
-rw-r--r--src/basic/login-util.h (renamed from src/shared/ima-util.h)8
-rw-r--r--src/basic/macro.h (renamed from src/shared/macro.h)0
-rw-r--r--src/basic/memfd-util.c (renamed from src/shared/memfd-util.c)3
-rw-r--r--src/basic/memfd-util.h (renamed from src/shared/memfd-util.h)2
-rw-r--r--src/basic/mempool.c (renamed from src/shared/mempool.c)2
-rw-r--r--src/basic/mempool.h (renamed from src/shared/mempool.h)2
-rw-r--r--src/basic/missing.h (renamed from src/shared/missing.h)39
-rw-r--r--src/basic/mkdir-label.c (renamed from src/shared/mkdir-label.c)0
-rw-r--r--src/basic/mkdir.c (renamed from src/shared/mkdir.c)0
-rw-r--r--src/basic/mkdir.h (renamed from src/shared/mkdir.h)0
-rw-r--r--src/basic/path-util.c (renamed from src/shared/path-util.c)6
-rw-r--r--src/basic/path-util.h (renamed from src/shared/path-util.h)4
-rw-r--r--src/basic/prioq.c (renamed from src/shared/prioq.c)0
-rw-r--r--src/basic/prioq.h (renamed from src/shared/prioq.h)0
-rw-r--r--src/basic/process-util.c (renamed from src/shared/process-util.c)6
-rw-r--r--src/basic/process-util.h (renamed from src/shared/process-util.h)10
-rw-r--r--src/basic/random-util.c (renamed from src/shared/random-util.c)2
-rw-r--r--src/basic/random-util.h (renamed from src/shared/random-util.h)0
-rw-r--r--src/basic/ratelimit.h (renamed from src/shared/ratelimit.h)0
-rw-r--r--src/basic/refcnt.h (renamed from src/shared/refcnt.h)0
-rw-r--r--src/basic/ring.h (renamed from src/shared/ring.h)4
-rw-r--r--src/basic/rm-rf.c (renamed from src/shared/rm-rf.c)21
-rw-r--r--src/basic/rm-rf.h (renamed from src/shared/rm-rf.h)0
-rw-r--r--src/basic/selinux-util.c (renamed from src/shared/selinux-util.c)3
-rw-r--r--src/basic/selinux-util.h (renamed from src/shared/selinux-util.h)2
-rw-r--r--src/basic/set.h (renamed from src/shared/set.h)2
-rw-r--r--src/basic/signal-util.c (renamed from src/shared/signal-util.c)2
-rw-r--r--src/basic/signal-util.h (renamed from src/shared/signal-util.h)0
-rw-r--r--src/basic/siphash24.c (renamed from src/shared/siphash24.c)0
-rw-r--r--src/basic/siphash24.h (renamed from src/shared/siphash24.h)0
-rw-r--r--src/basic/smack-util.c (renamed from src/shared/smack-util.c)0
-rw-r--r--src/basic/smack-util.h (renamed from src/shared/smack-util.h)0
-rw-r--r--src/basic/socket-util.h (renamed from src/shared/socket-util.h)8
-rw-r--r--src/basic/sparse-endian.h (renamed from src/shared/sparse-endian.h)0
-rw-r--r--src/basic/special.h (renamed from src/shared/special.h)2
-rw-r--r--src/basic/strv.c (renamed from src/shared/strv.c)15
-rw-r--r--src/basic/strv.h (renamed from src/shared/strv.h)12
-rw-r--r--src/basic/terminal-util.c (renamed from src/shared/terminal-util.c)6
-rw-r--r--src/basic/terminal-util.h (renamed from src/shared/terminal-util.h)4
-rw-r--r--src/basic/time-util.c (renamed from src/shared/time-util.c)9
-rw-r--r--src/basic/time-util.h (renamed from src/shared/time-util.h)10
-rw-r--r--src/basic/unit-name.c (renamed from src/shared/unit-name.c)0
-rw-r--r--src/basic/unit-name.h (renamed from src/shared/unit-name.h)0
-rw-r--r--src/basic/utf8.c (renamed from src/shared/utf8.c)0
-rw-r--r--src/basic/utf8.h (renamed from src/shared/utf8.h)0
-rw-r--r--src/basic/util.c (renamed from src/shared/util.c)76
-rw-r--r--src/basic/util.h (renamed from src/shared/util.h)340
-rw-r--r--src/basic/verbs.c (renamed from src/shared/verbs.c)0
-rw-r--r--src/basic/verbs.h (renamed from src/shared/verbs.h)0
-rw-r--r--src/basic/virt.c (renamed from src/shared/virt.c)0
-rw-r--r--src/basic/virt.h (renamed from src/shared/virt.h)0
-rw-r--r--src/core/org.freedesktop.systemd1.conf212
-rw-r--r--src/core/org.freedesktop.systemd1.policy.in.in70
-rw-r--r--src/core/org.freedesktop.systemd1.service11
-rw-r--r--src/core/system.conf57
-rw-r--r--src/core/user.conf44
-rw-r--r--src/libelogind/sd-bus/bus-container.c245
-rw-r--r--src/libelogind/sd-bus/bus-control.c3
-rw-r--r--src/libelogind/sd-bus/bus-convenience.c12
-rw-r--r--src/libelogind/sd-bus/bus-creds.c27
-rw-r--r--src/libelogind/sd-bus/bus-internal.c29
-rw-r--r--src/libelogind/sd-bus/bus-internal.h6
-rw-r--r--src/libelogind/sd-bus/bus-match.c3
-rw-r--r--src/libelogind/sd-bus/bus-match.h2
-rw-r--r--src/libelogind/sd-bus/bus-message.c39
-rw-r--r--src/libelogind/sd-bus/bus-message.h4
-rw-r--r--src/libelogind/sd-bus/bus-objects.c6
-rw-r--r--src/libelogind/sd-bus/bus-slot.c3
-rw-r--r--src/libelogind/sd-bus/bus-track.c3
-rw-r--r--src/libelogind/sd-bus/bus-type.c3
-rw-r--r--src/libelogind/sd-bus/bus-type.h2
-rw-r--r--src/libelogind/sd-bus/sd-bus.c37
-rw-r--r--src/libelogind/sd-daemon/sd-daemon.c31
-rw-r--r--src/libelogind/sd-device/device-internal.h126
-rw-r--r--src/libelogind/sd-device/device-private.c1117
-rw-r--r--src/libelogind/sd-device/device-private.h64
-rw-r--r--src/libelogind/sd-device/device-util.h60
-rw-r--r--src/libelogind/sd-event/sd-event.c36
-rw-r--r--src/libelogind/sd-hwdb/hwdb-internal.h70
-rw-r--r--src/libelogind/sd-hwdb/sd-hwdb.c470
l---------src/libelogind/sd-netlink/Makefile (renamed from src/libelogind/sd-hwdb/Makefile)0
-rw-r--r--src/libelogind/sd-netlink/netlink-types.h (renamed from src/libsystemd/sd-netlink/netlink-types.h)0
-rw-r--r--src/libelogind/sd-network/network-util.c37
-rw-r--r--src/libelogind/sd-network/network-util.h29
-rw-r--r--src/libelogind/sd-network/sd-network.c422
l---------src/libelogind/sd-resolve/Makefile1
l---------src/libelogind/sd-rtnl/Makefile1
-rw-r--r--src/libelogind/sd-rtnl/local-addresses.h37
-rw-r--r--src/libelogind/sd-rtnl/rtnl-internal.h135
-rw-r--r--src/libelogind/sd-rtnl/rtnl-types.c561
-rw-r--r--src/libelogind/sd-rtnl/rtnl-types.h119
-rw-r--r--src/libelogind/sd-rtnl/rtnl-util.h47
l---------src/libelogind/sd-utf8/Makefile1
-rw-r--r--src/libelogind/sd-utf8/sd-utf8.c36
l---------src/libsystemd/sd-netlink/Makefile1
-rw-r--r--src/libsystemd/sd-netlink/local-addresses.c276
-rw-r--r--src/libsystemd/sd-netlink/local-addresses.h37
-rw-r--r--src/libsystemd/sd-netlink/netlink-util.c173
-rw-r--r--src/libsystemd/sd-netlink/netlink-util.h47
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c1060
-rw-r--r--src/libsystemd/sd-netlink/test-local-addresses.c58
-rw-r--r--src/libsystemd/sd-netlink/test-netlink.c443
-rw-r--r--src/login/elogind.conf (renamed from src/login/logind.conf)2
-rw-r--r--src/login/logind-button.h34
-rw-r--r--src/login/logind.c5
-rw-r--r--src/shared/MurmurHash2.c86
-rw-r--r--src/shared/MurmurHash2.h33
-rw-r--r--src/shared/acl-util.c3
-rw-r--r--src/shared/acl-util.h8
-rw-r--r--src/shared/acpi-fpdt.c160
-rw-r--r--src/shared/acpi-fpdt.h26
-rw-r--r--src/shared/af-list.c58
-rw-r--r--src/shared/architecture.c175
-rw-r--r--src/shared/arphrd-list.c58
-rw-r--r--src/shared/arphrd-list.h27
-rw-r--r--src/shared/async.c92
-rw-r--r--src/shared/async.h27
-rw-r--r--src/shared/barrier.c416
-rw-r--r--src/shared/barrier.h91
-rw-r--r--src/shared/base-filesystem.c117
-rw-r--r--src/shared/base-filesystem.h26
-rw-r--r--src/shared/build.h73
-rw-r--r--src/shared/bus-util.c (renamed from src/libelogind/sd-bus/bus-util.c)31
-rw-r--r--src/shared/bus-util.h (renamed from src/libelogind/sd-bus/bus-util.h)8
-rw-r--r--src/shared/calendarspec.c1006
-rw-r--r--src/shared/cap-list.c65
-rw-r--r--src/shared/cap-list.h26
-rw-r--r--src/shared/cgroup-show.c3
-rw-r--r--src/shared/cgroup-show.h2
-rw-r--r--src/shared/clock-util.c142
-rw-r--r--src/shared/clock-util.h29
-rw-r--r--src/shared/condition.h2
-rw-r--r--src/shared/conf-parser.c3
-rw-r--r--src/shared/conf-parser.h4
-rw-r--r--src/shared/device-nodes.c80
-rw-r--r--src/shared/env-util.c594
-rw-r--r--src/shared/exit-status.c241
-rw-r--r--src/shared/fdset.c284
-rw-r--r--src/shared/firewall-util.c344
-rw-r--r--src/shared/firewall-util.h82
-rw-r--r--src/shared/fstab-util.c180
-rw-r--r--src/shared/fstab-util.h50
-rw-r--r--src/shared/ima-util.c34
-rw-r--r--src/shared/import-util.c203
-rw-r--r--src/shared/import-util.h49
-rw-r--r--src/shared/in-addr-util.c338
-rw-r--r--src/shared/in-addr-util.h53
-rw-r--r--src/shared/json.c866
-rw-r--r--src/shared/json.h88
l---------src/shared/linux/Makefile1
-rw-r--r--src/shared/locale-util.c224
-rw-r--r--src/shared/locale-util.h54
-rw-r--r--src/shared/pager.c3
-rw-r--r--src/shared/pager.h10
-rw-r--r--src/shared/pty.c635
-rw-r--r--src/shared/pty.h72
-rw-r--r--src/shared/ptyfwd.c459
-rw-r--r--src/shared/ptyfwd.h38
-rw-r--r--src/shared/ratelimit.c55
-rw-r--r--src/shared/replace-var.c111
-rw-r--r--src/shared/replace-var.h24
-rw-r--r--src/shared/ring.c209
-rw-r--r--src/shared/seccomp-util.c92
-rw-r--r--src/shared/seccomp-util.h (renamed from src/shared/af-list.h)8
-rw-r--r--src/shared/sigbus.c152
-rw-r--r--src/shared/sigbus.h27
-rw-r--r--src/shared/strbuf.c201
-rw-r--r--src/shared/strbuf.h54
-rw-r--r--src/shared/strxcpyx.c100
-rw-r--r--src/shared/strxcpyx.h31
-rw-r--r--src/shared/sysctl-util.h27
-rw-r--r--src/shared/uid-range.c205
-rw-r--r--src/shared/uid-range.h35
-rw-r--r--src/shared/watchdog.c163
-rw-r--r--src/shared/watchdog.h28
-rw-r--r--src/shared/xml.c254
-rw-r--r--src/shared/xml.h34
-rwxr-xr-xsrc/systemctl/systemd-sysv-install.SKELETON47
-rw-r--r--src/systemd/sd-bus.h179
-rw-r--r--src/systemd/sd-daemon.h10
-rw-r--r--src/systemd/sd-device.h99
-rw-r--r--src/systemd/sd-dhcp-client.h75
-rw-r--r--src/systemd/sd-dhcp-lease.h54
-rw-r--r--src/systemd/sd-dhcp-server.h51
-rw-r--r--src/systemd/sd-dhcp6-client.h70
-rw-r--r--src/systemd/sd-event.h38
-rw-r--r--src/systemd/sd-hwdb.h47
-rw-r--r--src/systemd/sd-icmp6-nd.h79
-rw-r--r--src/systemd/sd-ipv4ll.h54
-rw-r--r--src/systemd/sd-lldp.h53
-rw-r--r--src/systemd/sd-network.h152
-rw-r--r--src/systemd/sd-resolve.h127
-rw-r--r--src/systemd/sd-utf8.h34
-rw-r--r--src/test/test-firewall-util.c60
-rw-r--r--src/test/test-netlink-manual.c147
252 files changed, 3246 insertions, 17466 deletions
diff --git a/.gitignore b/.gitignore
index cccb49d17..342d34f99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -291,3 +291,4 @@ stamp-*
/elogind-cgroups-agent
/rebuild_all.sh
/src/libelogind/libelogind.pc
+/elogind-inhibit
diff --git a/CODING_STYLE b/CODING_STYLE
index 91f09e80a..dbadfbdb5 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -210,11 +210,12 @@
c) recvmsg() must get MSG_CMSG_CLOEXEC set
d) F_DUPFD_CLOEXEC should be used instead of F_DUPFD, and so on
-- We never use the XDG version of basename(). glibc defines it in
- libgen.h. The only reason to include that file is because dirname()
+- We never use the POSIX version of basename() (which glibc defines it in
+ libgen.h), only the GNU version (which glibc defines in string.h).
+ The only reason to include libgen.h is because dirname()
is needed. Everytime you need that please immediately undefine
basename(), and add a comment about it, so that no code ever ends up
- using the XDG version!
+ using the POSIX version!
- Use the bool type for booleans, not integers. One exception: in public
headers (i.e those in src/systemd/sd-*.h) use integers after all, as "bool"
@@ -292,3 +293,24 @@
- When returning a return code from main(), please preferably use
EXIT_FAILURE and EXIT_SUCCESS as defined by libc.
+
+- The order in which header files are included doesn't matter too
+ much. However, please try to include the headers of external
+ libraries first (these are all headers enclosed in <>), followed by
+ the headers of our own public headers (these are all headers
+ starting with "sd-"), internal utility libraries from src/shared/,
+ followed by the headers of the specific component. Or in other
+ words:
+
+ #include <stdio.h>
+ #include "sd-daemon.h"
+ #include "util.h"
+ #include "frobnicator.h"
+
+ Where stdio.h is a public glibc API, sd-daemon.h is a public API of
+ our own, util.h is a utility library header from src/shared, and
+ frobnicator.h is an placeholder name for any systemd component. The
+ benefit of following this ordering is that more local definitions
+ are always defined after more global ones. Thus, our local
+ definitions will never "leak" into the global header files, possibly
+ altering their effect due to #ifdeffery.
diff --git a/Makefile-man.am b/Makefile-man.am
index f931ac436..65a6a894e 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -1,11 +1,10 @@
MANPAGES += \
man/loginctl.1 \
- man/logind.conf.5 \
- man/logind.8
+ man/elogind.conf.5
MANPAGES_ALIAS += \
- man/logind.conf.d.5
-man/logind.conf.d.5: man/logind.conf.5
-man/logind.conf.d.html: man/logind.conf.html
+ man/elogind.conf.d.5
+man/elogind.conf.d.5: man/elogind.conf.5
+man/elogind.conf.d.html: man/elogind.conf.html
$(html-alias)
if HAVE_PAM
@@ -228,8 +227,7 @@ endif
EXTRA_DIST += \
man/loginctl.xml \
- man/logind.xml \
- man/logind.conf.xml \
+ man/elogind.conf.xml \
man/pam_elogind.xml \
man/sd_get_seats.xml \
man/sd_login_monitor_new.xml \
diff --git a/Makefile.am b/Makefile.am
index e104c41d4..1cb1c2063 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,39 +38,36 @@ SUBDIRS = . po
# Keep the test-suite.log
.PRECIOUS: $(TEST_SUITE_LOG) Makefile
-LIBELOGIND_CURRENT=7
+LIBELOGIND_CURRENT=8
LIBELOGIND_REVISION=0
-LIBELOGIND_AGE=7
+LIBELOGIND_AGE=8
# Dirs of external packages
dbuspolicydir=@dbuspolicydir@
-dbussessionservicedir=@dbussessionservicedir@
dbussystemservicedir=@dbussystemservicedir@
pamlibdir=@pamlibdir@
pamconfdir=@pamconfdir@
+pkgconfigdatadir=$(datadir)/pkgconfig
pkgconfiglibdir=$(libdir)/pkgconfig
polkitpolicydir=$(datadir)/polkit-1/actions
bashcompletiondir=@bashcompletiondir@
zshcompletiondir=@zshcompletiondir@
-varlogdir=$(localstatedir)/log
-elogindstatedir=$(localstatedir)/lib/elogind
-systemsleepdir=$(pkglibexecdir)/sleep.d
-systemshutdowndir=$(pkglibexecdir)/shutdown.d
-
-udevrulesdir=@udevrulesdir@
-udevbindir=@udevbindir@
-
-PKTTYAGENT=$(bindir)/pkttyagent
# Our own, non-special dirs
pkgsysconfdir=$(sysconfdir)/elogind
pkgincludedir=$(includedir)/elogind
+udevrulesdir=@udevrulesdir@
+udevbindir=@udevbindir@
udevlibexecdir=$(udevbindir)
udevhomedir=$(udevlibexecdir)
udevhwdbdir=$(udevlibexecdir)/hwdb.d
-factory_etcdir = $(datadir)/factory/etc
factory_pamdir = $(datadir)/factory/etc/pam.d
+# And these are the special ones for /
+rootprefix=@rootprefix@
+rootbindir=$(rootprefix)/bin
+rootlibexecdir=$(rootprefix)/lib/elogind
+
EXTRA_DIST =
BUILT_SOURCES =
INSTALL_EXEC_HOOKS =
@@ -82,23 +79,19 @@ CLEAN_LOCAL_HOOKS =
pkginclude_HEADERS =
noinst_LTLIBRARIES =
lib_LTLIBRARIES =
-include_HEADERS =
noinst_DATA =
pkgconfiglib_DATA =
-polkitpolicy_in_in_files =
polkitpolicy_in_files =
polkitpolicy_files =
+dist_udevrules_DATA =
+nodist_udevrules_DATA =
dist_pkgsysconf_DATA =
-nodist_pkgsysconf_DATA =
-dist_pkgdata_DATA =
dist_dbuspolicy_DATA =
dist_dbussystemservice_DATA =
check_PROGRAMS =
check_DATA =
tests=
manual_tests =
-TEST_EXTENSIONS = .py
-PY_LOG_COMPILER = $(PYTHON)
if ENABLE_TESTS
noinst_PROGRAMS = $(manual_tests) $(tests)
TESTS = $(tests)
@@ -123,114 +116,51 @@ CLEANFILES = $(BUILT_SOURCES) \
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-DPKGSYSCONFDIR=\"$(pkgsysconfdir)\" \
- -DPOLKIT_AGENT_BINARY_PATH=\"$(PKTTYAGENT)\" \
- -DSYSTEM_CONFIG_UNIT_PATH=\"$(pkgsysconfdir)/system\" \
- -DSYSTEM_DATA_UNIT_PATH=\"$(systemunitdir)\" \
- -DSYSTEMD_CGROUP_AGENT_PATH=\"$(pkglibexecdir)/logind-cgroups-agent\" \
- -DUSER_CONFIG_UNIT_PATH=\"$(pkgsysconfdir)/user\" \
- -DUSER_DATA_UNIT_PATH=\"$(userunitdir)\" \
+ -DCERTIFICATE_ROOT=\"$(CERTIFICATEROOT)\" \
+ -DELOGIND_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/elogind-cgroups-agent\" \
-DROOTPREFIX=\"$(rootprefix)\" \
- -DSYSTEM_SLEEP_PATH=\"$(systemsleepdir)\" \
- -DSYSTEM_SHUTDOWN_PATH=\"$(systemshutdowndir)\" \
- -DHALT=\"$(HALT)\" \
- -DREBOOT=\"$(REBOOT)\" \
-DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
+ -DPOLKIT_AGENT_BINARY_PATH=\"$(bindir)/pkttyagent\" \
-DKEXEC=\"$(KEXEC)\" \
-DLIBDIR=\"$(libdir)\" \
-DROOTLIBDIR=\"$(rootlibdir)\" \
+ -DROOTLIBEXECDIR=\"$(rootlibexecdir)\" \
-DTEST_DIR=\"$(abs_top_srcdir)/test\" \
-I $(top_srcdir)/src \
- -I $(top_builddir)/src/shared \
+ -I $(top_builddir)/src/basic \
+ -I $(top_srcdir)/src/basic \
-I $(top_srcdir)/src/shared \
+ -I $(top_builddir)/src/shared \
-I $(top_srcdir)/src/login \
-I $(top_srcdir)/src/systemd \
+ -I $(top_builddir)/src/core \
+ -I $(top_srcdir)/src/core \
-I $(top_srcdir)/src/libelogind/sd-bus \
-I $(top_srcdir)/src/libelogind/sd-event \
- -I $(top_srcdir)/src/libelogind/sd-device \
- $(UDEV_CFLAGS) \
+ -I $(top_srcdir)/src/libelogind/sd-login \
+ -I $(top_srcdir)/src/libelogind/sd-netlink \
$(OUR_CPPFLAGS)
AM_CFLAGS = $(OUR_CFLAGS)
AM_LDFLAGS = $(OUR_LDFLAGS)
# ------------------------------------------------------------------------------
-SHUTDOWN_TARGET_WANTS =
-LOCAL_FS_TARGET_WANTS =
-MULTI_USER_TARGET_WANTS =
-GRAPHICAL_TARGET_WANTS =
-RESCUE_TARGET_WANTS =
-SYSINIT_TARGET_WANTS =
-SOCKETS_TARGET_WANTS =
-BUSNAMES_TARGET_WANTS =
-TIMERS_TARGET_WANTS =
-USER_SOCKETS_TARGET_WANTS =
-USER_DEFAULT_TARGET_WANTS =
-USER_BUSNAMES_TARGET_WANTS =
-
-SYSTEM_UNIT_ALIASES =
-USER_UNIT_ALIASES =
-GENERAL_ALIASES =
-
-install-target-wants-hook:
- what="$(SHUTDOWN_TARGET_WANTS)" && wants=shutdown.target && dir=$(systemunitdir) && $(add-wants)
- what="$(LOCAL_FS_TARGET_WANTS)" && wants=local-fs.target && dir=$(systemunitdir) && $(add-wants)
- what="$(MULTI_USER_TARGET_WANTS)" && wants=multi-user.target && dir=$(systemunitdir) && $(add-wants)
- what="$(GRAPHICAL_TARGET_WANTS)" && wants=graphical.target && dir=$(systemunitdir) && $(add-wants)
- what="$(RESCUE_TARGET_WANTS)" && wants=rescue.target && dir=$(systemunitdir) && $(add-wants)
- what="$(SYSINIT_TARGET_WANTS)" && wants=sysinit.target && dir=$(systemunitdir) && $(add-wants)
- what="$(SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(systemunitdir) && $(add-wants)
- what="$(TIMERS_TARGET_WANTS)" && wants=timers.target && dir=$(systemunitdir) && $(add-wants)
- what="$(SLICES_TARGET_WANTS)" && wants=slices.target && dir=$(systemunitdir) && $(add-wants)
- what="$(USER_SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(userunitdir) && $(add-wants)
- what="$(USER_DEFAULT_TARGET_WANTS)" && wants=default.target && dir=$(userunitdir) && $(add-wants)
-
-install-busnames-target-wants-hook:
- what="$(BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(systemunitdir) && $(add-wants)
- what="$(USER_BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(userunitdir) && $(add-wants)
-
-define add-wants
- [ -z "$$what" ] || ( \
- dir=$(DESTDIR)$$dir/$$wants.wants && \
- $(MKDIR_P) -m 0755 $$dir && \
- cd $$dir && \
- rm -f $$what && \
- for i in $$what; do $(LN_S) ../$$i . || exit $$? ; done )
-endef
-
-install-aliases-hook:
- set -- $(GENERAL_ALIASES) && \
- dir= && $(install-relative-aliases)
-
-define install-aliases
- while [ -n "$$1" ]; do \
- $(MKDIR_P) `dirname $(DESTDIR)$$dir/$$2` && \
- rm -f $(DESTDIR)$$dir/$$2 && \
- $(LN_S) $$1 $(DESTDIR)$$dir/$$2 && \
- shift 2 || exit $$?; \
- done
-endef
-
-define install-relative-aliases
- while [ -n "$$1" ]; do \
- $(MKDIR_P) `dirname $(DESTDIR)$$dir/$$2` && \
- rm -f $(DESTDIR)$$dir/$$2 && \
- $(LN_S) --relative $(DESTDIR)$$1 $(DESTDIR)$$dir/$$2 && \
- shift 2 || exit $$?; \
- done
+define move-to-rootlibdir
+ if test "$(libdir)" != "$(rootlibdir)"; then \
+ $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
+ so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
+ rm -f $(DESTDIR)$(libdir)/$$libname && \
+ $(LN_S) --relative -f $(DESTDIR)$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
+ mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
+ fi
endef
install-touch-usr-hook:
touch -c $(DESTDIR)/$(prefix)
INSTALL_EXEC_HOOKS += \
- install-target-wants-hook \
- install-aliases-hook \
install-touch-usr-hook
-if ENABLE_KDBUS
-INSTALL_EXEC_HOOKS += \
- install-busnames-target-wants-hook
-endif
# ------------------------------------------------------------------------------
AM_V_M4 = $(AM_V_M4_$(V))
@@ -254,8 +184,10 @@ AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
AM_V_RM_0 = @echo " RM " $@;
# ------------------------------------------------------------------------------
+rootbin_PROGRAMS =
bin_PROGRAMS =
-pkglibexec_PROGRAMS =
+rootlibexec_PROGRAMS =
+
dist_bashcompletion_DATA =
dist_zshcompletion_DATA =
@@ -264,10 +196,7 @@ dist_doc_DATA = \
NEWS \
LICENSE.LGPL2.1 \
LICENSE.GPL2 \
- LICENSE.MIT \
- src/libelogind/sd-bus/PORTING-DBUS1 \
- src/libelogind/sd-bus/DIFFERENCES \
- src/libelogind/sd-bus/GVARIANT-SERIALIZATION
+ DISTRO_PORTING
@INTLTOOL_POLICY_RULE@
@@ -315,235 +244,162 @@ CLEANFILES += \
endif
EXTRA_DIST += \
- $(XML_FILES) \
+ $(filter-out man/systemd.directives.xml,$(XML_FILES)) \
$(HTML_FILES) \
$(HTML_ALIAS) \
$(man_MANS) \
- tools/make-man-index.py \
- tools/make-directive-index.py \
- tools/xml_helper.py
+ $(NULL)
# ------------------------------------------------------------------------------
noinst_LTLIBRARIES += \
- libelogind-shared.la
-
-libelogind_shared_la_SOURCES = \
- src/shared/capability.c \
- src/shared/capability.h \
- src/shared/linux/auto_dev-ioctl.h \
- src/shared/ioprio.h \
- src/shared/missing.h \
- src/shared/initreq.h \
- src/shared/securebits.h \
- src/shared/special.h \
- src/shared/list.h \
- src/shared/unaligned.h \
- src/shared/macro.h \
- src/shared/def.h \
- src/shared/sparse-endian.h \
- src/shared/refcnt.h \
- src/shared/udev-util.h \
- src/shared/device-nodes.c \
- src/shared/device-nodes.h \
- src/shared/util.c \
- src/shared/util.h \
- src/shared/virt.c \
- src/shared/virt.h \
- src/shared/architecture.c \
- src/shared/architecture.h \
- src/shared/fstab-util.c \
- src/shared/fstab-util.h \
- src/shared/path-util.c \
- src/shared/path-util.h \
- src/shared/time-util.c \
- src/shared/time-util.h \
- src/shared/locale-util.c \
- src/shared/locale-util.h \
- src/shared/mempool.c \
- src/shared/mempool.h \
- src/shared/hashmap.c \
- src/shared/hashmap.h \
- src/shared/siphash24.c \
- src/shared/siphash24.h \
- src/shared/set.h \
- src/shared/fdset.c \
- src/shared/fdset.h \
- src/shared/prioq.c \
- src/shared/prioq.h \
+ libbasic.la
+
+libbasic_la_SOURCES = \
+ src/basic/missing.h \
+ src/basic/capability.c \
+ src/basic/capability.h \
+ src/basic/conf-files.c \
+ src/basic/conf-files.h \
+ src/basic/hostname-util.h \
+ src/basic/hostname-util.c \
+ src/basic/unit-name.c \
+ src/basic/unit-name.h \
+ src/basic/util.c \
+ src/basic/util.h \
+ src/basic/path-util.c \
+ src/basic/path-util.h \
+ src/basic/time-util.c \
+ src/basic/time-util.h \
+ src/basic/signal-util.c \
+ src/basic/signal-util.h \
+ src/basic/mempool.c \
+ src/basic/mempool.h \
+ src/basic/hashmap.c \
+ src/basic/hashmap.h \
+ src/basic/siphash24.c \
+ src/basic/siphash24.h \
+ src/basic/prioq.c \
+ src/basic/prioq.h \
+ src/basic/strv.c \
+ src/basic/strv.h \
+ src/basic/log.c \
+ src/basic/log.h \
+ src/basic/bus-label.c \
+ src/basic/bus-label.h \
+ src/basic/virt.c \
+ src/basic/virt.h \
+ src/basic/smack-util.c \
+ src/basic/smack-util.h \
+ src/basic/utf8.c \
+ src/basic/utf8.h \
+ src/basic/gunicode.c \
+ src/basic/gunicode.h \
+ src/basic/fileio.c \
+ src/basic/fileio.h \
+ src/basic/mkdir.c \
+ src/basic/mkdir.h \
+ src/basic/cgroup-util.c \
+ src/basic/cgroup-util.h \
+ src/basic/errno-list.c \
+ src/basic/errno-list.h \
+ src/basic/terminal-util.c \
+ src/basic/terminal-util.h \
+ src/basic/login-util.h \
+ src/basic/login-util.c \
+ src/basic/audit.c \
+ src/basic/audit.h \
+ src/basic/memfd-util.c \
+ src/basic/memfd-util.h \
+ src/basic/process-util.c \
+ src/basic/process-util.h \
+ src/basic/random-util.c \
+ src/basic/random-util.h \
+ src/basic/verbs.c \
+ src/basic/verbs.h \
+ src/basic/label.c \
+ src/basic/label.h \
+ src/basic/selinux-util.c \
+ src/basic/selinux-util.h \
+ src/basic/mkdir-label.c \
+ src/basic/fileio-label.c \
+ src/basic/fileio-label.h \
+ src/basic/rm-rf.c \
+ src/basic/rm-rf.h
+
+nodist_libbasic_la_SOURCES = \
+ src/basic/errno-from-name.h \
+ src/basic/errno-to-name.h \
+ src/basic/cap-from-name.h \
+ src/basic/cap-to-name.h
+
+libbasic_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(SELINUX_CFLAGS) \
+ $(CAP_CFLAGS) \
+ -pthread
+
+libbasic_la_LIBADD = \
+ $(SELINUX_LIBS) \
+ $(CAP_LIBS) \
+ -ldl \
+ -lrt \
+ -lm
+
+# -----------------------------------------------------------------------------
+noinst_LTLIBRARIES += \
+ libshared.la
+
+libshared_la_SOURCES = \
src/shared/sleep-config.c \
src/shared/sleep-config.h \
- src/shared/strv.c \
- src/shared/strv.h \
- src/shared/env-util.c \
- src/shared/env-util.h \
- src/shared/strbuf.c \
- src/shared/strbuf.h \
- src/shared/strxcpyx.c \
- src/shared/strxcpyx.h \
src/shared/conf-parser.c \
src/shared/conf-parser.h \
- src/shared/log.c \
- src/shared/log.h \
- src/shared/ratelimit.h \
- src/shared/ratelimit.c \
- src/shared/exit-status.c \
- src/shared/exit-status.h \
- src/shared/utf8.c \
- src/shared/utf8.h \
- src/shared/gunicode.c \
- src/shared/gunicode.h \
src/shared/pager.c \
src/shared/pager.h \
- src/shared/socket-util.c \
- src/shared/socket-util.h \
- src/shared/in-addr-util.c \
- src/shared/in-addr-util.h \
- src/shared/ether-addr-util.h \
- src/shared/conf-files.c \
- src/shared/conf-files.h \
- src/shared/cgroup-util.c \
- src/shared/cgroup-util.h \
- src/shared/cgroup-show.c \
- src/shared/cgroup-show.h \
- src/shared/logs-show.h \
- src/shared/unit-name.c \
- src/shared/unit-name.h \
- src/shared/watchdog.c \
- src/shared/watchdog.h \
- src/shared/replace-var.c \
- src/shared/replace-var.h \
src/shared/spawn-polkit-agent.c \
src/shared/spawn-polkit-agent.h \
- src/shared/clock-util.c \
- src/shared/clock-util.h \
- src/shared/calendarspec.c \
- src/shared/calendarspec.h \
- src/shared/fileio.c \
- src/shared/fileio.h \
- src/shared/output-mode.h \
- src/shared/MurmurHash2.c \
- src/shared/MurmurHash2.h \
- src/shared/acpi-fpdt.h \
- src/shared/acpi-fpdt.c \
- src/shared/mkdir.c \
- src/shared/mkdir.h \
- src/shared/smack-util.c \
- src/shared/smack-util.h \
src/shared/apparmor-util.c \
src/shared/apparmor-util.h \
- src/shared/ima-util.c \
- src/shared/ima-util.h \
- src/shared/ptyfwd.c \
- src/shared/ptyfwd.h \
- src/shared/errno-list.c \
- src/shared/errno-list.h \
- src/shared/af-list.c \
- src/shared/af-list.h \
- src/shared/arphrd-list.c \
- src/shared/arphrd-list.h \
- src/shared/cap-list.c \
- src/shared/cap-list.h \
- src/shared/audit.c \
- src/shared/audit.h \
- src/shared/xml.c \
- src/shared/xml.h \
- src/shared/json.c \
- src/shared/json.h \
- src/shared/selinux-util.c \
- src/shared/selinux-util.h \
- src/shared/label.c \
- src/shared/label.h \
- src/shared/socket-label.c \
- src/shared/mkdir-label.c \
- src/shared/fileio-label.h \
- src/shared/fileio-label.c \
- src/shared/bus-label.c \
- src/shared/bus-label.h \
- src/shared/gpt.h \
- src/shared/clean-ipc.h \
src/shared/clean-ipc.c \
- src/shared/login-shared.c \
- src/shared/login-shared.h \
- src/shared/ring.c \
- src/shared/ring.h \
- src/shared/barrier.c \
- src/shared/barrier.h \
- src/shared/pty.c \
- src/shared/pty.h \
- src/shared/async.c \
- src/shared/async.h \
- src/shared/base-filesystem.c \
- src/shared/base-filesystem.h \
- src/shared/memfd-util.c \
- src/shared/memfd-util.h \
- src/shared/process-util.c \
- src/shared/process-util.h \
- src/shared/random-util.c \
- src/shared/random-util.h \
- src/shared/terminal-util.c \
- src/shared/terminal-util.h \
- src/shared/uid-range.c \
- src/shared/uid-range.h \
- src/shared/nss-util.h \
- src/shared/verbs.c \
- src/shared/verbs.h \
- src/shared/sigbus.c \
- src/shared/sigbus.h \
- src/shared/build.h \
- src/shared/import-util.c \
- src/shared/import-util.h \
- src/shared/sysctl-util.c \
- src/shared/sysctl-util.h \
- src/shared/hostname-util.h \
- src/shared/hostname-util.c
-
-nodist_libelogind_shared_la_SOURCES = \
- src/shared/errno-from-name.h \
- src/shared/errno-to-name.h \
- src/shared/af-from-name.h \
- src/shared/af-to-name.h \
- src/shared/arphrd-from-name.h \
- src/shared/arphrd-to-name.h \
- src/shared/cap-from-name.h \
- src/shared/cap-to-name.h
-
-libelogind_shared_la_CFLAGS = \
- $(AM_CFLAGS) \
- $(CAP_CFLAGS) \
- $(SECCOMP_CFLAGS) \
- -pthread
-
-libelogind_shared_la_LIBADD = \
- $(CAP_LIBS) \
- -lm
+ src/shared/clean-ipc.h \
+ src/shared/cgroup-show.c \
+ src/shared/cgroup-show.h \
+ src/shared/bus-util.c \
+ src/shared/bus-util.h
-libelogind_shared_la_LDFLAGS = \
- $(CAP_LDFLAGS)
+if HAVE_SECCOMP
+libshared_la_SOURCES += \
+ src/shared/seccomp-util.h \
+ src/shared/seccomp-util.c
+endif
-# ------------------------------------------------------------------------------
if HAVE_ACL
-noinst_LTLIBRARIES += \
- libelogind-acl.la
-
-libelogind_acl_la_SOURCES = \
+libshared_la_SOURCES += \
src/shared/acl-util.c \
src/shared/acl-util.h
+endif
-libelogind_acl_la_CFLAGS = \
+libshared_la_CFLAGS = \
$(AM_CFLAGS) \
- $(ACL_CFLAGS)
+ $(ACL_CFLAGS) \
+ $(LIBIDN_CFLAGS) \
+ $(SECCOMP_CFLAGS)
-libelogind_acl_la_LIBADD = \
- $(ACL_LIBS)
-endif
+libshared_la_LIBADD = \
+ libelogind-internal.la \
+ $(UDEV_LIBS) \
+ $(ACL_LIBS) \
+ $(LIBIDN_LIBS) \
+ $(SECCOMP_LIBS)
gperf_txt_sources = \
- src/shared/errno-list.txt \
- src/shared/af-list.txt \
- src/shared/arphrd-list.txt \
- src/shared/cap-list.txt
+ src/basic/errno-list.txt \
+ src/basic/af-list.txt \
+ src/basic/arphrd-list.txt \
+ src/basic/cap-list.txt
BUILT_SOURCES += \
+ $(gperf_gperf_m4_sources:-gperf.gperf.m4=-gperf.c) \
$(gperf_gperf_sources:-gperf.gperf=-gperf.c) \
$(gperf_txt_sources:-list.txt=-from-name.h) \
$(gperf_txt_sources:-list.txt=-to-name.h)
@@ -555,61 +411,68 @@ DISTCLEANFILES = \
EXTRA_DIST += \
$(gperf_gperf_m4_sources) \
- $(gperf_gperf_sources) \
- $(gperf_txt_sources:-list.txt=-from-name.gperf)
+ $(gperf_gperf_sources)
CLEANFILES += \
$(gperf_txt_sources)
%-from-name.gperf: %-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
%-from-name.h: %-from-name.gperf
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
-src/shared/errno-list.txt:
+src/basic/errno-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - </dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' >$@
-src/shared/errno-to-name.h: src/shared/errno-list.txt
+src/basic/errno-to-name.h: src/basic/errno-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
-src/shared/af-list.txt:
+src/basic/af-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/socket.h - </dev/null | grep -v AF_UNSPEC | grep -v AF_MAX | $(AWK) '/^#define[ \t]+AF_[^ \t]+[ \t]+PF_[^ \t]/ { print $$2; }' >$@
-src/shared/af-to-name.h: src/shared/af-list.txt
+src/basic/af-to-name.h: src/basic/af-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const af_names[] = { "} !/AF_FILE/ && !/AF_ROUTE/ && !/AF_LOCAL/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
-src/shared/arphrd-list.txt:
+src/basic/arphrd-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include net/if_arp.h - </dev/null | $(AWK) '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $$2; }' | sed -e 's/ARPHRD_//' >$@
-src/shared/arphrd-to-name.h: src/shared/arphrd-list.txt
+src/basic/arphrd-to-name.h: src/basic/arphrd-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const arphrd_names[] = { "} !/CISCO/ { printf "[ARPHRD_%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
-src/shared/arphrd-from-name.gperf: src/shared/arphrd-list.txt
+src/basic/arphrd-from-name.gperf: src/basic/arphrd-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct arphrd_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, ARPHRD_%s\n", $$1, $$1 }' <$< >$@
-src/shared/cap-list.txt:
+src/basic/cap-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/capability.h -include missing.h - </dev/null | $(AWK) '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $$2; }' | grep -v CAP_LAST_CAP >$@
-src/shared/cap-to-name.h: src/shared/cap-list.txt
+src/basic/cap-to-name.h: src/basic/cap-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const capability_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, tolower($$1) } END{print "};"}' <$< >$@
-src/shared/cap-from-name.gperf: src/shared/cap-list.txt
+src/basic/cap-from-name.gperf: src/basic/cap-list.txt
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct capability_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
-src/shared/cap-from-name.h: src/shared/cap-from-name.gperf
+src/basic/cap-from-name.h: src/basic/cap-from-name.gperf
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_capability -H hash_capability_name -p -C <$< >$@
# ------------------------------------------------------------------------------
-dist_factory_etc_DATA =
if HAVE_PAM
dist_factory_pam_DATA = \
@@ -618,24 +481,26 @@ dist_factory_pam_DATA = \
endif
# ------------------------------------------------------------------------------
-noinst_LTLIBRARIES += \
- libelogind-internal.la
+rootlibexec_PROGRAMS += \
+ elogind-cgroups-agent
+
+elogind_cgroups_agent_SOURCES = \
+ src/cgroups-agent/cgroups-agent.c
+
+elogind_cgroups_agent_LDADD = \
+ libshared.la
+# ------------------------------------------------------------------------------
libelogind_internal_la_SOURCES = \
src/systemd/sd-bus.h \
src/systemd/sd-bus-protocol.h \
src/systemd/sd-bus-vtable.h \
- src/systemd/sd-utf8.h \
src/systemd/sd-event.h \
- src/systemd/sd-rtnl.h \
- src/systemd/sd-resolve.h \
src/systemd/sd-login.h \
src/systemd/sd-id128.h \
src/systemd/sd-daemon.h \
src/systemd/sd-path.h \
- src/systemd/sd-network.h \
- src/systemd/sd-hwdb.h \
- src/systemd/sd-device.h \
+ src/libelogind/libelogind.sym \
src/libelogind/sd-bus/sd-bus.c \
src/libelogind/sd-bus/bus-control.c \
src/libelogind/sd-bus/bus-control.h \
@@ -649,8 +514,6 @@ libelogind_internal_la_SOURCES = \
src/libelogind/sd-bus/bus-socket.h \
src/libelogind/sd-bus/bus-kernel.c \
src/libelogind/sd-bus/bus-kernel.h \
- src/libelogind/sd-bus/bus-container.c \
- src/libelogind/sd-bus/bus-container.h \
src/libelogind/sd-bus/bus-message.c \
src/libelogind/sd-bus/bus-message.h \
src/libelogind/sd-bus/bus-creds.c \
@@ -672,88 +535,68 @@ libelogind_internal_la_SOURCES = \
src/libelogind/sd-bus/bus-convenience.c \
src/libelogind/sd-bus/bus-track.c \
src/libelogind/sd-bus/bus-track.h \
- src/libelogind/sd-bus/bus-util.c \
- src/libelogind/sd-bus/bus-util.h \
src/libelogind/sd-bus/bus-slot.c \
src/libelogind/sd-bus/bus-slot.h \
src/libelogind/sd-bus/bus-protocol.h \
- src/libelogind/sd-bus/kdbus.h \
- src/libelogind/sd-utf8/sd-utf8.c \
src/libelogind/sd-event/sd-event.c \
src/libelogind/sd-event/event-util.h \
- src/libelogind/sd-rtnl/sd-rtnl.c \
- src/libelogind/sd-rtnl/rtnl-internal.h \
- src/libelogind/sd-rtnl/rtnl-message.c \
- src/libelogind/sd-rtnl/rtnl-types.h \
- src/libelogind/sd-rtnl/rtnl-types.c \
- src/libelogind/sd-rtnl/rtnl-util.h \
- src/libelogind/sd-rtnl/rtnl-util.c \
- src/libelogind/sd-rtnl/local-addresses.h \
- src/libelogind/sd-rtnl/local-addresses.c \
src/libelogind/sd-id128/sd-id128.c \
src/libelogind/sd-daemon/sd-daemon.c \
src/libelogind/sd-login/sd-login.c \
- src/libelogind/sd-path/sd-path.c \
- src/libelogind/sd-network/sd-network.c \
- src/libelogind/sd-network/network-util.h \
- src/libelogind/sd-network/network-util.c \
- src/libelogind/sd-hwdb/sd-hwdb.c \
- src/libelogind/sd-hwdb/hwdb-util.h \
- src/libelogind/sd-hwdb/hwdb-internal.h \
- src/libelogind/sd-device/device-internal.h \
- src/libelogind/sd-device/device-util.h \
- src/libelogind/sd-device/device-enumerator.c \
- src/libelogind/sd-device/device-enumerator-private.h \
- src/libelogind/sd-device/sd-device.c \
- src/libelogind/sd-device/device-private.c \
- src/libelogind/sd-device/device-private.h
-
-nodist_libelogind_internal_la_SOURCES = \
- src/libelogind/libelogind.sym
-
-libelogind_internal_la_CFLAGS = \
- $(AM_CFLAGS) \
- -pthread
+ src/libelogind/sd-path/sd-path.c
libelogind_internal_la_LIBADD = \
- libelogind-shared.la
+ libbasic.la \
+ -lresolv
-libelogind_internal_la_LDFLAGS = \
- $(AM_LDFLAGS)
+noinst_LTLIBRARIES += \
+ libelogind-internal.la
-lib_LTLIBRARIES += \
- libelogind.la
+EXTRA_DIST += \
+ src/libelogind/libelogind.pc.in \
+ src/libelogind/sd-bus/DIFFERENCES \
+ src/libelogind/sd-bus/GVARIANT-SERIALIZATION
+
+libelogind_la_SOURCES = \
+ $(libelogind_internal_la_SOURCES)
-libelogind_la_SOURCES =
+nodist_libelogind_la_SOURCES = \
+ $(nodist_libelogind_internal_la_SOURCES)
libelogind_la_CFLAGS = \
- $(AM_CFLAGS)
+ $(libelogind_internal_la_CFLAGS)
libelogind_la_LDFLAGS = \
$(AM_LDFLAGS) \
-version-info $(LIBELOGIND_CURRENT):$(LIBELOGIND_REVISION):$(LIBELOGIND_AGE) \
- -Wl,--version-script=src/libelogind/libelogind.sym
+ -Wl,--version-script=$(top_srcdir)/src/libelogind/libelogind.sym
libelogind_la_LIBADD = \
- libelogind-internal.la
+ $(libelogind_internal_la_LIBADD)
+
+libelogind-install-hook:
+ libname=libelogind.so && $(move-to-rootlibdir)
+
+libelogind-uninstall-hook:
+ rm -f $(DESTDIR)$(rootlibdir)/libelogind.so*
+
+INSTALL_EXEC_HOOKS += libelogind-install-hook
+UNINSTALL_EXEC_HOOKS += libelogind-uninstall-hook
pkgconfiglib_DATA += \
src/libelogind/libelogind.pc
pkginclude_HEADERS += \
+ src/systemd/sd-bus.h \
+ src/systemd/sd-bus-protocol.h \
+ src/systemd/sd-bus-vtable.h \
+ src/systemd/sd-event.h \
src/systemd/sd-login.h \
- src/systemd/sd-messages.h \
- src/systemd/sd-journal.h \
- src/systemd/_sd-common.h
-
-EXTRA_DIST += \
- src/libelogind/libelogind.sym.m4 \
- src/libelogind/libelogind.pc.in \
- src/libelogind/sd-bus/DIFFERENCES \
- src/libelogind/sd-bus/GVARIANT-SERIALIZATION
+ src/systemd/sd-id128.h \
+ src/systemd/sd-daemon.h
-BUILT_SOURCES += \
- src/libelogind/libelogind.sym
+lib_LTLIBRARIES += \
+ libelogind.la
# ------------------------------------------------------------------------------
elogind_SOURCES = \
@@ -788,24 +631,22 @@ libelogind_core_la_SOURCES = \
src/login/logind-session-dbus.c \
src/login/logind-seat-dbus.c \
src/login/logind-user-dbus.c \
+ src/login/logind-utmp.c \
src/login/logind-acl.h
libelogind_core_la_LIBADD = \
- $(UDEV_LIBS) \
- libelogind-internal.la
+ libshared.la
if HAVE_ACL
libelogind_core_la_SOURCES += \
src/login/logind-acl.c
-
-libelogind_core_la_LIBADD += \
- libelogind-acl.la
endif
noinst_LTLIBRARIES += \
libelogind-core.la
-pkglibexec_PROGRAMS += elogind
+rootlibexec_PROGRAMS += \
+ elogind
loginctl_SOURCES = \
src/login/loginctl.c \
@@ -813,63 +654,47 @@ loginctl_SOURCES = \
src/login/sysfs-show.c
loginctl_LDADD = \
- $(UDEV_LIBS) \
- libelogind-internal.la \
- libelogind-shared.la
+ libshared.la
-bin_PROGRAMS += \
+rootbin_PROGRAMS += \
loginctl
-logind_cgroups_agent_SOURCES = \
- src/cgroups-agent/cgroups-agent.c
-
-logind_cgroups_agent_LDADD = \
- libelogind-internal.la \
- libelogind-shared.la
-
-pkglibexec_PROGRAMS += \
- logind-cgroups-agent
-
dist_bashcompletion_DATA += \
shell-completion/bash/loginctl
dist_zshcompletion_DATA += \
- shell-completion/zsh/_loginctl
+ shell-completion/zsh/_loginctl \
+ shell-completion/zsh/_elogind-inhibit
-systemd_inhibit_SOURCES = \
+elogind_inhibit_SOURCES = \
src/login/inhibit.c
-systemd_inhibit_LDADD = \
- libelogind-internal.la \
- libelogind-shared.la
+elogind_inhibit_LDADD = \
+ libshared.la
-bin_PROGRAMS += \
- systemd-inhibit
+rootbin_PROGRAMS += \
+ elogind-inhibit
test_login_SOURCES = \
src/libelogind/sd-login/test-login.c
test_login_LDADD = \
- libelogind-internal.la \
- libelogind-shared.la
+ libshared.la
test_login_shared_SOURCES = \
src/login/test-login-shared.c
test_login_shared_LDADD = \
- libelogind-internal.la \
- libelogind-shared.la
+ libshared.la
test_inhibit_SOURCES = \
src/login/test-inhibit.c
test_inhibit_LDADD = \
- libelogind-internal.la \
- libelogind-shared.la
+ libshared.la
test_login_tables_SOURCES = \
- src/login/test-login-tables.c \
- src/shared/test-tables.h
+ src/login/test-login-tables.c
test_login_tables_LDADD = \
libelogind-core.la
@@ -889,8 +714,7 @@ pam_elogind_la_SOURCES = \
pam_elogind_la_CFLAGS = \
$(AM_CFLAGS) \
- $(PAM_CFLAGS) \
- -fvisibility=hidden
+ $(PAM_CFLAGS)
pam_elogind_la_LDFLAGS = \
$(AM_LDFLAGS) \
@@ -901,7 +725,7 @@ pam_elogind_la_LDFLAGS = \
-Wl,--version-script=$(top_srcdir)/src/login/pam_elogind.sym
pam_elogind_la_LIBADD = \
- libelogind-internal.la \
+ libshared.la \
$(PAM_LIBS)
pamlib_LTLIBRARIES = \
@@ -919,19 +743,16 @@ dist_dbuspolicy_DATA += \
src/login/org.freedesktop.login1.conf
dist_pkgsysconf_DATA += \
- src/login/logind.conf
+ src/login/elogind.conf
polkitpolicy_files += \
src/login/org.freedesktop.login1.policy
-SYSTEM_UNIT_ALIASES += \
- elogind.service dbus-org.freedesktop.login1.service
-
-dist_udevrules_DATA = \
+dist_udevrules_DATA += \
src/login/70-uaccess.rules \
src/login/70-power-switch.rules
-nodist_udevrules_DATA = \
+nodist_udevrules_DATA += \
src/login/71-seat.rules \
src/login/73-seat-late.rules
@@ -947,10 +768,14 @@ EXTRA_DIST += \
# ------------------------------------------------------------------------------
substitutions = \
+ '|rootlibexecdir=$(rootlibexecdir)|' \
+ '|rootbindir=$(rootbindir)|' \
'|bindir=$(bindir)|' \
- '|udevbindir=$(udevbindir)|' \
'|pkgsysconfdir=$(pkgsysconfdir)|' \
'|pkgdatadir=$(pkgdatadir)|' \
+ '|udevhwdbdir=$(udevhwdbdir)|' \
+ '|udevrulesdir=$(udevrulesdir)|' \
+ '|CERTIFICATEROOT=$(CERTIFICATEROOT)|' \
'|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
'|PACKAGE_NAME=$(PACKAGE_NAME)|' \
'|PACKAGE_URL=$(PACKAGE_URL)|' \
@@ -960,18 +785,29 @@ substitutions = \
'|includedir=$(includedir)|' \
'|VERSION=$(VERSION)|' \
'|rootprefix=$(rootprefix)|' \
+ '|udevlibexecdir=$(udevlibexecdir)|' \
+ '|SUSHELL=$(SUSHELL)|' \
+ '|SULOGIN=$(SULOGIN)|' \
+ '|DEBUGTTY=$(DEBUGTTY)|' \
+ '|KILL=$(KILL)|' \
+ '|KMOD=$(KMOD)|' \
'|MKDIR_P=$(MKDIR_P)|' \
+ '|QUOTAON=$(QUOTAON)|' \
+ '|RC_LOCAL_SCRIPT_PATH_START=$(RC_LOCAL_SCRIPT_PATH_START)|' \
+ '|RC_LOCAL_SCRIPT_PATH_STOP=$(RC_LOCAL_SCRIPT_PATH_STOP)|' \
+ '|PYTHON=$(PYTHON)|' \
+ '|PYTHON_BINARY=$(PYTHON_BINARY)|' \
+ '|NTP_SERVERS=$(NTP_SERVERS)|' \
+ '|DNS_SERVERS=$(DNS_SERVERS)|' \
'|systemuidmax=$(SYSTEM_UID_MAX)|' \
- '|systemgidmax=$(SYSTEM_GID_MAX)|'
+ '|systemgidmax=$(SYSTEM_GID_MAX)|' \
+ '|TTY_GID=$(TTY_GID)|'
SED_PROCESS = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
< $< > $@
-units/%: units/%.in
- $(SED_PROCESS)
-
man/%: man/%.in
$(SED_PROCESS)
@@ -984,9 +820,6 @@ sysctl.d/%: sysctl.d/%.in
%.conf: %.conf.in
$(SED_PROCESS)
-src/%.policy.in: src/%.policy.in.in
- $(SED_PROCESS)
-
shell-completion/%: shell-completion/%.in
$(SED_PROCESS)
@@ -1027,13 +860,11 @@ units/user/%: units/user/%.m4
if ENABLE_POLKIT
nodist_polkitpolicy_DATA = \
- $(polkitpolicy_files) \
- $(polkitpolicy_in_in_files:.policy.in.in=.policy)
+ $(polkitpolicy_files)
endif
EXTRA_DIST += \
- $(polkitpolicy_in_files) \
- $(polkitpolicy_in_in_files)
+ $(polkitpolicy_in_files)
# ------------------------------------------------------------------------------
if ENABLE_MANPAGES
@@ -1043,7 +874,7 @@ man/custom-entities.ent: configure.ac
printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
> $@ # '
-DISTCLEANFILES += \
+CLEANFILES += \
man/custom-entities.ent
XSLTPROC_FLAGS = \
@@ -1100,19 +931,159 @@ distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
clean-local: $(CLEAN_LOCAL_HOOKS)
rm -rf $(abs_srcdir)/install-tree
+ rm -f $(abs_srcdir)/hwdb/usb.ids $(abs_srcdir)/hwdb/pci.ids $(abs_srcdir)/hwdb/oui.txt \
+ $(abs_srcdir)/hwdb/iab.txt
DISTCHECK_CONFIGURE_FLAGS = \
--with-dbuspolicydir=$$dc_install_base/$(dbuspolicydir) \
- --with-dbussessionservicedir=$$dc_install_base/$(dbussessionservicedir) \
--with-dbussystemservicedir=$$dc_install_base/$(dbussystemservicedir) \
--with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
--with-zshcompletiondir=$$dc_install_base/$(zshcompletiondir) \
--with-pamlibdir=$$dc_install_base/$(pamlibdir) \
--with-pamconfdir=$$dc_install_base/$(pamconfdir) \
- --enable-kdbus \
- --with-udevrulesdir=$$dc_install_base/$(udevrulesdir)
+ --with-rootprefix=$$dc_install_base \
+ --enable-compat-libs
+
+DISTCHECK_CONFIGURE_FLAGS += \
+ --with-sysvinit-path= \
+ --with-sysvrcnd-path=
-if ENABLE_GTK_DOC
+if ENABLE_SPLIT_USR
+DISTCHECK_CONFIGURE_FLAGS += \
+ --enable-split-usr
+else
DISTCHECK_CONFIGURE_FLAGS += \
- --enable-gtk-doc
+ --disable-split-usr
endif
+
+#
+# Require python when making dist
+#
+.PHONY: dist-check-python dist-check-compat-libs dist-check-help
+dist-check-python:
+
+dist-check-compat-libs:
+
+dist-check-help: $(rootbin_PROGRAMS) $(bin_PROGRAMS)
+ for i in $(abspath $^); do \
+ if $$i --help | grep -v 'default:' | grep -E -q '.{80}.' ; then \
+ echo "$(basename $$i) --help output is too wide:"; \
+ $$i --help | awk 'length > 80' | grep -E --color=yes '.{80}'; \
+ exit 1; \
+ fi; done
+
+dist: dist-check-python dist-check-compat-libs
+
+.PHONY: git-tag
+git-tag:
+ git tag -s "v$(VERSION)" -m "elogind $(VERSION)"
+
+.PHONY: install-tree
+install-tree: all
+ rm -rf $(abs_srcdir)/install-tree
+ $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
+ tree $(abs_srcdir)/install-tree
+
+# Let's run all tests of the test suite, but under valgrind. Let's
+# exclude the one perl script we have in there
+.PHONY: valgrind-tests
+valgrind-tests: $(TESTS)
+ $(AM_V_GEN)for f in $(filter-out %.pl, $^); do \
+ if file $$f | grep -q shell; then \
+ echo -e "$${x}Skipping non-binary $$f"; else \
+ echo -e "$${x}Running $$f"; \
+ libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \
+ x="\n\n"; \
+ done
+
+exported-%: %
+ $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
+
+exported: $(addprefix exported-, $(lib_LTLIBRARIES))
+ $(AM_V_GEN)cat $^ > $@
+
+.PHONY: check-api-docs
+check-api-docs: exported man
+ $(AM_V_GEN)for symbol in `cat exported` ; do \
+ if test -f $(builddir)/man/$$symbol.html ; then \
+ echo " Symbol $$symbol() is documented." ; \
+ else \
+ echo "‣ Symbol $$symbol() lacks documentation." ; \
+ fi ; \
+ done
+
+OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
+ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
+
+undefined defined: $(ALL_OBJECTS)
+ $(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
+ $(NM) -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
+ done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
+
+CLEANFILES += \
+ defined \
+ undefined
+
+.PHONY: check-api-unused
+check-api-unused: defined undefined exported
+ ( cat exported undefined ) | sort -u | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2-
+
+.PHONY: check-includes
+check-includes: $(top_srcdir)/tools/check-includes.pl
+ $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
+ | xargs $(top_srcdir)/tools/check-includes.pl
+
+EXTRA_DIST += \
+ $(top_srcdir)/tools/check-includes.pl
+
+# Stupid test that everything purported to be exported really is
+define generate-sym-test
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_at)printf '#include <stdio.h>\n' > $@
+ $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
+ $(AM_V_at)printf 'void* functions[] = {\n' >> $@
+ $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
+ $(AM_V_at)printf '};\nint main(void) {\n' >> $@
+ $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
+ $(AM_V_at)printf 'return 0; }\n' >> $@
+endef
+
+test-libelogind-sym.c: \
+ $(top_builddir)/src/libelogind/libelogind.sym \
+ src/systemd/sd-daemon.h \
+ src/systemd/sd-login.h \
+ src/systemd/sd-bus.h \
+ src/systemd/sd-path.h \
+ src/systemd/sd-event.h
+ $(generate-sym-test)
+
+test_libelogind_sym_SOURCES = \
+ test-libelogind-sym.c
+test_libelogind_sym_LDADD = \
+ libelogind.la
+
+BUILT_SOURCES += \
+ $(test_libelogind_sym_SOURCES)
+
+tests += \
+ test-libelogind-sym
+
+.PHONY: cppcheck
+cppcheck:
+ cppcheck --enable=all -q $(top_srcdir)
+
+# Used to extract compile flags for YCM.
+print-%:
+ @echo $($*)
+
+git-contrib:
+ @git shortlog -s `git describe --abbrev=0`.. | cut -c8- | awk '{ print $$0 "," }' | sort -u
+
+EXTRA_DIST += \
+ tools/gdb-sd_dump_hashmaps.py
+
+list-keys:
+ gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --list-keys
+
+add-key:
+ gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -
diff --git a/NEWS b/NEWS
index 7a4621cc5..bda8a8eb6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,83 @@
systemd System and Service Manager
+CHANGES WITH 221:
+
+ * The sd-bus.h and sd-event.h APIs have now been declared
+ stable and have been added to the official interface of
+ libsystemd.so. sd-bus implements an alternative D-Bus client
+ library, that is relatively easy to use, very efficient and
+ supports both classic D-Bus as well as kdbus as transport
+ backend. sd-event is a generic event loop abstraction that
+ is built around Linux epoll, but adds features such as event
+ prioritization or efficient timer handling. Both APIs are good
+ choices for C programs looking for a bus and/or event loop
+ implementation that is minimal and does not have to be
+ portable to other kernels.
+
+ * kdbus support is no longer compile-time optional. It is now
+ always built-in. However, it can still be disabled at
+ runtime using the kdbus=0 kernel command line setting, and
+ that setting may be changed to default to off, by specifying
+ --disable-kdbus at build-time. Note though that the kernel
+ command line setting has no effect if the kdbus.ko kernel
+ module is not installed, in which case kdbus is (obviously)
+ also disabled. We encourage all downstream distributions to
+ begin testing kdbus by adding it to the kernel images in the
+ development distributions, and leaving kdbus support in
+ systemd enabled.
+
+ * The minimal required util-linux version has been bumped to
+ 2.26.
+
+ * Support for chkconfig (--enable-chkconfig) was removed in
+ favor of calling an abstraction tool
+ /lib/systemd/systemd-sysv-install. This needs to be
+ implemented for your distribution. See "SYSV INIT.D SCRIPTS"
+ in README for details.
+
+ * If there's a systemd unit and a SysV init script for the
+ same service name, and the user executes "systemctl enable"
+ for it (or a related call), then this will now enable both
+ (or execute the related operation on both), not just the
+ unit.
+
+ * The libudev API documentation has been converted from gtkdoc
+ into man pages.
+
+ * gudev has been removed from the systemd tree, it is now an
+ external project.
+
+ * The systemd-cgtop tool learnt a new --raw switch to generate
+ "raw" (machine parsable) output.
+
+ * networkd's IPForwarding= .network file setting learnt the
+ new setting "kernel", which ensures that networkd does not
+ change the IP forwarding sysctl from the default kernel
+ state.
+
+ * The systemd-logind bus API now exposes a new boolean
+ property "Docked" that reports whether logind considers the
+ system "docked", i.e. connected to a docking station or not.
+
+ Contributions from: Alex Crawford, Andreas Pokorny, Andrei
+ Borzenkov, Charles Duffy, Colin Guthrie, Cristian Rodríguez,
+ Daniele Medri, Daniel Hahler, Daniel Mack, David Herrmann,
+ David Mohr, Dimitri John Ledkov, Djalal Harouni, dslul, Ed
+ Swierk, Eric Cook, Filipe Brandenburger, Gianpaolo Macario,
+ Harald Hoyer, Iago López Galeiras, Igor Vuk, Jan Synacek,
+ Jason Pleau, Jason S. McMullan, Jean Delvare, Jeff Huang,
+ Jonathan Boulle, Karel Zak, Kay Sievers, kloun, Lennart
+ Poettering, Marc-Antoine Perennou, Marcel Holtmann, Mario
+ Limonciello, Martin Pitt, Michael Biebl, Michael Olbrich,
+ Michal Schmidt, Mike Gilbert, Nick Owens, Pablo Lezaeta Reyes,
+ Patrick Donnelly, Pavel Odvody, Peter Hutterer, Philip
+ Withnall, Ronny Chevalier, Simon McVittie, Susant Sahani,
+ Thomas Hindoe Paaboel Andersen, Tom Gundersen, Torstein
+ Husebø, Umut Tezduyar Lindskog, Viktar Vauchkevich, Werner
+ Fink, Zbigniew Jędrzejewski-Szmek
+
+ -- Berlin, 2015-06-19
+
CHANGES WITH 220:
* The gudev library has been extracted into a separate repository
@@ -227,7 +305,7 @@ CHANGES WITH 220:
Gundersen, Torstein Husebø, Umut Tezduyar Lindskog, Will
Woods, Zachary Cook, Zbigniew Jędrzejewski-Szmek
- -- Berlin, 2015-05-??
+ -- Berlin, 2015-05-22
CHANGES WITH 219:
@@ -3997,7 +4075,7 @@ CHANGES WITH 191:
* HandleSleepKey= in logind.conf has been split up into
HandleSuspendKey= and HandleHibernateKey=. The old setting
is not available anymore. X11 and the kernel are
- distuingishing between these keys and we should too. This
+ distinguishing between these keys and we should too. This
also means the inhibition lock for these keys has been split
into two.
@@ -4743,7 +4821,7 @@ CHANGES WITH 43:
* Various functionality updates to libsystemd-login.so
- * Track class of PAM logins to distuingish greeters from
+ * Track class of PAM logins to distinguish greeters from
normal user logins.
Contributions from: Kay Sievers, Lennart Poettering, Michael
diff --git a/README b/README
index e08b1ddd0..651aa9837 100644
--- a/README
+++ b/README
@@ -1,157 +1,264 @@
-Elogind User, Seat and Session Manager
-
-Introduction
-------------
-
-Elogind is the systemd project's "logind", extracted out to be a
-standalone daemon. It integrates with PAM to know the set of users
-that are logged in to a system and whether they are logged in
-graphically, on the console, or remotely. Elogind exposes this
-information via the standard org.freedesktop.login1 D-Bus interface,
-as well as through the file system using systemd's standard
-/run/systemd layout. Elogind also provides "libelogind", which is a
-subset of the facilities offered by "libsystemd". There is a
-"libelogind.pc" pkg-config file as well.
-
-All of the credit for elogind should go to the systemd developers.
-For more on systemd, see
-http://www.freedesktop.org/wiki/Software/systemd. All of the blame
-should go to Andy Wingo, who extracted elogind from systemd.
-
-Contributing
-------------
-
-Elogind was branched from systemd version 219, and preserves the git
-history of the systemd project. The version of elogind is the
-upstream systemd version, followed by the patchlevel of elogind. For
-example version 219.12 is the twelfth elogind release, which aims to
-provide a subset of the interfaces of systemd 219.
-
-To contribute to elogind, fork the current source code from github:
-
- https://github.com/elogind/elogind
-
-Send a pull request for the changes you like.
-
-To chat about elogind:
-
- #guix on irc.freenode.org
-
-Finally, bug reports:
-
- https://github.com/elogind/elogind/issues
-
-Why bother?
------------
-
-Elogind has been developed for use in GuixSD, the OS distribution of
-GNU Guix. See http://gnu.org/s/guix for more on Guix. GuixSD uses a
-specific init manager (DMD), for reasons that are not relevant here,
-but still aims to eventually be a full-featured distribution that can
-run GNOME and other desktop environments. However, to run GNOME these
-days means that you need to have support for the login1 D-Bus
-interface, which is currently only provided by systemd. That is the
-origin of this project: to take the excellent logind functionality
-from systemd and provide it as a standalone package.
-
-We like systemd. We realize that there are people out there that hate
-it. You're welcome to use elogind for whatever purpose you like --
-as-is, or as a jumping-off point for other things -- but please don't
-use it as part of some anti-systemd vendetta. Systemd hackers are
-smart folks that are trying to solve interesting problems on the free
-desktop, and their large adoption is largely because they solve
-problems that users and developers of user-focused applications care
-about. We are appreciative of their logind effort and think that
-everyone deserves to run it if they like, even if they use a different
-PID 1.
-
-Differences relative to systemd
--------------------------------
-
-The pkg-config file is called libelogind, not libsystemd or
-libsystemd-logind.
-
-The headers are in <elogind/...>, so like <elogind/sd-login.h> instead
-of <systemd/sd-login.h>.
-
-Libelogind just implements login-related functionality. It also
-provides the sd-bus API.
-
-Unlike systemd, whose logind arranges to manage resources for user
-sessions via RPC calls to systemd, in elogind there is no systemd so
-there is no global cgroup-based resource management. This has a few
-implications:
-
- * Elogind does not create "slices" for users. Elogind will not
- record that users are associated with slices.
-
- * The /run/systemd/slices directory will always be empty.
-
- * Elogind does not have the concept of a "scope", internally, as
- it's the same as a session. Any API that refers to scopes will
- always return an error code.
-
-On the other hand, elogind does use a similar strategy to systemd in
-that it places processes in a private cgroup for organizational
-purposes, without installing any controllers (see
-http://0pointer.de/blog/projects/cgroups-vs-cgroups.html). This
-allows elogind to map arbitrary processes to sessions, even if the
-process does the usual double-fork to be reparented to PID 1.
-
-Elogind does not manage virtual terminals.
-
-Elogind does monitor power button and the lid switch, like systemd,
-but instead of doing RPC to systemd to suspend, poweroff, or restart
-the machine, elogind just does this directly. For suspend, hybernate,
-and hybrid-sleep, elogind uses the same code as systemd-sleep.
-Instead of using a separate sleep.conf file to configure the sleep
-behavior, this is included in the [Sleep] section of
-/etc/elogind/login.conf. See the example login.conf for more. For
-shutdown, reboot, and kexec, elogind shells out to "halt", "reboot",
-and "kexec" binaries.
-
-The loginctl command has the poweroff, reboot, sleep, hibernate, and
-hybrid-sleep commands from systemd, as well as the --ignore-inhibitors
-flag.
-
-The PAM module is called pam_elogind.so, not pam_systemd.so.
-
-License
--------
-
-LGPLv2.1+ for all code
-
- - except src/shared/MurmurHash2.c which is Public Domain
- - except src/shared/siphash24.c which is CC0 Public Domain
- - except src/journal/lookup3.c which is Public Domain
-
-Dependencies
-------------
-
- glibc >= 2.14
- libcap
- libmount >= 2.20 (from util-linux)
- libseccomp >= 1.0.0 (optional)
- libblkid >= 2.24 (from util-linux) (optional)
- PAM >= 1.1.2 (optional)
- libacl (optional)
- libselinux (optional)
- make, gcc, and similar tools
-
-During runtime, you need the following additional dependencies:
-
- dbus >= 1.4.0 (strictly speaking optional, but recommended)
- PolicyKit (optional)
-
-When building from git, you need the following additional
-dependencies:
-
- pkg-config
- docbook-xsl
- xsltproc
- automake
- autoconf
- libtool
- intltool
- gperf
- gtkdocize (optional)
+systemd System and Service Manager
+
+DETAILS:
+ http://0pointer.de/blog/projects/systemd.html
+
+WEB SITE:
+ http://www.freedesktop.org/wiki/Software/systemd
+
+GIT:
+ git@github.com:systemd/systemd.git
+ https://github.com/systemd/systemd.git
+
+GITWEB:
+ https://github.com/systemd/systemd
+
+MAILING LIST:
+ http://lists.freedesktop.org/mailman/listinfo/systemd-devel
+ http://lists.freedesktop.org/mailman/listinfo/systemd-commits
+
+IRC:
+ #systemd on irc.freenode.org
+
+BUG REPORTS:
+ https://github.com/systemd/systemd/issues
+
+AUTHOR:
+ Lennart Poettering
+ Kay Sievers
+ ...and many others
+
+LICENSE:
+ LGPLv2.1+ for all code
+ - except src/basic/MurmurHash2.c which is Public Domain
+ - except src/basic/siphash24.c which is CC0 Public Domain
+ - except src/journal/lookup3.c which is Public Domain
+ - except src/udev/* which is (currently still) GPLv2, GPLv2+
+
+REQUIREMENTS:
+ Linux kernel >= 3.7
+ Linux kernel >= 3.8 for Smack support
+
+ Kernel Config Options:
+ CONFIG_DEVTMPFS
+ CONFIG_CGROUPS (it is OK to disable all controllers)
+ CONFIG_INOTIFY_USER
+ CONFIG_SIGNALFD
+ CONFIG_TIMERFD
+ CONFIG_EPOLL
+ CONFIG_NET
+ CONFIG_SYSFS
+ CONFIG_PROC_FS
+ CONFIG_FHANDLE (libudev, mount and bind mount handling)
+
+ udev will fail to work with the legacy sysfs layout:
+ CONFIG_SYSFS_DEPRECATED=n
+
+ Legacy hotplug slows down the system and confuses udev:
+ CONFIG_UEVENT_HELPER_PATH=""
+
+ Userspace firmware loading is not supported and should
+ be disabled in the kernel:
+ CONFIG_FW_LOADER_USER_HELPER=n
+
+ Some udev rules and virtualization detection relies on it:
+ CONFIG_DMIID
+
+ Support for some SCSI devices serial number retrieval, to
+ create additional symlinks in /dev/disk/ and /dev/tape:
+ CONFIG_BLK_DEV_BSG
+
+ Required for PrivateNetwork and PrivateDevices in service units:
+ CONFIG_NET_NS
+ CONFIG_DEVPTS_MULTIPLE_INSTANCES
+ Note that systemd-localed.service and other systemd units use
+ PrivateNetwork and PrivateDevices so this is effectively required.
+
+ Optional but strongly recommended:
+ CONFIG_IPV6
+ CONFIG_AUTOFS4_FS
+ CONFIG_TMPFS_XATTR
+ CONFIG_{TMPFS,EXT4,XFS,BTRFS_FS,...}_POSIX_ACL
+ CONFIG_SECCOMP
+ CONFIG_CHECKPOINT_RESTORE (for the kcmp() syscall)
+
+ Required for CPUShares in resource control unit settings
+ CONFIG_CGROUP_SCHED
+ CONFIG_FAIR_GROUP_SCHED
+
+ Required for CPUQuota in resource control unit settings
+ CONFIG_CFS_BANDWIDTH
+
+ For systemd-bootchart, several proc debug interfaces are required:
+ CONFIG_SCHEDSTATS
+ CONFIG_SCHED_DEBUG
+
+ For UEFI systems:
+ CONFIG_EFIVAR_FS
+ CONFIG_EFI_PARTITION
+
+ Note that kernel auditing is broken when used with systemd's
+ container code. When using systemd in conjunction with
+ containers, please make sure to either turn off auditing at
+ runtime using the kernel command line option "audit=0", or
+ turn it off at kernel compile time using:
+ CONFIG_AUDIT=n
+ If systemd is compiled with libseccomp support on
+ architectures which do not use socketcall() and where seccomp
+ is supported (this effectively means x86-64 and ARM, but
+ excludes 32-bit x86!), then nspawn will now install a
+ work-around seccomp filter that makes containers boot even
+ with audit being enabled. This works correctly only on kernels
+ 3.14 and newer though. TL;DR: turn audit off, still.
+
+ glibc >= 2.16
+ libcap
+ libmount >= 2.20 (from util-linux)
+ libseccomp >= 1.0.0 (optional)
+ libblkid >= 2.24 (from util-linux) (optional)
+ libkmod >= 15 (optional)
+ PAM >= 1.1.2 (optional)
+ libcryptsetup (optional)
+ libaudit (optional)
+ libacl (optional)
+ libselinux (optional)
+ liblzma (optional)
+ liblz4 >= 119 (optional)
+ libgcrypt (optional)
+ libqrencode (optional)
+ libmicrohttpd (optional)
+ libpython (optional)
+ libidn (optional)
+ elfutils >= 158 (optional)
+ make, gcc, and similar tools
+
+ During runtime, you need the following additional
+ dependencies:
+
+ util-linux >= v2.26 required
+ dbus >= 1.4.0 (strictly speaking optional, but recommended)
+ dracut (optional)
+ PolicyKit (optional)
+
+ When building from git, you need the following additional
+ dependencies:
+
+ pkg-config
+ docbook-xsl
+ xsltproc
+ automake
+ autoconf
+ libtool
+ intltool
+ gperf
+ python (optional)
+ python-lxml (optional, but required to build the indices)
+ sphinx (optional)
+
+ When systemd-hostnamed is used, it is strongly recommended to
+ install nss-myhostname to ensure that, in a world of
+ dynamically changing hostnames, the hostname stays resolvable
+ under all circumstances. In fact, systemd-hostnamed will warn
+ if nss-myhostname is not installed.
+
+ To build HTML documentation for python-systemd using sphinx,
+ please first install systemd (using 'make install'), and then
+ invoke sphinx-build with 'make sphinx-<target>', with <target>
+ being 'html' or 'latexpdf'. If using DESTDIR for installation,
+ pass the same DESTDIR to 'make sphinx-html' invocation.
+
+USERS AND GROUPS:
+ Default udev rules use the following standard system group
+ names, which need to be resolvable by getgrnam() at any time,
+ even in the very early boot stages, where no other databases
+ and network are available:
+
+ audio, cdrom, dialout, disk, input, kmem, lp, tape, tty, video
+
+ During runtime, the journal daemon requires the
+ "systemd-journal" system group to exist. New journal files will
+ be readable by this group (but not writable), which may be used
+ to grant specific users read access. In addition, system
+ groups "wheel" and "adm" will be given read-only access to
+ journal files using systemd-tmpfiles.service.
+
+ The journal gateway daemon requires the
+ "systemd-journal-gateway" system user and group to
+ exist. During execution this network facing service will drop
+ privileges and assume this uid/gid for security reasons.
+
+ Similarly, the NTP daemon requires the "systemd-timesync" system
+ user and group to exist.
+
+ Similarly, the network management daemon requires the
+ "systemd-network" system user and group to exist.
+
+ Similarly, the name resolution daemon requires the
+ "systemd-resolve" system user and group to exist.
+
+ Similarly, the kdbus dbus1 proxy daemon requires the
+ "systemd-bus-proxy" system user and group to exist.
+
+NSS:
+ systemd ships with three NSS modules:
+
+ nss-myhostname resolves the local hostname to locally
+ configured IP addresses, as well as "localhost" to
+ 127.0.0.1/::1.
+
+ nss-resolve enables DNS resolution via the systemd-resolved
+ DNS/LLMNR caching stub resolver "systemd-resolved".
+
+ nss-mymachines enables resolution of all local containers
+ registered with machined to their respective IP addresses.
+
+ To make use of these NSS modules, please add them to the
+ "hosts: " line in /etc/nsswitch.conf. The "resolve" module
+ should replace the glibc "dns" module in this file.
+
+ The three modules should be used in the following order:
+
+ hosts: files mymachines resolve myhostname
+
+SYSV INIT.D SCRIPTS:
+ When calling "systemctl enable/disable/is-enabled" on a unit which is a
+ SysV init.d script, it calls /usr/lib/systemd/systemd-sysv-install;
+ this needs to translate the action into the distribution specific
+ mechanism such as chkconfig or update-rc.d. Packagers need to provide
+ this script if you need this functionality (you don't if you disabled
+ SysV init support).
+
+ Please see src/systemctl/systemd-sysv-install.SKELETON for how this
+ needs to look like, and provide an implementation at the marked places.
+
+WARNINGS:
+ systemd will warn you during boot if /etc/mtab is not a
+ symlink to /proc/mounts. Please ensure that /etc/mtab is a
+ proper symlink.
+
+ systemd will warn you during boot if /usr is on a different
+ file system than /. While in systemd itself very little will
+ break if /usr is on a separate partition, many of its
+ dependencies very likely will break sooner or later in one
+ form or another. For example, udev rules tend to refer to
+ binaries in /usr, binaries that link to libraries in /usr or
+ binaries that refer to data files in /usr. Since these
+ breakages are not always directly visible, systemd will warn
+ about this, since this kind of file system setup is not really
+ supported anymore by the basic set of Linux OS components.
+
+ systemd requires that the /run mount point exists. systemd also
+ requires that /var/run is a symlink to /run.
+
+ For more information on this issue consult
+ http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
+
+ To run systemd under valgrind, compile with VALGRIND defined
+ (e.g. ./configure CPPFLAGS='... -DVALGRIND=1'). Otherwise,
+ false positives will be triggered by code which violates
+ some rules but is actually safe.
+
+ENGINEERING AND CONSULTING SERVICES:
+ ENDOCODE <https://endocode.com/> offers professional
+ engineering and consulting services for systemd. Please
+ contact Chris Kühl <chris@endocode.com> for more information.
diff --git a/TODO b/TODO
index 43b69681a..386599bc1 100644
--- a/TODO
+++ b/TODO
@@ -26,6 +26,31 @@ External:
Features:
+* "systemctl edit" should know a mode to create a new unit file
+
+* there's probably something wrong with having user mounts below /sys,
+ as we have for debugfs. for exmaple, src/core/mount.c handles mounts
+ prefixed with /sys generally special.
+ http://lists.freedesktop.org/archives/systemd-devel/2015-June/032962.html
+
+* Add PassEnvironment= setting to service units, to import select env vars from PID 1 into the service env block
+
+* nspawn: fix logic always print a final newline on output.
+ https://github.com/systemd/systemd/pull/272#issuecomment-113153176
+
+* make nspawn's --network-veth switch more powerful:
+ http://lists.freedesktop.org/archives/systemd-devel/2015-June/033121.html
+
+* man: document that unless you use StandardError=null the shell >/dev/stderr won't work in shell scripts in services
+
+* man: clarify that "machinectl show" shows different information than "machinectl status" (no cgroup tree, no IP addresses, ...)
+
+* "systemctl daemon-reload" should result in /etc/systemd/system.conf being reloaded by systemd
+
+* install: include generator dirs in unit file search paths
+
+* networkd: add support for configuring ipv6 privacy extensions
+
* introduce an NSS module that uses machined info to give container UIDs pretty names when user namespacing is used.
* stop using off_t, it's a crazy type. Use uint64_t instead.
@@ -537,8 +562,6 @@ Features:
* maybe do not install getty@tty1.service symlink in /etc but in /usr?
-* re-enable "make check" for gtk-doc (broken for unknown reason)
-
* fstab: add new mount option x-systemd-after=/foobar/waldo to allow manual dependencies to other mount points
https://bugzilla.redhat.com/show_bug.cgi?id=812826
diff --git a/autogen.sh b/autogen.sh
index 3997db30e..9d2c652a9 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -21,21 +21,13 @@ oldpwd=$(pwd)
topdir=$(dirname $0)
cd $topdir
-if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then
- # This part is allowed to fail
- cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
- chmod +x .git/hooks/pre-commit && \
- echo "Activated pre-commit hook." || :
-fi
-
-if which gtkdocize >/dev/null 2>/dev/null; then
- gtkdocize --docdir docs/ --flavour no-tmpl
- gtkdocargs=--enable-gtk-doc
-else
- echo "You don't have gtk-doc installed, and thus won't be able to generate the documentation."
- rm -f docs/gtk-doc.make
- echo 'EXTRA_DIST =' > docs/gtk-doc.make
-fi
+# We do not need this, we are not systemd upstream!
+#if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then
+# # This part is allowed to fail
+# cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+# chmod +x .git/hooks/pre-commit && \
+# echo "Activated pre-commit hook." || :
+#fi
intltoolize --force --automake
autoreconf --force --install --symlink
diff --git a/configure.ac b/configure.ac
index 9b6365ac1..c8a4aff8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
AC_PREREQ([2.64])
AC_INIT([elogind],
- [220],
+ [221],
[https://github.com/elogind/elogind/issues],
[elogind],
[https://github.com/elogind/elogind])
@@ -47,6 +47,7 @@ AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is
SET_ARCH(X86_64, x86_64*)
SET_ARCH(IA32, i*86*)
SET_ARCH(MIPS, mips*)
+SET_ARCH(AARCH64, aarch64*)
# i18n stuff for the PolicyKit policy files, heck whether intltool can be found, disable NLS otherwise
AC_CHECK_PROG(intltool_found, [intltool-merge], [yes], [no])
@@ -144,11 +145,9 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-pipe \
-Wall \
-Wextra \
- -Wno-inline \
-Wundef \
"-Wformat=2 -Wformat-security -Wformat-nonliteral" \
-Wlogical-op \
- -Wsign-compare \
-Wmissing-include-dirs \
-Wold-style-definition \
-Wpointer-arith \
@@ -156,17 +155,18 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-Wdeclaration-after-statement \
-Wfloat-equal \
-Wsuggest-attribute=noreturn \
- -Wmissing-prototypes \
+ -Werror=missing-prototypes \
+ -Werror=implicit-function-declaration \
+ -Werror=missing-declarations \
+ -Werror=return-type \
+ -Werror=shadow \
-Wstrict-prototypes \
-Wredundant-decls \
- -Wmissing-declarations \
-Wmissing-noreturn \
-Wshadow \
-Wendif-labels \
-Wstrict-aliasing=2 \
-Wwrite-strings \
- -Wno-long-long \
- -Wno-overlength-strings \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-unused-result \
@@ -179,8 +179,6 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-fdiagnostics-show-option \
-fno-strict-aliasing \
-fvisibility=hidden \
- -ffunction-sections \
- -fdata-sections \
-fstack-protector \
-fstack-protector-strong \
-fPIE \
@@ -204,10 +202,21 @@ AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
[AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $sanitizer_cppflags")
+AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
+ [CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
+ -Wl,--gc-sections])],
+ [AC_MSG_RESULT([skipping --gc-sections, optimization not enabled])])
+AC_SUBST([OUR_CFLAGS], "$with_ldflags $sanitizer_cflags")
+
+AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
+ [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+ -ffunction-sections -fdata-sections])],
+ [AC_MSG_RESULT([skipping -ffunction/data-section, optimization not enabled])])
+AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
+
CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
-Wl,--as-needed \
-Wl,--no-undefined \
- -Wl,--gc-sections \
-Wl,-z,relro \
-Wl,-z,now \
-pie \
@@ -269,6 +278,7 @@ AC_CHECK_DECLS([IFLA_INET6_ADDR_GEN_MODE,
IFLA_PHYS_PORT_ID,
IFLA_BOND_AD_INFO,
IFLA_VLAN_PROTOCOL,
+ IFLA_VXLAN_REMCSUM_NOPARTIAL,
IFLA_VXLAN_LOCAL6,
IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
IFLA_BRIDGE_VLAN_INFO,
@@ -285,6 +295,7 @@ AC_CHECK_DECLS([IFLA_INET6_ADDR_GEN_MODE,
#include <linux/if_tunnel.h>
#include <linux/if_link.h>
#include <linux/if_bridge.h>
+#include <linux/if_addr.h>
#include <linux/neighbour.h>
]])
@@ -310,7 +321,12 @@ AC_ARG_WITH([udevrulesdir],
[],
[with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)/rules.d])
AC_SUBST([udevrulesdir], [$with_udevrulesdir])
-AC_SUBST([udevbindir], [$($PKG_CONFIG --variable=udevdir udev)/../bin])
+
+AC_ARG_WITH([udevbindir],
+ AS_HELP_STRING([--with-udevbindir=DIR], [Directory for udev binary files]),
+ [],
+ [with_udevbindir=$($PKG_CONFIG --variable=udevdir udev)])
+AC_SUBST([udevbindir], [$with_udevbindir])
# ------------------------------------------------------------------------------
have_coverage=no
@@ -526,9 +542,9 @@ AM_CONDITIONAL(ENABLE_POLKIT, [test "x$have_polkit" = "xyes"])
# ------------------------------------------------------------------------------
have_kdbus=no
-AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--enable-kdbus], [do connect to kdbus by default]))
-if test "x$enable_kdbus" = "xyes"; then
- AC_DEFINE(ENABLE_KDBUS, 1, [Define if kdbus support is to be enabled])
+AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--disable-kdbus], [do not connect to kdbus by default]))
+if test "x$enable_kdbus" != "xno"; then
+ AC_DEFINE(ENABLE_KDBUS, 1, [Define if kdbus is to be connected to by default])
have_kdbus=yes
M4_DEFINES="$M4_DEFINES -DENABLE_KDBUS"
fi
@@ -555,16 +571,13 @@ AC_ARG_WITH([dbuspolicydir],
AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
[],
[with_dbuspolicydir=${sysconfdir}/dbus-1/system.d])
-
-AC_ARG_WITH([dbussessionservicedir],
- AS_HELP_STRING([--with-dbussessionservicedir=DIR], [D-Bus session service directory]),
- [],
- [with_dbussessionservicedir=${datadir}/dbus-1/services])
+AX_NORMALIZE_PATH([with_dbuspolicydir])
AC_ARG_WITH([dbussystemservicedir],
AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]),
[],
[with_dbussystemservicedir=${datadir}/dbus-1/system-services])
+AX_NORMALIZE_PATH([with_dbussystemservicedir])
AC_ARG_WITH([bashcompletiondir],
AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
@@ -574,25 +587,42 @@ AC_ARG_WITH([bashcompletiondir],
] , [
with_bashcompletiondir=${datadir}/bash-completion/completions
])])
+AX_NORMALIZE_PATH([with_bashcompletiondir])
AC_ARG_WITH([zshcompletiondir],
AS_HELP_STRING([--with-zshcompletiondir=DIR], [Zsh completions directory]),
[], [with_zshcompletiondir=${datadir}/zsh/site-functions])
+AX_NORMALIZE_PATH([with_zshcompletiondir])
+
+AC_ARG_WITH([rootprefix],
+ AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]),
+ [], [with_rootprefix=${ac_default_prefix}])
+# --with-rootprefix= (empty) should default to "/" but AX_NORMALIZE_PATH
+# defaults those to ".", solve that here for now until we can find a suitable
+# fix for AX_NORMALIZE_PATH upstream at autoconf-archive.
+# See: https://github.com/systemd/systemd/issues/54
+if test "x${with_rootprefix}" = "x"; then
+ with_rootprefix="/"
+fi
+AX_NORMALIZE_PATH([with_rootprefix])
AC_ARG_WITH([rootlibdir],
AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]),
[],
[with_rootlibdir=${libdir}])
+AX_NORMALIZE_PATH([with_rootlibdir])
AC_ARG_WITH([pamlibdir],
AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]),
[],
[with_pamlibdir=${with_rootlibdir}/security])
+AX_NORMALIZE_PATH([with_pamlibdir])
AC_ARG_WITH([pamconfdir],
AS_HELP_STRING([--with-pamconfdir=DIR], [Directory for PAM configuration]),
[],
[with_pamconfdir=${sysconfdir}/pam.d])
+AX_NORMALIZE_PATH([with_pamconfdir])
AC_ARG_ENABLE([split-usr],
AS_HELP_STRING([--enable-split-usr], [Assume that /bin, /sbin aren\'t symlinks into /usr]),
@@ -606,10 +636,9 @@ AC_ARG_ENABLE([split-usr],
AS_IF([test "x${enable_split_usr}" = "xyes"], [
AC_DEFINE(HAVE_SPLIT_USR, 1, [Define if /bin, /sbin aren't symlinks into /usr])
])
+AM_CONDITIONAL(ENABLE_SPLIT_USR, [test "x${enable_split_usr}" = "xyes"])
-# Work around intltoolize and gtk-doc problems in VPATH builds
-AM_CONDITIONAL([ENABLE_GTK_DOC_TESTS], [test "x$0" = "x./configure"],
- [Define to do gtk-doc tests])
+# work around intltool-update issues during 'make distcheck'
AS_IF([test "x$0" != "x./configure"], [
AC_SUBST([INTLTOOL_UPDATE], [/usr/bin/env true])
])
@@ -650,16 +679,17 @@ AS_IF([test x$enable_debug_mmap_cache = xyes], [
test -z "$enable_debug" && enable_debug="none"
AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
-AC_SUBST([dbussessionservicedir], [$with_dbussessionservicedir])
AC_SUBST([dbussystemservicedir], [$with_dbussystemservicedir])
AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
AC_SUBST([zshcompletiondir], [$with_zshcompletiondir])
AC_SUBST([pamlibdir], [$with_pamlibdir])
AC_SUBST([pamconfdir], [$with_pamconfdir])
+AC_SUBST([rootprefix], [$with_rootprefix])
AC_SUBST([rootlibdir], [$with_rootlibdir])
AC_CONFIG_FILES([
- Makefile po/Makefile.in
+ Makefile
+ po/Makefile.in
])
AC_OUTPUT
@@ -677,12 +707,12 @@ AC_MSG_RESULT([
dbus: ${have_dbus}
kdbus: ${have_kdbus}
man pages: ${have_manpages}
- gtk-doc: ${enable_gtk_doc}
test coverage: ${have_coverage}
Split /usr: ${enable_split_usr}
extra debugging: ${enable_debug}
prefix: ${prefix}
+ rootprefix: ${with_rootprefix}
sysconf dir: ${sysconfdir}
datarootdir: ${datarootdir}
includedir: ${includedir}
@@ -691,7 +721,6 @@ AC_MSG_RESULT([
PAM modules dir: ${with_pamlibdir}
PAM configuration dir: ${with_pamconfdir}
D-Bus policy dir: ${with_dbuspolicydir}
- D-Bus session dir: ${with_dbussessionservicedir}
D-Bus system dir: ${with_dbussystemservicedir}
Bash completions dir: ${with_bashcompletiondir}
Zsh completions dir: ${with_zshcompletiondir}
diff --git a/docs/gtk-doc.make b/docs/gtk-doc.make
new file mode 120000
index 000000000..3ee6bad7f
--- /dev/null
+++ b/docs/gtk-doc.make
@@ -0,0 +1 @@
+/usr/share/gtk-doc/data/gtk-doc.notmpl.make \ No newline at end of file
diff --git a/factory/etc/pam.d/system-auth b/factory/etc/pam.d/system-auth
index dec7a8f01..6f5f4ade2 100644
--- a/factory/etc/pam.d/system-auth
+++ b/factory/etc/pam.d/system-auth
@@ -8,5 +8,5 @@ account sufficient pam_unix.so
password sufficient pam_unix.so nullok sha512 shadow try_first_pass try_authtok
-session optional pam_loginuid.so
--session optional pam_systemd.so
+-session optional pam_elogind.so
session sufficient pam_unix.so
diff --git a/m4/gtk-doc.m4 b/m4/gtk-doc.m4
new file mode 100644
index 000000000..36755432b
--- /dev/null
+++ b/m4/gtk-doc.m4
@@ -0,0 +1,88 @@
+dnl -*- mode: autoconf -*-
+
+# serial 2
+
+dnl Usage:
+dnl GTK_DOC_CHECK([minimum-gtk-doc-version])
+AC_DEFUN([GTK_DOC_CHECK],
+[
+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+ AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+
+ ifelse([$1],[],[gtk_doc_requires="gtk-doc"],[gtk_doc_requires="gtk-doc >= $1"])
+ AC_MSG_CHECKING([for gtk-doc])
+ PKG_CHECK_EXISTS([$gtk_doc_requires],[have_gtk_doc=yes],[have_gtk_doc=no])
+ AC_MSG_RESULT($have_gtk_doc)
+
+ if test "$have_gtk_doc" = "no"; then
+ AC_MSG_WARN([
+ You will not be able to create source packages with 'make dist'
+ because $gtk_doc_requires is not found.])
+ fi
+
+ dnl check for tools we added during development
+ dnl Use AC_CHECK_PROG to avoid the check target using an absolute path that
+ dnl may not be writable by the user. Currently, automake requires that the
+ dnl test name must end in '.test'.
+ dnl https://bugzilla.gnome.org/show_bug.cgi?id=701638
+ AC_CHECK_PROG([GTKDOC_CHECK],[gtkdoc-check],[gtkdoc-check.test])
+ AC_PATH_PROG([GTKDOC_CHECK_PATH],[gtkdoc-check])
+ AC_PATH_PROGS([GTKDOC_REBASE],[gtkdoc-rebase],[true])
+ AC_PATH_PROG([GTKDOC_MKPDF],[gtkdoc-mkpdf])
+
+ dnl for overriding the documentation installation directory
+ AC_ARG_WITH([html-dir],
+ AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),,
+ [with_html_dir='${datadir}/gtk-doc/html'])
+ HTML_DIR="$with_html_dir"
+ AC_SUBST([HTML_DIR])
+
+ dnl enable/disable documentation building
+ AC_ARG_ENABLE([gtk-doc],
+ AS_HELP_STRING([--enable-gtk-doc],
+ [use gtk-doc to build documentation [[default=no]]]),,
+ [enable_gtk_doc=no])
+
+ AC_MSG_CHECKING([whether to build gtk-doc documentation])
+ AC_MSG_RESULT($enable_gtk_doc)
+
+ if test "x$enable_gtk_doc" = "xyes" && test "$have_gtk_doc" = "no"; then
+ AC_MSG_ERROR([
+ You must have $gtk_doc_requires installed to build documentation for
+ $PACKAGE_NAME. Please install gtk-doc or disable building the
+ documentation by adding '--disable-gtk-doc' to '[$]0'.])
+ fi
+
+ dnl don't check for glib if we build glib
+ if test "x$PACKAGE_NAME" != "xglib"; then
+ dnl don't fail if someone does not have glib
+ PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0 >= 2.10.0,,[:])
+ fi
+
+ dnl enable/disable output formats
+ AC_ARG_ENABLE([gtk-doc-html],
+ AS_HELP_STRING([--enable-gtk-doc-html],
+ [build documentation in html format [[default=yes]]]),,
+ [enable_gtk_doc_html=yes])
+ AC_ARG_ENABLE([gtk-doc-pdf],
+ AS_HELP_STRING([--enable-gtk-doc-pdf],
+ [build documentation in pdf format [[default=no]]]),,
+ [enable_gtk_doc_pdf=no])
+
+ if test -z "$GTKDOC_MKPDF"; then
+ enable_gtk_doc_pdf=no
+ fi
+
+ if test -z "$AM_DEFAULT_VERBOSITY"; then
+ AM_DEFAULT_VERBOSITY=1
+ fi
+ AC_SUBST([AM_DEFAULT_VERBOSITY])
+
+ AM_CONDITIONAL([HAVE_GTK_DOC], [test x$have_gtk_doc = xyes])
+ AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
+ AM_CONDITIONAL([GTK_DOC_BUILD_HTML], [test x$enable_gtk_doc_html = xyes])
+ AM_CONDITIONAL([GTK_DOC_BUILD_PDF], [test x$enable_gtk_doc_pdf = xyes])
+ AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"])
+ AM_CONDITIONAL([GTK_DOC_USE_REBASE], [test -n "$GTKDOC_REBASE"])
+])
diff --git a/man/custom-html.xsl b/man/custom-html.xsl
index 5ee5d228c..99acc4341 100644
--- a/man/custom-html.xsl
+++ b/man/custom-html.xsl
@@ -271,9 +271,10 @@
<xsl:text>index.html</xsl:text>
</xsl:attribute>
<xsl:text>Index </xsl:text>
+ </a>
<span style="float:right">
- <xsl:text>elogind </xsl:text>
+ <xsl:text>elogind</xsl:text>
<xsl:value-of select="$elogind.version"/>
</span>
<hr/>
diff --git a/man/logind.conf.xml b/man/elogind.conf.xml
index 9332e8075..b6392a693 100644
--- a/man/logind.conf.xml
+++ b/man/elogind.conf.xml
@@ -21,10 +21,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
-<refentry id="logind.conf" xmlns:xi="http://www.w3.org/2001/XInclude">
+<refentry id="elogind.conf" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
- <title>logind.conf</title>
- <productname>systemd</productname>
+ <title>elogind.conf</title>
+ <productname>elogind</productname>
<authorgroup>
<author>
@@ -37,29 +37,25 @@
</refentryinfo>
<refmeta>
- <refentrytitle>logind.conf</refentrytitle>
+ <refentrytitle>elogind.conf</refentrytitle>
<manvolnum>5</manvolnum>
</refmeta>
<refnamediv>
- <refname>logind.conf</refname>
- <refname>logind.conf.d</refname>
+ <refname>elogind.conf</refname>
+ <refname>elogind.conf.d</refname>
<refpurpose>Login manager configuration files</refpurpose>
</refnamediv>
<refsynopsisdiv>
- <para><filename>/etc/systemd/logind.conf</filename></para>
- <para><filename>/etc/systemd/logind.conf.d/*.conf</filename></para>
- <para><filename>/run/systemd/logind.conf.d/*.conf</filename></para>
- <para><filename>/usr/lib/systemd/logind.conf.d/*.conf</filename></para>
+ <para><filename>/etc/elogind/elogind.conf</filename></para>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
- <para>These files configure various parameters of the systemd
+ <para>These files configure various parameters of the elogind
login manager,
- <citerefentry><refentrytitle>logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>
</refsect1>
@@ -211,13 +207,13 @@
<term><varname>HoldoffTimeoutSec=</varname></term>
<listitem><para>Specifies the timeout after system startup or
- system resume in which systemd will hold off on reacting to
+ system resume in which elogind will hold off on reacting to
LID events. This is required for the system to properly
- detect any hotplugged devices so systemd can ignore LID events
+ detect any hotplugged devices so elogind can ignore LID events
if external monitors, or docks, are connected. If set to 0,
- systemd will always react immediately, possibly before the
+ elogind will always react immediately, possibly before the
kernel fully probed all hotplugged devices. This is safe, as
- long as you do not care for systemd to account for devices
+ long as you do not care for elogind to account for devices
that have been plugged or unplugged while the system was off.
Defaults to 30s.</para></listitem>
</varlistentry>
@@ -257,10 +253,7 @@
<refsect1>
<title>See Also</title>
<para>
- <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>loginctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/loginctl.xml b/man/loginctl.xml
index 4e09e7a1c..1c2d9132e 100644
--- a/man/loginctl.xml
+++ b/man/loginctl.xml
@@ -25,7 +25,7 @@
<refentryinfo>
<title>loginctl</title>
- <productname>systemd</productname>
+ <productname>elogind</productname>
<authorgroup>
<author>
@@ -44,7 +44,7 @@
<refnamediv>
<refname>loginctl</refname>
- <refpurpose>Control the systemd login manager</refpurpose>
+ <refpurpose>Control the elogind login manager</refpurpose>
</refnamediv>
<refsynopsisdiv>
@@ -60,10 +60,7 @@
<title>Description</title>
<para><command>loginctl</command> may be used to introspect and
- control the state of the
- <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- login manager
- <citerefentry><refentrytitle>logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+ control the state of the elogind login manager</para>
</refsect1>
<refsect1>
@@ -404,10 +401,7 @@
<refsect1>
<title>See Also</title>
<para>
- <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>elogind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/pam_elogind.xml b/man/pam_elogind.xml
index 7c3690aab..927ad1f08 100644
--- a/man/pam_elogind.xml
+++ b/man/pam_elogind.xml
@@ -88,7 +88,7 @@
<orderedlist>
<listitem><para>If enabled in
- <citerefentry><refentrytitle>logind.conf</refentrytitle>
+ <citerefentry><refentrytitle>elogind.conf</refentrytitle>
<manvolnum>5</manvolnum></citerefentry>, all processes of the
session are terminated. If the last concurrent session of a user
ends, the user's elogind instance will be terminated too, and so
@@ -279,8 +279,8 @@ session required pam_elogind.so</programlisting>
<refsect1>
<title>See Also</title>
<para>
- <citerefentry><refentrytitle>logind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>elogind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>loginctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
diff --git a/man/sd_is_fifo.xml b/man/sd_is_fifo.xml
new file mode 100644
index 000000000..627cb87aa
--- /dev/null
+++ b/man/sd_is_fifo.xml
@@ -0,0 +1,200 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd 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.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<refentry id="sd_is_fifo"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <refentryinfo>
+ <title>sd_is_fifo</title>
+ <productname>systemd</productname>
+
+ <authorgroup>
+ <author>
+ <contrib>Developer</contrib>
+ <firstname>Lennart</firstname>
+ <surname>Poettering</surname>
+ <email>lennart@poettering.net</email>
+ </author>
+ </authorgroup>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>sd_is_fifo</refentrytitle>
+ <manvolnum>3</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>sd_is_fifo</refname>
+ <refname>sd_is_socket</refname>
+ <refname>sd_is_socket_inet</refname>
+ <refname>sd_is_socket_unix</refname>
+ <refname>sd_is_mq</refname>
+ <refname>sd_is_special</refname>
+ <refpurpose>Check the type of a file descriptor</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_fifo</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>const char *<parameter>path</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_socket</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>int <parameter>family</parameter></paramdef>
+ <paramdef>int <parameter>type</parameter></paramdef>
+ <paramdef>int <parameter>listening</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_socket_inet</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>int <parameter>family</parameter></paramdef>
+ <paramdef>int <parameter>type</parameter></paramdef>
+ <paramdef>int <parameter>listening</parameter></paramdef>
+ <paramdef>uint16_t <parameter>port</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_socket_unix</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>int <parameter>type</parameter></paramdef>
+ <paramdef>int <parameter>listening</parameter></paramdef>
+ <paramdef>const char *<parameter>path</parameter></paramdef>
+ <paramdef>size_t <parameter>length</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_mq</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>const char *<parameter>path</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_is_special</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ <paramdef>const char *<parameter>path</parameter></paramdef>
+ </funcprototype>
+
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para><function>sd_is_fifo()</function> may be called to check
+ whether the specified file descriptor refers to a FIFO or pipe. If
+ the <parameter>path</parameter> parameter is not
+ <constant>NULL</constant>, it is checked whether the FIFO is bound
+ to the specified file system path.</para>
+
+ <para><function>sd_is_socket()</function> may be called to check
+ whether the specified file descriptor refers to a socket. If the
+ <parameter>family</parameter> parameter is not
+ <constant>AF_UNSPEC</constant>, it is checked whether the socket
+ is of the specified family (AF_UNIX, <constant>AF_INET</constant>,
+ ...). If the <parameter>type</parameter> parameter is not 0, it is
+ checked whether the socket is of the specified type
+ (<constant>SOCK_STREAM</constant>,
+ <constant>SOCK_DGRAM</constant>, ...). If the
+ <parameter>listening</parameter> parameter is positive, it is
+ checked whether the socket is in accepting mode, i.e.
+ <function>listen()</function> has been called for it. If
+ <parameter>listening</parameter> is 0, it is checked whether the
+ socket is not in this mode. If the parameter is negative, no such
+ check is made. The <parameter>listening</parameter> parameter
+ should only be used for stream sockets and should be set to a
+ negative value otherwise.</para>
+
+ <para><function>sd_is_socket_inet()</function> is similar to
+ <function>sd_is_socket()</function>, but optionally checks the
+ IPv4 or IPv6 port number the socket is bound to, unless
+ <parameter>port</parameter> is zero. For this call
+ <parameter>family</parameter> must be passed as either
+ <constant>AF_UNSPEC</constant>, <constant>AF_INET</constant>, or
+ <constant>AF_INET6</constant>.</para>
+
+ <para><function>sd_is_socket_unix()</function> is similar to
+ <function>sd_is_socket()</function> but optionally checks the
+ <constant>AF_UNIX</constant> path the socket is bound to, unless
+ the <parameter>path</parameter> parameter is
+ <constant>NULL</constant>. For normal file system
+ <constant>AF_UNIX</constant> sockets, set the
+ <parameter>length</parameter> parameter to 0. For Linux abstract
+ namespace sockets, set the <parameter>length</parameter> to the
+ size of the address, including the initial 0 byte, and set the
+ <parameter>path</parameter> to the initial 0 byte of the socket
+ address.</para>
+
+ <para><function>sd_is_mq()</function> may be called to check
+ whether the specified file descriptor refers to a POSIX message
+ queue. If the <parameter>path</parameter> parameter is not
+ <constant>NULL</constant>, it is checked whether the message queue
+ is bound to the specified name.</para>
+
+ <para><function>sd_is_special()</function> may be called to check
+ whether the specified file descriptor refers to a special file. If
+ the <parameter>path</parameter> parameter is not
+ <constant>NULL</constant>, it is checked whether the file
+ descriptor is bound to the specified file name. Special files in
+ this context are character device nodes and files in
+ <filename>/proc</filename> or <filename>/sys</filename>.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>Return Value</title>
+
+ <para>On failure, these calls return a negative errno-style error
+ code. If the file descriptor is of the specified type and bound to
+ the specified address, a positive return value is returned,
+ otherwise zero.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>Notes</title>
+
+ <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
+
+ <para>Internally, these function use a combination of
+ <filename>fstat()</filename> and
+ <filename>getsockname()</filename> to check the file descriptor
+ type and where it is bound to.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+ <para>
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ </para>
+ </refsect1>
+
+</refentry>
diff --git a/shell-completion/zsh/_elogind-inhibit b/shell-completion/zsh/_elogind-inhibit
new file mode 100644
index 000000000..1ecb6dc7e
--- /dev/null
+++ b/shell-completion/zsh/_elogind-inhibit
@@ -0,0 +1,33 @@
+#compdef systemd-inhibit
+
+_systemd_inhibit_command(){
+ if (( CURRENT == 1 )); then
+ compset -q
+ _normal
+ else
+ local n=${words[(b:2:i)[^-]*]}
+ if (( n <= CURRENT )); then
+ compset -n $n
+ _alternative \
+ 'files:file:_files' \
+ 'commands:command:_normal' && return 0
+ fi
+ _default
+ fi
+}
+
+_inhibit_what() {
+ local _inhibit
+ _inhibit=(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)
+ _values -s : "${_inhibit[@]}"
+}
+
+_arguments \
+ {-h,--help}'[Show this help]' \
+ '--version[Show package version]' \
+ '--what=[Operations to inhibit]:options:_inhibit_what' \
+ '--who=[A descriptive string who is inhibiting]' \
+ '--why=[A descriptive string why is being inhibited]' \
+ '--mode=[One of block or delay]' \
+ '--list[List active inhibitors]' \
+ '*:commands:_systemd_inhibit_command'
diff --git a/src/basic/.gitignore b/src/basic/.gitignore
new file mode 100644
index 000000000..e22411e48
--- /dev/null
+++ b/src/basic/.gitignore
@@ -0,0 +1,16 @@
+/cap-from-name.gperf
+/cap-from-name.h
+/cap-list.txt
+/cap-to-name.h
+/errno-from-name.gperf
+/errno-from-name.h
+/errno-list.txt
+/errno-to-name.h
+/af-from-name.gperf
+/af-from-name.h
+/af-list.txt
+/af-to-name.h
+/arphrd-from-name.gperf
+/arphrd-from-name.h
+/arphrd-list.txt
+/arphrd-to-name.h
diff --git a/src/shared/Makefile b/src/basic/Makefile
index d0b0e8e00..d0b0e8e00 120000
--- a/src/shared/Makefile
+++ b/src/basic/Makefile
diff --git a/src/shared/audit.c b/src/basic/audit.c
index 54148fcf1..54148fcf1 100644
--- a/src/shared/audit.c
+++ b/src/basic/audit.c
diff --git a/src/shared/audit.h b/src/basic/audit.h
index 6de331c73..6de331c73 100644
--- a/src/shared/audit.h
+++ b/src/basic/audit.h
diff --git a/src/basic/btrfs-util.h b/src/basic/btrfs-util.h
new file mode 100644
index 000000000..94ab1b59b
--- /dev/null
+++ b/src/basic/btrfs-util.h
@@ -0,0 +1,88 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Lennart Poettering
+
+ systemd 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.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#pragma once
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+#include "time-util.h"
+
+typedef struct BtrfsSubvolInfo {
+ uint64_t subvol_id;
+ usec_t otime;
+
+ sd_id128_t uuid;
+ sd_id128_t parent_uuid;
+
+ bool read_only;
+} BtrfsSubvolInfo;
+
+typedef struct BtrfsQuotaInfo {
+ uint64_t referenced;
+ uint64_t exclusive;
+ uint64_t referenced_max;
+ uint64_t exclusive_max;
+} BtrfsQuotaInfo;
+
+typedef enum BtrfsSnapshotFlags {
+ BTRFS_SNAPSHOT_FALLBACK_COPY = 1,
+ BTRFS_SNAPSHOT_READ_ONLY = 2,
+ BTRFS_SNAPSHOT_RECURSIVE = 4,
+} BtrfsSnapshotFlags;
+
+int btrfs_is_filesystem(int fd);
+int btrfs_is_subvol(int fd);
+
+int btrfs_subvol_make(const char *path);
+int btrfs_subvol_make_label(const char *path);
+
+int btrfs_subvol_snapshot_fd(int old_fd, const char *new_path, BtrfsSnapshotFlags flags);
+int btrfs_subvol_snapshot(const char *old_path, const char *new_path, BtrfsSnapshotFlags flags);
+
+int btrfs_subvol_set_read_only_fd(int fd, bool b);
+int btrfs_subvol_set_read_only(const char *path, bool b);
+// UNNEEDED int btrfs_subvol_get_read_only_fd(int fd);
+int btrfs_subvol_get_id(int fd, const char *subvolume, uint64_t *ret);
+int btrfs_subvol_get_id_fd(int fd, uint64_t *ret);
+int btrfs_subvol_get_info_fd(int fd, BtrfsSubvolInfo *info);
+int btrfs_subvol_get_quota_fd(int fd, BtrfsQuotaInfo *quota);
+
+int btrfs_reflink(int infd, int outfd);
+// UNNEEDED int btrfs_clone_range(int infd, uint64_t in_offset, int ofd, uint64_t out_offset, uint64_t sz);
+
+int btrfs_get_block_device_fd(int fd, dev_t *dev);
+int btrfs_get_block_device(const char *path, dev_t *dev);
+
+int btrfs_defrag_fd(int fd);
+int btrfs_defrag(const char *p);
+
+int btrfs_quota_enable_fd(int fd, bool b);
+int btrfs_quota_enable(const char *path, bool b);
+
+int btrfs_quota_limit_fd(int fd, uint64_t referenced_max);
+int btrfs_quota_limit(const char *path, uint64_t referenced_max);
+
+int btrfs_resize_loopback_fd(int fd, uint64_t size, bool grow_only);
+int btrfs_resize_loopback(const char *path, uint64_t size, bool grow_only);
+
+int btrfs_subvol_remove(const char *path, bool recursive);
+int btrfs_subvol_remove_fd(int fd, const char *subvolume, bool recursive);
diff --git a/src/basic/build.h b/src/basic/build.h
new file mode 100644
index 000000000..24873ab9d
--- /dev/null
+++ b/src/basic/build.h
@@ -0,0 +1,157 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd 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.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifdef HAVE_PAM
+#define _PAM_FEATURE_ "+PAM"
+#else
+#define _PAM_FEATURE_ "-PAM"
+#endif
+
+#ifdef HAVE_AUDIT
+#define _AUDIT_FEATURE_ "+AUDIT"
+#else
+#define _AUDIT_FEATURE_ "-AUDIT"
+#endif
+
+#ifdef HAVE_SELINUX
+#define _SELINUX_FEATURE_ "+SELINUX"
+#else
+#define _SELINUX_FEATURE_ "-SELINUX"
+#endif
+
+#ifdef HAVE_APPARMOR
+#define _APPARMOR_FEATURE_ "+APPARMOR"
+#else
+#define _APPARMOR_FEATURE_ "-APPARMOR"
+#endif
+
+#ifdef HAVE_IMA
+#define _IMA_FEATURE_ "+IMA"
+#else
+#define _IMA_FEATURE_ "-IMA"
+#endif
+
+#ifdef HAVE_SMACK
+#define _SMACK_FEATURE_ "+SMACK"
+#else
+#define _SMACK_FEATURE_ "-SMACK"
+#endif
+
+#ifdef HAVE_SYSV_COMPAT
+#define _SYSVINIT_FEATURE_ "+SYSVINIT"
+#else
+#define _SYSVINIT_FEATURE_ "-SYSVINIT"
+#endif
+
+#ifdef HAVE_UTMP
+#define _UTMP_FEATURE_ "+UTMP"
+#else
+#define _UTMP_FEATURE_ "-UTMP"
+#endif
+
+#ifdef HAVE_LIBCRYPTSETUP
+#define _LIBCRYPTSETUP_FEATURE_ "+LIBCRYPTSETUP"
+#else
+#define _LIBCRYPTSETUP_FEATURE_ "-LIBCRYPTSETUP"
+#endif
+
+#ifdef HAVE_GCRYPT
+#define _GCRYPT_FEATURE_ "+GCRYPT"
+#else
+#define _GCRYPT_FEATURE_ "-GCRYPT"
+#endif
+
+#ifdef HAVE_GNUTLS
+#define _GNUTLS_FEATURE_ "+GNUTLS"
+#else
+#define _GNUTLS_FEATURE_ "-GNUTLS"
+#endif
+
+#ifdef HAVE_ACL
+#define _ACL_FEATURE_ "+ACL"
+#else
+#define _ACL_FEATURE_ "-ACL"
+#endif
+
+#ifdef HAVE_XZ
+#define _XZ_FEATURE_ "+XZ"
+#else
+#define _XZ_FEATURE_ "-XZ"
+#endif
+
+#ifdef HAVE_LZ4
+#define _LZ4_FEATURE_ "+LZ4"
+#else
+#define _LZ4_FEATURE_ "-LZ4"
+#endif
+
+#ifdef HAVE_SECCOMP
+#define _SECCOMP_FEATURE_ "+SECCOMP"
+#else
+#define _SECCOMP_FEATURE_ "-SECCOMP"
+#endif
+
+#ifdef HAVE_BLKID
+#define _BLKID_FEATURE_ "+BLKID"
+#else
+#define _BLKID_FEATURE_ "-BLKID"
+#endif
+
+#ifdef HAVE_ELFUTILS
+#define _ELFUTILS_FEATURE_ "+ELFUTILS"
+#else
+#define _ELFUTILS_FEATURE_ "-ELFUTILS"
+#endif
+
+#ifdef HAVE_KMOD
+#define _KMOD_FEATURE_ "+KMOD"
+#else
+#define _KMOD_FEATURE_ "-KMOD"
+#endif
+
+#ifdef HAVE_LIBIDN
+#define _IDN_FEATURE_ "+IDN"
+#else
+#define _IDN_FEATURE_ "-IDN"
+#endif
+
+#define SYSTEMD_FEATURES \
+ _PAM_FEATURE_ " " \
+ _AUDIT_FEATURE_ " " \
+ _SELINUX_FEATURE_ " " \
+ _IMA_FEATURE_ " " \
+ _APPARMOR_FEATURE_ " " \
+ _SMACK_FEATURE_ " " \
+ _SYSVINIT_FEATURE_ " " \
+ _UTMP_FEATURE_ " " \
+ _LIBCRYPTSETUP_FEATURE_ " " \
+ _GCRYPT_FEATURE_ " " \
+ _GNUTLS_FEATURE_ " " \
+ _ACL_FEATURE_ " " \
+ _XZ_FEATURE_ " " \
+ _LZ4_FEATURE_ " " \
+ _SECCOMP_FEATURE_ " " \
+ _BLKID_FEATURE_ " " \
+ _ELFUTILS_FEATURE_ " " \
+ _KMOD_FEATURE_ " " \
+ _IDN_FEATURE_
diff --git a/src/shared/bus-label.c b/src/basic/bus-label.c
index ccc9f2bf8..ccc9f2bf8 100644
--- a/src/shared/bus-label.c
+++ b/src/basic/bus-label.c
diff --git a/src/shared/bus-label.h b/src/basic/bus-label.h
index ed1dc4e0a..ed1dc4e0a 100644
--- a/src/shared/bus-label.h
+++ b/src/basic/bus-label.h
diff --git a/src/shared/calendarspec.h b/src/basic/calendarspec.h
index 7baf31824..7baf31824 100644
--- a/src/shared/calendarspec.h
+++ b/src/basic/calendarspec.h
diff --git a/src/shared/capability.c b/src/basic/capability.c
index 8dbe4da5b..3963753d4 100644
--- a/src/shared/capability.c
+++ b/src/basic/capability.c
@@ -224,6 +224,8 @@ int capability_bounding_set_drop_usermode(uint64_t drop) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
_cleanup_cap_free_ cap_t d = NULL;
unsigned i, j = 0;
@@ -305,3 +307,4 @@ int drop_capability(cap_value_t cv) {
return 0;
}
+#endif // 0
diff --git a/src/shared/capability.h b/src/basic/capability.h
index 4eb5c2a83..01a285835 100644
--- a/src/shared/capability.h
+++ b/src/basic/capability.h
@@ -31,9 +31,9 @@ int have_effective_cap(int value);
int capability_bounding_set_drop(uint64_t drop, bool right_now);
int capability_bounding_set_drop_usermode(uint64_t drop);
-int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities);
+// UNNEEDED int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities);
-int drop_capability(cap_value_t cv);
+// UNNEEDED int drop_capability(cap_value_t cv);
DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
#define _cleanup_cap_free_ _cleanup_(cap_freep)
diff --git a/src/shared/cgroup-util.c b/src/basic/cgroup-util.c
index 99d06540a..ba9eeb921 100644
--- a/src/shared/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -33,10 +33,14 @@
#include "set.h"
#include "macro.h"
#include "util.h"
+#include "formats-util.h"
+#include "process-util.h"
#include "path-util.h"
+#include "unit-name.h"
#include "fileio.h"
#include "special.h"
#include "mkdir.h"
+#include "login-util.h"
int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
_cleanup_free_ char *fs = NULL;
@@ -437,9 +441,7 @@ static const char *normalize_controller(const char *controller) {
assert(controller);
- if (streq(controller, SYSTEMD_CGROUP_CONTROLLER))
- return "elogind";
- else if (startswith(controller, "name="))
+ if (startswith(controller, "name="))
return controller + 5;
else
return controller;
@@ -479,15 +481,17 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
assert(fs);
- if (controller && !cg_controller_is_valid(controller, true))
+ if (controller && !cg_controller_is_valid(controller))
return -EINVAL;
if (_unlikely_(!good)) {
int r;
- r = path_is_mount_point("/sys/fs/cgroup", false);
- if (r <= 0)
- return r < 0 ? r : -ENOENT;
+ r = path_is_mount_point("/sys/fs/cgroup", 0);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ return -ENOENT;
/* Cache this to save a few stat()s */
good = true;
@@ -520,7 +524,7 @@ int cg_get_path_and_check(const char *controller, const char *path, const char *
assert(fs);
- if (!cg_controller_is_valid(controller, true))
+ if (!cg_controller_is_valid(controller))
return -EINVAL;
/* Normalize the controller syntax */
@@ -571,6 +575,8 @@ int cg_trim(const char *controller, const char *path, bool delete_root) {
return r;
}
+/// UNNEDED by elogind
+#if 0
int cg_delete(const char *controller, const char *path) {
_cleanup_free_ char *parent = NULL;
int r;
@@ -584,6 +590,7 @@ int cg_delete(const char *controller, const char *path) {
r = cg_migrate_recursive(controller, path, controller, parent, false, true);
return r == -ENOENT ? 0 : r;
}
+#endif // 0
int cg_create(const char *controller, const char *path) {
_cleanup_free_ char *fs = NULL;
@@ -736,7 +743,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
assert(pid >= 0);
if (controller) {
- if (!cg_controller_is_valid(controller, true))
+ if (!cg_controller_is_valid(controller))
return -EINVAL;
controller = normalize_controller(controller);
@@ -965,7 +972,7 @@ int cg_split_spec(const char *spec, char **controller, char **path) {
e = strchr(spec, ':');
if (!e) {
- if (!cg_controller_is_valid(spec, true))
+ if (!cg_controller_is_valid(spec))
return -EINVAL;
if (controller) {
@@ -988,7 +995,7 @@ int cg_split_spec(const char *spec, char **controller, char **path) {
t = strdup(normalize_controller(v));
if (!t)
return -ENOMEM;
- if (!cg_controller_is_valid(t, true)) {
+ if (!cg_controller_is_valid(t)) {
free(t);
return -EINVAL;
}
@@ -1057,9 +1064,21 @@ int cg_mangle_path(const char *path, char **result) {
}
int cg_get_root_path(char **path) {
+ char *p, *e;
+ int r;
+
assert(path);
- return cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 1, path);
+ r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 1, &p);
+ if (r < 0)
+ return r;
+
+ e = endswith(p, "/" SPECIAL_SYSTEM_SLICE);
+ if (e)
+ *e = 0;
+
+ *path = p;
+ return 0;
}
int cg_shift_path(const char *cgroup, const char *root, const char **shifted) {
@@ -1122,34 +1141,293 @@ int cg_pid_get_path_shifted(pid_t pid, const char *root, char **cgroup) {
return 0;
}
-int cg_path_get_session(const char *path, char **session) {
- const char *e, *n, *s;
+int cg_path_decode_unit(const char *cgroup, char **unit){
+ char *c, *s;
+ size_t n;
+
+ assert(cgroup);
+ assert(unit);
+
+ n = strcspn(cgroup, "/");
+ if (n < 3)
+ return -ENXIO;
+
+ c = strndupa(cgroup, n);
+ c = cg_unescape(c);
+
+ if (!unit_name_is_valid(c, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
+ return -ENXIO;
+
+ s = strdup(c);
+ if (!s)
+ return -ENOMEM;
+
+ *unit = s;
+ return 0;
+}
+
+static bool valid_slice_name(const char *p, size_t n) {
+
+ if (!p)
+ return false;
+
+ if (n < strlen("x.slice"))
+ return false;
+
+ if (memcmp(p + n - 6, ".slice", 6) == 0) {
+ char buf[n+1], *c;
+
+ memcpy(buf, p, n);
+ buf[n] = 0;
- /* Elogind uses a flat hierarchy, just "/SESSION". The only
- wrinkle is that SESSION might be escaped. */
+ c = cg_unescape(buf);
+
+ return unit_name_is_valid(c, UNIT_NAME_PLAIN);
+ }
+
+ return false;
+}
+
+static const char *skip_slices(const char *p) {
+ assert(p);
+
+ /* Skips over all slice assignments */
+
+ for (;;) {
+ size_t n;
+
+ p += strspn(p, "/");
+
+ n = strcspn(p, "/");
+ if (!valid_slice_name(p, n))
+ return p;
+
+ p += n;
+ }
+}
+
+int cg_path_get_unit(const char *path, char **ret) {
+ const char *e;
+ char *unit;
+ int r;
assert(path);
- assert(path[0] == '/');
+ assert(ret);
+
+ e = skip_slices(path);
+
+ r = cg_path_decode_unit(e, &unit);
+ if (r < 0)
+ return r;
- e = path + 1;
- n = strchrnul(e, '/');
- if (e == n)
- return -ENOENT;
+ /* We skipped over the slices, don't accept any now */
+ if (endswith(unit, ".slice")) {
+ free(unit);
+ return -ENXIO;
+ }
- s = strndupa(e, n - e);
- s = cg_unescape(s);
+ *ret = unit;
+ return 0;
+}
- if (!s[0])
- return -ENOENT;
+int cg_pid_get_unit(pid_t pid, char **unit) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ assert(unit);
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_unit(cgroup, unit);
+}
+
+/**
+ * Skip session-*.scope, but require it to be there.
+ */
+static const char *skip_session(const char *p) {
+ size_t n;
+
+ if (isempty(p))
+ return NULL;
+
+ p += strspn(p, "/");
+
+ n = strcspn(p, "/");
+ if (n < strlen("session-x.scope"))
+ return NULL;
+
+ if (memcmp(p, "session-", 8) == 0 && memcmp(p + n - 6, ".scope", 6) == 0) {
+ char buf[n - 8 - 6 + 1];
+
+ memcpy(buf, p + 8, n - 8 - 6);
+ buf[n - 8 - 6] = 0;
+
+ /* Note that session scopes never need unescaping,
+ * since they cannot conflict with the kernel's own
+ * names, hence we don't need to call cg_unescape()
+ * here. */
+
+ if (!session_id_valid(buf))
+ return false;
+
+ p += n;
+ p += strspn(p, "/");
+ return p;
+ }
+
+ return NULL;
+}
+
+/**
+ * Skip user@*.service, but require it to be there.
+ */
+static const char *skip_user_manager(const char *p) {
+ size_t n;
+
+ if (isempty(p))
+ return NULL;
+
+ p += strspn(p, "/");
+
+ n = strcspn(p, "/");
+ if (n < strlen("user@x.service"))
+ return NULL;
+
+ if (memcmp(p, "user@", 5) == 0 && memcmp(p + n - 8, ".service", 8) == 0) {
+ char buf[n - 5 - 8 + 1];
+
+ memcpy(buf, p + 5, n - 5 - 8);
+ buf[n - 5 - 8] = 0;
+
+ /* Note that user manager services never need unescaping,
+ * since they cannot conflict with the kernel's own
+ * names, hence we don't need to call cg_unescape()
+ * here. */
+
+ if (parse_uid(buf, NULL) < 0)
+ return NULL;
+
+ p += n;
+ p += strspn(p, "/");
+
+ return p;
+ }
+
+ return NULL;
+}
+
+static const char *skip_user_prefix(const char *path) {
+ const char *e, *t;
+
+ assert(path);
+
+ /* Skip slices, if there are any */
+ e = skip_slices(path);
+
+ /* Skip the user manager, if it's in the path now... */
+ t = skip_user_manager(e);
+ if (t)
+ return t;
+
+ /* Alternatively skip the user session if it is in the path... */
+ return skip_session(e);
+}
+
+int cg_path_get_user_unit(const char *path, char **ret) {
+ const char *t;
+
+ assert(path);
+ assert(ret);
+
+ t = skip_user_prefix(path);
+ if (!t)
+ return -ENXIO;
+
+ /* And from here on it looks pretty much the same as for a
+ * system unit, hence let's use the same parser from here
+ * on. */
+ return cg_path_get_unit(t, ret);
+}
+
+/// UNNEDED by elogind
+#if 0
+int cg_pid_get_user_unit(pid_t pid, char **unit) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ assert(unit);
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_user_unit(cgroup, unit);
+}
+#endif // 0
+
+int cg_path_get_machine_name(const char *path, char **machine) {
+ _cleanup_free_ char *u = NULL, *sl = NULL;
+ int r;
+
+ r = cg_path_get_unit(path, &u);
+ if (r < 0)
+ return r;
+
+ sl = strjoin("/run/systemd/machines/unit:", u, NULL);
+ if (!sl)
+ return -ENOMEM;
+
+ return readlink_malloc(sl, machine);
+}
+
+/// UNNEDED by elogind
+#if 0
+int cg_pid_get_machine_name(pid_t pid, char **machine) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ assert(machine);
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_machine_name(cgroup, machine);
+}
+#endif // 0
+
+int cg_path_get_session(const char *path, char **session) {
+ _cleanup_free_ char *unit = NULL;
+ char *start, *end;
+ int r;
+
+ assert(path);
+
+ r = cg_path_get_unit(path, &unit);
+ if (r < 0)
+ return r;
+
+ start = startswith(unit, "session-");
+ if (!start)
+ return -ENXIO;
+ end = endswith(start, ".scope");
+ if (!end)
+ return -ENXIO;
+
+ *end = 0;
+ if (!session_id_valid(start))
+ return -ENXIO;
if (session) {
- char *r;
+ char *rr;
- r = strdup(s);
- if (!r)
+ rr = strdup(start);
+ if (!rr)
return -ENOMEM;
- *session = r;
+ *session = rr;
}
return 0;
@@ -1166,6 +1444,121 @@ int cg_pid_get_session(pid_t pid, char **session) {
return cg_path_get_session(cgroup, session);
}
+int cg_path_get_owner_uid(const char *path, uid_t *uid) {
+ _cleanup_free_ char *slice = NULL;
+ char *start, *end;
+ int r;
+
+ assert(path);
+
+ r = cg_path_get_slice(path, &slice);
+ if (r < 0)
+ return r;
+
+ start = startswith(slice, "user-");
+ if (!start)
+ return -ENXIO;
+ end = endswith(start, ".slice");
+ if (!end)
+ return -ENXIO;
+
+ *end = 0;
+ if (parse_uid(start, uid) < 0)
+ return -ENXIO;
+
+ return 0;
+}
+
+/// UNNEDED by elogind
+#if 0
+int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_owner_uid(cgroup, uid);
+}
+#endif // 0
+
+int cg_path_get_slice(const char *p, char **slice) {
+ const char *e = NULL;
+
+ assert(p);
+ assert(slice);
+
+ /* Finds the right-most slice unit from the beginning, but
+ * stops before we come to the first non-slice unit. */
+
+ for (;;) {
+ size_t n;
+
+ p += strspn(p, "/");
+
+ n = strcspn(p, "/");
+ if (!valid_slice_name(p, n)) {
+
+ if (!e) {
+ char *s;
+
+ s = strdup("-.slice");
+ if (!s)
+ return -ENOMEM;
+
+ *slice = s;
+ return 0;
+ }
+
+ return cg_path_decode_unit(e, slice);
+ }
+
+ e = p;
+ p += n;
+ }
+}
+
+int cg_pid_get_slice(pid_t pid, char **slice) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ assert(slice);
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_slice(cgroup, slice);
+}
+
+int cg_path_get_user_slice(const char *p, char **slice) {
+ const char *t;
+ assert(p);
+ assert(slice);
+
+ t = skip_user_prefix(p);
+ if (!t)
+ return -ENXIO;
+
+ /* And now it looks pretty much the same as for a system
+ * slice, so let's just use the same parser from here on. */
+ return cg_path_get_slice(t, slice);
+}
+
+int cg_pid_get_user_slice(pid_t pid, char **slice) {
+ _cleanup_free_ char *cgroup = NULL;
+ int r;
+
+ assert(slice);
+
+ r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
+ if (r < 0)
+ return r;
+
+ return cg_path_get_user_slice(cgroup, slice);
+}
+
char *cg_escape(const char *p) {
bool need_prefix = false;
@@ -1227,17 +1620,15 @@ char *cg_unescape(const char *p) {
DIGITS LETTERS \
"_"
-bool cg_controller_is_valid(const char *p, bool allow_named) {
+bool cg_controller_is_valid(const char *p) {
const char *t, *s;
if (!p)
return false;
- if (allow_named) {
- s = startswith(p, "name=");
- if (s)
- p = s;
- }
+ s = startswith(p, "name=");
+ if (s)
+ p = s;
if (*p == 0 || *p == '_')
return false;
@@ -1252,6 +1643,78 @@ bool cg_controller_is_valid(const char *p, bool allow_named) {
return true;
}
+/// UNNEEDED by elogind
+#if 0
+int cg_slice_to_path(const char *unit, char **ret) {
+ _cleanup_free_ char *p = NULL, *s = NULL, *e = NULL;
+ const char *dash;
+ int r;
+
+ assert(unit);
+ assert(ret);
+
+ if (streq(unit, "-.slice")) {
+ char *x;
+
+ x = strdup("");
+ if (!x)
+ return -ENOMEM;
+ *ret = x;
+ return 0;
+ }
+
+ if (!unit_name_is_valid(unit, UNIT_NAME_PLAIN))
+ return -EINVAL;
+
+ if (!endswith(unit, ".slice"))
+ return -EINVAL;
+
+ r = unit_name_to_prefix(unit, &p);
+ if (r < 0)
+ return r;
+
+ dash = strchr(p, '-');
+
+ /* Don't allow initial dashes */
+ if (dash == p)
+ return -EINVAL;
+
+ while (dash) {
+ _cleanup_free_ char *escaped = NULL;
+ char n[dash - p + sizeof(".slice")];
+
+ /* Don't allow trailing or double dashes */
+ if (dash[1] == 0 || dash[1] == '-')
+ return -EINVAL;
+
+ strcpy(stpncpy(n, p, dash - p), ".slice");
+ if (!unit_name_is_valid(n, UNIT_NAME_PLAIN))
+ return -EINVAL;
+
+ escaped = cg_escape(n);
+ if (!escaped)
+ return -ENOMEM;
+
+ if (!strextend(&s, escaped, "/", NULL))
+ return -ENOMEM;
+
+ dash = strchr(dash+1, '-');
+ }
+
+ e = cg_escape(unit);
+ if (!e)
+ return -ENOMEM;
+
+ if (!strextend(&s, e, NULL))
+ return -ENOMEM;
+
+ *ret = s;
+ s = NULL;
+
+ return 0;
+}
+#endif // 0
+
int cg_set_attribute(const char *controller, const char *path, const char *attribute, const char *value) {
_cleanup_free_ char *p = NULL;
int r;
@@ -1328,7 +1791,7 @@ int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t
if (!p)
p = path;
- cg_attach_fallback(n, path, pid);
+ cg_attach_fallback(n, p, pid);
}
bit <<= 1;
diff --git a/src/shared/cgroup-util.h b/src/basic/cgroup-util.h
index 496fe053b..8a432aad0 100644
--- a/src/shared/cgroup-util.h
+++ b/src/basic/cgroup-util.h
@@ -77,7 +77,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path);
int cg_trim(const char *controller, const char *path, bool delete_root);
int cg_rmdir(const char *controller, const char *path);
-int cg_delete(const char *controller, const char *path);
+// UNNEEDED int cg_delete(const char *controller, const char *path);
int cg_create(const char *controller, const char *path);
int cg_attach(const char *controller, const char *path, pid_t pid);
@@ -99,16 +99,33 @@ int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_
int cg_get_root_path(char **path);
int cg_path_get_session(const char *path, char **session);
+int cg_path_get_owner_uid(const char *path, uid_t *uid);
+int cg_path_get_unit(const char *path, char **unit);
+int cg_path_get_user_unit(const char *path, char **unit);
+int cg_path_get_machine_name(const char *path, char **machine);
+int cg_path_get_slice(const char *path, char **slice);
+int cg_path_get_user_slice(const char *path, char **slice);
int cg_shift_path(const char *cgroup, const char *cached_root, const char **shifted);
int cg_pid_get_path_shifted(pid_t pid, const char *cached_root, char **cgroup);
int cg_pid_get_session(pid_t pid, char **session);
+// UNNEEDED int cg_pid_get_owner_uid(pid_t pid, uid_t *uid);
+int cg_pid_get_unit(pid_t pid, char **unit);
+// UNNEEDED int cg_pid_get_user_unit(pid_t pid, char **unit);
+// UNNEEDED int cg_pid_get_machine_name(pid_t pid, char **machine);
+int cg_pid_get_slice(pid_t pid, char **slice);
+int cg_pid_get_user_slice(pid_t pid, char **slice);
+
+int cg_path_decode_unit(const char *cgroup, char **unit);
+
char *cg_escape(const char *p);
char *cg_unescape(const char *p) _pure_;
bool cg_controller_is_valid(const char *p);
+// UNNEEDED int cg_slice_to_path(const char *unit, char **ret);
+
typedef const char* (*cg_migrate_callback_t)(CGroupControllerMask mask, void *userdata);
int cg_create_everywhere(CGroupControllerMask supported, CGroupControllerMask mask, const char *path);
diff --git a/src/shared/conf-files.c b/src/basic/conf-files.c
index da8745b28..da8745b28 100644
--- a/src/shared/conf-files.c
+++ b/src/basic/conf-files.c
diff --git a/src/shared/conf-files.h b/src/basic/conf-files.h
index 3169a907f..3169a907f 100644
--- a/src/shared/conf-files.h
+++ b/src/basic/conf-files.h
diff --git a/src/shared/def.h b/src/basic/def.h
index ea54e25e2..5aaba1fe8 100644
--- a/src/shared/def.h
+++ b/src/basic/def.h
@@ -35,7 +35,7 @@
* the watchdog pings will keep the loop busy. */
#define DEFAULT_EXIT_USEC (30*USEC_PER_SEC)
-#define SYSTEMD_CGROUP_CONTROLLER "name=elogind"
+#define SYSTEMD_CGROUP_CONTROLLER "systemd"
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
#define SIGNALS_IGNORE SIGPIPE
diff --git a/src/shared/device-nodes.h b/src/basic/device-nodes.h
index 04ba4897e..04ba4897e 100644
--- a/src/shared/device-nodes.h
+++ b/src/basic/device-nodes.h
diff --git a/src/shared/env-util.h b/src/basic/env-util.h
index 803aa61ca..803aa61ca 100644
--- a/src/shared/env-util.h
+++ b/src/basic/env-util.h
diff --git a/src/shared/errno-list.c b/src/basic/errno-list.c
index 34d133148..fff37eb3e 100644
--- a/src/shared/errno-list.c
+++ b/src/basic/errno-list.c
@@ -53,6 +53,9 @@ int errno_from_name(const char *name) {
return sc->id;
}
+/// UNNEEDED by elogind
+#if 0
int errno_max(void) {
return ELEMENTSOF(errno_names);
}
+#endif // 0
diff --git a/src/shared/errno-list.h b/src/basic/errno-list.h
index ba533294e..0b819fc5f 100644
--- a/src/shared/errno-list.h
+++ b/src/basic/errno-list.h
@@ -24,4 +24,4 @@
const char *errno_to_name(int id);
int errno_from_name(const char *name);
-int errno_max(void);
+// UNNEEDED int errno_max(void);
diff --git a/src/shared/exit-status.h b/src/basic/exit-status.h
index 7259cd1d1..7259cd1d1 100644
--- a/src/shared/exit-status.h
+++ b/src/basic/exit-status.h
diff --git a/src/shared/fdset.h b/src/basic/fdset.h
index 340438d7c..88fb83895 100644
--- a/src/shared/fdset.h
+++ b/src/basic/fdset.h
@@ -30,21 +30,21 @@ FDSet* fdset_free(FDSet *s);
int fdset_put(FDSet *s, int fd);
int fdset_put_dup(FDSet *s, int fd);
-int fdset_consume(FDSet *s, int fd);
+// UNNEEDED int fdset_consume(FDSet *s, int fd);
bool fdset_contains(FDSet *s, int fd);
int fdset_remove(FDSet *s, int fd);
int fdset_new_array(FDSet **ret, int *fds, unsigned n_fds);
int fdset_new_fill(FDSet **ret);
-int fdset_new_listen_fds(FDSet **ret, bool unset);
+// UNNEEDED int fdset_new_listen_fds(FDSet **ret, bool unset);
int fdset_cloexec(FDSet *fds, bool b);
-int fdset_close_others(FDSet *fds);
+// UNNEEDED int fdset_close_others(FDSet *fds);
unsigned fdset_size(FDSet *fds);
-bool fdset_isempty(FDSet *fds);
+// UNNEEDED bool fdset_isempty(FDSet *fds);
int fdset_iterate(FDSet *s, Iterator *i);
diff --git a/src/shared/fileio-label.c b/src/basic/fileio-label.c
index f596f1d11..1443cefc1 100644
--- a/src/shared/fileio-label.c
+++ b/src/basic/fileio-label.c
@@ -38,6 +38,8 @@ int write_string_file_atomic_label(const char *fn, const char *line) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
int write_env_file_label(const char *fname, char **l) {
int r;
@@ -66,3 +68,4 @@ int fopen_temporary_label(const char *target,
return r;
}
+#endif // 0
diff --git a/src/shared/fileio-label.h b/src/basic/fileio-label.h
index 25fa351be..af31cf6a7 100644
--- a/src/shared/fileio-label.h
+++ b/src/basic/fileio-label.h
@@ -26,6 +26,6 @@
#include "fileio.h"
int write_string_file_atomic_label(const char *fn, const char *line);
-int write_env_file_label(const char *fname, char **l);
-int fopen_temporary_label(const char *target,
- const char *path, FILE **f, char **temp_path);
+// UNNEEDED int write_env_file_label(const char *fname, char **l);
+// UNNEEDED int fopen_temporary_label(const char *target,
+// const char *path, FILE **f, char **temp_path);
diff --git a/src/shared/fileio.c b/src/basic/fileio.c
index d592bf5ac..718ed3642 100644
--- a/src/shared/fileio.c
+++ b/src/basic/fileio.c
@@ -631,6 +631,8 @@ int load_env_file(FILE *f, const char *fname, const char *newline, char ***rl) {
return 0;
}
+/// UNNEDED by elogind
+#if 0
static int load_env_file_push_pairs(
const char *filename, unsigned line,
const char *key, char *value,
@@ -689,6 +691,7 @@ int load_env_file_pairs(FILE *f, const char *fname, const char *newline, char **
*rl = m;
return 0;
}
+#endif // 0
static void write_env_var(FILE *f, const char *v) {
const char *p;
@@ -750,6 +753,8 @@ int write_env_file(const char *fname, char **l) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
int executable_is_script(const char *path, char **interpreter) {
int r;
_cleanup_free_ char *line = NULL;
@@ -778,6 +783,7 @@ int executable_is_script(const char *path, char **interpreter) {
*interpreter = ans;
return 1;
}
+#endif // 0
/**
* Retrieve one field from a file like /proc/self/status. pattern
diff --git a/src/shared/fileio.h b/src/basic/fileio.h
index 2e8148ff2..1fdad924e 100644
--- a/src/shared/fileio.h
+++ b/src/basic/fileio.h
@@ -42,10 +42,10 @@ int verify_one_line_file(const char *fn, const char *line);
int parse_env_file(const char *fname, const char *separator, ...) _sentinel_;
int load_env_file(FILE *f, const char *fname, const char *separator, char ***l);
-int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l);
+// UNNEEDED int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l);
int write_env_file(const char *fname, char **l);
-int executable_is_script(const char *path, char **interpreter);
+// UNNEEDED int executable_is_script(const char *path, char **interpreter);
int get_status_field(const char *filename, const char *pattern, char **field);
diff --git a/src/shared/gunicode.c b/src/basic/gunicode.c
index d89a2f3ed..d89a2f3ed 100644
--- a/src/shared/gunicode.c
+++ b/src/basic/gunicode.c
diff --git a/src/shared/gunicode.h b/src/basic/gunicode.h
index e70818fdd..e70818fdd 100644
--- a/src/shared/gunicode.h
+++ b/src/basic/gunicode.h
diff --git a/src/shared/hashmap.c b/src/basic/hashmap.c
index e5f05f36f..55e198960 100644
--- a/src/shared/hashmap.c
+++ b/src/basic/hashmap.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <errno.h>
+#include <pthread.h>
#include "util.h"
#include "hashmap.h"
@@ -157,6 +158,7 @@ struct hashmap_debug_info {
/* Tracks all existing hashmaps. Get at it from gdb. See sd_dump_hashmaps.py */
static LIST_HEAD(struct hashmap_debug_info, hashmap_debug_list);
+static pthread_mutex_t hashmap_debug_list_mutex = PTHREAD_MUTEX_INITIALIZER;
#define HASHMAP_DEBUG_FIELDS struct hashmap_debug_info debug;
@@ -806,10 +808,12 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu
}
#ifdef ENABLE_DEBUG_HASHMAP
- LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
h->debug.func = func;
h->debug.file = file;
h->debug.line = line;
+ assert_se(pthread_mutex_lock(&hashmap_debug_list_mutex) == 0);
+ LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
+ assert_se(pthread_mutex_unlock(&hashmap_debug_list_mutex) == 0);
#endif
return h;
@@ -861,7 +865,9 @@ static void hashmap_free_no_clear(HashmapBase *h) {
assert(!h->n_direct_entries);
#ifdef ENABLE_DEBUG_HASHMAP
+ assert_se(pthread_mutex_lock(&hashmap_debug_list_mutex) == 0);
LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug);
+ assert_se(pthread_mutex_unlock(&hashmap_debug_list_mutex) == 0);
#endif
if (h->from_pool)
@@ -1794,6 +1800,8 @@ char **internal_hashmap_get_strv(HashmapBase *h) {
return sv;
}
+/// UNNEEDED by elogind
+#if 0
void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
struct ordered_hashmap_entry *e;
unsigned hash, idx;
@@ -1811,7 +1819,7 @@ void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
return NULL;
return ordered_bucket_at(h, e->iterate_next)->p.value;
}
-
+#endif // 0
int set_consume(Set *s, void *value) {
int r;
@@ -1840,6 +1848,8 @@ int set_put_strdup(Set *s, const char *p) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
int set_put_strdupv(Set *s, char **l) {
int n = 0, r;
char **i;
@@ -1854,3 +1864,4 @@ int set_put_strdupv(Set *s, char **l) {
return n;
}
+#endif // 0
diff --git a/src/shared/hashmap.h b/src/basic/hashmap.h
index 5723f09ca..03c8ae1c5 100644
--- a/src/shared/hashmap.h
+++ b/src/basic/hashmap.h
@@ -65,7 +65,6 @@ typedef struct {
} Iterator;
#define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
-#define _IDX_ITERATOR_NIL (UINT_MAX)
#define ITERATOR_FIRST ((Iterator) { .idx = _IDX_ITERATOR_FIRST, .next_key = NULL })
typedef unsigned long (*hash_func_t)(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
@@ -370,7 +369,7 @@ static inline void *ordered_hashmap_first(OrderedHashmap *h) {
}
/* no hashmap_next */
-void *ordered_hashmap_next(OrderedHashmap *h, const void *key);
+// UNNEEDED void *ordered_hashmap_next(OrderedHashmap *h, const void *key);
char **internal_hashmap_get_strv(HashmapBase *h);
static inline char **hashmap_get_strv(Hashmap *h) {
diff --git a/src/shared/hostname-util.c b/src/basic/hostname-util.c
index e336f269f..e336f269f 100644
--- a/src/shared/hostname-util.c
+++ b/src/basic/hostname-util.c
diff --git a/src/shared/hostname-util.h b/src/basic/hostname-util.h
index 0c4763cf5..0c4763cf5 100644
--- a/src/shared/hostname-util.h
+++ b/src/basic/hostname-util.h
diff --git a/src/shared/ioprio.h b/src/basic/ioprio.h
index e5c71d004..e5c71d004 100644
--- a/src/shared/ioprio.h
+++ b/src/basic/ioprio.h
diff --git a/src/shared/label.c b/src/basic/label.c
index 82f10b21b..82f10b21b 100644
--- a/src/shared/label.c
+++ b/src/basic/label.c
diff --git a/src/shared/label.h b/src/basic/label.h
index 8070bcb02..8070bcb02 100644
--- a/src/shared/label.h
+++ b/src/basic/label.h
diff --git a/src/shared/list.h b/src/basic/list.h
index 2939216ad..2939216ad 100644
--- a/src/shared/list.h
+++ b/src/basic/list.h
diff --git a/src/shared/log.c b/src/basic/log.c
index b96afc4de..b96afc4de 100644
--- a/src/shared/log.c
+++ b/src/basic/log.c
diff --git a/src/shared/log.h b/src/basic/log.h
index 569762d08..569762d08 100644
--- a/src/shared/log.h
+++ b/src/basic/log.h
diff --git a/src/shared/login-shared.c b/src/basic/login-util.c
index 64650a913..e25437f0f 100644
--- a/src/shared/login-shared.c
+++ b/src/basic/login-util.c
@@ -19,7 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "login-shared.h"
+#include "login-util.h"
#include "def.h"
bool session_id_valid(const char *id) {
diff --git a/src/shared/ima-util.h b/src/basic/login-util.h
index d38216170..a79f20c1b 100644
--- a/src/shared/ima-util.h
+++ b/src/basic/login-util.h
@@ -1,11 +1,9 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-#pragma once
-
/***
This file is part of systemd.
- Copyright 2013 Lennart Poettering
+ Copyright 2013 Zbigniew Jędrzejewski-Szmek
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#pragma once
+
#include <stdbool.h>
-bool use_ima(void);
+bool session_id_valid(const char *id);
diff --git a/src/shared/macro.h b/src/basic/macro.h
index 58530a398..58530a398 100644
--- a/src/shared/macro.h
+++ b/src/basic/macro.h
diff --git a/src/shared/memfd-util.c b/src/basic/memfd-util.c
index e99a738e1..b6dc19082 100644
--- a/src/shared/memfd-util.c
+++ b/src/basic/memfd-util.c
@@ -145,6 +145,8 @@ int memfd_set_size(int fd, uint64_t sz) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int memfd_new_and_map(const char *name, size_t sz, void **p) {
_cleanup_close_ int fd = -1;
int r;
@@ -169,3 +171,4 @@ int memfd_new_and_map(const char *name, size_t sz, void **p) {
return r;
}
+#endif // 0
diff --git a/src/shared/memfd-util.h b/src/basic/memfd-util.h
index 3ed551fb3..9aa87b783 100644
--- a/src/shared/memfd-util.h
+++ b/src/basic/memfd-util.h
@@ -24,7 +24,7 @@
int memfd_new(const char *name);
-int memfd_new_and_map(const char *name, size_t sz, void **p);
+// UNNEEDED int memfd_new_and_map(const char *name, size_t sz, void **p);
int memfd_map(int fd, uint64_t offset, size_t size, void **p);
diff --git a/src/shared/mempool.c b/src/basic/mempool.c
index d5d98d882..19c0edfa6 100644
--- a/src/shared/mempool.c
+++ b/src/basic/mempool.c
@@ -90,7 +90,7 @@ void mempool_free_tile(struct mempool *mp, void *p) {
#ifdef VALGRIND
-void mempool_drop(struct mempool *mp) {
+// UNNEEDED void mempool_drop(struct mempool *mp) {
struct pool *p = mp->first_pool;
while (p) {
struct pool *n;
diff --git a/src/shared/mempool.h b/src/basic/mempool.h
index 42f473bee..a0d081a69 100644
--- a/src/shared/mempool.h
+++ b/src/basic/mempool.h
@@ -45,5 +45,5 @@ struct mempool pool_name = { \
#ifdef VALGRIND
-void mempool_drop(struct mempool *mp);
+// UNNEEDED void mempool_drop(struct mempool *mp);
#endif
diff --git a/src/shared/missing.h b/src/basic/missing.h
index 2b979aeb1..93da55cf4 100644
--- a/src/shared/missing.h
+++ b/src/basic/missing.h
@@ -265,6 +265,11 @@ struct btrfs_qgroup_inherit {
__u64 qgroups[0];
};
+struct btrfs_ioctl_qgroup_limit_args {
+ __u64 qgroupid;
+ struct btrfs_qgroup_limit lim;
+};
+
struct btrfs_ioctl_vol_args_v2 {
__s64 fd;
__u64 transid;
@@ -356,6 +361,14 @@ struct btrfs_ioctl_clone_range_args {
__u64 src_offset, src_length;
__u64 dest_offset;
};
+
+#define BTRFS_QUOTA_CTL_ENABLE 1
+#define BTRFS_QUOTA_CTL_DISABLE 2
+#define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
+struct btrfs_ioctl_quota_ctl_args {
+ __u64 cmd;
+ __u64 status;
+};
#endif
#ifndef BTRFS_IOC_DEFRAG
@@ -363,6 +376,11 @@ struct btrfs_ioctl_clone_range_args {
struct btrfs_ioctl_vol_args)
#endif
+#ifndef BTRFS_IOC_RESIZE
+#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
+ struct btrfs_ioctl_vol_args)
+#endif
+
#ifndef BTRFS_IOC_CLONE
#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
#endif
@@ -420,6 +438,16 @@ struct btrfs_ioctl_clone_range_args {
struct btrfs_ioctl_vol_args)
#endif
+#ifndef BTRFS_IOC_QUOTA_CTL
+#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
+ struct btrfs_ioctl_quota_ctl_args)
+#endif
+
+#ifndef BTRFS_IOC_QGROUP_LIMIT
+#define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
+ struct btrfs_ioctl_qgroup_limit_args)
+#endif
+
#ifndef BTRFS_FIRST_FREE_OBJECTID
#define BTRFS_FIRST_FREE_OBJECTID 256
#endif
@@ -701,7 +729,7 @@ static inline int setns(int fd, int nstype) {
#define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
#endif
-#if !HAVE_DECL_IFLA_VXLAN_LOCAL6
+#if !HAVE_DECL_IFLA_VXLAN_REMCSUM_NOPARTIAL
#define IFLA_VXLAN_UNSPEC 0
#define IFLA_VXLAN_ID 1
#define IFLA_VXLAN_GROUP 2
@@ -720,7 +748,14 @@ static inline int setns(int fd, int nstype) {
#define IFLA_VXLAN_PORT 15
#define IFLA_VXLAN_GROUP6 16
#define IFLA_VXLAN_LOCAL6 17
-#define __IFLA_VXLAN_MAX 18
+#define IFLA_VXLAN_UDP_CSUM 18
+#define IFLA_VXLAN_UDP_ZERO_CSUM6_TX 19
+#define IFLA_VXLAN_UDP_ZERO_CSUM6_RX 20
+#define IFLA_VXLAN_REMCSUM_TX 21
+#define IFLA_VXLAN_REMCSUM_RX 22
+#define IFLA_VXLAN_GBP 23
+#define IFLA_VXLAN_REMCSUM_NOPARTIAL 24
+#define __IFLA_VXLAN_MAX 25
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
#endif
diff --git a/src/shared/mkdir-label.c b/src/basic/mkdir-label.c
index 221dd67eb..221dd67eb 100644
--- a/src/shared/mkdir-label.c
+++ b/src/basic/mkdir-label.c
diff --git a/src/shared/mkdir.c b/src/basic/mkdir.c
index 7ee454698..7ee454698 100644
--- a/src/shared/mkdir.c
+++ b/src/basic/mkdir.c
diff --git a/src/shared/mkdir.h b/src/basic/mkdir.h
index 2392d1fd1..2392d1fd1 100644
--- a/src/shared/mkdir.h
+++ b/src/basic/mkdir.h
diff --git a/src/shared/path-util.c b/src/basic/path-util.c
index 8f49d6526..cc985b067 100644
--- a/src/shared/path-util.c
+++ b/src/basic/path-util.c
@@ -130,6 +130,8 @@ char *path_make_absolute_cwd(const char *p) {
return strjoin(cwd, "/", p, NULL);
}
+/// UNNEEDED by elogind
+#if 0
int path_make_relative(const char *from_dir, const char *to_path, char **_r) {
char *r, *p;
unsigned n_parents;
@@ -214,6 +216,7 @@ int path_make_relative(const char *from_dir, const char *to_path, char **_r) {
*_r = r;
return 0;
}
+#endif // 0
char **path_strv_make_absolute_cwd(char **l) {
char **s;
@@ -759,6 +762,8 @@ int find_binary(const char *name, bool local, char **filename) {
}
}
+/// UNNEEDED by elogind
+#if 0
bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
bool changed = false;
const char* const* i;
@@ -793,6 +798,7 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
return changed;
}
+#endif // 0
int fsck_exists(const char *fstype) {
_cleanup_free_ char *p = NULL, *d = NULL;
diff --git a/src/shared/path-util.h b/src/basic/path-util.h
index 1eac89c51..5e6e3db89 100644
--- a/src/shared/path-util.h
+++ b/src/basic/path-util.h
@@ -41,7 +41,7 @@ int path_get_parent(const char *path, char **parent);
bool path_is_absolute(const char *p) _pure_;
char* path_make_absolute(const char *p, const char *prefix);
char* path_make_absolute_cwd(const char *p);
-int path_make_relative(const char *from_dir, const char *to_path, char **_r);
+// UNNEEDED int path_make_relative(const char *from_dir, const char *to_path, char **_r);
char* path_kill_slashes(char *path);
char* path_startswith(const char *path, const char *prefix) _pure_;
int path_compare(const char *a, const char *b) _pure_;
@@ -60,7 +60,7 @@ int path_is_os_tree(const char *path);
int find_binary(const char *name, bool local, char **filename);
-bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
+// UNNEEDED bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
int fsck_exists(const char *fstype);
diff --git a/src/shared/prioq.c b/src/basic/prioq.c
index b89888be0..b89888be0 100644
--- a/src/shared/prioq.c
+++ b/src/basic/prioq.c
diff --git a/src/shared/prioq.h b/src/basic/prioq.h
index 1c044b135..1c044b135 100644
--- a/src/shared/prioq.h
+++ b/src/basic/prioq.h
diff --git a/src/shared/process-util.c b/src/basic/process-util.c
index cfc876567..9e7ddca91 100644
--- a/src/shared/process-util.c
+++ b/src/basic/process-util.c
@@ -197,6 +197,8 @@ int is_kernel_thread(pid_t pid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int get_process_capeff(pid_t pid, char **capeff) {
const char *p;
@@ -207,6 +209,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
return get_status_field(p, "\nCapEff:", capeff);
}
+#endif // 0
static int get_process_link_contents(const char *proc_file, char **name) {
int r;
@@ -278,6 +281,8 @@ int get_process_uid(pid_t pid, uid_t *uid) {
return get_process_id(pid, "Uid:", uid);
}
+/// UNNEEDED by elogind
+#if 0
int get_process_gid(pid_t pid, gid_t *gid) {
assert_cc(sizeof(uid_t) == sizeof(gid_t));
return get_process_id(pid, "Gid:", gid);
@@ -335,6 +340,7 @@ int get_process_environ(pid_t pid, char **env) {
return 0;
}
+#endif // 0
int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
int r;
diff --git a/src/shared/process-util.h b/src/basic/process-util.h
index 07431d043..0f0475a81 100644
--- a/src/shared/process-util.h
+++ b/src/basic/process-util.h
@@ -46,11 +46,11 @@ int get_process_comm(pid_t pid, char **name);
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
int get_process_exe(pid_t pid, char **name);
int get_process_uid(pid_t pid, uid_t *uid);
-int get_process_gid(pid_t pid, gid_t *gid);
-int get_process_capeff(pid_t pid, char **capeff);
-int get_process_cwd(pid_t pid, char **cwd);
-int get_process_root(pid_t pid, char **root);
-int get_process_environ(pid_t pid, char **environ);
+// UNNEEDED int get_process_gid(pid_t pid, gid_t *gid);
+// UNNEEDED int get_process_capeff(pid_t pid, char **capeff);
+// UNNEEDED int get_process_cwd(pid_t pid, char **cwd);
+// UNNEEDED int get_process_root(pid_t pid, char **root);
+// UNNEEDED int get_process_environ(pid_t pid, char **environ);
int wait_for_terminate(pid_t pid, siginfo_t *status);
int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_code);
diff --git a/src/shared/random-util.c b/src/basic/random-util.c
index 88f518250..b230044f5 100644
--- a/src/shared/random-util.c
+++ b/src/basic/random-util.c
@@ -23,7 +23,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
+#ifdef HAVE_SYS_AUXV_H
#include <sys/auxv.h>
+#endif
#include <linux/random.h>
#include "random-util.h"
diff --git a/src/shared/random-util.h b/src/basic/random-util.h
index f7862c8c8..f7862c8c8 100644
--- a/src/shared/random-util.h
+++ b/src/basic/random-util.h
diff --git a/src/shared/ratelimit.h b/src/basic/ratelimit.h
index 58efca7df..58efca7df 100644
--- a/src/shared/ratelimit.h
+++ b/src/basic/ratelimit.h
diff --git a/src/shared/refcnt.h b/src/basic/refcnt.h
index 0502c20a2..0502c20a2 100644
--- a/src/shared/refcnt.h
+++ b/src/basic/refcnt.h
diff --git a/src/shared/ring.h b/src/basic/ring.h
index a7c44d1b5..fc857e7a9 100644
--- a/src/shared/ring.h
+++ b/src/basic/ring.h
@@ -32,7 +32,7 @@ struct Ring {
};
/* flush buffer so it is empty again */
-void ring_flush(Ring *r);
+// UNNEEDED void ring_flush(Ring *r);
/* flush buffer, free allocated data and reset to initial state */
void ring_clear(Ring *r);
@@ -41,7 +41,7 @@ void ring_clear(Ring *r);
size_t ring_peek(Ring *r, struct iovec *vec);
/* copy data into external linear buffer */
-size_t ring_copy(Ring *r, void *buf, size_t size);
+// UNNEEDED size_t ring_copy(Ring *r, void *buf, size_t size);
/* push data to the end of the buffer */
int ring_push(Ring *r, const void *u8, size_t size);
diff --git a/src/shared/rm-rf.c b/src/basic/rm-rf.c
index d70e959d8..d35d17295 100644
--- a/src/shared/rm-rf.c
+++ b/src/basic/rm-rf.c
@@ -21,6 +21,7 @@
#include "util.h"
#include "path-util.h"
+// #include "btrfs-util.h"
#include "rm-rf.h"
int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
@@ -114,14 +115,14 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
safe_close(subdir_fd);
continue;
}
+
#if 0
if ((flags & REMOVE_SUBVOLUME) && st.st_ino == 256) {
/* This could be a subvolume, try to remove it */
-
r = btrfs_subvol_remove_fd(fd, de->d_name, true);
if (r < 0) {
- if (r != -ENOTTY && r != -EINVAL) {
+ if (r != -ENOTTY && r != -EINVAL) {
if (ret == 0)
ret = r;
@@ -137,8 +138,9 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
safe_close(subdir_fd);
continue;
}
- }
-#endif //
+ }
+#endif // 0
+
/* We pass REMOVE_PHYSICAL here, to avoid
* doing the fstatfs() to check the file
* system type again for each directory */
@@ -174,19 +176,20 @@ int rm_rf(const char *path, RemoveFlags flags) {
log_error("Attempted to remove entire root file system, and we can't allow that.");
return -EPERM;
}
-#if 0
+
if ((flags & (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) == (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) {
/* Try to remove as subvolume first */
- r = btrfs_subvol_remove(path, true);
+#if 0
+ r = btrfs_subvol_remove(path, true);
if (r >= 0)
return r;
- if (r != -ENOTTY && r != -EINVAL)
+ if (r != -ENOTTY && r != -EINVAL && r != -ENOTDIR)
return r;
-
+#endif // 0
/* Not btrfs or not a subvolume */
}
-#endif // 0
+
fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
if (fd < 0) {
diff --git a/src/shared/rm-rf.h b/src/basic/rm-rf.h
index 769bbc853..769bbc853 100644
--- a/src/shared/rm-rf.h
+++ b/src/basic/rm-rf.h
diff --git a/src/shared/selinux-util.c b/src/basic/selinux-util.c
index 7c58985cd..69885d9fc 100644
--- a/src/shared/selinux-util.c
+++ b/src/basic/selinux-util.c
@@ -168,6 +168,8 @@ int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
return 0;
}
+/// UNNEDED by elogind
+#if 0
int mac_selinux_apply(const char *path, const char *label) {
#ifdef HAVE_SELINUX
@@ -185,6 +187,7 @@ int mac_selinux_apply(const char *path, const char *label) {
#endif
return 0;
}
+#endif // 0
int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
int r = -EOPNOTSUPP;
diff --git a/src/shared/selinux-util.h b/src/basic/selinux-util.h
index 846718529..6f6b08d0f 100644
--- a/src/shared/selinux-util.h
+++ b/src/basic/selinux-util.h
@@ -31,7 +31,7 @@ int mac_selinux_init(const char *prefix);
void mac_selinux_finish(void);
int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs);
-int mac_selinux_apply(const char *path, const char *label);
+// UNNEEDED int mac_selinux_apply(const char *path, const char *label);
int mac_selinux_get_create_label_from_exe(const char *exe, char **label);
int mac_selinux_get_our_label(char **label);
diff --git a/src/shared/set.h b/src/basic/set.h
index 51e40d3a6..1d1699959 100644
--- a/src/shared/set.h
+++ b/src/basic/set.h
@@ -122,7 +122,7 @@ static inline char **set_get_strv(Set *s) {
int set_consume(Set *s, void *value);
int set_put_strdup(Set *s, const char *p);
-int set_put_strdupv(Set *s, char **l);
+// UNNEEDED int set_put_strdupv(Set *s, char **l);
#define SET_FOREACH(e, s, i) \
for ((i) = ITERATOR_FIRST; set_iterate((s), &(i), (void**)&(e)); )
diff --git a/src/shared/signal-util.c b/src/basic/signal-util.c
index d24730d43..90abe8af8 100644
--- a/src/shared/signal-util.c
+++ b/src/basic/signal-util.c
@@ -167,7 +167,7 @@ int sigprocmask_many(int how, sigset_t *old, ...) {
if (sigemptyset(&ss) < 0)
return -errno;
- va_start(ap, how);
+ va_start(ap, old);
r = sigset_add_many_ap(&ss, ap);
va_end(ap);
diff --git a/src/shared/signal-util.h b/src/basic/signal-util.h
index 5e6eb50b0..5e6eb50b0 100644
--- a/src/shared/signal-util.h
+++ b/src/basic/signal-util.h
diff --git a/src/shared/siphash24.c b/src/basic/siphash24.c
index f68bd283a..f68bd283a 100644
--- a/src/shared/siphash24.c
+++ b/src/basic/siphash24.c
diff --git a/src/shared/siphash24.h b/src/basic/siphash24.h
index 62e1168a7..62e1168a7 100644
--- a/src/shared/siphash24.h
+++ b/src/basic/siphash24.h
diff --git a/src/shared/smack-util.c b/src/basic/smack-util.c
index 047aa294f..047aa294f 100644
--- a/src/shared/smack-util.c
+++ b/src/basic/smack-util.c
diff --git a/src/shared/smack-util.h b/src/basic/smack-util.h
index 50f55b1f4..50f55b1f4 100644
--- a/src/shared/smack-util.h
+++ b/src/basic/smack-util.h
diff --git a/src/shared/socket-util.h b/src/basic/socket-util.h
index 6b0ce7836..cccc6a654 100644
--- a/src/shared/socket-util.h
+++ b/src/basic/socket-util.h
@@ -86,7 +86,7 @@ int socket_address_listen(
mode_t directory_mode,
mode_t socket_mode,
const char *label);
-int make_socket_fd(int log_level, const char* address, int flags);
+// UNNEEDED int make_socket_fd(int log_level, const char* address, int flags);
bool socket_address_is(const SocketAddress *a, const char *s, int type);
bool socket_address_is_netlink(const SocketAddress *a, const char *s);
@@ -103,10 +103,10 @@ int sockaddr_port(const struct sockaddr *_sa) _pure_;
int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ipv6, bool include_port, char **ret);
int getpeername_pretty(int fd, char **ret);
-int getsockname_pretty(int fd, char **ret);
+// UNNEEDED int getsockname_pretty(int fd, char **ret);
int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
-int getnameinfo_pretty(int fd, char **ret);
+// UNNEEDED int getnameinfo_pretty(int fd, char **ret);
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
@@ -114,7 +114,7 @@ SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *
int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s) _pure_;
-bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
+// UNNEEDED bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
#define ETHER_ADDR_TO_STRING_MAX (3*6)
diff --git a/src/shared/sparse-endian.h b/src/basic/sparse-endian.h
index c913fda8c..c913fda8c 100644
--- a/src/shared/sparse-endian.h
+++ b/src/basic/sparse-endian.h
diff --git a/src/shared/special.h b/src/basic/special.h
index 1bf5c0e35..e51310eb6 100644
--- a/src/shared/special.h
+++ b/src/basic/special.h
@@ -95,6 +95,8 @@
/* Magic early boot services */
#define SPECIAL_FSCK_SERVICE "systemd-fsck@.service"
+#define SPECIAL_QUOTACHECK_SERVICE "systemd-quotacheck.service"
+#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
/* Services systemd relies on */
diff --git a/src/shared/strv.c b/src/basic/strv.c
index d44a72fc4..31d83f3ef 100644
--- a/src/shared/strv.c
+++ b/src/basic/strv.c
@@ -253,6 +253,8 @@ char **strv_split(const char *s, const char *separator) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
char **strv_split_newlines(const char *s) {
char **l;
unsigned n;
@@ -277,6 +279,7 @@ char **strv_split_newlines(const char *s) {
return l;
}
+#endif // 0
int strv_split_quoted(char ***t, const char *s, UnquoteFlags flags) {
size_t n = 0, allocated = 0;
@@ -477,6 +480,8 @@ int strv_consume(char ***l, char *value) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
int strv_consume_pair(char ***l, char *a, char *b) {
int r;
@@ -488,6 +493,7 @@ int strv_consume_pair(char ***l, char *a, char *b) {
return r;
}
+#endif // 0
int strv_consume_prepend(char ***l, char *value) {
int r;
@@ -524,6 +530,8 @@ char **strv_uniq(char **l) {
return l;
}
+/// UNNEEDED by elogind
+#if 0
bool strv_is_uniq(char **l) {
char **i;
@@ -533,6 +541,7 @@ bool strv_is_uniq(char **l) {
return true;
}
+#endif // 0
char **strv_remove(char **l, const char *s) {
char **f, **t;
@@ -642,6 +651,8 @@ char **strv_sort(char **l) {
return l;
}
+/// UNNEEDED by elogind
+#if 0
bool strv_equal(char **a, char **b) {
if (!a || !b)
return a == b;
@@ -652,6 +663,7 @@ bool strv_equal(char **a, char **b) {
return true;
}
+#endif // 0
void strv_print(char **l) {
char **s;
@@ -660,6 +672,8 @@ void strv_print(char **l) {
puts(*s);
}
+/// UNNEEDED by elogind
+#if 0
int strv_extendf(char ***l, const char *format, ...) {
va_list ap;
char *x;
@@ -692,6 +706,7 @@ char **strv_reverse(char **l) {
return l;
}
+#endif // 0
bool strv_fnmatch(char* const* patterns, const char *s, int flags) {
char* const* p;
diff --git a/src/shared/strv.h b/src/basic/strv.h
index 22f8f98fd..2a2003c3d 100644
--- a/src/shared/strv.h
+++ b/src/basic/strv.h
@@ -43,19 +43,19 @@ unsigned strv_length(char * const *l) _pure_;
int strv_extend_strv(char ***a, char **b);
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int strv_extend(char ***l, const char *value);
-int strv_extendf(char ***l, const char *format, ...) _printf_(2,0);
+// UNNEEDED int strv_extendf(char ***l, const char *format, ...) _printf_(2,0);
int strv_push(char ***l, char *value);
int strv_push_pair(char ***l, char *a, char *b);
int strv_push_prepend(char ***l, char *value);
int strv_consume(char ***l, char *value);
-int strv_consume_pair(char ***l, char *a, char *b);
+// UNNEEDED int strv_consume_pair(char ***l, char *a, char *b);
int strv_consume_prepend(char ***l, char *value);
char **strv_remove(char **l, const char *s);
char **strv_uniq(char **l);
-bool strv_is_uniq(char **l);
+// UNNEEDED bool strv_is_uniq(char **l);
-bool strv_equal(char **a, char **b);
+// UNNEEDED bool strv_equal(char **a, char **b);
#define strv_contains(l, s) (!!strv_find((l), (s)))
@@ -71,7 +71,7 @@ static inline bool strv_isempty(char * const *l) {
}
char **strv_split(const char *s, const char *separator);
-char **strv_split_newlines(const char *s);
+// UNNEEDED char **strv_split_newlines(const char *s);
int strv_split_quoted(char ***t, const char *s, UnquoteFlags flags);
@@ -144,7 +144,7 @@ void strv_print(char **l);
_l[0]; \
}))
-char **strv_reverse(char **l);
+// UNNEEDED char **strv_reverse(char **l);
bool strv_fnmatch(char* const* patterns, const char *s, int flags);
diff --git a/src/shared/terminal-util.c b/src/basic/terminal-util.c
index 042b88f22..103643614 100644
--- a/src/shared/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -174,6 +174,8 @@ int ask_char(char *ret, const char *replies, const char *text, ...) {
}
}
+/// UNNEEDED by elogind
+#if 0
int ask_string(char **ret, const char *text, ...) {
assert(ret);
assert(text);
@@ -216,6 +218,7 @@ int ask_string(char **ret, const char *text, ...) {
}
}
}
+#endif // 0
int reset_terminal_fd(int fd, bool switch_to_text) {
struct termios termios;
@@ -882,10 +885,13 @@ unsigned lines(void) {
}
/* intended to be used as a SIGWINCH sighandler */
+/// UNNEEDED by elogind
+#if 0
void columns_lines_cache_reset(int signum) {
cached_columns = 0;
cached_lines = 0;
}
+#endif // 0
bool on_tty(void) {
static int cached_on_tty = -1;
diff --git a/src/shared/terminal-util.h b/src/basic/terminal-util.h
index 188714f22..f6eace411 100644
--- a/src/shared/terminal-util.h
+++ b/src/basic/terminal-util.h
@@ -50,7 +50,7 @@ int chvt(int vt);
int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
int ask_char(char *ret, const char *replies, const char *text, ...) _printf_(3, 4);
-int ask_string(char **ret, const char *text, ...) _printf_(2, 3);
+// UNNEEDED int ask_string(char **ret, const char *text, ...) _printf_(2, 3);
int vt_disallocate(const char *name);
@@ -74,7 +74,7 @@ int fd_columns(int fd);
unsigned columns(void);
int fd_lines(int fd);
unsigned lines(void);
-void columns_lines_cache_reset(int _unused_ signum);
+// UNNEEDED void columns_lines_cache_reset(int _unused_ signum);
bool on_tty(void);
diff --git a/src/shared/time-util.c b/src/basic/time-util.c
index 12f1b193b..ecca227c7 100644
--- a/src/shared/time-util.c
+++ b/src/basic/time-util.c
@@ -173,9 +173,12 @@ char *format_timestamp(char *buf, size_t l, usec_t t) {
return format_timestamp_internal(buf, l, t, false);
}
+/// UNNEEDED by elogind
+#if 0
char *format_timestamp_utc(char *buf, size_t l, usec_t t) {
return format_timestamp_internal(buf, l, t, true);
}
+#endif // 0
static char *format_timestamp_internal_us(char *buf, size_t l, usec_t t, bool utc) {
struct tm tm;
@@ -415,6 +418,8 @@ int dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int parse_timestamp(const char *t, usec_t *usec) {
static const struct {
const char *name;
@@ -615,6 +620,7 @@ finish:
return 0;
}
+#endif // 0
int parse_sec(const char *t, usec_t *usec) {
static const struct {
@@ -864,6 +870,8 @@ int parse_nsec(const char *t, nsec_t *nsec) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
bool ntp_synced(void) {
struct timex txc = {};
@@ -977,6 +985,7 @@ bool timezone_is_valid(const char *name) {
return true;
}
+#endif // 0
clockid_t clock_boottime_or_monotonic(void) {
static clockid_t clock = -1;
diff --git a/src/shared/time-util.h b/src/basic/time-util.h
index 7a64d454a..48ca453e6 100644
--- a/src/shared/time-util.h
+++ b/src/basic/time-util.h
@@ -87,7 +87,7 @@ usec_t timeval_load(const struct timeval *tv) _pure_;
struct timeval *timeval_store(struct timeval *tv, usec_t u);
char *format_timestamp(char *buf, size_t l, usec_t t);
-char *format_timestamp_utc(char *buf, size_t l, usec_t t);
+// UNNEEDED char *format_timestamp_utc(char *buf, size_t l, usec_t t);
char *format_timestamp_us(char *buf, size_t l, usec_t t);
char *format_timestamp_us_utc(char *buf, size_t l, usec_t t);
char *format_timestamp_relative(char *buf, size_t l, usec_t t);
@@ -96,15 +96,15 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy);
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
int dual_timestamp_deserialize(const char *value, dual_timestamp *t);
-int parse_timestamp(const char *t, usec_t *usec);
+// UNNEEDED int parse_timestamp(const char *t, usec_t *usec);
int parse_sec(const char *t, usec_t *usec);
int parse_nsec(const char *t, nsec_t *nsec);
-bool ntp_synced(void);
+// UNNEEDED bool ntp_synced(void);
-int get_timezones(char ***l);
-bool timezone_is_valid(const char *name);
+// UNNEEDED int get_timezones(char ***l);
+// UNNEEDED bool timezone_is_valid(const char *name);
clockid_t clock_boottime_or_monotonic(void);
diff --git a/src/shared/unit-name.c b/src/basic/unit-name.c
index bf52463d8..bf52463d8 100644
--- a/src/shared/unit-name.c
+++ b/src/basic/unit-name.c
diff --git a/src/shared/unit-name.h b/src/basic/unit-name.h
index b2043d087..b2043d087 100644
--- a/src/shared/unit-name.h
+++ b/src/basic/unit-name.h
diff --git a/src/shared/utf8.c b/src/basic/utf8.c
index 800884ffe..800884ffe 100644
--- a/src/shared/utf8.c
+++ b/src/basic/utf8.c
diff --git a/src/shared/utf8.h b/src/basic/utf8.h
index e745649f0..e745649f0 100644
--- a/src/shared/utf8.h
+++ b/src/basic/utf8.h
diff --git a/src/shared/util.c b/src/basic/util.c
index 950519ed0..3945abdbe 100644
--- a/src/shared/util.c
+++ b/src/basic/util.c
@@ -789,6 +789,8 @@ char *strstrip(char *s) {
return s;
}
+/// UNNEEDED by elogind
+#if 0
char *delete_chars(char *s, const char *bad) {
char *f, *t;
@@ -805,6 +807,7 @@ char *delete_chars(char *s, const char *bad) {
return s;
}
+#endif // 0
char *file_in_same_dir(const char *path, const char *filename) {
char *e, *ret;
@@ -1923,6 +1926,8 @@ int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
assert(fd >= 0);
@@ -1940,6 +1945,7 @@ int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
return 0;
}
+#endif // 0
cpu_set_t* cpu_set_malloc(unsigned *ncpus) {
cpu_set_t *r;
@@ -2144,6 +2150,8 @@ int touch(const char *path) {
return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, 0);
}
+/// UNNEEDED by elogind
+#if 0
static char *unquote(const char *s, const char* quotes) {
size_t l;
assert(s);
@@ -2163,6 +2171,7 @@ static char *unquote(const char *s, const char* quotes) {
return strdup(s);
}
+#endif // 0
noreturn void freeze(void) {
@@ -2198,6 +2207,8 @@ int null_or_empty_path(const char *fn) {
return null_or_empty(&st);
}
+/// UNNEEDED by elogind
+#if 0
int null_or_empty_fd(int fd) {
struct stat st;
@@ -2208,6 +2219,7 @@ int null_or_empty_fd(int fd) {
return null_or_empty(&st);
}
+#endif // 0
DIR *xopendirat(int fd, const char *name, int flags) {
int nfd;
@@ -2228,6 +2240,8 @@ DIR *xopendirat(int fd, const char *name, int flags) {
return d;
}
+/// UNNEEDED by elogind
+#if 0
static char *tag_to_udev_node(const char *tagvalue, const char *by) {
_cleanup_free_ char *t = NULL, *u = NULL;
size_t enc_len;
@@ -2264,6 +2278,7 @@ char *fstab_node_to_udev_node(const char *p) {
return strdup(p);
}
+#endif // 0
bool dirent_is_file(const struct dirent *de) {
assert(de);
@@ -2293,6 +2308,8 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
return endswith(de->d_name, suffix);
}
+/// UNNEEDED by elogind
+#if 0
static int do_execute(char **directories, usec_t timeout, char *argv[]) {
_cleanup_hashmap_free_free_ Hashmap *pids = NULL;
_cleanup_set_free_free_ Set *seen = NULL;
@@ -2432,6 +2449,7 @@ void execute_directories(const char* const* directories, usec_t timeout, char *a
wait_for_terminate_and_warn(name, executor_pid, true);
}
+#endif // 0
bool nulstr_contains(const char*nulstr, const char *needle) {
const char *i;
@@ -2446,9 +2464,12 @@ bool nulstr_contains(const char*nulstr, const char *needle) {
return false;
}
+/// UNNEEDED by elogind
+#if 0
bool plymouth_running(void) {
return access("/run/plymouth/pid", F_OK) >= 0;
}
+#endif // 0
char* strshorten(char *s, size_t l) {
assert(s);
@@ -2566,6 +2587,8 @@ int symlink_atomic(const char *from, const char *to) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int symlink_idempotent(const char *from, const char *to) {
_cleanup_free_ char *p = NULL;
int r;
@@ -2629,6 +2652,7 @@ int mkfifo_atomic(const char *path, mode_t mode) {
return 0;
}
+#endif // 0
bool display_is_local(const char *display) {
assert(display);
@@ -2829,6 +2853,8 @@ int in_gid(gid_t gid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int in_group(const char *name) {
int r;
gid_t gid;
@@ -2839,6 +2865,7 @@ int in_group(const char *name) {
return in_gid(gid);
}
+#endif // 0
int glob_exists(const char *path) {
_cleanup_globfree_ glob_t g = {};
@@ -2859,6 +2886,8 @@ int glob_exists(const char *path) {
return errno ? -errno : -EIO;
}
+/// UNNEEDED by elogind
+#if 0
int glob_extend(char ***strv, const char *path) {
_cleanup_globfree_ glob_t g = {};
int k;
@@ -2882,6 +2911,7 @@ int glob_extend(char ***strv, const char *path) {
return k;
}
+#endif // 0
int dirent_ensure_type(DIR *d, struct dirent *de) {
struct stat st;
@@ -3196,6 +3226,8 @@ bool kexec_loaded(void) {
return loaded;
}
+/// UNNEEDED by elogind
+#if 0
int prot_from_flags(int flags) {
switch (flags & O_ACCMODE) {
@@ -3213,7 +3245,7 @@ int prot_from_flags(int flags) {
return -EINVAL;
}
}
-
+#endif // 0
char *format_bytes(char *buf, size_t l, off_t t) {
unsigned i;
@@ -3427,6 +3459,8 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
bool http_etag_is_valid(const char *etag) {
if (isempty(etag))
return false;
@@ -3439,6 +3473,7 @@ bool http_etag_is_valid(const char *etag) {
return true;
}
+#endif // 0
bool http_url_is_valid(const char *url) {
const char *p;
@@ -3678,6 +3713,8 @@ bool path_is_safe(const char *p) {
return true;
}
+/// UNNEEDED by elogind
+#if 0
/* hey glibc, APIs with callbacks without a user pointer are so useless */
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar) (const void *, const void *, void *), void *arg) {
@@ -3705,6 +3742,7 @@ void init_gettext(void) {
setlocale(LC_ALL, "");
textdomain(GETTEXT_PACKAGE);
}
+#endif // 0
bool is_locale_utf8(void) {
const char *set;
@@ -4047,6 +4085,8 @@ int search_and_fopen(const char *path, const char *mode, const char *root, const
return search_and_fopen_internal(path, mode, root, copy, _f);
}
+/// UNNEEDED by elogind
+#if 0
int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f) {
_cleanup_strv_free_ char **s = NULL;
@@ -4068,6 +4108,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root
return search_and_fopen_internal(path, mode, root, s, _f);
}
+#endif // 0
char *strextend(char **x, ...) {
va_list ap;
@@ -4226,6 +4267,8 @@ bool id128_is_valid(const char *s) {
return true;
}
+/// UNNEEDED by elogind
+#if 0
int split_pair(const char *s, const char *sep, char **l, char **r) {
char *x, *a, *b;
@@ -4269,6 +4312,7 @@ int shall_restore_state(void) {
return parse_boolean(value) != 0;
}
+#endif // 0
int proc_cmdline(char **ret) {
assert(ret);
@@ -4318,6 +4362,8 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int get_proc_cmdline_key(const char *key, char **value) {
_cleanup_free_ char *line = NULL, *ret = NULL;
bool found = false;
@@ -4370,6 +4416,7 @@ int get_proc_cmdline_key(const char *key, char **value) {
return found;
}
+#endif // 0
int container_get_leader(const char *machine, pid_t *pid) {
_cleanup_free_ char *s = NULL, *class = NULL;
@@ -4611,6 +4658,8 @@ int fd_warn_permissions(const char *path, int fd) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
unsigned long personality_from_string(const char *p) {
/* Parse a personality specifier. We introduce our own
@@ -4636,6 +4685,7 @@ unsigned long personality_from_string(const char *p) {
return PERSONALITY_INVALID;
}
+#endif // 0
const char* personality_to_string(unsigned long p) {
@@ -4668,6 +4718,8 @@ uint64_t physical_memory(void) {
return (uint64_t) mem * (uint64_t) page_size();
}
+/// UNNEEDED by elogind
+#if 0
void hexdump(FILE *f, const void *p, size_t s) {
const uint8_t *b = p;
unsigned n = 0;
@@ -4710,6 +4762,7 @@ void hexdump(FILE *f, const void *p, size_t s) {
s -= 16;
}
}
+#endif // 0
int update_reboot_param_file(const char *param) {
int r = 0;
@@ -5043,6 +5096,8 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int tempfn_random_child(const char *p, const char *extra, char **ret) {
char *t, *x;
uint64_t u;
@@ -5117,6 +5172,7 @@ int take_password_lock(const char *root) {
return fd;
}
+#endif // 0
int is_symlink(const char *path) {
struct stat info;
@@ -5141,6 +5197,8 @@ int is_dir(const char* path, bool follow) {
return !!S_ISDIR(st.st_mode);
}
+/// UNNEEDED by elogind
+#if 0
int is_device_node(const char *path) {
struct stat info;
@@ -5149,6 +5207,7 @@ int is_device_node(const char *path) {
return !!(S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode));
}
+#endif // 0
int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
_cleanup_free_ char *s = NULL;
@@ -5350,6 +5409,8 @@ int unquote_first_word_and_warn(
return r;
}
+/// UNNEEDED by elogind
+#if 0
int unquote_many_words(const char **p, UnquoteFlags flags, ...) {
va_list ap;
char **l;
@@ -5405,6 +5466,7 @@ int unquote_many_words(const char **p, UnquoteFlags flags, ...) {
return c;
}
+#endif // 0
int free_and_strdup(char **p, const char *s) {
char *t;
@@ -5457,6 +5519,8 @@ int ptsname_malloc(int fd, char **ret) {
}
}
+/// UNNEEDED by elogind
+#if 0
int openpt_in_namespace(pid_t pid, int flags) {
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
_cleanup_close_pair_ int pair[2] = { -1, -1 };
@@ -5542,6 +5606,7 @@ int openpt_in_namespace(pid_t pid, int flags) {
return -EIO;
}
+#endif // 0
ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute, void *value, size_t size, int flags) {
_cleanup_close_ int fd = -1;
@@ -5605,6 +5670,8 @@ int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags) {
return parse_crtime(le, usec);
}
+/// UNNEEDED by elogind
+#if 0
int path_getcrtime(const char *p, usec_t *usec) {
le64_t le;
ssize_t n;
@@ -5620,6 +5687,7 @@ int path_getcrtime(const char *p, usec_t *usec) {
return parse_crtime(le, usec);
}
+#endif // 0
int fd_setcrtime(int fd, usec_t usec) {
le64_t le;
@@ -5780,6 +5848,8 @@ int read_attr_path(const char *p, unsigned *ret) {
return read_attr_fd(fd, ret);
}
+/// UNNEEDED by elogind
+#if 0
static size_t nul_length(const uint8_t *p, size_t sz) {
size_t n = 0;
@@ -5841,6 +5911,7 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
return q - (const uint8_t*) p;
}
+#endif // 0
void sigkill_wait(pid_t *pid) {
if (!pid)
@@ -5852,6 +5923,8 @@ void sigkill_wait(pid_t *pid) {
(void) wait_for_terminate(*pid, NULL);
}
+/// UNNEEDED by elogind
+#if 0
int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
int a = 0, b = 0, c = 0;
int k;
@@ -5893,6 +5966,7 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
*p += k;
return 1;
}
+#endif // 0
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
size_t i;
diff --git a/src/shared/util.h b/src/basic/util.h
index 11ab9f6c0..4e30fe128 100644
--- a/src/shared/util.h
+++ b/src/basic/util.h
@@ -40,51 +40,12 @@
#include <locale.h>
#include <mntent.h>
#include <sys/inotify.h>
-
-#if SIZEOF_PID_T == 4
-# define PID_PRI PRIi32
-#elif SIZEOF_PID_T == 2
-# define PID_PRI PRIi16
-#else
-# error Unknown pid_t size
-#endif
-#define PID_FMT "%" PID_PRI
-
-#if SIZEOF_UID_T == 4
-# define UID_FMT "%" PRIu32
-#elif SIZEOF_UID_T == 2
-# define UID_FMT "%" PRIu16
-#else
-# error Unknown uid_t size
-#endif
-
-#if SIZEOF_GID_T == 4
-# define GID_FMT "%" PRIu32
-#elif SIZEOF_GID_T == 2
-# define GID_FMT "%" PRIu16
-#else
-# error Unknown gid_t size
-#endif
-
-#if SIZEOF_TIME_T == 8
-# define PRI_TIME PRIi64
-#elif SIZEOF_TIME_T == 4
-# define PRI_TIME PRIu32
-#else
-# error Unknown time_t size
-#endif
-
-#if SIZEOF_RLIM_T == 8
-# define RLIM_FMT "%" PRIu64
-#elif SIZEOF_RLIM_T == 4
-# define RLIM_FMT "%" PRIu32
-#else
-# error Unknown rlim_t size
-#endif
+#include <sys/statfs.h>
#include "macro.h"
#include "missing.h"
#include "time-util.h"
+#include "formats-util.h"
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"
@@ -101,16 +62,6 @@
#define FORMAT_BYTES_MAX 8
-#define ANSI_HIGHLIGHT_ON "\x1B[1;39m"
-#define ANSI_RED_ON "\x1B[31m"
-#define ANSI_HIGHLIGHT_RED_ON "\x1B[1;31m"
-#define ANSI_GREEN_ON "\x1B[32m"
-#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
-#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
-#define ANSI_HIGHLIGHT_BLUE_ON "\x1B[1;34m"
-#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
-#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
-
size_t page_size(void) _pure_;
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
@@ -182,6 +133,7 @@ static inline char *startswith_no_case(const char *s, const char *prefix) {
}
char *endswith(const char *s, const char *postfix) _pure_;
+char *endswith_no_case(const char *s, const char *postfix) _pure_;
char *first_word(const char *s, const char *word) _pure_;
@@ -265,14 +217,9 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo
#define _FOREACH_WORD(word, length, s, separator, quoted, state) \
for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted)))
-pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
-
char *strappend(const char *s, const char *suffix);
char *strnappend(const char *s, const char *suffix, size_t length);
-char *replace_env(const char *format, char **env);
-char **replace_env_argv(char **argv, char **env);
-
int readlinkat_malloc(int fd, const char *p, char **ret);
int readlink_malloc(const char *p, char **r);
int readlink_value(const char *p, char **ret);
@@ -280,24 +227,13 @@ int readlink_and_make_absolute(const char *p, char **r);
int readlink_and_canonicalize(const char *p, char **r);
char *strstrip(char *s);
-char *delete_chars(char *s, const char *bad);
+// UNNEEDED char *delete_chars(char *s, const char *bad);
char *truncate_nl(char *s);
char *file_in_same_dir(const char *path, const char *filename);
int rmdir_parents(const char *path, const char *stop);
-int get_process_state(pid_t pid);
-int get_process_comm(pid_t pid, char **name);
-int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
-int get_process_exe(pid_t pid, char **name);
-int get_process_uid(pid_t pid, uid_t *uid);
-int get_process_gid(pid_t pid, gid_t *gid);
-int get_process_capeff(pid_t pid, char **capeff);
-int get_process_cwd(pid_t pid, char **cwd);
-int get_process_root(pid_t pid, char **root);
-int get_process_environ(pid_t pid, char **environ);
-
char hexchar(int x) _const_;
int unhexchar(char c) _const_;
char octchar(int x) _const_;
@@ -306,9 +242,15 @@ char decchar(int x) _const_;
int undecchar(char c) _const_;
char *cescape(const char *s);
-char *cunescape(const char *s);
-char *cunescape_length(const char *s, size_t length);
-char *cunescape_length_with_prefix(const char *s, size_t length, const char *prefix);
+size_t cescape_char(char c, char *buf);
+
+typedef enum UnescapeFlags {
+ UNESCAPE_RELAX = 1,
+} UnescapeFlags;
+
+int cunescape(const char *s, UnescapeFlags flags, char **ret);
+int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret);
+int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret);
char *xescape(const char *s, const char *bad);
@@ -321,26 +263,6 @@ bool hidden_file(const char *filename) _pure_;
bool chars_intersect(const char *a, const char *b) _pure_;
-int make_stdio(int fd);
-int make_null_stdio(void);
-int make_console_stdio(void);
-
-int dev_urandom(void *p, size_t n);
-void random_bytes(void *p, size_t n);
-void initialize_srand(void);
-
-static inline uint64_t random_u64(void) {
- uint64_t u;
- random_bytes(&u, sizeof(u));
- return u;
-}
-
-static inline uint32_t random_u32(void) {
- uint32_t u;
- random_bytes(&u, sizeof(u));
- return u;
-}
-
/* For basic lookup tables with strictly enumerated entries */
#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
scope const char *name##_to_string(type i) { \
@@ -406,19 +328,6 @@ int close_all_fds(const int except[], unsigned n_except);
bool fstype_is_network(const char *fstype);
-int chvt(int vt);
-
-int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
-int ask_char(char *ret, const char *replies, const char *text, ...) _printf_(3, 4);
-int ask_string(char **ret, const char *text, ...) _printf_(2, 3);
-
-int reset_terminal_fd(int fd, bool switch_to_text);
-int reset_terminal(const char *name);
-
-int open_terminal(const char *name, int mode);
-int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm, usec_t timeout);
-int release_terminal(void);
-
int flush_fd(int fd);
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
@@ -432,72 +341,22 @@ bool is_device_path(const char *path);
int dir_is_empty(const char *path);
char* dirname_malloc(const char *path);
-void rename_process(const char name[8]);
-
-bool hostname_is_set(void);
-
char* lookup_uid(uid_t uid);
-char* gethostname_malloc(void);
char* getlogname_malloc(void);
char* getusername_malloc(void);
-int getttyname_malloc(int fd, char **r);
-int getttyname_harder(int fd, char **r);
-
-int get_ctty_devnr(pid_t pid, dev_t *d);
-int get_ctty(pid_t, dev_t *_devnr, char **r);
-
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
-
-int is_fd_on_temporary_fs(int fd);
+// UNNEEDED int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
-int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev);
-int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev);
-int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky);
-int rm_rf_dangerous(const char *path, bool only_dirs, bool delete_root, bool honour_sticky);
+bool is_temporary_fs(const struct statfs *s) _pure_;
+int fd_is_temporary_fs(int fd);
int pipe_eof(int fd);
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
-int status_vprintf(const char *status, bool ellipse, bool ephemeral, const char *format, va_list ap) _printf_(4,0);
-int status_printf(const char *status, bool ellipse, bool ephemeral, const char *format, ...) _printf_(4,5);
-
#define xsprintf(buf, fmt, ...) assert_se((size_t) snprintf(buf, ELEMENTSOF(buf), fmt, __VA_ARGS__) < ELEMENTSOF(buf))
-int fd_columns(int fd);
-unsigned columns(void);
-int fd_lines(int fd);
-unsigned lines(void);
-void columns_lines_cache_reset(int _unused_ signum);
-
-bool on_tty(void);
-
-static inline const char *ansi_highlight(void) {
- return on_tty() ? ANSI_HIGHLIGHT_ON : "";
-}
-
-static inline const char *ansi_highlight_red(void) {
- return on_tty() ? ANSI_HIGHLIGHT_RED_ON : "";
-}
-
-static inline const char *ansi_highlight_green(void) {
- return on_tty() ? ANSI_HIGHLIGHT_GREEN_ON : "";
-}
-
-static inline const char *ansi_highlight_yellow(void) {
- return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
-}
-
-static inline const char *ansi_highlight_blue(void) {
- return on_tty() ? ANSI_HIGHLIGHT_BLUE_ON : "";
-}
-
-static inline const char *ansi_highlight_off(void) {
- return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
-}
-
int files_same(const char *filea, const char *fileb);
int running_in_chroot(void);
@@ -509,52 +368,31 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
int touch(const char *path);
-char *unquote(const char *s, const char *quotes);
-char *normalize_env_assignment(const char *s);
-
-int wait_for_terminate(pid_t pid, siginfo_t *status);
-int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_code);
-
noreturn void freeze(void);
bool null_or_empty(struct stat *st) _pure_;
int null_or_empty_path(const char *fn);
-int null_or_empty_fd(int fd);
+// UNNEEDED int null_or_empty_fd(int fd);
DIR *xopendirat(int dirfd, const char *name, int flags);
-char *fstab_node_to_udev_node(const char *p);
-
-char *resolve_dev_console(char **active);
-bool tty_is_vc(const char *tty);
-bool tty_is_vc_resolve(const char *tty);
-bool tty_is_console(const char *tty) _pure_;
-int vtnr_from_tty(const char *tty);
-const char *default_term_for_tty(const char *tty);
-
-void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
+// UNNEEDED char *fstab_node_to_udev_node(const char *p);
-int kill_and_sigcont(pid_t pid, int sig);
+// UNNEEDED void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
bool nulstr_contains(const char*nulstr, const char *needle);
-bool plymouth_running(void);
-
-bool hostname_is_valid(const char *s) _pure_;
-char* hostname_cleanup(char *s, bool lowercase);
+// UNNEEDED bool plymouth_running(void);
bool machine_name_is_valid(const char *s) _pure_;
char* strshorten(char *s, size_t l);
-int terminal_vhangup_fd(int fd);
-int terminal_vhangup(const char *name);
-
-int vt_disallocate(const char *name);
+// UNNEEDED int symlink_idempotent(const char *from, const char *to);
int symlink_atomic(const char *from, const char *to);
-int mknod_atomic(const char *path, mode_t mode, dev_t dev);
-int mkfifo_atomic(const char *path, mode_t mode);
+// UNNEEDED int mknod_atomic(const char *path, mode_t mode, dev_t dev);
+// UNNEEDED int mkfifo_atomic(const char *path, mode_t mode);
int fchmod_umask(int fd, mode_t mode);
@@ -565,13 +403,13 @@ int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **h
int get_group_creds(const char **groupname, gid_t *gid);
int in_gid(gid_t gid);
-int in_group(const char *name);
+// UNNEEDED int in_group(const char *name);
char* uid_to_name(uid_t uid);
char* gid_to_name(gid_t gid);
int glob_exists(const char *path);
-int glob_extend(char ***strv, const char *path);
+// UNNEEDED int glob_extend(char ***strv, const char *path);
int dirent_ensure_type(DIR *d, struct dirent *de);
@@ -621,7 +459,7 @@ extern char **saved_argv;
bool kexec_loaded(void);
-int prot_from_flags(int flags) _const_;
+// UNNEEDED int prot_from_flags(int flags) _const_;
char *format_bytes(char *buf, size_t l, off_t t);
@@ -629,8 +467,6 @@ int fd_wait_for_event(int fd, int event, usec_t timeout);
void* memdup(const void *p, size_t l) _alloc_(2);
-int is_kernel_thread(pid_t pid);
-
int fd_inc_sndbuf(int fd, size_t n);
int fd_inc_rcvbuf(int fd, size_t n);
@@ -638,17 +474,13 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
int setrlimit_closest(int resource, const struct rlimit *rlim);
-int getenv_for_pid(pid_t pid, const char *field, char **_value);
-
bool http_url_is_valid(const char *url) _pure_;
bool documentation_url_is_valid(const char *url) _pure_;
-bool http_etag_is_valid(const char *etag);
+// UNNEEDED bool http_etag_is_valid(const char *etag);
bool in_initrd(void);
-void warn_melody(void);
-
int get_home_dir(char **ret);
int get_shell(char **_ret);
@@ -716,12 +548,12 @@ _pure_ static inline bool string_is_glob(const char *p) {
return !!strpbrk(p, GLOB_CHARS);
}
-void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
- int (*compar) (const void *, const void *, void *),
- void *arg);
+// UNNEEDED void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
+// UNNEEDED int (*compar) (const void *, const void *, void *),
+// UNNEEDED void *arg);
#define _(String) gettext (String)
-void init_gettext(void);
+// UNNEEDED void init_gettext(void);
bool is_locale_utf8(void);
typedef enum DrawSpecialChar {
@@ -745,7 +577,7 @@ char *strip_tab_ansi(char **p, size_t *l);
int on_ac_power(void);
int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f);
-int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f);
+// UNNEEDED int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f);
#define FOREACH_LINE(line, f, on_error) \
for (;;) \
@@ -916,35 +748,37 @@ int unlink_noerrno(const char *path);
_d_; \
})
-#define procfs_file_alloca(pid, field) \
- ({ \
- pid_t _pid_ = (pid); \
- const char *_r_; \
- if (_pid_ == 0) { \
- _r_ = ("/proc/self/" field); \
- } else { \
- _r_ = alloca(strlen("/proc/") + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
- sprintf((char*) _r_, "/proc/"PID_FMT"/" field, _pid_); \
- } \
- _r_; \
- })
-
bool id128_is_valid(const char *s) _pure_;
-int split_pair(const char *s, const char *sep, char **l, char **r);
+// UNNEEDED int split_pair(const char *s, const char *sep, char **l, char **r);
-int shall_restore_state(void);
+// UNNEEDED int shall_restore_state(void);
/**
* Normal qsort requires base to be nonnull. Here were require
* that only if nmemb > 0.
*/
-static inline void qsort_safe(void *base, size_t nmemb, size_t size,
- int (*compar)(const void *, const void *)) {
- if (nmemb) {
- assert(base);
- qsort(base, nmemb, size, compar);
- }
+static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
+ if (nmemb <= 1)
+ return;
+
+ assert(base);
+ qsort(base, nmemb, size, compar);
+}
+
+/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */
+static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
+
+ if (needlelen <= 0)
+ return (void*) haystack;
+
+ if (haystacklen < needlelen)
+ return NULL;
+
+ assert(haystack);
+ assert(needle);
+
+ return memmem(haystack, haystacklen, needle, needlelen);
}
int proc_cmdline(char **ret);
@@ -956,9 +790,6 @@ int container_get_leader(const char *machine, pid_t *pid);
int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *root_fd);
int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int root_fd);
-bool pid_is_alive(pid_t pid);
-bool pid_is_unwaited(pid_t pid);
-
int getpeercred(int fd, struct ucred *ucred);
int getpeersec(int fd, char **ret);
@@ -969,12 +800,19 @@ int open_tmpfile(const char *path, int flags);
int fd_warn_permissions(const char *path, int fd);
-unsigned long personality_from_string(const char *p);
+#ifndef PERSONALITY_INVALID
+/* personality(7) documents that 0xffffffffUL is used for querying the
+ * current personality, hence let's use that here as error
+ * indicator. */
+#define PERSONALITY_INVALID 0xffffffffLU
+#endif
+
+// UNNEEDED unsigned long personality_from_string(const char *p);
const char *personality_to_string(unsigned long);
uint64_t physical_memory(void);
-void hexdump(FILE *f, const void *p, size_t s);
+// UNNEEDED void hexdump(FILE *f, const void *p, size_t s);
union file_handle_union {
struct file_handle handle;
@@ -992,16 +830,15 @@ int fflush_and_check(FILE *f);
int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
int tempfn_random(const char *p, const char *extra, char **ret);
-int tempfn_random_child(const char *p, const char *extra, char **ret);
+// UNNEEDED int tempfn_random_child(const char *p, const char *extra, char **ret);
-bool is_localhost(const char *hostname);
-
-int take_password_lock(const char *root);
+// UNNEEDED int take_password_lock(const char *root);
int is_symlink(const char *path);
int is_dir(const char *path, bool follow);
+// UNNEEDED int is_device_node(const char *path);
-typedef enum UnquoteFlags{
+typedef enum UnquoteFlags {
UNQUOTE_RELAX = 1,
UNQUOTE_CUNESCAPE = 2,
UNQUOTE_CUNESCAPE_RELAX = 4,
@@ -1009,12 +846,10 @@ typedef enum UnquoteFlags{
int unquote_first_word(const char **p, char **ret, UnquoteFlags flags);
int unquote_first_word_and_warn(const char **p, char **ret, UnquoteFlags flags, const char *unit, const char *filename, unsigned line, const char *rvalue);
-int unquote_many_words(const char **p, UnquoteFlags flags, ...) _sentinel_;
+// UNNEEDED int unquote_many_words(const char **p, UnquoteFlags flags, ...) _sentinel_;
int free_and_strdup(char **p, const char *s);
-int sethostname_idempotent(const char *s);
-
#define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1)
#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \
@@ -1031,45 +866,40 @@ union inotify_event_buffer {
int ptsname_malloc(int fd, char **ret);
-int openpt_in_namespace(pid_t pid, int flags);
+// UNNEEDED int openpt_in_namespace(pid_t pid, int flags);
ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute, void *value, size_t size, int flags);
int fd_setcrtime(int fd, usec_t usec);
int fd_getcrtime(int fd, usec_t *usec);
-int path_getcrtime(const char *p, usec_t *usec);
+// UNNEEDED int path_getcrtime(const char *p, usec_t *usec);
int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags);
-int chattr_fd(int fd, bool b, unsigned mask);
-int chattr_path(const char *p, bool b, unsigned mask);
-int change_attr_fd(int fd, unsigned value, unsigned mask);
+int same_fd(int a, int b);
+
+int chattr_fd(int fd, unsigned value, unsigned mask);
+int chattr_path(const char *p, unsigned value, unsigned mask);
int read_attr_fd(int fd, unsigned *ret);
int read_attr_path(const char *p, unsigned *ret);
-typedef struct LockFile {
- char *path;
- int fd;
- int operation;
-} LockFile;
-
-int make_lock_file(const char *p, int operation, LockFile *ret);
-int make_lock_file_for(const char *p, int operation, LockFile *ret);
-void release_lock_file(LockFile *f);
-
-#define _cleanup_release_lock_file_ _cleanup_(release_lock_file)
-
-#define LOCK_FILE_INIT { .fd = -1, .path = NULL }
-
#define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })
-ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length);
+// UNNEEDED ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length);
void sigkill_wait(pid_t *pid);
#define _cleanup_sigkill_wait_ _cleanup_(sigkill_wait)
-int syslog_parse_priority(const char **p, int *priority, bool with_facility);
+// UNNEEDED int syslog_parse_priority(const char **p, int *priority, bool with_facility);
void cmsg_close_all(struct msghdr *mh);
int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
+
+char *shell_maybe_quote(const char *s);
+
+int parse_mode(const char *s, mode_t *ret);
+
+int mount_move_root(const char *path);
+
+int reset_uid_gid(void);
diff --git a/src/shared/verbs.c b/src/basic/verbs.c
index c7beccc2d..c7beccc2d 100644
--- a/src/shared/verbs.c
+++ b/src/basic/verbs.c
diff --git a/src/shared/verbs.h b/src/basic/verbs.h
index 03013beb8..03013beb8 100644
--- a/src/shared/verbs.h
+++ b/src/basic/verbs.h
diff --git a/src/shared/virt.c b/src/basic/virt.c
index 1299a75ed..1299a75ed 100644
--- a/src/shared/virt.c
+++ b/src/basic/virt.c
diff --git a/src/shared/virt.h b/src/basic/virt.h
index 4ec33946c..4ec33946c 100644
--- a/src/shared/virt.h
+++ b/src/basic/virt.h
diff --git a/src/core/org.freedesktop.systemd1.conf b/src/core/org.freedesktop.systemd1.conf
new file mode 100644
index 000000000..6a7a37ee9
--- /dev/null
+++ b/src/core/org.freedesktop.systemd1.conf
@@ -0,0 +1,212 @@
+<?xml version="1.0"?> <!--*-nxml-*-->
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<!--
+ This file is part of systemd.
+
+ systemd 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.
+-->
+
+<busconfig>
+
+ <policy user="root">
+ <allow own="org.freedesktop.systemd1"/>
+
+ <!-- Root clients can do everything -->
+ <allow send_destination="org.freedesktop.systemd1"/>
+ <allow receive_sender="org.freedesktop.systemd1"/>
+
+ <!-- systemd may receive activator requests -->
+ <allow receive_interface="org.freedesktop.systemd1.Activator"
+ receive_member="ActivationRequest"/>
+ </policy>
+
+ <policy context="default">
+ <deny send_destination="org.freedesktop.systemd1"/>
+
+ <!-- Completely open to anyone -->
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.DBus.Introspectable"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.DBus.Peer"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.DBus.Properties"
+ send_member="Get"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.DBus.Properties"
+ send_member="GetAll"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="GetUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="GetUnitByPID"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="LoadUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="GetJob"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ListUnits"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ListUnitsFiltered"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ListUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="GetUnitFileState"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ListJobs"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="Subscribe"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="Unsubscribe"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="Dump"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="GetDefaultTarget"/>
+
+ <!-- Managed via polkit or other criteria -->
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="StartUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="StartUnitReplace"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="StopUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ReloadUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="RestartUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="TryRestartUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ReloadOrRestartUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ReloadOrTryRestartUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="KillUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ResetFailedUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="SetUnitProperties"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="StartTransientUnit"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="CancelJob"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="Reload"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="Reexecute"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="EnableUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="DisableUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="ReenableUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="LinkUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="PresetUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="PresetUnitFilesWithMode"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="MaskUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="UnmaskUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="SetDefaultTarget"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="PresetAllUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Manager"
+ send_member="AddDependencyUnitFiles"/>
+
+ <allow send_destination="org.freedesktop.systemd1"
+ send_interface="org.freedesktop.systemd1.Job"
+ send_member="Cancel"/>
+
+ <allow receive_sender="org.freedesktop.systemd1"/>
+ </policy>
+
+</busconfig>
diff --git a/src/core/org.freedesktop.systemd1.policy.in.in b/src/core/org.freedesktop.systemd1.policy.in.in
new file mode 100644
index 000000000..cc39a9e1c
--- /dev/null
+++ b/src/core/org.freedesktop.systemd1.policy.in.in
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?> <!--*-nxml-*-->
+<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
+
+<!--
+ This file is part of systemd.
+
+ systemd 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.
+-->
+
+<policyconfig>
+
+ <vendor>The systemd Project</vendor>
+ <vendor_url>http://www.freedesktop.org/wiki/Software/systemd</vendor_url>
+
+ <action id="org.freedesktop.systemd1.reply-password">
+ <_description>Send passphrase back to system</_description>
+ <_message>Authentication is required to send the entered passphrase back to the system.</_message>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">@rootlibexecdir@/systemd-reply-password</annotate>
+ </action>
+
+ <action id="org.freedesktop.systemd1.manage-units">
+ <_description>Manage system services or other units</_description>
+ <_message>Authentication is required to manage system services or other units.</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.systemd1.manage-unit-files">
+ <_description>Manage system service or unit files</_description>
+ <_message>Authentication is required to manage system service or unit files.</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.systemd1.set-environment">
+ <_description>Set or unset system and service manager environment variables</_description>
+ <_message>Authentication is required to set or unset system and service manager environment variables.</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.systemd1.reload-daemon">
+ <_description>Reload the systemd state</_description>
+ <_message>Authentication is required to reload the systemd state.</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+</policyconfig>
diff --git a/src/core/org.freedesktop.systemd1.service b/src/core/org.freedesktop.systemd1.service
new file mode 100644
index 000000000..d4df3e93a
--- /dev/null
+++ b/src/core/org.freedesktop.systemd1.service
@@ -0,0 +1,11 @@
+# This file is part of systemd.
+#
+# systemd 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.
+
+[D-BUS Service]
+Name=org.freedesktop.systemd1
+Exec=/bin/false
+User=root
diff --git a/src/core/system.conf b/src/core/system.conf
new file mode 100644
index 000000000..231609033
--- /dev/null
+++ b/src/core/system.conf
@@ -0,0 +1,57 @@
+# This file is part of systemd.
+#
+# systemd 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.
+#
+# Entries in this file show the compile time defaults.
+# You can change settings by editing this file.
+# Defaults can be restored by simply deleting this file.
+#
+# See systemd-system.conf(5) for details.
+
+[Manager]
+#LogLevel=info
+#LogTarget=journal-or-kmsg
+#LogColor=yes
+#LogLocation=no
+#DumpCore=yes
+#CrashShell=no
+#ShowStatus=yes
+#CrashChVT=1
+#CPUAffinity=1 2
+#JoinControllers=cpu,cpuacct net_cls,net_prio
+#RuntimeWatchdogSec=0
+#ShutdownWatchdogSec=10min
+#CapabilityBoundingSet=
+#SystemCallArchitectures=
+#TimerSlackNSec=
+#DefaultTimerAccuracySec=1min
+#DefaultStandardOutput=journal
+#DefaultStandardError=inherit
+#DefaultTimeoutStartSec=90s
+#DefaultTimeoutStopSec=90s
+#DefaultRestartSec=100ms
+#DefaultStartLimitInterval=10s
+#DefaultStartLimitBurst=5
+#DefaultEnvironment=
+#DefaultCPUAccounting=no
+#DefaultBlockIOAccounting=no
+#DefaultMemoryAccounting=no
+#DefaultLimitCPU=
+#DefaultLimitFSIZE=
+#DefaultLimitDATA=
+#DefaultLimitSTACK=
+#DefaultLimitCORE=
+#DefaultLimitRSS=
+#DefaultLimitNOFILE=
+#DefaultLimitAS=
+#DefaultLimitNPROC=
+#DefaultLimitMEMLOCK=
+#DefaultLimitLOCKS=
+#DefaultLimitSIGPENDING=
+#DefaultLimitMSGQUEUE=
+#DefaultLimitNICE=
+#DefaultLimitRTPRIO=
+#DefaultLimitRTTIME=
diff --git a/src/core/user.conf b/src/core/user.conf
new file mode 100644
index 000000000..87c816437
--- /dev/null
+++ b/src/core/user.conf
@@ -0,0 +1,44 @@
+# This file is part of systemd.
+#
+# systemd 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.
+#
+# You can override the directives in this file by creating files in
+# /etc/systemd/user.conf.d/*.conf.
+#
+# See systemd-user.conf(5) for details
+
+[Manager]
+#LogLevel=info
+#LogTarget=console
+#LogColor=yes
+#LogLocation=no
+#SystemCallArchitectures=
+#TimerSlackNSec=
+#DefaultTimerAccuracySec=1min
+#DefaultStandardOutput=inherit
+#DefaultStandardError=inherit
+#DefaultTimeoutStartSec=90s
+#DefaultTimeoutStopSec=90s
+#DefaultRestartSec=100ms
+#DefaultStartLimitInterval=10s
+#DefaultStartLimitBurst=5
+#DefaultEnvironment=
+#DefaultLimitCPU=
+#DefaultLimitFSIZE=
+#DefaultLimitDATA=
+#DefaultLimitSTACK=
+#DefaultLimitCORE=
+#DefaultLimitRSS=
+#DefaultLimitNOFILE=
+#DefaultLimitAS=
+#DefaultLimitNPROC=
+#DefaultLimitMEMLOCK=
+#DefaultLimitLOCKS=
+#DefaultLimitSIGPENDING=
+#DefaultLimitMSGQUEUE=
+#DefaultLimitNICE=
+#DefaultLimitRTPRIO=
+#DefaultLimitRTTIME=
diff --git a/src/libelogind/sd-bus/bus-container.c b/src/libelogind/sd-bus/bus-container.c
deleted file mode 100644
index fa7a20744..000000000
--- a/src/libelogind/sd-bus/bus-container.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "util.h"
-#include "process-util.h"
-#include "bus-internal.h"
-#include "bus-socket.h"
-#include "bus-container.h"
-
-int bus_container_connect_socket(sd_bus *b) {
- _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
- pid_t child;
- siginfo_t si;
- int r;
-
- assert(b);
- assert(b->input_fd < 0);
- assert(b->output_fd < 0);
- assert(b->nspid > 0 || b->machine);
-
- if (b->nspid <= 0) {
- r = container_get_leader(b->machine, &b->nspid);
- if (r < 0)
- return r;
- }
-
- r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &rootfd);
- if (r < 0)
- return r;
-
- b->input_fd = socket(b->sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (b->input_fd < 0)
- return -errno;
-
- b->output_fd = b->input_fd;
-
- bus_socket_setup(b);
-
- child = fork();
- if (child < 0)
- return -errno;
-
- if (child == 0) {
- pid_t grandchild;
-
- r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd);
- if (r < 0)
- _exit(255);
-
- /* We just changed PID namespace, however it will only
- * take effect on the children we now fork. Hence,
- * let's fork another time, and connect from this
- * grandchild, so that SO_PEERCRED of our connection
- * comes from a process from within the container, and
- * not outside of it */
-
- grandchild = fork();
- if (grandchild < 0)
- _exit(255);
-
- if (grandchild == 0) {
-
- r = connect(b->input_fd, &b->sockaddr.sa, b->sockaddr_size);
- if (r < 0) {
- if (errno == EINPROGRESS)
- _exit(1);
-
- _exit(255);
- }
-
- _exit(EXIT_SUCCESS);
- }
-
- r = wait_for_terminate(grandchild, &si);
- if (r < 0)
- _exit(255);
-
- if (si.si_code != CLD_EXITED)
- _exit(255);
-
- _exit(si.si_status);
- }
-
- r = wait_for_terminate(child, &si);
- if (r < 0)
- return r;
-
- if (si.si_code != CLD_EXITED)
- return -EIO;
-
- if (si.si_status == 1)
- return 1;
-
- if (si.si_status != EXIT_SUCCESS)
- return -EIO;
-
- return bus_socket_start_auth(b);
-}
-
-int bus_container_connect_kernel(sd_bus *b) {
- _cleanup_close_pair_ int pair[2] = { -1, -1 };
- _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
- union {
- struct cmsghdr cmsghdr;
- uint8_t buf[CMSG_SPACE(sizeof(int))];
- } control = {};
- struct msghdr mh = {
- .msg_control = &control,
- .msg_controllen = sizeof(control),
- };
- struct cmsghdr *cmsg;
- pid_t child;
- siginfo_t si;
- int r;
- _cleanup_close_ int fd = -1;
-
- assert(b);
- assert(b->input_fd < 0);
- assert(b->output_fd < 0);
- assert(b->nspid > 0 || b->machine);
-
- if (b->nspid <= 0) {
- r = container_get_leader(b->machine, &b->nspid);
- if (r < 0)
- return r;
- }
-
- r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &rootfd);
- if (r < 0)
- return r;
-
- if (socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) < 0)
- return -errno;
-
- child = fork();
- if (child < 0)
- return -errno;
-
- if (child == 0) {
- pid_t grandchild;
-
- pair[0] = safe_close(pair[0]);
-
- r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd);
- if (r < 0)
- _exit(EXIT_FAILURE);
-
- /* We just changed PID namespace, however it will only
- * take effect on the children we now fork. Hence,
- * let's fork another time, and connect from this
- * grandchild, so that kdbus only sees the credentials
- * of this process which comes from within the
- * container, and not outside of it */
-
- grandchild = fork();
- if (grandchild < 0)
- _exit(EXIT_FAILURE);
-
- if (grandchild == 0) {
-
- fd = open(b->kernel, O_RDWR|O_NOCTTY|O_CLOEXEC);
- if (fd < 0)
- _exit(EXIT_FAILURE);
-
- cmsg = CMSG_FIRSTHDR(&mh);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(int));
- memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
-
- mh.msg_controllen = cmsg->cmsg_len;
-
- if (sendmsg(pair[1], &mh, MSG_NOSIGNAL) < 0)
- _exit(EXIT_FAILURE);
-
- _exit(EXIT_SUCCESS);
- }
-
- r = wait_for_terminate(grandchild, &si);
- if (r < 0)
- _exit(EXIT_FAILURE);
-
- if (si.si_code != CLD_EXITED)
- _exit(EXIT_FAILURE);
-
- _exit(si.si_status);
- }
-
- pair[1] = safe_close(pair[1]);
-
- r = wait_for_terminate(child, &si);
- if (r < 0)
- return r;
-
- if (si.si_code != CLD_EXITED)
- return -EIO;
-
- if (si.si_status != EXIT_SUCCESS)
- return -EIO;
-
- if (recvmsg(pair[0], &mh, MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) < 0)
- return -errno;
-
- CMSG_FOREACH(cmsg, &mh)
- if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
- int *fds;
- unsigned n_fds;
-
- fds = (int*) CMSG_DATA(cmsg);
- n_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int);
-
- if (n_fds != 1) {
- close_many(fds, n_fds);
- return -EIO;
- }
-
- fd = fds[0];
- }
-
- b->input_fd = b->output_fd = fd;
- fd = -1;
-
- return bus_kernel_take_fd(b);
-}
diff --git a/src/libelogind/sd-bus/bus-control.c b/src/libelogind/sd-bus/bus-control.c
index 4c45a58e8..3cdce6600 100644
--- a/src/libelogind/sd-bus/bus-control.c
+++ b/src/libelogind/sd-bus/bus-control.c
@@ -1526,6 +1526,8 @@ int bus_remove_match_internal(
return bus_remove_match_internal_dbus1(bus, match);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machine) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
const char *mid;
@@ -1570,3 +1572,4 @@ _public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_
return sd_id128_from_string(mid, machine);
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-convenience.c b/src/libelogind/sd-bus/bus-convenience.c
index dfd82e746..59c7c86ae 100644
--- a/src/libelogind/sd-bus/bus-convenience.c
+++ b/src/libelogind/sd-bus/bus-convenience.c
@@ -58,6 +58,8 @@ _public_ int sd_bus_emit_signal(
return sd_bus_send(bus, m, NULL);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_call_method_async(
sd_bus *bus,
sd_bus_slot **slot,
@@ -94,6 +96,7 @@ _public_ int sd_bus_call_method_async(
return sd_bus_call_async(bus, slot, m, callback, userdata, 0);
}
+#endif // 0
_public_ int sd_bus_call_method(
sd_bus *bus,
@@ -249,6 +252,8 @@ _public_ int sd_bus_reply_method_errno(
return sd_bus_reply_method_error(call, &berror);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_reply_method_errnof(
sd_bus_message *call,
int error,
@@ -276,6 +281,7 @@ _public_ int sd_bus_reply_method_errnof(
return sd_bus_reply_method_error(call, &berror);
}
+#endif // 0
_public_ int sd_bus_get_property(
sd_bus *bus,
@@ -314,6 +320,8 @@ _public_ int sd_bus_get_property(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_property_trivial(
sd_bus *bus,
const char *destination,
@@ -350,6 +358,7 @@ _public_ int sd_bus_get_property_trivial(
return 0;
}
+#endif // 0
_public_ int sd_bus_get_property_string(
sd_bus *bus,
@@ -394,6 +403,8 @@ _public_ int sd_bus_get_property_string(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_property_strv(
sd_bus *bus,
const char *destination,
@@ -476,6 +487,7 @@ _public_ int sd_bus_set_property(
return sd_bus_call(bus, m, 0, error, NULL);
}
+#endif // 0
_public_ int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_bus_creds **creds) {
sd_bus_creds *c;
diff --git a/src/libelogind/sd-bus/bus-creds.c b/src/libelogind/sd-bus/bus-creds.c
index 1c365b7fc..40ed95dbe 100644
--- a/src/libelogind/sd-bus/bus-creds.c
+++ b/src/libelogind/sd-bus/bus-creds.c
@@ -128,11 +128,14 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
return NULL;
}
+/// UNNEEDED by elogind
+#if 0
_public_ uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c) {
assert_return(c, 0);
return c->mask;
}
+#endif // 0
_public_ uint64_t sd_bus_creds_get_augmented_mask(const sd_bus_creds *c) {
assert_return(c, 0);
@@ -152,6 +155,8 @@ sd_bus_creds* bus_creds_new(void) {
return c;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t mask) {
sd_bus_creds *c;
int r;
@@ -183,6 +188,7 @@ _public_ int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t m
*ret = c;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_uid(sd_bus_creds *c, uid_t *uid) {
assert_return(c, -EINVAL);
@@ -206,6 +212,8 @@ _public_ int sd_bus_creds_get_euid(sd_bus_creds *c, uid_t *euid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_suid(sd_bus_creds *c, uid_t *suid) {
assert_return(c, -EINVAL);
assert_return(suid, -EINVAL);
@@ -239,6 +247,7 @@ _public_ int sd_bus_creds_get_gid(sd_bus_creds *c, gid_t *gid) {
*gid = c->gid;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_egid(sd_bus_creds *c, gid_t *egid) {
assert_return(c, -EINVAL);
@@ -251,6 +260,8 @@ _public_ int sd_bus_creds_get_egid(sd_bus_creds *c, gid_t *egid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_sgid(sd_bus_creds *c, gid_t *sgid) {
assert_return(c, -EINVAL);
assert_return(sgid, -EINVAL);
@@ -283,6 +294,7 @@ _public_ int sd_bus_creds_get_supplementary_gids(sd_bus_creds *c, const gid_t **
*gids = c->supplementary_gids;
return (int) c->n_supplementary_gids;
}
+#endif // 0
_public_ int sd_bus_creds_get_pid(sd_bus_creds *c, pid_t *pid) {
assert_return(c, -EINVAL);
@@ -296,6 +308,8 @@ _public_ int sd_bus_creds_get_pid(sd_bus_creds *c, pid_t *pid) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid) {
assert_return(c, -EINVAL);
assert_return(ppid, -EINVAL);
@@ -312,6 +326,7 @@ _public_ int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid) {
*ppid = c->ppid;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_tid(sd_bus_creds *c, pid_t *tid) {
assert_return(c, -EINVAL);
@@ -336,6 +351,8 @@ _public_ int sd_bus_creds_get_selinux_context(sd_bus_creds *c, const char **ret)
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_comm(sd_bus_creds *c, const char **ret) {
assert_return(c, -EINVAL);
assert_return(ret, -EINVAL);
@@ -493,6 +510,7 @@ _public_ int sd_bus_creds_get_user_slice(sd_bus_creds *c, const char **ret) {
*ret = c->user_slice;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_session(sd_bus_creds *c, const char **ret) {
int r;
@@ -559,6 +577,8 @@ _public_ int sd_bus_creds_get_cmdline(sd_bus_creds *c, char ***cmdline) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessionid) {
assert_return(c, -EINVAL);
assert_return(sessionid, -EINVAL);
@@ -572,6 +592,7 @@ _public_ int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessio
*sessionid = c->audit_session_id;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_audit_login_uid(sd_bus_creds *c, uid_t *uid) {
assert_return(c, -EINVAL);
@@ -601,6 +622,8 @@ _public_ int sd_bus_creds_get_tty(sd_bus_creds *c, const char **ret) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **unique_name) {
assert_return(c, -EINVAL);
assert_return(unique_name, -EINVAL);
@@ -663,6 +686,7 @@ _public_ int sd_bus_creds_get_description(sd_bus_creds *c, const char **ret) {
*ret = c->unescaped_description;
return 0;
}
+#endif // 0
static int has_cap(sd_bus_creds *c, unsigned offset, int capability) {
size_t sz;
@@ -689,6 +713,8 @@ _public_ int sd_bus_creds_has_effective_cap(sd_bus_creds *c, int capability) {
return has_cap(c, CAP_OFFSET_EFFECTIVE, capability);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_has_permitted_cap(sd_bus_creds *c, int capability) {
assert_return(c, -EINVAL);
assert_return(capability >= 0, -EINVAL);
@@ -718,6 +744,7 @@ _public_ int sd_bus_creds_has_bounding_cap(sd_bus_creds *c, int capability) {
return has_cap(c, CAP_OFFSET_BOUNDING, capability);
}
+#endif // 0
static int parse_caps(sd_bus_creds *c, unsigned offset, const char *p) {
size_t sz, max;
diff --git a/src/libelogind/sd-bus/bus-internal.c b/src/libelogind/sd-bus/bus-internal.c
index 37793e48e..8bc2a14bf 100644
--- a/src/libelogind/sd-bus/bus-internal.c
+++ b/src/libelogind/sd-bus/bus-internal.c
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "bus-message.h"
#include "bus-internal.h"
bool object_path_is_valid(const char *p) {
@@ -166,6 +167,8 @@ bool service_name_is_valid(const char *p) {
return true;
}
+/// UNNEEDED by elogind
+#if 0
char* service_name_startswith(const char *a, const char *b) {
const char *p;
@@ -185,6 +188,7 @@ char* service_name_startswith(const char *a, const char *b) {
return NULL;
}
+#endif // 0
bool member_name_is_valid(const char *p) {
const char *q;
@@ -345,3 +349,28 @@ char *bus_address_escape(const char *v) {
*b = 0;
return r;
}
+
+int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error) {
+ assert(m);
+
+ if (r < 0) {
+ if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+ sd_bus_reply_method_errno(m, r, error);
+
+ } else if (sd_bus_error_is_set(error)) {
+ if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+ sd_bus_reply_method_error(m, error);
+ } else
+ return r;
+
+ log_debug("Failed to process message [type=%s sender=%s path=%s interface=%s member=%s signature=%s]: %s",
+ bus_message_type_to_string(m->header->type),
+ strna(m->sender),
+ strna(m->path),
+ strna(m->interface),
+ strna(m->member),
+ strna(m->root_container.signature),
+ bus_error_message(error, r));
+
+ return 1;
+}
diff --git a/src/libelogind/sd-bus/bus-internal.h b/src/libelogind/sd-bus/bus-internal.h
index a8e1eb1f3..05dae42b2 100644
--- a/src/libelogind/sd-bus/bus-internal.h
+++ b/src/libelogind/sd-bus/bus-internal.h
@@ -344,7 +344,7 @@ struct sd_bus {
bool interface_name_is_valid(const char *p) _pure_;
bool service_name_is_valid(const char *p) _pure_;
-char* service_name_startswith(const char *a, const char *b);
+// UNNEEDED char* service_name_startswith(const char *a, const char *b);
bool member_name_is_valid(const char *p) _pure_;
bool object_path_is_valid(const char *p) _pure_;
char *object_path_startswith(const char *a, const char *b) _pure_;
@@ -388,6 +388,8 @@ int bus_set_address_user(sd_bus *bus);
int bus_set_address_system_remote(sd_bus *b, const char *host);
int bus_set_address_system_machine(sd_bus *b, const char *machine);
-int bus_remove_match_by_string(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+// UNNEEDED int bus_remove_match_by_string(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
int bus_get_root_path(sd_bus *bus);
+
+int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
diff --git a/src/libelogind/sd-bus/bus-match.c b/src/libelogind/sd-bus/bus-match.c
index 132b37526..53c231331 100644
--- a/src/libelogind/sd-bus/bus-match.c
+++ b/src/libelogind/sd-bus/bus-match.c
@@ -909,6 +909,8 @@ fail:
return r;
}
+/// UNNEEDED by elogind
+#if 0
char *bus_match_to_string(struct bus_match_component *components, unsigned n_components) {
_cleanup_free_ FILE *f = NULL;
char *buffer = NULL;
@@ -948,6 +950,7 @@ char *bus_match_to_string(struct bus_match_component *components, unsigned n_com
return buffer;
}
+#endif // 0
int bus_match_add(
struct bus_match_node *root,
diff --git a/src/libelogind/sd-bus/bus-match.h b/src/libelogind/sd-bus/bus-match.h
index 56516be9f..cefb87e08 100644
--- a/src/libelogind/sd-bus/bus-match.h
+++ b/src/libelogind/sd-bus/bus-match.h
@@ -95,6 +95,6 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
int bus_match_parse(const char *match, struct bus_match_component **_components, unsigned *_n_components);
void bus_match_parse_free(struct bus_match_component *components, unsigned n_components);
-char *bus_match_to_string(struct bus_match_component *components, unsigned n_components);
+// UNNEEDED char *bus_match_to_string(struct bus_match_component *components, unsigned n_components);
enum bus_match_scope bus_match_get_scope(const struct bus_match_component *components, unsigned n_components);
diff --git a/src/libelogind/sd-bus/bus-message.c b/src/libelogind/sd-bus/bus-message.c
index 006e4a2b5..b7948a6ca 100644
--- a/src/libelogind/sd-bus/bus-message.c
+++ b/src/libelogind/sd-bus/bus-message.c
@@ -832,6 +832,8 @@ _public_ int sd_bus_message_new_method_errno(
return sd_bus_message_new_method_error(call, m, &berror);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_new_method_errnof(
sd_bus_message *call,
sd_bus_message **m,
@@ -848,6 +850,7 @@ _public_ int sd_bus_message_new_method_errnof(
return sd_bus_message_new_method_error(call, m, &berror);
}
+#endif // 0
void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
assert(bus);
@@ -943,6 +946,8 @@ _public_ sd_bus_message* sd_bus_message_unref(sd_bus_message *m) {
return NULL;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type) {
assert_return(m, -EINVAL);
assert_return(type, -EINVAL);
@@ -988,6 +993,7 @@ _public_ int sd_bus_message_get_auto_start(sd_bus_message *m) {
return !(m->header->flags & BUS_MESSAGE_NO_AUTO_START);
}
+#endif // 0
_public_ int sd_bus_message_get_allow_interactive_authorization(sd_bus_message *m) {
assert_return(m, -EINVAL);
@@ -1033,6 +1039,8 @@ _public_ const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m) {
return &m->error;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_get_monotonic_usec(sd_bus_message *m, uint64_t *usec) {
assert_return(m, -EINVAL);
assert_return(usec, -EINVAL);
@@ -1065,6 +1073,7 @@ _public_ int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t *seqnum) {
*seqnum = m->seqnum;
return 0;
}
+#endif // 0
_public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
assert_return(m, NULL);
@@ -1075,6 +1084,8 @@ _public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
return &m->creds;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_is_signal(
sd_bus_message *m,
const char *interface,
@@ -1093,6 +1104,7 @@ _public_ int sd_bus_message_is_signal(
return 1;
}
+#endif // 0
_public_ int sd_bus_message_is_method_call(
sd_bus_message *m,
@@ -1125,6 +1137,8 @@ _public_ int sd_bus_message_is_method_error(sd_bus_message *m, const char *name)
return 1;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_set_expect_reply(sd_bus_message *m, int b) {
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
@@ -1137,6 +1151,7 @@ _public_ int sd_bus_message_set_expect_reply(sd_bus_message *m, int b) {
return 0;
}
+#endif // 0
_public_ int sd_bus_message_set_auto_start(sd_bus_message *m, int b) {
assert_return(m, -EINVAL);
@@ -1150,6 +1165,8 @@ _public_ int sd_bus_message_set_auto_start(sd_bus_message *m, int b) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *m, int b) {
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
@@ -1161,6 +1178,7 @@ _public_ int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *
return 0;
}
+#endif // 0
static struct bus_container *message_get_container(sd_bus_message *m) {
assert(m);
@@ -1712,6 +1730,8 @@ _public_ int sd_bus_message_append_string_space(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_append_string_iovec(
sd_bus_message *m,
const struct iovec *iov,
@@ -1745,6 +1765,7 @@ _public_ int sd_bus_message_append_string_iovec(
return 0;
}
+#endif // 0
static int bus_message_open_array(
sd_bus_message *m,
@@ -2636,6 +2657,8 @@ _public_ int sd_bus_message_append_array(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_append_array_iovec(
sd_bus_message *m,
char type,
@@ -2846,6 +2869,7 @@ _public_ int sd_bus_message_append_string_memfd(
return 0;
}
+#endif // 0
_public_ int sd_bus_message_append_strv(sd_bus_message *m, char **l) {
char **i;
@@ -3146,6 +3170,8 @@ static bool message_end_of_array(sd_bus_message *m, size_t index) {
}
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_at_end(sd_bus_message *m, int complete) {
assert_return(m, -EINVAL);
assert_return(m->sealed, -EPERM);
@@ -3161,6 +3187,7 @@ _public_ int sd_bus_message_at_end(sd_bus_message *m, int complete) {
return false;
}
+#endif // 0
static struct bus_body_part* find_part(sd_bus_message *m, size_t index, size_t sz, void **p) {
struct bus_body_part *part;
@@ -5544,6 +5571,8 @@ _public_ int sd_bus_message_set_destination(sd_bus_message *m, const char *desti
return message_append_field_string(m, BUS_MESSAGE_HEADER_DESTINATION, SD_BUS_TYPE_STRING, destination, &m->destination);
}
+/// UNNEEDED by elogind
+#if 0
int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
size_t total;
void *p, *e;
@@ -5571,6 +5600,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
return 0;
}
+#endif // 0
int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
const char *s;
@@ -5687,6 +5717,8 @@ _public_ const char* sd_bus_message_get_signature(sd_bus_message *m, int complet
return strempty(c->signature);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_is_empty(sd_bus_message *m) {
assert_return(m, -EINVAL);
@@ -5698,6 +5730,7 @@ _public_ int sd_bus_message_has_signature(sd_bus_message *m, const char *signatu
return streq(strempty(m->root_container.signature), strempty(signature));
}
+#endif // 0
_public_ int sd_bus_message_copy(sd_bus_message *m, sd_bus_message *source, int all) {
bool done_something = false;
@@ -5778,6 +5811,8 @@ _public_ int sd_bus_message_copy(sd_bus_message *m, sd_bus_message *source, int
return done_something;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_message_verify_type(sd_bus_message *m, char type, const char *contents) {
const char *c;
char t;
@@ -5802,6 +5837,7 @@ _public_ int sd_bus_message_verify_type(sd_bus_message *m, char type, const char
return 1;
}
+#endif // 0
_public_ sd_bus *sd_bus_message_get_bus(sd_bus_message *m) {
assert_return(m, NULL);
@@ -5894,6 +5930,8 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int bus_message_append_sender(sd_bus_message *m, const char *sender) {
assert(m);
assert(sender);
@@ -5919,3 +5957,4 @@ _public_ int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority) {
m->priority = priority;
return 0;
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-message.h b/src/libelogind/sd-bus/bus-message.h
index 088d5b110..2f338ff6f 100644
--- a/src/libelogind/sd-bus/bus-message.h
+++ b/src/libelogind/sd-bus/bus-message.h
@@ -193,7 +193,7 @@ static inline bool BUS_MESSAGE_IS_GVARIANT(sd_bus_message *m) {
}
int bus_message_seal(sd_bus_message *m, uint64_t serial, usec_t timeout);
-int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
+// UNNEEDED int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
int bus_message_read_strv_extend(sd_bus_message *m, char ***l);
int bus_message_from_header(
@@ -238,7 +238,7 @@ int bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_e
int bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
-int bus_message_append_sender(sd_bus_message *m, const char *sender);
+// UNNEEDED int bus_message_append_sender(sd_bus_message *m, const char *sender);
void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m);
void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m);
diff --git a/src/libelogind/sd-bus/bus-objects.c b/src/libelogind/sd-bus/bus-objects.c
index c25293e5e..a3d9e552d 100644
--- a/src/libelogind/sd-bus/bus-objects.c
+++ b/src/libelogind/sd-bus/bus-objects.c
@@ -2366,6 +2366,8 @@ _public_ int sd_bus_emit_object_added(sd_bus *bus, const char *path) {
return sd_bus_send(bus, m, NULL);
}
+/// UNNEEDED by elogind
+#if 0
static int object_removed_append_all_prefix(
sd_bus *bus,
sd_bus_message *m,
@@ -2535,6 +2537,7 @@ _public_ int sd_bus_emit_object_removed(sd_bus *bus, const char *path) {
return sd_bus_send(bus, m, NULL);
}
+#endif // 0
static int interfaces_added_append_one_prefix(
sd_bus *bus,
@@ -2773,6 +2776,8 @@ _public_ int sd_bus_emit_interfaces_removed(sd_bus *bus, const char *path, const
return sd_bus_emit_interfaces_removed_strv(bus, path, interfaces);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_add_object_manager(sd_bus *bus, sd_bus_slot **slot, const char *path) {
sd_bus_slot *s;
struct node *n;
@@ -2807,3 +2812,4 @@ fail:
return r;
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-slot.c b/src/libelogind/sd-bus/bus-slot.c
index b149ea16d..862619606 100644
--- a/src/libelogind/sd-bus/bus-slot.c
+++ b/src/libelogind/sd-bus/bus-slot.c
@@ -214,6 +214,8 @@ _public_ sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot) {
return NULL;
}
+/// UNNEEDED by elogind
+#if 0
_public_ sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot) {
assert_return(slot, NULL);
@@ -281,3 +283,4 @@ _public_ int sd_bus_slot_get_description(sd_bus_slot *slot, const char **descrip
*description = slot->description;
return 0;
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-track.c b/src/libelogind/sd-bus/bus-track.c
index e43891be2..12ab53b7b 100644
--- a/src/libelogind/sd-bus/bus-track.c
+++ b/src/libelogind/sd-bus/bus-track.c
@@ -317,6 +317,8 @@ void bus_track_dispatch(sd_bus_track *track) {
sd_bus_track_unref(track);
}
+/// UNNEEDED by elogind
+#if 0
_public_ void *sd_bus_track_get_userdata(sd_bus_track *track) {
assert_return(track, NULL);
@@ -333,3 +335,4 @@ _public_ void *sd_bus_track_set_userdata(sd_bus_track *track, void *userdata) {
return ret;
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-type.c b/src/libelogind/sd-bus/bus-type.c
index 6bc7b880a..afdf234ef 100644
--- a/src/libelogind/sd-bus/bus-type.c
+++ b/src/libelogind/sd-bus/bus-type.c
@@ -45,6 +45,8 @@ bool bus_type_is_valid(char c) {
return !!memchr(valid, c, sizeof(valid));
}
+/// UNNEEDED by elogind
+#if 0
bool bus_type_is_valid_in_signature(char c) {
static const char valid[] = {
SD_BUS_TYPE_BYTE,
@@ -70,6 +72,7 @@ bool bus_type_is_valid_in_signature(char c) {
return !!memchr(valid, c, sizeof(valid));
}
+#endif // 0
bool bus_type_is_basic(char c) {
static const char valid[] = {
diff --git a/src/libelogind/sd-bus/bus-type.h b/src/libelogind/sd-bus/bus-type.h
index 581574ab7..9a2a4f809 100644
--- a/src/libelogind/sd-bus/bus-type.h
+++ b/src/libelogind/sd-bus/bus-type.h
@@ -27,7 +27,7 @@
#include "sd-bus.h"
bool bus_type_is_valid(char c) _const_;
-bool bus_type_is_valid_in_signature(char c) _const_;
+// UNNEEDED bool bus_type_is_valid_in_signature(char c) _const_;
bool bus_type_is_basic(char c) _const_;
/* "trivial" is systemd's term for what the D-Bus Specification calls
* a "fixed type": that is, a basic type of fixed length */
diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c
index 87263b74f..eb9525ed7 100644
--- a/src/libelogind/sd-bus/sd-bus.c
+++ b/src/libelogind/sd-bus/sd-bus.c
@@ -229,6 +229,8 @@ _public_ int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]) {
char *p, **a;
@@ -302,6 +304,7 @@ _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
return 0;
}
+#endif // 0
_public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
uint64_t new_flags;
@@ -342,6 +345,8 @@ _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
@@ -367,6 +372,7 @@ _public_ int sd_bus_set_description(sd_bus *bus, const char *description) {
return free_and_strdup(&bus->description, description);
}
+#endif // 0
_public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
@@ -376,12 +382,15 @@ _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_allow_interactive_authorization(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
return bus->allow_interactive_authorization;
}
+#endif // 0
static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {
const char *s;
@@ -1023,10 +1032,12 @@ static int bus_start_address(sd_bus *b) {
if (b->exec_path)
r = bus_socket_exec(b);
- else if ((b->nspid > 0 || b->machine) && b->kernel)
+#if 0
+ else if ((b->nspid > 0 || b->machine) && b->kernel)
r = bus_container_connect_kernel(b);
else if ((b->nspid > 0 || b->machine) && b->sockaddr.sa.sa_family != AF_UNSPEC)
r = bus_container_connect_socket(b);
+#endif // 0
else if (b->kernel)
r = bus_kernel_connect(b);
else if (b->sockaddr.sa.sa_family != AF_UNSPEC)
@@ -1470,6 +1481,8 @@ _public_ sd_bus *sd_bus_unref(sd_bus *bus) {
return NULL;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_is_open(sd_bus *bus) {
assert_return(bus, -EINVAL);
@@ -1477,6 +1490,7 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
return BUS_IS_OPEN(bus->state);
}
+#endif // 0
_public_ int sd_bus_can_send(sd_bus *bus, char type) {
int r;
@@ -1502,6 +1516,8 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
return bus_type_is_valid(type);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
int r;
@@ -1516,6 +1532,7 @@ _public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
*id = bus->server_id;
return 0;
}
+#endif // 0
static int bus_seal_message(sd_bus *b, sd_bus_message *m, usec_t timeout) {
assert(b);
@@ -2771,9 +2788,12 @@ _public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
return bus_process_internal(bus, false, 0, ret);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_process_priority(sd_bus *bus, int64_t priority, sd_bus_message **ret) {
return bus_process_internal(bus, true, priority, ret);
}
+#endif // 0
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
struct pollfd p[2] = {};
@@ -2992,6 +3012,8 @@ finish:
return r;
}
+/// UNNEEDED by elogind
+#if 0
int bus_remove_match_by_string(
sd_bus *bus,
const char *match,
@@ -3022,6 +3044,7 @@ finish:
return r;
}
+#endif // 0
bool bus_pid_changed(sd_bus *bus) {
assert(bus);
@@ -3267,11 +3290,14 @@ _public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) {
return bus->current_message;
}
+/// UNNEEDED by elogind
+#if 0
_public_ sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus) {
assert_return(bus, NULL);
return bus->current_slot;
}
+#endif // 0
_public_ sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus) {
assert_return(bus, NULL);
@@ -3358,6 +3384,8 @@ _public_ int sd_bus_default(sd_bus **ret) {
return sd_bus_default_system(ret);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_tid(sd_bus *b, pid_t *tid) {
assert_return(b, -EINVAL);
assert_return(tid, -EINVAL);
@@ -3415,6 +3443,7 @@ _public_ int sd_bus_path_decode(const char *path, const char *prefix, char **ext
*external_id = ret;
return 1;
}
+#endif // 0
_public_ int sd_bus_try_close(sd_bus *bus) {
int r;
@@ -3442,6 +3471,8 @@ _public_ int sd_bus_try_close(sd_bus *bus) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
assert_return(bus, -EINVAL);
assert_return(description, -EINVAL);
@@ -3451,6 +3482,7 @@ _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
*description = bus->description;
return 0;
}
+#endif // 0
int bus_get_root_path(sd_bus *bus) {
int r;
@@ -3470,6 +3502,8 @@ int bus_get_root_path(sd_bus *bus) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
int r;
@@ -3567,3 +3601,4 @@ _public_ int sd_bus_is_monitor(sd_bus *bus) {
return !!(bus->hello_flags & KDBUS_HELLO_MONITOR);
}
+#endif // 0
diff --git a/src/libelogind/sd-daemon/sd-daemon.c b/src/libelogind/sd-daemon/sd-daemon.c
index 7bbb3517b..82ac72c72 100644
--- a/src/libelogind/sd-daemon/sd-daemon.c
+++ b/src/libelogind/sd-daemon/sd-daemon.c
@@ -307,6 +307,37 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
return 1;
}
+_public_ int sd_is_mq(int fd, const char *path) {
+ struct mq_attr attr;
+
+ assert_return(fd >= 0, -EINVAL);
+
+ if (mq_getattr(fd, &attr) < 0)
+ return -errno;
+
+ if (path) {
+ char fpath[PATH_MAX];
+ struct stat a, b;
+
+ assert_return(path_is_absolute(path), -EINVAL);
+
+ if (fstat(fd, &a) < 0)
+ return -errno;
+
+ strncpy(stpcpy(fpath, "/dev/mqueue"), path, sizeof(fpath) - 12);
+ fpath[sizeof(fpath)-1] = 0;
+
+ if (stat(fpath, &b) < 0)
+ return -errno;
+
+ if (a.st_dev != b.st_dev ||
+ a.st_ino != b.st_ino)
+ return 0;
+ }
+
+ return 1;
+}
+
_public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state, const int *fds, unsigned n_fds) {
union sockaddr_union sockaddr = {
.sa.sa_family = AF_UNIX,
diff --git a/src/libelogind/sd-device/device-internal.h b/src/libelogind/sd-device/device-internal.h
deleted file mode 100644
index b96441de5..000000000
--- a/src/libelogind/sd-device/device-internal.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/***
- This file is part of systemd.
-
- Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#pragma once
-
-#include "hashmap.h"
-#include "set.h"
-
-struct sd_device {
- uint64_t n_ref;
-
- sd_device *parent;
- bool parent_set; /* no need to try to reload parent */
-
- OrderedHashmap *properties;
- Iterator properties_iterator;
- uint64_t properties_generation; /* changes whenever the properties are changed */
- uint64_t properties_iterator_generation; /* generation when iteration was started */
-
- /* the subset of the properties that should be written to the db*/
- OrderedHashmap *properties_db;
-
- Hashmap *sysattr_values; /* cached sysattr values */
-
- Set *sysattrs; /* names of sysattrs */
- Iterator sysattrs_iterator;
- bool sysattrs_read; /* don't try to re-read sysattrs once read */
-
- Set *tags;
- Iterator tags_iterator;
- uint64_t tags_generation; /* changes whenever the tags are changed */
- uint64_t tags_iterator_generation; /* generation when iteration was started */
- bool property_tags_outdated; /* need to update TAGS= property */
-
- Set *devlinks;
- Iterator devlinks_iterator;
- uint64_t devlinks_generation; /* changes whenever the devlinks are changed */
- uint64_t devlinks_iterator_generation; /* generation when iteration was started */
- bool property_devlinks_outdated; /* need to update DEVLINKS= property */
- int devlink_priority;
-
- char **properties_strv; /* the properties hashmap as a strv */
- uint8_t *properties_nulstr; /* the same as a nulstr */
- size_t properties_nulstr_len;
- bool properties_buf_outdated; /* need to reread hashmap */
-
- int watch_handle;
-
- char *syspath;
- const char *devpath;
- const char *sysnum;
- char *sysname;
- bool sysname_set; /* don't reread sysname */
-
- char *devtype;
- int ifindex;
- char *devname;
- dev_t devnum;
-
- char *subsystem;
- bool subsystem_set; /* don't reread subsystem */
- char *driver;
- bool driver_set; /* don't reread driver */
-
- char *id_filename;
-
- bool is_initialized;
- uint64_t usec_initialized;
-
- mode_t devmode;
- uid_t devuid;
- gid_t devgid;
-
- bool uevent_loaded; /* don't reread uevent */
- bool db_loaded; /* don't reread db */
-
- bool sealed; /* don't read more information from uevent/db */
- bool db_persist; /* don't clean up the db when switching from initrd to real root */
-};
-
-typedef enum DeviceAction {
- DEVICE_ACTION_ADD,
- DEVICE_ACTION_REMOVE,
- DEVICE_ACTION_CHANGE,
- DEVICE_ACTION_MOVE,
- DEVICE_ACTION_ONLINE,
- DEVICE_ACTION_OFFLINE,
- _DEVICE_ACTION_MAX,
- _DEVICE_ACTION_INVALID = -1,
-} DeviceAction;
-
-int device_new_aux(sd_device **ret);
-int device_add_property_aux(sd_device *device, const char *key, const char *value, bool db);
-int device_add_property_internal(sd_device *device, const char *key, const char *value);
-int device_read_uevent_file(sd_device *device);
-int device_read_db_aux(sd_device *device, bool force);
-
-int device_set_syspath(sd_device *device, const char *_syspath, bool verify);
-int device_set_ifindex(sd_device *device, const char *ifindex);
-int device_set_devmode(sd_device *device, const char *devmode);
-int device_set_devname(sd_device *device, const char *_devname);
-int device_set_devtype(sd_device *device, const char *_devtype);
-int device_set_devnum(sd_device *device, const char *major, const char *minor);
-int device_set_subsystem(sd_device *device, const char *_subsystem);
-int device_set_driver(sd_device *device, const char *_driver);
-int device_set_usec_initialized(sd_device *device, const char *initialized);
-
-DeviceAction device_action_from_string(const char *s) _pure_;
-const char *device_action_to_string(DeviceAction a) _const_;
diff --git a/src/libelogind/sd-device/device-private.c b/src/libelogind/sd-device/device-private.c
deleted file mode 100644
index 2e6043324..000000000
--- a/src/libelogind/sd-device/device-private.c
+++ /dev/null
@@ -1,1117 +0,0 @@
-/***
- This file is part of systemd.
-
- Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <ctype.h>
-#include <sys/types.h>
-#include <net/if.h>
-
-#include "util.h"
-#include "macro.h"
-#include "refcnt.h"
-#include "path-util.h"
-#include "strxcpyx.h"
-#include "fileio.h"
-#include "hashmap.h"
-#include "set.h"
-#include "strv.h"
-#include "mkdir.h"
-
-#include "sd-device.h"
-
-#include "device-util.h"
-#include "device-internal.h"
-#include "device-private.h"
-
-int device_add_property(sd_device *device, const char *key, const char *value) {
- int r;
-
- assert(device);
- assert(key);
-
- r = device_add_property_aux(device, key, value, false);
- if (r < 0)
- return r;
-
- if (key[0] != '.') {
- r = device_add_property_aux(device, key, value, true);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
-static int device_add_property_internal_from_string(sd_device *device, const char *str) {
- _cleanup_free_ char *key = NULL;
- char *value;
-
- assert(device);
- assert(str);
-
- key = strdup(str);
- if (!key)
- return -ENOMEM;
-
- value = strchr(key, '=');
- if (!value)
- return -EINVAL;
-
- *value = '\0';
-
- if (isempty(++value))
- value = NULL;
-
- return device_add_property_internal(device, key, value);
-}
-
-static int handle_db_line(sd_device *device, char key, const char *value) {
- char *path;
- int r;
-
- assert(device);
- assert(value);
-
- switch (key) {
- case 'S':
- path = strjoina("/dev/", value);
- r = device_add_devlink(device, path);
- if (r < 0)
- return r;
-
- break;
- case 'L':
- r = safe_atoi(value, &device->devlink_priority);
- if (r < 0)
- return r;
-
- break;
- case 'E':
- r = device_add_property_internal_from_string(device, value);
- if (r < 0)
- return r;
-
- break;
- case 'G':
- r = device_add_tag(device, value);
- if (r < 0)
- return r;
-
- break;
- case 'W':
- r = safe_atoi(value, &device->watch_handle);
- if (r < 0)
- return r;
-
- break;
- case 'I':
- r = device_set_usec_initialized(device, value);
- if (r < 0)
- return r;
-
- break;
- default:
- log_debug("device db: unknown key '%c'", key);
- }
-
- return 0;
-}
-
-void device_set_devlink_priority(sd_device *device, int priority) {
- assert(device);
-
- device->devlink_priority = priority;
-}
-
-void device_set_is_initialized(sd_device *device) {
- assert(device);
-
- device->is_initialized = true;
-}
-
-int device_ensure_usec_initialized(sd_device *device, sd_device *device_old) {
- char num[DECIMAL_STR_MAX(usec_t)];
- usec_t usec_initialized;
- int r;
-
- assert(device);
-
- if (device_old && device_old->usec_initialized > 0)
- usec_initialized = device_old->usec_initialized;
- else
- usec_initialized = now(CLOCK_MONOTONIC);
-
- r = snprintf(num, sizeof(num), USEC_FMT, usec_initialized);
- if (r < 0)
- return -errno;
-
- r = device_set_usec_initialized(device, num);
- if (r < 0)
- return r;
-
- return 0;
-}
-
-static int device_read_db(sd_device *device) {
- _cleanup_free_ char *db = NULL;
- char *path;
- const char *id, *value;
- char key;
- size_t db_len;
- unsigned i;
- int r;
-
- enum {
- PRE_KEY,
- KEY,
- PRE_VALUE,
- VALUE,
- INVALID_LINE,
- } state = PRE_KEY;
-
- assert(device);
-
- if (device->db_loaded || device->sealed)
- return 0;
-
- r = device_get_id_filename(device, &id);
- if (r < 0)
- return r;
-
- path = strjoina("/run/udev/data/", id);
-
- r = read_full_file(path, &db, &db_len);
- if (r < 0) {
- if (r == -ENOENT)
- return 0;
- else {
- log_debug("sd-device: failed to read db '%s': %s", path, strerror(-r));
- return r;
- }
- }
-
- /* devices with a database entry are initialized */
- device_set_is_initialized(device);
-
- for (i = 0; i < db_len; i++) {
- switch (state) {
- case PRE_KEY:
- if (!strchr(NEWLINE, db[i])) {
- key = db[i];
-
- state = KEY;
- }
-
- break;
- case KEY:
- if (db[i] != ':') {
- log_debug("sd-device: ignoring invalid db entry with key '%c'", key);
-
- state = INVALID_LINE;
- } else {
- db[i] = '\0';
-
- state = PRE_VALUE;
- }
-
- break;
- case PRE_VALUE:
- value = &db[i];
-
- state = VALUE;
-
- break;
- case INVALID_LINE:
- if (strchr(NEWLINE, db[i]))
- state = PRE_KEY;
-
- break;
- case VALUE:
- if (strchr(NEWLINE, db[i])) {
- db[i] = '\0';
- r = handle_db_line(device, key, value);
- if (r < 0)
- log_debug("sd-device: failed to handle db entry '%c:%s': %s", key, value, strerror(-r));
-
- state = PRE_KEY;
- }
-
- break;
- default:
- assert_not_reached("invalid state when parsing db");
- }
- }
-
- device->db_loaded = true;
-
- return 0;
-}
-
-uint64_t device_get_properties_generation(sd_device *device) {
- assert(device);
-
- return device->properties_generation;
-}
-
-uint64_t device_get_tags_generation(sd_device *device) {
- assert(device);
-
- return device->tags_generation;
-}
-
-uint64_t device_get_devlinks_generation(sd_device *device) {
- assert(device);
-
- return device->devlinks_generation;
-}
-
-int device_get_devnode_mode(sd_device *device, mode_t *mode) {
- int r;
-
- assert(device);
- assert(mode);
-
- r = device_read_db(device);
- if (r < 0)
- return r;
-
- *mode = device->devmode;
-
- return 0;
-}
-
-int device_get_devnode_uid(sd_device *device, uid_t *uid) {
- int r;
-
- assert(device);
- assert(uid);
-
- r = device_read_db(device);
- if (r < 0)
- return r;
-
- *uid = device->devuid;
-
- return 0;
-}
-
-static int device_set_devuid(sd_device *device, const char *uid) {
- unsigned u;
- int r;
-
- assert(device);
- assert(uid);
-
- r = safe_atou(uid, &u);
- if (r < 0)
- return r;
-
- r = device_add_property_internal(device, "DEVUID", uid);
- if (r < 0)
- return r;
-
- device->devuid = u;
-
- return 0;
-}
-
-int device_get_devnode_gid(sd_device *device, gid_t *gid) {
- int r;
-
- assert(device);
- assert(gid);
-
- r = device_read_db(device);
- if (r < 0)
- return r;
-
- *gid = device->devgid;
-
- return 0;
-}
-
-static int device_set_devgid(sd_device *device, const char *gid) {
- unsigned g;
- int r;
-
- assert(device);
- assert(gid);
-
- r = safe_atou(gid, &g);
- if (r < 0)
- return r;
-
- r = device_add_property_internal(device, "DEVGID", gid);
- if (r < 0)
- return r;
-
- device->devgid = g;
-
- return 0;
-}
-
-static int device_amend(sd_device *device, const char *key, const char *value) {
- int r;
-
- assert(device);
- assert(key);
- assert(value);
-
- if (streq(key, "DEVPATH")) {
- char *path;
-
- path = strjoina("/sys", value);
-
- /* the caller must verify or trust this data (e.g., if it comes from the kernel) */
- r = device_set_syspath(device, path, false);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set syspath to '%s': %m", path);
- } else if (streq(key, "SUBSYSTEM")) {
- r = device_set_subsystem(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set subsystem to '%s': %m", value);
- } else if (streq(key, "DEVTYPE")) {
- r = device_set_devtype(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devtype to '%s': %m", value);
- } else if (streq(key, "DEVNAME")) {
- r = device_set_devname(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devname to '%s': %m", value);
- } else if (streq(key, "USEC_INITIALIZED")) {
- r = device_set_usec_initialized(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set usec-initialized to '%s': %m", value);
- } else if (streq(key, "DRIVER")) {
- r = device_set_driver(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set driver to '%s': %m", value);
- } else if (streq(key, "IFINDEX")) {
- r = device_set_ifindex(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set ifindex to '%s': %m", value);
- } else if (streq(key, "DEVMODE")) {
- r = device_set_devmode(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devmode to '%s': %m", value);
- } else if (streq(key, "DEVUID")) {
- r = device_set_devuid(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devuid to '%s': %m", value);
- } else if (streq(key, "DEVGID")) {
- r = device_set_devgid(device, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devgid to '%s': %m", value);
- } else if (streq(key, "DEVLINKS")) {
- const char *word, *state;
- size_t l;
-
- FOREACH_WORD(word, l, value, state) {
- char devlink[l + 1];
-
- strncpy(devlink, word, l);
- devlink[l] = '\0';
-
- r = device_add_devlink(device, devlink);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not add devlink '%s': %m", devlink);
- }
- } else if (streq(key, "TAGS")) {
- const char *word, *state;
- size_t l;
-
- FOREACH_WORD_SEPARATOR(word, l, value, ":", state) {
- char tag[l + 1];
-
- (void)strncpy(tag, word, l);
- tag[l] = '\0';
-
- r = device_add_tag(device, tag);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not add tag '%s': %m", tag);
- }
- } else {
- r = device_add_property_internal(device, key, value);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not add property '%s=%s': %m", key, value);
- }
-
- return 0;
-}
-
-static const char* const device_action_table[_DEVICE_ACTION_MAX] = {
- [DEVICE_ACTION_ADD] = "add",
- [DEVICE_ACTION_REMOVE] = "remove",
- [DEVICE_ACTION_CHANGE] = "change",
- [DEVICE_ACTION_MOVE] = "move",
- [DEVICE_ACTION_ONLINE] = "online",
- [DEVICE_ACTION_OFFLINE] = "offline",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(device_action, DeviceAction);
-
-static int device_append(sd_device *device, char *key, const char **_major, const char **_minor, uint64_t *_seqnum,
- DeviceAction *_action) {
- DeviceAction action = _DEVICE_ACTION_INVALID;
- uint64_t seqnum = 0;
- const char *major = NULL, *minor = NULL;
- char *value;
- int r;
-
- assert(device);
- assert(key);
- assert(_major);
- assert(_minor);
- assert(_seqnum);
- assert(_action);
-
- value = strchr(key, '=');
- if (!value) {
- log_debug("sd-device: not a key-value pair: '%s'", key);
- return -EINVAL;
- }
-
- *value = '\0';
-
- value++;
-
- if (streq(key, "MAJOR"))
- major = value;
- else if (streq(key, "MINOR"))
- minor = value;
- else {
- if (streq(key, "ACTION")) {
- action = device_action_from_string(value);
- if (action == _DEVICE_ACTION_INVALID)
- return -EINVAL;
- } else if (streq(key, "SEQNUM")) {
- r = safe_atou64(value, &seqnum);
- if (r < 0)
- return r;
- else if (seqnum == 0)
- /* kernel only sends seqnum > 0 */
- return -EINVAL;
- }
-
- r = device_amend(device, key, value);
- if (r < 0)
- return r;
- }
-
- if (major != 0)
- *_major = major;
-
- if (minor != 0)
- *_minor = minor;
-
- if (action != _DEVICE_ACTION_INVALID)
- *_action = action;
-
- if (seqnum > 0)
- *_seqnum = seqnum;
-
- return 0;
-}
-
-void device_seal(sd_device *device) {
- assert(device);
-
- device->sealed = true;
-}
-
-static int device_verify(sd_device *device, DeviceAction action, uint64_t seqnum) {
- assert(device);
-
- if (!device->devpath || !device->subsystem || action == _DEVICE_ACTION_INVALID || seqnum == 0) {
- log_debug("sd-device: device created from strv lacks devpath, subsystem, action or seqnum");
- return -EINVAL;
- }
-
- device->sealed = true;
-
- return 0;
-}
-
-int device_new_from_strv(sd_device **ret, char **strv) {
- _cleanup_device_unref_ sd_device *device = NULL;
- char **key;
- const char *major = NULL, *minor = NULL;
- DeviceAction action = _DEVICE_ACTION_INVALID;
- uint64_t seqnum;
- int r;
-
- assert(ret);
- assert(strv);
-
- r = device_new_aux(&device);
- if (r < 0)
- return r;
-
- STRV_FOREACH(key, strv) {
- r = device_append(device, *key, &major, &minor, &seqnum, &action);
- if (r < 0)
- return r;
- }
-
- if (major) {
- r = device_set_devnum(device, major, minor);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devnum %s:%s: %m", major, minor);
- }
-
- r = device_verify(device, action, seqnum);
- if (r < 0)
- return r;
-
- *ret = device;
- device = NULL;
-
- return 0;
-}
-
-int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
- _cleanup_device_unref_ sd_device *device = NULL;
- const char *major = NULL, *minor = NULL;
- DeviceAction action = _DEVICE_ACTION_INVALID;
- uint64_t seqnum;
- unsigned i = 0;
- int r;
-
- assert(ret);
- assert(nulstr);
- assert(len);
-
- r = device_new_aux(&device);
- if (r < 0)
- return r;
-
- while (i < len) {
- char *key;
- const char *end;
-
- key = (char*)&nulstr[i];
- end = memchr(key, '\0', len - i);
- if (!end) {
- log_debug("sd-device: failed to parse nulstr");
- return -EINVAL;
- }
- i += end - key + 1;
-
- r = device_append(device, key, &major, &minor, &seqnum, &action);
- if (r < 0)
- return r;
- }
-
- if (major) {
- r = device_set_devnum(device, major, minor);
- if (r < 0)
- return log_debug_errno(r, "sd-device: could not set devnum %s:%s: %m", major, minor);
- }
-
- r = device_verify(device, action, seqnum);
- if (r < 0)
- return r;
-
- *ret = device;
- device = NULL;
-
- return 0;
-}
-
-static int device_update_properties_bufs(sd_device *device) {
- const char *val, *prop;
- _cleanup_free_ char **buf_strv = NULL;
- _cleanup_free_ uint8_t *buf_nulstr = NULL;
- size_t allocated_nulstr = 0;
- size_t nulstr_len = 0, num = 0, i = 0;
-
- assert(device);
-
- if (!device->properties_buf_outdated)
- return 0;
-
- FOREACH_DEVICE_PROPERTY(device, prop, val) {
- size_t len = 0;
-
- len = strlen(prop) + 1 + strlen(val);
-
- buf_nulstr = GREEDY_REALLOC0(buf_nulstr, allocated_nulstr, nulstr_len + len + 2);
- if (!buf_nulstr)
- return -ENOMEM;
-
- strscpyl((char *)buf_nulstr + nulstr_len, len + 1, prop, "=", val, NULL);
- nulstr_len += len + 1;
- ++num;
- }
-
- /* build buf_strv from buf_nulstr */
- buf_strv = new0(char *, num + 1);
- if (!buf_strv)
- return -ENOMEM;
-
- NULSTR_FOREACH(val, (char*) buf_nulstr) {
- buf_strv[i] = (char *) val;
- assert(i < num);
- i++;
- }
-
- free(device->properties_nulstr);
- device->properties_nulstr = buf_nulstr;
- buf_nulstr = NULL;
- device->properties_nulstr_len = nulstr_len;
- free(device->properties_strv);
- device->properties_strv = buf_strv;
- buf_strv = NULL;
-
- device->properties_buf_outdated = false;
-
- return 0;
-}
-
-int device_get_properties_nulstr(sd_device *device, const uint8_t **nulstr, size_t *len) {
- int r;
-
- assert(device);
- assert(nulstr);
- assert(len);
-
- r = device_update_properties_bufs(device);
- if (r < 0)
- return r;
-
- *nulstr = device->properties_nulstr;
- *len = device->properties_nulstr_len;
-
- return 0;
-}
-
-int device_get_properties_strv(sd_device *device, char ***strv) {
- int r;
-
- assert(device);
- assert(strv);
-
- r = device_update_properties_bufs(device);
- if (r < 0)
- return r;
-
- *strv = device->properties_strv;
-
- return 0;
-}
-
-int device_get_devlink_priority(sd_device *device, int *priority) {
- int r;
-
- assert(device);
- assert(priority);
-
- r = device_read_db(device);
- if (r < 0)
- return r;
-
- *priority = device->devlink_priority;
-
- return 0;
-}
-
-int device_get_watch_handle(sd_device *device, int *handle) {
- int r;
-
- assert(device);
- assert(handle);
-
- r = device_read_db(device);
- if (r < 0)
- return r;
-
- *handle = device->watch_handle;
-
- return 0;
-}
-
-void device_set_watch_handle(sd_device *device, int handle) {
- assert(device);
-
- device->watch_handle = handle;
-}
-
-int device_rename(sd_device *device, const char *name) {
- _cleanup_free_ char *dirname = NULL;
- char *new_syspath;
- const char *interface;
- int r;
-
- assert(device);
- assert(name);
-
- dirname = dirname_malloc(device->syspath);
- if (!dirname)
- return -ENOMEM;
-
- new_syspath = strjoina(dirname, "/", name);
-
- /* the user must trust that the new name is correct */
- r = device_set_syspath(device, new_syspath, false);
- if (r < 0)
- return r;
-
- r = sd_device_get_property_value(device, "INTERFACE", &interface);
- if (r >= 0) {
- r = device_add_property_internal(device, "INTERFACE", name);
- if (r < 0)
- return r;
-
- /* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
- r = device_add_property_internal(device, "INTERFACE_OLD", interface);
- if (r < 0)
- return r;
- } else if (r != -ENOENT)
- return r;
-
- return 0;
-}
-
-int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
- _cleanup_device_unref_ sd_device *ret = NULL;
- int r;
-
- assert(old_device);
- assert(new_device);
-
- r = device_new_aux(&ret);
- if (r < 0)
- return r;
-
- r = device_set_syspath(ret, old_device->syspath, false);
- if (r < 0)
- return r;
-
- r = device_set_subsystem(ret, old_device->subsystem);
- if (r < 0)
- return r;
-
- ret->devnum = old_device->devnum;
-
- *new_device = ret;
- ret = NULL;
-
- return 0;
-}
-
-int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
- _cleanup_device_unref_ sd_device *ret = NULL;
- int r;
-
- assert(old_device);
- assert(new_device);
-
- r = device_shallow_clone(old_device, &ret);
- if (r < 0)
- return r;
-
- r = device_read_db(ret);
- if (r < 0)
- return r;
-
- ret->sealed = true;
-
- *new_device = ret;
- ret = NULL;
-
- return 0;
-}
-
-int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action) {
- _cleanup_device_unref_ sd_device *ret = NULL;
- int r;
-
- assert(new_device);
- assert(syspath);
- assert(action);
-
- r = sd_device_new_from_syspath(&ret, syspath);
- if (r < 0)
- return r;
-
- r = device_read_uevent_file(ret);
- if (r < 0)
- return r;
-
- r = device_add_property_internal(ret, "ACTION", action);
- if (r < 0)
- return r;
-
- *new_device = ret;
- ret = NULL;
-
- return 0;
-}
-
-int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
- const char *property, *value;
- int r;
-
- assert(device_dst);
- assert(device_src);
-
- FOREACH_DEVICE_PROPERTY(device_src, property, value) {
- r = device_add_property(device_dst, property, value);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
-void device_cleanup_tags(sd_device *device) {
- assert(device);
-
- set_free_free(device->tags);
- device->tags = NULL;
- device->property_tags_outdated = true;
- device->tags_generation ++;
-}
-
-void device_cleanup_devlinks(sd_device *device) {
- assert(device);
-
- set_free_free(device->devlinks);
- device->devlinks = NULL;
- device->property_devlinks_outdated = true;
- device->devlinks_generation ++;
-}
-
-void device_remove_tag(sd_device *device, const char *tag) {
- assert(device);
- assert(tag);
-
- free(set_remove(device->tags, tag));
- device->property_tags_outdated = true;
- device->tags_generation ++;
-}
-
-static int device_tag(sd_device *device, const char *tag, bool add) {
- const char *id;
- char *path;
- int r;
-
- assert(device);
- assert(tag);
-
- r = device_get_id_filename(device, &id);
- if (r < 0)
- return r;
-
- path = strjoina("/run/udev/tags/", tag, "/", id);
-
- if (add) {
- r = touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0444);
- if (r < 0)
- return r;
- } else {
- r = unlink(path);
- if (r < 0 && errno != ENOENT)
- return -errno;
- }
-
- return 0;
-}
-
-int device_tag_index(sd_device *device, sd_device *device_old, bool add) {
- const char *tag;
- int r = 0, k;
-
- if (add && device_old) {
- /* delete possible left-over tags */
- FOREACH_DEVICE_TAG(device_old, tag) {
- if (!sd_device_has_tag(device, tag)) {
- k = device_tag(device_old, tag, false);
- if (r >= 0 && k < 0)
- r = k;
- }
- }
- }
-
- FOREACH_DEVICE_TAG(device, tag) {
- k = device_tag(device, tag, add);
- if (r >= 0 && k < 0)
- r = k;
- }
-
- return r;
-}
-
-static bool device_has_info(sd_device *device) {
- assert(device);
-
- if (!set_isempty(device->devlinks))
- return true;
-
- if (device->devlink_priority != 0)
- return true;
-
- if (!ordered_hashmap_isempty(device->properties_db))
- return true;
-
- if (!set_isempty(device->tags))
- return true;
-
- if (device->watch_handle >= 0)
- return true;
-
- return false;
-}
-
-void device_set_db_persist(sd_device *device) {
- assert(device);
-
- device->db_persist = true;
-}
-
-int device_update_db(sd_device *device) {
- const char *id;
- char *path;
- _cleanup_fclose_ FILE *f = NULL;
- _cleanup_free_ char *path_tmp = NULL;
- bool has_info;
- int r;
-
- assert(device);
-
- has_info = device_has_info(device);
-
- r = device_get_id_filename(device, &id);
- if (r < 0)
- return r;
-
- path = strjoina("/run/udev/data/", id);
-
- /* do not store anything for otherwise empty devices */
- if (!has_info && major(device->devnum) == 0 && device->ifindex == 0) {
- r = unlink(path);
- if (r < 0 && errno != ENOENT)
- return -errno;
-
- return 0;
- }
-
- /* write a database file */
- r = mkdir_parents(path, 0755);
- if (r < 0)
- return r;
-
- r = fopen_temporary(path, &f, &path_tmp);
- if (r < 0)
- return r;
-
- /*
- * set 'sticky' bit to indicate that we should not clean the
- * database when we transition from initramfs to the real root
- */
- if (device->db_persist) {
- r = fchmod(fileno(f), 01644);
- if (r < 0) {
- r = -errno;
- goto fail;
- }
- } else {
- r = fchmod(fileno(f), 0644);
- if (r < 0) {
- r = -errno;
- goto fail;
- }
- }
-
- if (has_info) {
- const char *property, *value, *tag;
- Iterator i;
-
- if (major(device->devnum) > 0) {
- const char *devlink;
-
- FOREACH_DEVICE_DEVLINK(device, devlink)
- fprintf(f, "S:%s\n", devlink + strlen("/dev/"));
-
- if (device->devlink_priority != 0)
- fprintf(f, "L:%i\n", device->devlink_priority);
-
- if (device->watch_handle >= 0)
- fprintf(f, "W:%i\n", device->watch_handle);
- }
-
- if (device->usec_initialized > 0)
- fprintf(f, "I:"USEC_FMT"\n", device->usec_initialized);
-
- ORDERED_HASHMAP_FOREACH_KEY(value, property, device->properties_db, i)
- fprintf(f, "E:%s=%s\n", property, value);
-
- FOREACH_DEVICE_TAG(device, tag)
- fprintf(f, "G:%s\n", tag);
- }
-
- r = fflush_and_check(f);
- if (r < 0)
- goto fail;
-
- r = rename(path_tmp, path);
- if (r < 0) {
- r = -errno;
- goto fail;
- }
-
- log_debug("created %s file '%s' for '%s'", has_info ? "db" : "empty",
- path, device->devpath);
-
- return 0;
-
-fail:
- log_error_errno(r, "failed to create %s file '%s' for '%s'", has_info ? "db" : "empty",
- path, device->devpath);
- unlink(path);
- unlink(path_tmp);
-
- return r;
-}
-
-int device_delete_db(sd_device *device) {
- const char *id;
- char *path;
- int r;
-
- assert(device);
-
- r = device_get_id_filename(device, &id);
- if (r < 0)
- return r;
-
- path = strjoina("/run/udev/data/", id);
-
- r = unlink(path);
- if (r < 0 && errno != ENOENT)
- return -errno;
-
- return 0;
-}
-
-int device_read_db_force(sd_device *device) {
- assert(device);
-
- return device_read_db_aux(device, true);
-}
diff --git a/src/libelogind/sd-device/device-private.h b/src/libelogind/sd-device/device-private.h
deleted file mode 100644
index 49a7b66a2..000000000
--- a/src/libelogind/sd-device/device-private.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len);
-int device_new_from_strv(sd_device **ret, char **strv);
-
-int device_get_id_filename(sd_device *device, const char **ret);
-
-int device_get_devlink_priority(sd_device *device, int *priority);
-int device_get_watch_handle(sd_device *device, int *handle);
-int device_get_devnode_mode(sd_device *device, mode_t *mode);
-int device_get_devnode_uid(sd_device *device, uid_t *uid);
-int device_get_devnode_gid(sd_device *device, gid_t *gid);
-
-void device_seal(sd_device *device);
-void device_set_is_initialized(sd_device *device);
-void device_set_watch_handle(sd_device *device, int fd);
-void device_set_db_persist(sd_device *device);
-void device_set_devlink_priority(sd_device *device, int priority);
-int device_ensure_usec_initialized(sd_device *device, sd_device *device_old);
-int device_add_devlink(sd_device *device, const char *devlink);
-int device_add_property(sd_device *device, const char *property, const char *value);
-int device_add_tag(sd_device *device, const char *tag);
-void device_remove_tag(sd_device *device, const char *tag);
-void device_cleanup_tags(sd_device *device);
-void device_cleanup_devlinks(sd_device *device);
-
-uint64_t device_get_properties_generation(sd_device *device);
-uint64_t device_get_tags_generation(sd_device *device);
-uint64_t device_get_devlinks_generation(sd_device *device);
-
-int device_get_properties_nulstr(sd_device *device, const uint8_t **nulstr, size_t *len);
-int device_get_properties_strv(sd_device *device, char ***strv);
-
-int device_rename(sd_device *device, const char *name);
-int device_shallow_clone(sd_device *old_device, sd_device **new_device);
-int device_clone_with_db(sd_device *old_device, sd_device **new_device);
-int device_copy_properties(sd_device *device_dst, sd_device *device_src);
-int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action);
-
-int device_tag_index(sd_device *dev, sd_device *dev_old, bool add);
-int device_update_db(sd_device *device);
-int device_delete_db(sd_device *device);
-int device_read_db_force(sd_device *device);
diff --git a/src/libelogind/sd-device/device-util.h b/src/libelogind/sd-device/device-util.h
deleted file mode 100644
index 9b05a2498..000000000
--- a/src/libelogind/sd-device/device-util.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014-2015 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "util.h"
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device*, sd_device_unref);
-#define _cleanup_device_unref_ _cleanup_(sd_device_unrefp)
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device_enumerator*, sd_device_enumerator_unref);
-#define _cleanup_device_enumerator_unref_ _cleanup_(sd_device_enumerator_unrefp)
-
-#define FOREACH_DEVICE_PROPERTY(device, key, value) \
- for (key = sd_device_get_property_first(device, &(value)); \
- key; \
- key = sd_device_get_property_next(device, &(value)))
-
-#define FOREACH_DEVICE_TAG(device, tag) \
- for (tag = sd_device_get_tag_first(device); \
- tag; \
- tag = sd_device_get_tag_next(device))
-
-#define FOREACH_DEVICE_SYSATTR(device, attr) \
- for (attr = sd_device_get_sysattr_first(device); \
- attr; \
- attr = sd_device_get_sysattr_next(device))
-
-#define FOREACH_DEVICE_DEVLINK(device, devlink) \
- for (devlink = sd_device_get_devlink_first(device); \
- devlink; \
- devlink = sd_device_get_devlink_next(device))
-
-#define FOREACH_DEVICE(enumerator, device) \
- for (device = sd_device_enumerator_get_device_first(enumerator); \
- device; \
- device = sd_device_enumerator_get_device_next(enumerator))
-
-#define FOREACH_SUBSYSTEM(enumerator, device) \
- for (device = sd_device_enumerator_get_subsystem_first(enumerator); \
- device; \
- device = sd_device_enumerator_get_subsystem_next(enumerator))
diff --git a/src/libelogind/sd-event/sd-event.c b/src/libelogind/sd-event/sd-event.c
index 76964aa0c..629f78032 100644
--- a/src/libelogind/sd-event/sd-event.c
+++ b/src/libelogind/sd-event/sd-event.c
@@ -517,6 +517,8 @@ static int source_io_register(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
static clockid_t event_source_type_to_clock(EventSourceType t) {
switch (t) {
@@ -540,6 +542,7 @@ static clockid_t event_source_type_to_clock(EventSourceType t) {
return (clockid_t) -1;
}
}
+#endif // 0
static EventSourceType clock_to_event_source_type(clockid_t clock) {
@@ -1229,6 +1232,8 @@ _public_ int sd_event_add_exit(
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
assert_return(s, NULL);
@@ -1237,6 +1242,7 @@ _public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
return s;
}
+#endif // 0
_public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
@@ -1274,6 +1280,8 @@ _public_ int sd_event_source_set_description(sd_event_source *s, const char *des
return free_and_strdup(&s->description, description);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_description(sd_event_source *s, const char **description) {
assert_return(s, -EINVAL);
assert_return(description, -EINVAL);
@@ -1283,6 +1291,7 @@ _public_ int sd_event_source_get_description(sd_event_source *s, const char **de
*description = s->description;
return 0;
}
+#endif // 0
_public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
assert_return(s, NULL);
@@ -1290,6 +1299,8 @@ _public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
return s->event;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_pending(sd_event_source *s) {
assert_return(s, -EINVAL);
assert_return(s->type != SOURCE_EXIT, -EDOM);
@@ -1306,6 +1317,7 @@ _public_ int sd_event_source_get_io_fd(sd_event_source *s) {
return s->io.fd;
}
+#endif // 0
_public_ int sd_event_source_set_io_fd(sd_event_source *s, int fd) {
int r;
@@ -1343,6 +1355,8 @@ _public_ int sd_event_source_set_io_fd(sd_event_source *s, int fd) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_io_events(sd_event_source *s, uint32_t* events) {
assert_return(s, -EINVAL);
assert_return(events, -EINVAL);
@@ -1352,6 +1366,7 @@ _public_ int sd_event_source_get_io_events(sd_event_source *s, uint32_t* events)
*events = s->io.events;
return 0;
}
+#endif // 0
_public_ int sd_event_source_set_io_events(sd_event_source *s, uint32_t events) {
int r;
@@ -1378,6 +1393,8 @@ _public_ int sd_event_source_set_io_events(sd_event_source *s, uint32_t events)
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_io_revents(sd_event_source *s, uint32_t* revents) {
assert_return(s, -EINVAL);
assert_return(revents, -EINVAL);
@@ -1403,6 +1420,7 @@ _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority)
return s->priority;
}
+#endif // 0
_public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) {
assert_return(s, -EINVAL);
@@ -1426,6 +1444,8 @@ _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority)
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_enabled(sd_event_source *s, int *m) {
assert_return(s, -EINVAL);
assert_return(m, -EINVAL);
@@ -1434,6 +1454,7 @@ _public_ int sd_event_source_get_enabled(sd_event_source *s, int *m) {
*m = s->enabled;
return 0;
}
+#endif // 0
_public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
int r;
@@ -1640,6 +1661,8 @@ _public_ int sd_event_source_set_time(sd_event_source *s, uint64_t usec) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec) {
assert_return(s, -EINVAL);
assert_return(usec, -EINVAL);
@@ -1694,6 +1717,7 @@ _public_ int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid) {
*pid = s->child.pid;
return 0;
}
+#endif // 0
_public_ int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t callback) {
int r;
@@ -1727,6 +1751,8 @@ _public_ int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ void* sd_event_source_get_userdata(sd_event_source *s) {
assert_return(s, NULL);
@@ -1743,6 +1769,7 @@ _public_ void *sd_event_source_set_userdata(sd_event_source *s, void *userdata)
return ret;
}
+#endif // 0
static usec_t sleep_between(sd_event *e, usec_t a, usec_t b) {
usec_t c;
@@ -2507,6 +2534,8 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
return r;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_loop(sd_event *e) {
int r;
@@ -2536,6 +2565,7 @@ _public_ int sd_event_get_fd(sd_event *e) {
return e->epoll_fd;
}
+#endif // 0
_public_ int sd_event_get_state(sd_event *e) {
assert_return(e, -EINVAL);
@@ -2567,6 +2597,8 @@ _public_ int sd_event_exit(sd_event *e, int code) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
assert_return(e, -EINVAL);
assert_return(usec, -EINVAL);
@@ -2595,6 +2627,7 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
return 0;
}
+#endif // 0
_public_ int sd_event_default(sd_event **ret) {
@@ -2687,9 +2720,12 @@ fail:
return r;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_event_get_watchdog(sd_event *e) {
assert_return(e, -EINVAL);
assert_return(!event_pid_changed(e), -ECHILD);
return e->watchdog;
}
+#endif // 0
diff --git a/src/libelogind/sd-hwdb/hwdb-internal.h b/src/libelogind/sd-hwdb/hwdb-internal.h
deleted file mode 100644
index fedccdec7..000000000
--- a/src/libelogind/sd-hwdb/hwdb-internal.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/***
- This file is part of systemd.
-
- Copyright 2012 Kay Sievers <kay@vrfy.org>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-#pragma once
-
-#include "sparse-endian.h"
-
-#define HWDB_SIG { 'K', 'S', 'L', 'P', 'H', 'H', 'R', 'H' }
-
-/* on-disk trie objects */
-struct trie_header_f {
- uint8_t signature[8];
-
- /* version of tool which created the file */
- le64_t tool_version;
- le64_t file_size;
-
- /* size of structures to allow them to grow */
- le64_t header_size;
- le64_t node_size;
- le64_t child_entry_size;
- le64_t value_entry_size;
-
- /* offset of the root trie node */
- le64_t nodes_root_off;
-
- /* size of the nodes and string section */
- le64_t nodes_len;
- le64_t strings_len;
-} _packed_;
-
-struct trie_node_f {
- /* prefix of lookup string, shared by all children */
- le64_t prefix_off;
- /* size of children entry array appended to the node */
- uint8_t children_count;
- uint8_t padding[7];
- /* size of value entry array appended to the node */
- le64_t values_count;
-} _packed_;
-
-/* array of child entries, follows directly the node record */
-struct trie_child_entry_f {
- /* index of the child node */
- uint8_t c;
- uint8_t padding[7];
- /* offset of the child node */
- le64_t child_off;
-} _packed_;
-
-/* array of value entries, follows directly the node record/child array */
-struct trie_value_entry_f {
- le64_t key_off;
- le64_t value_off;
-} _packed_;
diff --git a/src/libelogind/sd-hwdb/sd-hwdb.c b/src/libelogind/sd-hwdb/sd-hwdb.c
deleted file mode 100644
index 40aa77ee5..000000000
--- a/src/libelogind/sd-hwdb/sd-hwdb.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/***
- This file is part of systemd.
-
- Copyright 2012 Kay Sievers <kay@vrfy.org>
- Copyright 2008 Alan Jenkins <alan.christopher.jenkins@googlemail.com>
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <inttypes.h>
-#include <stdlib.h>
-#include <fnmatch.h>
-#include <sys/mman.h>
-
-#include "sd-hwdb.h"
-
-#include "hashmap.h"
-#include "refcnt.h"
-
-#include "hwdb-util.h"
-#include "hwdb-internal.h"
-
-struct sd_hwdb {
- RefCount n_ref;
- int refcount;
-
- FILE *f;
- struct stat st;
- union {
- struct trie_header_f *head;
- const char *map;
- };
-
- char *modalias;
-
- OrderedHashmap *properties;
- Iterator properties_iterator;
- bool properties_modified;
-};
-
-struct linebuf {
- char bytes[LINE_MAX];
- size_t size;
- size_t len;
-};
-
-static void linebuf_init(struct linebuf *buf) {
- buf->size = 0;
- buf->len = 0;
-}
-
-static const char *linebuf_get(struct linebuf *buf) {
- if (buf->len + 1 >= sizeof(buf->bytes))
- return NULL;
- buf->bytes[buf->len] = '\0';
- return buf->bytes;
-}
-
-static bool linebuf_add(struct linebuf *buf, const char *s, size_t len) {
- if (buf->len + len >= sizeof(buf->bytes))
- return false;
- memcpy(buf->bytes + buf->len, s, len);
- buf->len += len;
- return true;
-}
-
-static bool linebuf_add_char(struct linebuf *buf, char c)
-{
- if (buf->len + 1 >= sizeof(buf->bytes))
- return false;
- buf->bytes[buf->len++] = c;
- return true;
-}
-
-static void linebuf_rem(struct linebuf *buf, size_t count) {
- assert(buf->len >= count);
- buf->len -= count;
-}
-
-static void linebuf_rem_char(struct linebuf *buf) {
- linebuf_rem(buf, 1);
-}
-
-static const struct trie_child_entry_f *trie_node_children(sd_hwdb *hwdb, const struct trie_node_f *node) {
- return (const struct trie_child_entry_f *)((const char *)node + le64toh(hwdb->head->node_size));
-}
-
-static const struct trie_value_entry_f *trie_node_values(sd_hwdb *hwdb, const struct trie_node_f *node) {
- const char *base = (const char *)node;
-
- base += le64toh(hwdb->head->node_size);
- base += node->children_count * le64toh(hwdb->head->child_entry_size);
- return (const struct trie_value_entry_f *)base;
-}
-
-static const struct trie_node_f *trie_node_from_off(sd_hwdb *hwdb, le64_t off) {
- return (const struct trie_node_f *)(hwdb->map + le64toh(off));
-}
-
-static const char *trie_string(sd_hwdb *hwdb, le64_t off) {
- return hwdb->map + le64toh(off);
-}
-
-static int trie_children_cmp_f(const void *v1, const void *v2) {
- const struct trie_child_entry_f *n1 = v1;
- const struct trie_child_entry_f *n2 = v2;
-
- return n1->c - n2->c;
-}
-
-static const struct trie_node_f *node_lookup_f(sd_hwdb *hwdb, const struct trie_node_f *node, uint8_t c) {
- struct trie_child_entry_f *child;
- struct trie_child_entry_f search;
-
- search.c = c;
- child = bsearch(&search, trie_node_children(hwdb, node), node->children_count,
- le64toh(hwdb->head->child_entry_size), trie_children_cmp_f);
- if (child)
- return trie_node_from_off(hwdb, child->child_off);
- return NULL;
-}
-
-static int hwdb_add_property(sd_hwdb *hwdb, const char *key, const char *value) {
- int r;
-
- assert(hwdb);
- assert(key);
- assert(value);
-
- /*
- * Silently ignore all properties which do not start with a
- * space; future extensions might use additional prefixes.
- */
- if (key[0] != ' ')
- return 0;
-
- key++;
-
- r = ordered_hashmap_ensure_allocated(&hwdb->properties, &string_hash_ops);
- if (r < 0)
- return r;
-
- r = ordered_hashmap_replace(hwdb->properties, key, (char*)value);
- if (r < 0)
- return r;
-
- hwdb->properties_modified = true;
-
- return 0;
-}
-
-static int trie_fnmatch_f(sd_hwdb *hwdb, const struct trie_node_f *node, size_t p,
- struct linebuf *buf, const char *search) {
- size_t len;
- size_t i;
- const char *prefix;
- int err;
-
- prefix = trie_string(hwdb, node->prefix_off);
- len = strlen(prefix + p);
- linebuf_add(buf, prefix + p, len);
-
- for (i = 0; i < node->children_count; i++) {
- const struct trie_child_entry_f *child = &trie_node_children(hwdb, node)[i];
-
- linebuf_add_char(buf, child->c);
- err = trie_fnmatch_f(hwdb, trie_node_from_off(hwdb, child->child_off), 0, buf, search);
- if (err < 0)
- return err;
- linebuf_rem_char(buf);
- }
-
- if (le64toh(node->values_count) && fnmatch(linebuf_get(buf), search, 0) == 0)
- for (i = 0; i < le64toh(node->values_count); i++) {
- err = hwdb_add_property(hwdb, trie_string(hwdb, trie_node_values(hwdb, node)[i].key_off),
- trie_string(hwdb, trie_node_values(hwdb, node)[i].value_off));
- if (err < 0)
- return err;
- }
-
- linebuf_rem(buf, len);
- return 0;
-}
-
-static int trie_search_f(sd_hwdb *hwdb, const char *search) {
- struct linebuf buf;
- const struct trie_node_f *node;
- size_t i = 0;
- int err;
-
- linebuf_init(&buf);
-
- node = trie_node_from_off(hwdb, hwdb->head->nodes_root_off);
- while (node) {
- const struct trie_node_f *child;
- size_t p = 0;
-
- if (node->prefix_off) {
- uint8_t c;
-
- for (; (c = trie_string(hwdb, node->prefix_off)[p]); p++) {
- if (c == '*' || c == '?' || c == '[')
- return trie_fnmatch_f(hwdb, node, p, &buf, search + i + p);
- if (c != search[i + p])
- return 0;
- }
- i += p;
- }
-
- child = node_lookup_f(hwdb, node, '*');
- if (child) {
- linebuf_add_char(&buf, '*');
- err = trie_fnmatch_f(hwdb, child, 0, &buf, search + i);
- if (err < 0)
- return err;
- linebuf_rem_char(&buf);
- }
-
- child = node_lookup_f(hwdb, node, '?');
- if (child) {
- linebuf_add_char(&buf, '?');
- err = trie_fnmatch_f(hwdb, child, 0, &buf, search + i);
- if (err < 0)
- return err;
- linebuf_rem_char(&buf);
- }
-
- child = node_lookup_f(hwdb, node, '[');
- if (child) {
- linebuf_add_char(&buf, '[');
- err = trie_fnmatch_f(hwdb, child, 0, &buf, search + i);
- if (err < 0)
- return err;
- linebuf_rem_char(&buf);
- }
-
- if (search[i] == '\0') {
- size_t n;
-
- for (n = 0; n < le64toh(node->values_count); n++) {
- err = hwdb_add_property(hwdb, trie_string(hwdb, trie_node_values(hwdb, node)[n].key_off),
- trie_string(hwdb, trie_node_values(hwdb, node)[n].value_off));
- if (err < 0)
- return err;
- }
- return 0;
- }
-
- child = node_lookup_f(hwdb, node, search[i]);
- node = child;
- i++;
- }
- return 0;
-}
-
-static const char hwdb_bin_paths[] =
- "/etc/systemd/hwdb/hwdb.bin\0"
- "/etc/udev/hwdb.bin\0"
- "/usr/lib/systemd/hwdb/hwdb.bin\0"
-#ifdef HAVE_SPLIT_USR
- "/lib/systemd/hwdb/hwdb.bin\0"
-#endif
- UDEVLIBEXECDIR "/hwdb.bin\0";
-
-_public_ int sd_hwdb_new(sd_hwdb **ret) {
- _cleanup_hwdb_unref_ sd_hwdb *hwdb = NULL;
- const char *hwdb_bin_path;
- const char sig[] = HWDB_SIG;
-
- assert_return(ret, -EINVAL);
-
- hwdb = new0(sd_hwdb, 1);
- if (!hwdb)
- return -ENOMEM;
-
- hwdb->n_ref = REFCNT_INIT;
-
- /* find hwdb.bin in hwdb_bin_paths */
- NULSTR_FOREACH(hwdb_bin_path, hwdb_bin_paths) {
- hwdb->f = fopen(hwdb_bin_path, "re");
- if (hwdb->f)
- break;
- else if (errno == ENOENT)
- continue;
- else
- return log_debug_errno(errno, "error reading %s: %m", hwdb_bin_path);
- }
-
- if (!hwdb->f) {
- log_debug("hwdb.bin does not exist, please run udevadm hwdb --update");
- return -ENOENT;
- }
-
- if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
- (size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8)
- return log_debug_errno(errno, "error reading %s: %m", hwdb_bin_path);
-
- hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
- if (hwdb->map == MAP_FAILED)
- return log_debug_errno(errno, "error mapping %s: %m", hwdb_bin_path);
-
- if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
- (size_t)hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
- log_debug("error recognizing the format of %s", hwdb_bin_path);
- return -EINVAL;
- }
-
- log_debug("=== trie on-disk ===");
- log_debug("tool version: %"PRIu64, le64toh(hwdb->head->tool_version));
- log_debug("file size: %8"PRIi64" bytes", hwdb->st.st_size);
- log_debug("header size %8"PRIu64" bytes", le64toh(hwdb->head->header_size));
- log_debug("strings %8"PRIu64" bytes", le64toh(hwdb->head->strings_len));
- log_debug("nodes %8"PRIu64" bytes", le64toh(hwdb->head->nodes_len));
-
- *ret = hwdb;
- hwdb = NULL;
-
- return 0;
-}
-
-_public_ sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb) {
- assert_return(hwdb, NULL);
-
- assert_se(REFCNT_INC(hwdb->n_ref) >= 2);
-
- return hwdb;
-}
-
-_public_ sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb) {
- if (hwdb && REFCNT_DEC(hwdb->n_ref) == 0) {
- if (hwdb->map)
- munmap((void *)hwdb->map, hwdb->st.st_size);
- if (hwdb->f)
- fclose(hwdb->f);
- free(hwdb->modalias);
- ordered_hashmap_free(hwdb->properties);
- free(hwdb);
- }
-
- return NULL;
-}
-
-bool hwdb_validate(sd_hwdb *hwdb) {
- bool found = false;
- const char* p;
- struct stat st;
-
- if (!hwdb)
- return false;
- if (!hwdb->f)
- return false;
-
- /* if hwdb.bin doesn't exist anywhere, we need to update */
- NULSTR_FOREACH(p, hwdb_bin_paths) {
- if (stat(p, &st) >= 0) {
- found = true;
- break;
- }
- }
- if (!found)
- return true;
-
- if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim))
- return true;
- return false;
-}
-
-static int properties_prepare(sd_hwdb *hwdb, const char *modalias) {
- _cleanup_free_ char *mod = NULL;
- int r;
-
- assert(hwdb);
- assert(modalias);
-
- if (streq_ptr(modalias, hwdb->modalias))
- return 0;
-
- mod = strdup(modalias);
- if (!mod)
- return -ENOMEM;
-
- ordered_hashmap_clear(hwdb->properties);
-
- hwdb->properties_modified = true;
-
- r = trie_search_f(hwdb, modalias);
- if (r < 0)
- return r;
-
- free(hwdb->modalias);
- hwdb->modalias = mod;
- mod = NULL;
-
- return 0;
-}
-
-_public_ int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **_value) {
- const char *value;
- int r;
-
- assert_return(hwdb, -EINVAL);
- assert_return(hwdb->f, -EINVAL);
- assert_return(modalias, -EINVAL);
- assert_return(_value, -EINVAL);
-
- r = properties_prepare(hwdb, modalias);
- if (r < 0)
- return r;
-
- value = ordered_hashmap_get(hwdb->properties, key);
- if (!value)
- return -ENOENT;
-
- *_value = value;
-
- return 0;
-}
-
-_public_ int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias) {
- int r;
-
- assert_return(hwdb, -EINVAL);
- assert_return(hwdb->f, -EINVAL);
- assert_return(modalias, -EINVAL);
-
- r = properties_prepare(hwdb, modalias);
- if (r < 0)
- return r;
-
- hwdb->properties_modified = false;
- hwdb->properties_iterator = ITERATOR_FIRST;
-
- return 0;
-}
-
-_public_ int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value) {
- const void *k;
- void *v;
-
- assert_return(hwdb, -EINVAL);
- assert_return(key, -EINVAL);
- assert_return(value, -EINVAL);
-
- if (hwdb->properties_modified)
- return -EAGAIN;
-
- ordered_hashmap_iterate(hwdb->properties, &hwdb->properties_iterator, &v, &k);
- if (!k)
- return 0;
-
- *key = k;
- *value = v;
-
- return 1;
-}
diff --git a/src/libelogind/sd-hwdb/Makefile b/src/libelogind/sd-netlink/Makefile
index 94aaae2c4..94aaae2c4 120000
--- a/src/libelogind/sd-hwdb/Makefile
+++ b/src/libelogind/sd-netlink/Makefile
diff --git a/src/libsystemd/sd-netlink/netlink-types.h b/src/libelogind/sd-netlink/netlink-types.h
index bf7c64154..bf7c64154 100644
--- a/src/libsystemd/sd-netlink/netlink-types.h
+++ b/src/libelogind/sd-netlink/netlink-types.h
diff --git a/src/libelogind/sd-network/network-util.c b/src/libelogind/sd-network/network-util.c
deleted file mode 100644
index 48958e8a9..000000000
--- a/src/libelogind/sd-network/network-util.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "strv.h"
-#include "network-util.h"
-
-bool network_is_online(void) {
- _cleanup_free_ char *state = NULL;
- int r;
-
- r = sd_network_get_operational_state(&state);
- if (r < 0) /* if we don't know anything, we consider the system online */
- return true;
-
- if (STR_IN_SET(state, "routable", "degraded"))
- return true;
-
- return false;
-}
diff --git a/src/libelogind/sd-network/network-util.h b/src/libelogind/sd-network/network-util.h
deleted file mode 100644
index 11a001234..000000000
--- a/src/libelogind/sd-network/network-util.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Thomas Hindø Paabøl Andersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-network.h"
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_network_monitor*, sd_network_monitor_unref);
-#define _cleanup_network_monitor_unref_ _cleanup_(sd_network_monitor_unrefp)
-
-bool network_is_online(void);
diff --git a/src/libelogind/sd-network/sd-network.c b/src/libelogind/sd-network/sd-network.c
deleted file mode 100644
index b63fdf8fc..000000000
--- a/src/libelogind/sd-network/sd-network.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2011 Lennart Poettering
- Copyright 2014 Tom Gundersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-#include <errno.h>
-#include <sys/inotify.h>
-#include <poll.h>
-
-#include "util.h"
-#include "macro.h"
-#include "strv.h"
-#include "fileio.h"
-#include "sd-network.h"
-
-_public_ int sd_network_get_operational_state(char **state) {
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(state, -EINVAL);
-
- r = parse_env_file("/run/systemd/netif/state", NEWLINE, "OPER_STATE", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- *state = s;
- s = NULL;
-
- return 0;
-}
-
-static int network_get_strv(const char *key, char ***ret) {
- _cleanup_strv_free_ char **a = NULL;
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(ret, -EINVAL);
-
- r = parse_env_file("/run/systemd/netif/state", NEWLINE, key, &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s)) {
- *ret = NULL;
- return 0;
- }
-
- a = strv_split(s, " ");
- if (!a)
- return -ENOMEM;
-
- strv_uniq(a);
- r = strv_length(a);
-
- *ret = a;
- a = NULL;
-
- return r;
-}
-
-_public_ int sd_network_get_dns(char ***ret) {
- return network_get_strv("DNS", ret);
-}
-
-_public_ int sd_network_get_ntp(char ***ret) {
- return network_get_strv("NTP", ret);
-}
-
-_public_ int sd_network_get_domains(char ***ret) {
- return network_get_strv("DOMAINS", ret);
-}
-
-_public_ int sd_network_link_get_setup_state(int ifindex, char **state) {
- _cleanup_free_ char *s = NULL, *p = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(state, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, "ADMIN_STATE", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- *state = s;
- s = NULL;
-
- return 0;
-}
-
-_public_ int sd_network_link_get_network_file(int ifindex, char **filename) {
- _cleanup_free_ char *s = NULL, *p = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(filename, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, "NETWORK_FILE", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- *filename = s;
- s = NULL;
-
- return 0;
-}
-
-_public_ int sd_network_link_get_operational_state(int ifindex, char **state) {
- _cleanup_free_ char *s = NULL, *p = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(state, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, "OPER_STATE", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- *state = s;
- s = NULL;
-
- return 0;
-}
-
-_public_ int sd_network_link_get_llmnr(int ifindex, char **llmnr) {
- _cleanup_free_ char *s = NULL, *p = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(llmnr, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, "LLMNR", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- *llmnr = s;
- s = NULL;
-
- return 0;
-}
-
-_public_ int sd_network_link_get_lldp(int ifindex, char **lldp) {
- _cleanup_free_ char *s = NULL, *p = NULL;
- size_t size;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(lldp, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/lldp/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = read_full_file(p, &s, &size);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (size <= 0)
- return -ENODATA;
-
- *lldp = s;
- s = NULL;
-
- return 0;
-}
-
-
-static int network_get_link_strv(const char *key, int ifindex, char ***ret) {
- _cleanup_free_ char *p = NULL, *s = NULL;
- _cleanup_strv_free_ char **a = NULL;
- int r;
-
- assert_return(ifindex > 0, -EINVAL);
- assert_return(ret, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, key, &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s)) {
- *ret = NULL;
- return 0;
- }
-
- a = strv_split(s, " ");
- if (!a)
- return -ENOMEM;
-
- strv_uniq(a);
- r = strv_length(a);
-
- *ret = a;
- a = NULL;
-
- return r;
-}
-
-_public_ int sd_network_link_get_dns(int ifindex, char ***ret) {
- return network_get_link_strv("DNS", ifindex, ret);
-}
-
-_public_ int sd_network_link_get_ntp(int ifindex, char ***ret) {
- return network_get_link_strv("NTP", ifindex, ret);
-}
-
-_public_ int sd_network_link_get_domains(int ifindex, char ***ret) {
- return network_get_link_strv("DOMAINS", ifindex, ret);
-}
-
-_public_ int sd_network_link_get_carrier_bound_to(int ifindex, char ***ret) {
- return network_get_link_strv("CARRIER_BOUND_TO", ifindex, ret);
-}
-
-_public_ int sd_network_link_get_carrier_bound_by(int ifindex, char ***ret) {
- return network_get_link_strv("CARRIER_BOUND_BY", ifindex, ret);
-}
-
-_public_ int sd_network_link_get_wildcard_domain(int ifindex) {
- int r;
- _cleanup_free_ char *p = NULL, *s = NULL;
-
- assert_return(ifindex > 0, -EINVAL);
-
- if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0)
- return -ENOMEM;
-
- r = parse_env_file(p, NEWLINE, "WILDCARD_DOMAIN", &s, NULL);
- if (r == -ENOENT)
- return -ENODATA;
- if (r < 0)
- return r;
- if (isempty(s))
- return -ENODATA;
-
- return parse_boolean(s);
-}
-
-static inline int MONITOR_TO_FD(sd_network_monitor *m) {
- return (int) (unsigned long) m - 1;
-}
-
-static inline sd_network_monitor* FD_TO_MONITOR(int fd) {
- return (sd_network_monitor*) (unsigned long) (fd + 1);
-}
-
-static int monitor_add_inotify_watch(int fd) {
- int k;
-
- k = inotify_add_watch(fd, "/run/systemd/netif/links/", IN_MOVED_TO|IN_DELETE);
- if (k >= 0)
- return 0;
- else if (errno != ENOENT)
- return -errno;
-
- k = inotify_add_watch(fd, "/run/systemd/netif/", IN_CREATE|IN_ISDIR);
- if (k >= 0)
- return 0;
- else if (errno != ENOENT)
- return -errno;
-
- k = inotify_add_watch(fd, "/run/systemd/", IN_CREATE|IN_ISDIR);
- if (k < 0)
- return -errno;
-
- return 0;
-}
-
-_public_ int sd_network_monitor_new(sd_network_monitor **m, const char *category) {
- _cleanup_close_ int fd = -1;
- int k;
- bool good = false;
-
- assert_return(m, -EINVAL);
-
- fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
- if (fd < 0)
- return -errno;
-
- if (!category || streq(category, "links")) {
- k = monitor_add_inotify_watch(fd);
- if (k < 0)
- return k;
-
- good = true;
- }
-
- if (!good)
- return -EINVAL;
-
- *m = FD_TO_MONITOR(fd);
- fd = -1;
-
- return 0;
-}
-
-_public_ sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m) {
- int fd;
-
- if (m) {
- fd = MONITOR_TO_FD(m);
- close_nointr(fd);
- }
-
- return NULL;
-}
-
-_public_ int sd_network_monitor_flush(sd_network_monitor *m) {
- union inotify_event_buffer buffer;
- struct inotify_event *e;
- ssize_t l;
- int fd, k;
-
- assert_return(m, -EINVAL);
-
- fd = MONITOR_TO_FD(m);
-
- l = read(fd, &buffer, sizeof(buffer));
- if (l < 0) {
- if (errno == EAGAIN || errno == EINTR)
- return 0;
-
- return -errno;
- }
-
- FOREACH_INOTIFY_EVENT(e, buffer, l) {
- if (e->mask & IN_ISDIR) {
- k = monitor_add_inotify_watch(fd);
- if (k < 0)
- return k;
-
- k = inotify_rm_watch(fd, e->wd);
- if (k < 0)
- return -errno;
- }
- }
-
- return 0;
-}
-
-_public_ int sd_network_monitor_get_fd(sd_network_monitor *m) {
-
- assert_return(m, -EINVAL);
-
- return MONITOR_TO_FD(m);
-}
-
-_public_ int sd_network_monitor_get_events(sd_network_monitor *m) {
-
- assert_return(m, -EINVAL);
-
- /* For now we will only return POLLIN here, since we don't
- * need anything else ever for inotify. However, let's have
- * this API to keep our options open should we later on need
- * it. */
- return POLLIN;
-}
-
-_public_ int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec) {
-
- assert_return(m, -EINVAL);
- assert_return(timeout_usec, -EINVAL);
-
- /* For now we will only return (uint64_t) -1, since we don't
- * need any timeout. However, let's have this API to keep our
- * options open should we later on need it. */
- *timeout_usec = (uint64_t) -1;
- return 0;
-}
diff --git a/src/libelogind/sd-resolve/Makefile b/src/libelogind/sd-resolve/Makefile
deleted file mode 120000
index 94aaae2c4..000000000
--- a/src/libelogind/sd-resolve/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../../Makefile \ No newline at end of file
diff --git a/src/libelogind/sd-rtnl/Makefile b/src/libelogind/sd-rtnl/Makefile
deleted file mode 120000
index 94aaae2c4..000000000
--- a/src/libelogind/sd-rtnl/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../../Makefile \ No newline at end of file
diff --git a/src/libelogind/sd-rtnl/local-addresses.h b/src/libelogind/sd-rtnl/local-addresses.h
deleted file mode 100644
index bdc28d351..000000000
--- a/src/libelogind/sd-rtnl/local-addresses.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2011 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "sd-rtnl.h"
-#include "in-addr-util.h"
-
-struct local_address {
- int family, ifindex;
- unsigned char scope;
- uint32_t metric;
- union in_addr_union address;
-};
-
-int local_addresses(sd_rtnl *rtnl, int ifindex, int af, struct local_address **ret);
-
-int local_gateways(sd_rtnl *rtnl, int ifindex, int af, struct local_address **ret);
diff --git a/src/libelogind/sd-rtnl/rtnl-internal.h b/src/libelogind/sd-rtnl/rtnl-internal.h
deleted file mode 100644
index 05b88b1ad..000000000
--- a/src/libelogind/sd-rtnl/rtnl-internal.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <linux/netlink.h>
-
-#include "refcnt.h"
-#include "prioq.h"
-#include "list.h"
-
-#include "sd-rtnl.h"
-
-#include "rtnl-types.h"
-
-#define RTNL_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC))
-
-#define RTNL_WQUEUE_MAX 1024
-#define RTNL_RQUEUE_MAX 64*1024
-
-#define RTNL_CONTAINER_DEPTH 32
-
-struct reply_callback {
- sd_rtnl_message_handler_t callback;
- void *userdata;
- usec_t timeout;
- uint64_t serial;
- unsigned prioq_idx;
-};
-
-struct match_callback {
- sd_rtnl_message_handler_t callback;
- uint16_t type;
- void *userdata;
-
- LIST_FIELDS(struct match_callback, match_callbacks);
-};
-
-struct sd_rtnl {
- RefCount n_ref;
-
- int fd;
-
- union {
- struct sockaddr sa;
- struct sockaddr_nl nl;
- } sockaddr;
-
- sd_rtnl_message **rqueue;
- unsigned rqueue_size;
- size_t rqueue_allocated;
-
- sd_rtnl_message **rqueue_partial;
- unsigned rqueue_partial_size;
- size_t rqueue_partial_allocated;
-
- sd_rtnl_message **wqueue;
- unsigned wqueue_size;
- size_t wqueue_allocated;
-
- struct nlmsghdr *rbuffer;
- size_t rbuffer_allocated;
-
- bool processing:1;
-
- uint32_t serial;
-
- struct Prioq *reply_callbacks_prioq;
- Hashmap *reply_callbacks;
-
- LIST_HEAD(struct match_callback, match_callbacks);
-
- pid_t original_pid;
-
- sd_event_source *io_event_source;
- sd_event_source *time_event_source;
- sd_event_source *exit_event_source;
- sd_event *event;
-};
-
-struct sd_rtnl_message {
- RefCount n_ref;
-
- sd_rtnl *rtnl;
-
- struct nlmsghdr *hdr;
- const struct NLTypeSystem *(container_type_system[RTNL_CONTAINER_DEPTH]); /* the type of the container and all its parents */
- size_t container_offsets[RTNL_CONTAINER_DEPTH]; /* offset from hdr to each container's start */
- unsigned n_containers; /* number of containers */
- size_t next_rta_offset; /* offset from hdr to next rta */
- size_t *rta_offset_tb[RTNL_CONTAINER_DEPTH];
- unsigned short rta_tb_size[RTNL_CONTAINER_DEPTH];
- bool sealed:1;
- bool broadcast:1;
-
- sd_rtnl_message *next; /* next in a chain of multi-part messages */
-};
-
-int message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t type);
-
-int socket_write_message(sd_rtnl *nl, sd_rtnl_message *m);
-int socket_read_message(sd_rtnl *nl);
-
-int rtnl_rqueue_make_room(sd_rtnl *rtnl);
-int rtnl_rqueue_partial_make_room(sd_rtnl *rtnl);
-
-int rtnl_message_read_internal(sd_rtnl_message *m, unsigned short type, void **data);
-int rtnl_message_parse(sd_rtnl_message *m,
- size_t **rta_offset_tb,
- unsigned short *rta_tb_size,
- int max,
- struct rtattr *rta,
- unsigned int rt_len);
-
-/* Make sure callbacks don't destroy the rtnl connection */
-#define RTNL_DONT_DESTROY(rtnl) \
- _cleanup_rtnl_unref_ _unused_ sd_rtnl *_dont_destroy_##rtnl = sd_rtnl_ref(rtnl)
diff --git a/src/libelogind/sd-rtnl/rtnl-types.c b/src/libelogind/sd-rtnl/rtnl-types.c
deleted file mode 100644
index ab456c34f..000000000
--- a/src/libelogind/sd-rtnl/rtnl-types.c
+++ /dev/null
@@ -1,561 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdint.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/in6.h>
-#include <linux/veth.h>
-#include <linux/if_bridge.h>
-#include <linux/if_addr.h>
-#include <linux/if.h>
-
-#include <linux/ip.h>
-#include <linux/if_link.h>
-#include <linux/if_tunnel.h>
-
-#include "macro.h"
-#include "util.h"
-
-#include "rtnl-types.h"
-#include "missing.h"
-
-static const NLTypeSystem rtnl_link_type_system;
-
-static const NLType rtnl_link_info_data_veth_types[VETH_INFO_MAX + 1] = {
- [VETH_INFO_PEER] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
-};
-
-static const NLType rtnl_link_info_data_ipvlan_types[IFLA_IPVLAN_MAX + 1] = {
- [IFLA_IPVLAN_MODE] = { .type = NLA_U16 },
-};
-
-static const NLType rtnl_link_info_data_macvlan_types[IFLA_MACVLAN_MAX + 1] = {
- [IFLA_MACVLAN_MODE] = { .type = NLA_U32 },
- [IFLA_MACVLAN_FLAGS] = { .type = NLA_U16 },
-};
-
-static const NLType rtnl_link_info_data_bridge_types[IFLA_BRIDGE_MAX + 1] = {
- [IFLA_BRIDGE_FLAGS] = { .type = NLA_U16 },
- [IFLA_BRIDGE_MODE] = { .type = NLA_U16 },
-/*
- [IFLA_BRIDGE_VLAN_INFO] = { .type = NLA_BINARY,
- .len = sizeof(struct bridge_vlan_info), },
-*/
-};
-
-static const NLType rtnl_link_info_data_vlan_types[IFLA_VLAN_MAX + 1] = {
- [IFLA_VLAN_ID] = { .type = NLA_U16 },
-/*
- [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
- [IFLA_VLAN_EGRESS_QOS] = { .type = NLA_NESTED },
- [IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED },
-*/
- [IFLA_VLAN_PROTOCOL] = { .type = NLA_U16 },
-};
-
-static const NLType rtnl_link_info_data_vxlan_types[IFLA_VXLAN_MAX+1] = {
- [IFLA_VXLAN_ID] = { .type = NLA_U32 },
- [IFLA_VXLAN_GROUP] = {.type = NLA_IN_ADDR },
- [IFLA_VXLAN_LINK] = { .type = NLA_U32 },
- [IFLA_VXLAN_LOCAL] = { .type = NLA_U32},
- [IFLA_VXLAN_TTL] = { .type = NLA_U8 },
- [IFLA_VXLAN_TOS] = { .type = NLA_U8 },
- [IFLA_VXLAN_LEARNING] = { .type = NLA_U8 },
- [IFLA_VXLAN_AGEING] = { .type = NLA_U32 },
- [IFLA_VXLAN_LIMIT] = { .type = NLA_U32 },
- [IFLA_VXLAN_PORT_RANGE] = { .type = NLA_U32},
- [IFLA_VXLAN_PROXY] = { .type = NLA_U8 },
- [IFLA_VXLAN_RSC] = { .type = NLA_U8 },
- [IFLA_VXLAN_L2MISS] = { .type = NLA_U8 },
- [IFLA_VXLAN_L3MISS] = { .type = NLA_U8 },
-};
-
-static const NLType rtnl_bond_arp_target_types[BOND_ARP_TARGETS_MAX + 1] = {
- [BOND_ARP_TARGETS_0] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_1] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_2] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_3] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_4] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_5] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_6] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_7] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_8] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_9] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_10] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_11] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_12] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_13] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_14] = { .type = NLA_U32 },
- [BOND_ARP_TARGETS_MAX] = { .type = NLA_U32 },
-};
-
-static const NLTypeSystem rtnl_bond_arp_type_system = {
- .max = ELEMENTSOF(rtnl_bond_arp_target_types) - 1,
- .types = rtnl_bond_arp_target_types,
-};
-
-static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = {
- [IFLA_BOND_MODE] = { .type = NLA_U8 },
- [IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 },
- [IFLA_BOND_MIIMON] = { .type = NLA_U32 },
- [IFLA_BOND_UPDELAY] = { .type = NLA_U32 },
- [IFLA_BOND_DOWNDELAY] = { .type = NLA_U32 },
- [IFLA_BOND_USE_CARRIER] = { .type = NLA_U8 },
- [IFLA_BOND_ARP_INTERVAL] = { .type = NLA_U32 },
- [IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED, .type_system = &rtnl_bond_arp_type_system },
- [IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 },
- [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 },
- [IFLA_BOND_PRIMARY] = { .type = NLA_U32 },
- [IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 },
- [IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 },
- [IFLA_BOND_XMIT_HASH_POLICY] = { .type = NLA_U8 },
- [IFLA_BOND_RESEND_IGMP] = { .type = NLA_U32 },
- [IFLA_BOND_NUM_PEER_NOTIF] = { .type = NLA_U8 },
- [IFLA_BOND_ALL_SLAVES_ACTIVE] = { .type = NLA_U8 },
- [IFLA_BOND_MIN_LINKS] = { .type = NLA_U32 },
- [IFLA_BOND_LP_INTERVAL] = { .type = NLA_U32 },
- [IFLA_BOND_PACKETS_PER_SLAVE] = { .type = NLA_U32 },
- [IFLA_BOND_AD_LACP_RATE] = { .type = NLA_U8 },
- [IFLA_BOND_AD_SELECT] = { .type = NLA_U8 },
- [IFLA_BOND_AD_INFO] = { .type = NLA_NESTED },
-};
-
-static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = {
- [IFLA_IPTUN_LINK] = { .type = NLA_U32 },
- [IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR },
- [IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR },
- [IFLA_IPTUN_TTL] = { .type = NLA_U8 },
- [IFLA_IPTUN_TOS] = { .type = NLA_U8 },
- [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
- [IFLA_IPTUN_FLAGS] = { .type = NLA_U16 },
- [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
- [IFLA_IPTUN_6RD_PREFIX] = { .type = NLA_IN_ADDR },
- [IFLA_IPTUN_6RD_RELAY_PREFIX] = { .type = NLA_U32 },
- [IFLA_IPTUN_6RD_PREFIXLEN] = { .type = NLA_U16 },
- [IFLA_IPTUN_6RD_RELAY_PREFIXLEN] = { .type = NLA_U16 },
-};
-
-static const NLType rtnl_link_info_data_ipgre_types[IFLA_GRE_MAX + 1] = {
- [IFLA_GRE_LINK] = { .type = NLA_U32 },
- [IFLA_GRE_IFLAGS] = { .type = NLA_U16 },
- [IFLA_GRE_OFLAGS] = { .type = NLA_U16 },
- [IFLA_GRE_IKEY] = { .type = NLA_U32 },
- [IFLA_GRE_OKEY] = { .type = NLA_U32 },
- [IFLA_GRE_LOCAL] = { .type = NLA_IN_ADDR },
- [IFLA_GRE_REMOTE] = { .type = NLA_IN_ADDR },
- [IFLA_GRE_TTL] = { .type = NLA_U8 },
- [IFLA_GRE_TOS] = { .type = NLA_U8 },
- [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
-};
-
-static const NLType rtnl_link_info_data_ipvti_types[IFLA_VTI_MAX + 1] = {
- [IFLA_VTI_LINK] = { .type = NLA_U32 },
- [IFLA_VTI_IKEY] = { .type = NLA_U32 },
- [IFLA_VTI_OKEY] = { .type = NLA_U32 },
- [IFLA_VTI_LOCAL] = { .type = NLA_IN_ADDR },
- [IFLA_VTI_REMOTE] = { .type = NLA_IN_ADDR },
-};
-
-static const NLType rtnl_link_info_data_ip6tnl_types[IFLA_IPTUN_MAX + 1] = {
- [IFLA_IPTUN_LINK] = { .type = NLA_U32 },
- [IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR },
- [IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR },
- [IFLA_IPTUN_TTL] = { .type = NLA_U8 },
- [IFLA_IPTUN_FLAGS] = { .type = NLA_U32 },
- [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
- [IFLA_IPTUN_ENCAP_LIMIT] = { .type = NLA_U8 },
- [IFLA_IPTUN_FLOWINFO] = { .type = NLA_U32},
-};
-
-/* these strings must match the .kind entries in the kernel */
-static const char* const nl_union_link_info_data_table[_NL_UNION_LINK_INFO_DATA_MAX] = {
- [NL_UNION_LINK_INFO_DATA_BOND] = "bond",
- [NL_UNION_LINK_INFO_DATA_BRIDGE] = "bridge",
- [NL_UNION_LINK_INFO_DATA_VLAN] = "vlan",
- [NL_UNION_LINK_INFO_DATA_VETH] = "veth",
- [NL_UNION_LINK_INFO_DATA_DUMMY] = "dummy",
- [NL_UNION_LINK_INFO_DATA_MACVLAN] = "macvlan",
- [NL_UNION_LINK_INFO_DATA_IPVLAN] = "ipvlan",
- [NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan",
- [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip",
- [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre",
- [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = "gretap",
- [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = "ip6gre",
- [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = "ip6gretap",
- [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = "sit",
- [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = "vti",
- [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = "vti6",
- [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = "ip6tnl",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data, NLUnionLinkInfoData);
-
-static const NLTypeSystem rtnl_link_info_data_type_systems[_NL_UNION_LINK_INFO_DATA_MAX] = {
- [NL_UNION_LINK_INFO_DATA_BOND] = { .max = ELEMENTSOF(rtnl_link_info_data_bond_types) - 1,
- .types = rtnl_link_info_data_bond_types },
- [NL_UNION_LINK_INFO_DATA_BRIDGE] = { .max = ELEMENTSOF(rtnl_link_info_data_bridge_types) - 1,
- .types = rtnl_link_info_data_bridge_types },
- [NL_UNION_LINK_INFO_DATA_VLAN] = { .max = ELEMENTSOF(rtnl_link_info_data_vlan_types) - 1,
- .types = rtnl_link_info_data_vlan_types },
- [NL_UNION_LINK_INFO_DATA_VETH] = { .max = ELEMENTSOF(rtnl_link_info_data_veth_types) - 1,
- .types = rtnl_link_info_data_veth_types },
- [NL_UNION_LINK_INFO_DATA_MACVLAN] = { .max = ELEMENTSOF(rtnl_link_info_data_macvlan_types) - 1,
- .types = rtnl_link_info_data_macvlan_types },
- [NL_UNION_LINK_INFO_DATA_IPVLAN] = { .max = ELEMENTSOF(rtnl_link_info_data_ipvlan_types) - 1,
- .types = rtnl_link_info_data_ipvlan_types },
- [NL_UNION_LINK_INFO_DATA_VXLAN] = { .max = ELEMENTSOF(rtnl_link_info_data_vxlan_types) - 1,
- .types = rtnl_link_info_data_vxlan_types },
- [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_iptun_types) - 1,
- .types = rtnl_link_info_data_iptun_types },
- [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
- .types = rtnl_link_info_data_ipgre_types },
- [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
- .types = rtnl_link_info_data_ipgre_types },
- [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
- .types = rtnl_link_info_data_ipgre_types },
- [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
- .types = rtnl_link_info_data_ipgre_types },
- [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_iptun_types) - 1,
- .types = rtnl_link_info_data_iptun_types },
- [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipvti_types) - 1,
- .types = rtnl_link_info_data_ipvti_types },
- [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ipvti_types) - 1,
- .types = rtnl_link_info_data_ipvti_types },
- [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = { .max = ELEMENTSOF(rtnl_link_info_data_ip6tnl_types) - 1,
- .types = rtnl_link_info_data_ip6tnl_types },
-
-};
-
-static const NLTypeSystemUnion rtnl_link_info_data_type_system_union = {
- .num = _NL_UNION_LINK_INFO_DATA_MAX,
- .lookup = nl_union_link_info_data_from_string,
- .type_systems = rtnl_link_info_data_type_systems,
- .match_type = NL_MATCH_SIBLING,
- .match = IFLA_INFO_KIND,
-};
-
-static const NLType rtnl_link_info_types[IFLA_INFO_MAX + 1] = {
- [IFLA_INFO_KIND] = { .type = NLA_STRING },
- [IFLA_INFO_DATA] = { .type = NLA_UNION, .type_system_union = &rtnl_link_info_data_type_system_union},
-/*
- [IFLA_INFO_XSTATS],
- [IFLA_INFO_SLAVE_KIND] = { .type = NLA_STRING },
- [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED },
-*/
-};
-
-static const NLTypeSystem rtnl_link_info_type_system = {
- .max = ELEMENTSOF(rtnl_link_info_types) - 1,
- .types = rtnl_link_info_types,
-};
-
-static const struct NLType rtnl_prot_info_bridge_port_types[IFLA_BRPORT_MAX + 1] = {
- [IFLA_BRPORT_STATE] = { .type = NLA_U8 },
- [IFLA_BRPORT_COST] = { .type = NLA_U32 },
- [IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 },
- [IFLA_BRPORT_MODE] = { .type = NLA_U8 },
- [IFLA_BRPORT_GUARD] = { .type = NLA_U8 },
- [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 },
- [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 },
- [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 },
-};
-
-static const NLTypeSystem rtnl_prot_info_type_systems[AF_MAX] = {
- [AF_BRIDGE] = { .max = ELEMENTSOF(rtnl_prot_info_bridge_port_types) - 1,
- .types = rtnl_prot_info_bridge_port_types },
-};
-
-static const NLTypeSystemUnion rtnl_prot_info_type_system_union = {
- .num = AF_MAX,
- .type_systems = rtnl_prot_info_type_systems,
- .match_type = NL_MATCH_PROTOCOL,
-};
-
-static const struct NLType rtnl_af_spec_inet6_types[IFLA_INET6_MAX + 1] = {
- [IFLA_INET6_FLAGS] = { .type = NLA_U32 },
-/*
- IFLA_INET6_CONF,
- IFLA_INET6_STATS,
- IFLA_INET6_MCAST,
- IFLA_INET6_CACHEINFO,
- IFLA_INET6_ICMP6STATS,
-*/
- [IFLA_INET6_TOKEN] = { .type = NLA_IN_ADDR },
- [IFLA_INET6_ADDR_GEN_MODE] = { .type = NLA_U8 },
-};
-
-static const NLTypeSystem rtnl_af_spec_inet6_type_system = {
- .max = ELEMENTSOF(rtnl_af_spec_inet6_types) - 1,
- .types = rtnl_af_spec_inet6_types,
-};
-
-static const NLType rtnl_af_spec_types[AF_MAX + 1] = {
- [AF_INET6] = { .type = NLA_NESTED, .type_system = &rtnl_af_spec_inet6_type_system },
-};
-
-static const NLTypeSystem rtnl_af_spec_type_system = {
- .max = ELEMENTSOF(rtnl_af_spec_types) - 1,
- .types = rtnl_af_spec_types,
-};
-
-static const NLType rtnl_link_types[IFLA_MAX + 1 ] = {
- [IFLA_ADDRESS] = { .type = NLA_ETHER_ADDR, },
- [IFLA_BROADCAST] = { .type = NLA_ETHER_ADDR, },
- [IFLA_IFNAME] = { .type = NLA_STRING, .size = IFNAMSIZ - 1, },
- [IFLA_MTU] = { .type = NLA_U32 },
- [IFLA_LINK] = { .type = NLA_U32 },
-/*
- [IFLA_QDISC],
- [IFLA_STATS],
- [IFLA_COST],
- [IFLA_PRIORITY],
-*/
- [IFLA_MASTER] = { .type = NLA_U32 },
-/*
- [IFLA_WIRELESS],
-*/
- [IFLA_PROTINFO] = { .type = NLA_UNION, .type_system_union = &rtnl_prot_info_type_system_union },
- [IFLA_TXQLEN] = { .type = NLA_U32 },
-/*
- [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
-*/
- [IFLA_WEIGHT] = { .type = NLA_U32 },
- [IFLA_OPERSTATE] = { .type = NLA_U8 },
- [IFLA_LINKMODE] = { .type = NLA_U8 },
- [IFLA_LINKINFO] = { .type = NLA_NESTED, .type_system = &rtnl_link_info_type_system },
- [IFLA_NET_NS_PID] = { .type = NLA_U32 },
- [IFLA_IFALIAS] = { .type = NLA_STRING, .size = IFALIASZ - 1 },
-/*
- [IFLA_NUM_VF],
- [IFLA_VFINFO_LIST] = {. type = NLA_NESTED, },
- [IFLA_STATS64],
- [IFLA_VF_PORTS] = { .type = NLA_NESTED },
- [IFLA_PORT_SELF] = { .type = NLA_NESTED },
-*/
- [IFLA_AF_SPEC] = { .type = NLA_NESTED, .type_system = &rtnl_af_spec_type_system },
-/*
- [IFLA_VF_PORTS],
- [IFLA_PORT_SELF],
- [IFLA_AF_SPEC],
-*/
- [IFLA_GROUP] = { .type = NLA_U32 },
- [IFLA_NET_NS_FD] = { .type = NLA_U32 },
- [IFLA_EXT_MASK] = { .type = NLA_U32 },
- [IFLA_PROMISCUITY] = { .type = NLA_U32 },
- [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
- [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
- [IFLA_CARRIER] = { .type = NLA_U8 },
-/*
- [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
-*/
-};
-
-static const NLTypeSystem rtnl_link_type_system = {
- .max = ELEMENTSOF(rtnl_link_types) - 1,
- .types = rtnl_link_types,
-};
-
-/* IFA_FLAGS was defined in kernel 3.14, but we still support older
- * kernels where IFA_MAX is lower. */
-static const NLType rtnl_address_types[CONST_MAX(IFA_MAX, IFA_FLAGS) + 1] = {
- [IFA_ADDRESS] = { .type = NLA_IN_ADDR },
- [IFA_LOCAL] = { .type = NLA_IN_ADDR },
- [IFA_LABEL] = { .type = NLA_STRING, .size = IFNAMSIZ - 1 },
- [IFA_BROADCAST] = { .type = NLA_IN_ADDR }, /* 6? */
- [IFA_CACHEINFO] = { .type = NLA_CACHE_INFO, .size = sizeof(struct ifa_cacheinfo) },
-/*
- [IFA_ANYCAST],
- [IFA_MULTICAST],
- [IFA_FLAGS] = { .type = NLA_U32 },
-*/
-};
-
-static const NLTypeSystem rtnl_address_type_system = {
- .max = ELEMENTSOF(rtnl_address_types) - 1,
- .types = rtnl_address_types,
-};
-
-static const NLType rtnl_route_types[RTA_MAX + 1] = {
- [RTA_DST] = { .type = NLA_IN_ADDR }, /* 6? */
- [RTA_SRC] = { .type = NLA_IN_ADDR }, /* 6? */
- [RTA_IIF] = { .type = NLA_U32 },
- [RTA_OIF] = { .type = NLA_U32 },
- [RTA_GATEWAY] = { .type = NLA_IN_ADDR },
- [RTA_PRIORITY] = { .type = NLA_U32 },
- [RTA_PREFSRC] = { .type = NLA_IN_ADDR }, /* 6? */
-/*
- [RTA_METRICS] = { .type = NLA_NESTED },
- [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
-*/
- [RTA_FLOW] = { .type = NLA_U32 }, /* 6? */
-/*
- RTA_CACHEINFO,
- RTA_TABLE,
- RTA_MARK,
- RTA_MFC_STATS,
-*/
-};
-
-static const NLTypeSystem rtnl_route_type_system = {
- .max = ELEMENTSOF(rtnl_route_types) - 1,
- .types = rtnl_route_types,
-};
-
-static const NLType rtnl_neigh_types[NDA_MAX + 1] = {
- [NDA_DST] = { .type = NLA_IN_ADDR },
- [NDA_LLADDR] = { .type = NLA_ETHER_ADDR },
- [NDA_CACHEINFO] = { .type = NLA_CACHE_INFO, .size = sizeof(struct nda_cacheinfo) },
- [NDA_PROBES] = { .type = NLA_U32 },
- [NDA_VLAN] = { .type = NLA_U16 },
- [NDA_PORT] = { .type = NLA_U16 },
- [NDA_VNI] = { .type = NLA_U32 },
- [NDA_IFINDEX] = { .type = NLA_U32 },
-};
-
-static const NLTypeSystem rtnl_neigh_type_system = {
- .max = ELEMENTSOF(rtnl_neigh_types) - 1,
- .types = rtnl_neigh_types,
-};
-
-static const NLType rtnl_types[RTM_MAX + 1] = {
- [NLMSG_DONE] = { .type = NLA_META, .size = 0 },
- [NLMSG_ERROR] = { .type = NLA_META, .size = sizeof(struct nlmsgerr) },
- [RTM_NEWLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
- [RTM_DELLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
- [RTM_GETLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
- [RTM_SETLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
- [RTM_NEWADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
- [RTM_DELADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
- [RTM_GETADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
- [RTM_NEWROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
- [RTM_DELROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
- [RTM_GETROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
- [RTM_NEWNEIGH] = { .type = NLA_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) },
- [RTM_DELNEIGH] = { .type = NLA_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) },
- [RTM_GETNEIGH] = { .type = NLA_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) },
-};
-
-const NLTypeSystem rtnl_type_system = {
- .max = ELEMENTSOF(rtnl_types) - 1,
- .types = rtnl_types,
-};
-
-int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, uint16_t type) {
- const NLType *nl_type;
-
- assert(ret);
-
- if (!type_system)
- type_system = &rtnl_type_system;
-
- assert(type_system->types);
-
- if (type > type_system->max)
- return -EOPNOTSUPP;
-
- nl_type = &type_system->types[type];
-
- if (nl_type->type == NLA_UNSPEC)
- return -EOPNOTSUPP;
-
- *ret = nl_type;
-
- return 0;
-}
-
-int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type) {
- const NLType *nl_type;
- int r;
-
- assert(ret);
-
- r = type_system_get_type(type_system, &nl_type, type);
- if (r < 0)
- return r;
-
- assert(nl_type->type == NLA_NESTED);
- assert(nl_type->type_system);
-
- *ret = nl_type->type_system;
-
- return 0;
-}
-
-int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type) {
- const NLType *nl_type;
- int r;
-
- assert(ret);
-
- r = type_system_get_type(type_system, &nl_type, type);
- if (r < 0)
- return r;
-
- assert(nl_type->type == NLA_UNION);
- assert(nl_type->type_system_union);
-
- *ret = nl_type->type_system_union;
-
- return 0;
-}
-
-int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key) {
- int type;
-
- assert(type_system_union);
- assert(type_system_union->match_type == NL_MATCH_SIBLING);
- assert(type_system_union->lookup);
- assert(type_system_union->type_systems);
- assert(ret);
- assert(key);
-
- type = type_system_union->lookup(key);
- if (type < 0)
- return -EOPNOTSUPP;
-
- assert(type < type_system_union->num);
-
- *ret = &type_system_union->type_systems[type];
-
- return 0;
-}
-
-int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol) {
- const NLTypeSystem *type_system;
-
- assert(type_system_union);
- assert(type_system_union->type_systems);
- assert(type_system_union->match_type == NL_MATCH_PROTOCOL);
- assert(ret);
-
- if (protocol >= type_system_union->num)
- return -EOPNOTSUPP;
-
- type_system = &type_system_union->type_systems[protocol];
- if (type_system->max == 0)
- return -EOPNOTSUPP;
-
- *ret = type_system;
-
- return 0;
-}
diff --git a/src/libelogind/sd-rtnl/rtnl-types.h b/src/libelogind/sd-rtnl/rtnl-types.h
deleted file mode 100644
index de1544bf3..000000000
--- a/src/libelogind/sd-rtnl/rtnl-types.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-enum {
- NLA_UNSPEC,
- NLA_META,
- NLA_U8,
- NLA_U16,
- NLA_U32,
- NLA_U64,
- NLA_STRING,
- NLA_IN_ADDR,
- NLA_ETHER_ADDR,
- NLA_CACHE_INFO,
- NLA_NESTED,
- NLA_UNION,
-};
-
-typedef enum NLMatchType {
- NL_MATCH_SIBLING,
- NL_MATCH_PROTOCOL,
-} NLMatchType;
-
-typedef struct NLTypeSystemUnion NLTypeSystemUnion;
-typedef struct NLTypeSystem NLTypeSystem;
-typedef struct NLType NLType;
-
-struct NLTypeSystemUnion {
- int num;
- NLMatchType match_type;
- uint16_t match;
- int (*lookup)(const char *);
- const NLTypeSystem *type_systems;
-};
-
-struct NLTypeSystem {
- uint16_t max;
- const NLType *types;
-};
-
-struct NLType {
- uint16_t type;
- size_t size;
- const NLTypeSystem *type_system;
- const NLTypeSystemUnion *type_system_union;
-};
-
-int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, uint16_t type);
-int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type);
-int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type);
-int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key);
-int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol);
-
-typedef enum NLUnionLinkInfoData {
- NL_UNION_LINK_INFO_DATA_BOND,
- NL_UNION_LINK_INFO_DATA_BRIDGE,
- NL_UNION_LINK_INFO_DATA_VLAN,
- NL_UNION_LINK_INFO_DATA_VETH,
- NL_UNION_LINK_INFO_DATA_DUMMY,
- NL_UNION_LINK_INFO_DATA_MACVLAN,
- NL_UNION_LINK_INFO_DATA_IPVLAN,
- NL_UNION_LINK_INFO_DATA_VXLAN,
- NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
- NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
- NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL,
- NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL,
- NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL,
- NL_UNION_LINK_INFO_DATA_SIT_TUNNEL,
- NL_UNION_LINK_INFO_DATA_VTI_TUNNEL,
- NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL,
- NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL,
- _NL_UNION_LINK_INFO_DATA_MAX,
- _NL_UNION_LINK_INFO_DATA_INVALID = -1
-} NLUnionLinkInfoData;
-
-const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
-NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;
-
-/* Maximum ARP IP target defined in kernel */
-#define BOND_MAX_ARP_TARGETS 16
-
-typedef enum BondArpTargets {
- BOND_ARP_TARGETS_0,
- BOND_ARP_TARGETS_1,
- BOND_ARP_TARGETS_2,
- BOND_ARP_TARGETS_3,
- BOND_ARP_TARGETS_4,
- BOND_ARP_TARGETS_5,
- BOND_ARP_TARGETS_6,
- BOND_ARP_TARGETS_7,
- BOND_ARP_TARGETS_8,
- BOND_ARP_TARGETS_9,
- BOND_ARP_TARGETS_10,
- BOND_ARP_TARGETS_11,
- BOND_ARP_TARGETS_12,
- BOND_ARP_TARGETS_13,
- BOND_ARP_TARGETS_14,
- BOND_ARP_TARGETS_MAX = BOND_MAX_ARP_TARGETS,
-} BondArpTargets;
diff --git a/src/libelogind/sd-rtnl/rtnl-util.h b/src/libelogind/sd-rtnl/rtnl-util.h
deleted file mode 100644
index 9e4bdb867..000000000
--- a/src/libelogind/sd-rtnl/rtnl-util.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "util.h"
-#include "sd-rtnl.h"
-
-int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_rtnl_message **ret);
-uint32_t rtnl_message_get_serial(sd_rtnl_message *m);
-void rtnl_message_seal(sd_rtnl_message *m);
-
-bool rtnl_message_type_is_link(uint16_t type);
-bool rtnl_message_type_is_addr(uint16_t type);
-bool rtnl_message_type_is_route(uint16_t type);
-bool rtnl_message_type_is_neigh(uint16_t type);
-
-int rtnl_set_link_name(sd_rtnl **rtnl, int ifindex, const char *name);
-int rtnl_set_link_properties(sd_rtnl **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, unsigned mtu);
-
-int rtnl_log_parse_error(int r);
-int rtnl_log_create_error(int r);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_rtnl*, sd_rtnl_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_rtnl_message*, sd_rtnl_message_unref);
-
-#define _cleanup_rtnl_unref_ _cleanup_(sd_rtnl_unrefp)
-#define _cleanup_rtnl_message_unref_ _cleanup_(sd_rtnl_message_unrefp)
diff --git a/src/libelogind/sd-utf8/Makefile b/src/libelogind/sd-utf8/Makefile
deleted file mode 120000
index 94aaae2c4..000000000
--- a/src/libelogind/sd-utf8/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../../Makefile \ No newline at end of file
diff --git a/src/libelogind/sd-utf8/sd-utf8.c b/src/libelogind/sd-utf8/sd-utf8.c
deleted file mode 100644
index 6f2aa6064..000000000
--- a/src/libelogind/sd-utf8/sd-utf8.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "util.h"
-#include "utf8.h"
-#include "sd-utf8.h"
-
-_public_ const char *sd_utf8_is_valid(const char *s) {
- assert_return(s, NULL);
-
- return utf8_is_valid(s);
-}
-
-_public_ const char *sd_ascii_is_valid(const char *s) {
- assert_return(s, NULL);
-
- return ascii_is_valid(s);
-}
diff --git a/src/libsystemd/sd-netlink/Makefile b/src/libsystemd/sd-netlink/Makefile
deleted file mode 120000
index 94aaae2c4..000000000
--- a/src/libsystemd/sd-netlink/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../../Makefile \ No newline at end of file
diff --git a/src/libsystemd/sd-netlink/local-addresses.c b/src/libsystemd/sd-netlink/local-addresses.c
deleted file mode 100644
index e2f637f7f..000000000
--- a/src/libsystemd/sd-netlink/local-addresses.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2011 Lennart Poettering
- Copyright 2014 Tom Gundersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "sd-netlink.h"
-#include "netlink-util.h"
-#include "macro.h"
-#include "local-addresses.h"
-
-static int address_compare(const void *_a, const void *_b) {
- const struct local_address *a = _a, *b = _b;
-
- /* Order lowest scope first, IPv4 before IPv6, lowest interface index first */
-
- if (a->family == AF_INET && b->family == AF_INET6)
- return -1;
- if (a->family == AF_INET6 && b->family == AF_INET)
- return 1;
-
- if (a->scope < b->scope)
- return -1;
- if (a->scope > b->scope)
- return 1;
-
- if (a->metric < b->metric)
- return -1;
- if (a->metric > b->metric)
- return 1;
-
- if (a->ifindex < b->ifindex)
- return -1;
- if (a->ifindex > b->ifindex)
- return 1;
-
- return memcmp(&a->address, &b->address, FAMILY_ADDRESS_SIZE(a->family));
-}
-
-int local_addresses(sd_netlink *context, int ifindex, int af, struct local_address **ret) {
- _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL;
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- _cleanup_free_ struct local_address *list = NULL;
- size_t n_list = 0, n_allocated = 0;
- sd_netlink_message *m;
- int r;
-
- assert(ret);
-
- if (context)
- rtnl = sd_netlink_ref(context);
- else {
- r = sd_netlink_open(&rtnl);
- if (r < 0)
- return r;
- }
-
- r = sd_rtnl_message_new_addr(rtnl, &req, RTM_GETADDR, 0, af);
- if (r < 0)
- return r;
-
- r = sd_netlink_call(rtnl, req, 0, &reply);
- if (r < 0)
- return r;
-
- for (m = reply; m; m = sd_netlink_message_next(m)) {
- struct local_address *a;
- unsigned char flags;
- uint16_t type;
- int ifi, family;
-
- r = sd_netlink_message_get_errno(m);
- if (r < 0)
- return r;
-
- r = sd_netlink_message_get_type(m, &type);
- if (r < 0)
- return r;
- if (type != RTM_NEWADDR)
- continue;
-
- r = sd_rtnl_message_addr_get_ifindex(m, &ifi);
- if (r < 0)
- return r;
- if (ifindex > 0 && ifi != ifindex)
- continue;
-
- r = sd_rtnl_message_addr_get_family(m, &family);
- if (r < 0)
- return r;
- if (af != AF_UNSPEC && af != family)
- continue;
-
- r = sd_rtnl_message_addr_get_flags(m, &flags);
- if (r < 0)
- return r;
- if (flags & IFA_F_DEPRECATED)
- continue;
-
- if (!GREEDY_REALLOC0(list, n_allocated, n_list+1))
- return -ENOMEM;
-
- a = list + n_list;
-
- r = sd_rtnl_message_addr_get_scope(m, &a->scope);
- if (r < 0)
- return r;
-
- if (ifindex == 0 && (a->scope == RT_SCOPE_HOST || a->scope == RT_SCOPE_NOWHERE))
- continue;
-
- switch (family) {
-
- case AF_INET:
- r = sd_netlink_message_read_in_addr(m, IFA_LOCAL, &a->address.in);
- if (r < 0) {
- r = sd_netlink_message_read_in_addr(m, IFA_ADDRESS, &a->address.in);
- if (r < 0)
- continue;
- }
- break;
-
- case AF_INET6:
- r = sd_netlink_message_read_in6_addr(m, IFA_LOCAL, &a->address.in6);
- if (r < 0) {
- r = sd_netlink_message_read_in6_addr(m, IFA_ADDRESS, &a->address.in6);
- if (r < 0)
- continue;
- }
- break;
-
- default:
- continue;
- }
-
- a->ifindex = ifi;
- a->family = family;
-
- n_list++;
- };
-
- if (n_list > 0)
- qsort(list, n_list, sizeof(struct local_address), address_compare);
-
- *ret = list;
- list = NULL;
-
- return (int) n_list;
-}
-
-int local_gateways(sd_netlink *context, int ifindex, int af, struct local_address **ret) {
- _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL;
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- _cleanup_free_ struct local_address *list = NULL;
- sd_netlink_message *m = NULL;
- size_t n_list = 0, n_allocated = 0;
- int r;
-
- assert(ret);
-
- if (context)
- rtnl = sd_netlink_ref(context);
- else {
- r = sd_netlink_open(&rtnl);
- if (r < 0)
- return r;
- }
-
- r = sd_rtnl_message_new_route(rtnl, &req, RTM_GETROUTE, af, RTPROT_UNSPEC);
- if (r < 0)
- return r;
-
- r = sd_netlink_message_request_dump(req, true);
- if (r < 0)
- return r;
-
- r = sd_netlink_call(rtnl, req, 0, &reply);
- if (r < 0)
- return r;
-
- for (m = reply; m; m = sd_netlink_message_next(m)) {
- struct local_address *a;
- uint16_t type;
- unsigned char dst_len, src_len;
- uint32_t ifi;
- int family;
-
- r = sd_netlink_message_get_errno(m);
- if (r < 0)
- return r;
-
- r = sd_netlink_message_get_type(m, &type);
- if (r < 0)
- return r;
- if (type != RTM_NEWROUTE)
- continue;
-
- /* We only care for default routes */
- r = sd_rtnl_message_route_get_dst_prefixlen(m, &dst_len);
- if (r < 0)
- return r;
- if (dst_len != 0)
- continue;
-
- r = sd_rtnl_message_route_get_src_prefixlen(m, &src_len);
- if (r < 0)
- return r;
- if (src_len != 0)
- continue;
-
- r = sd_netlink_message_read_u32(m, RTA_OIF, &ifi);
- if (r < 0)
- return r;
- if (ifindex > 0 && (int) ifi != ifindex)
- continue;
-
- r = sd_rtnl_message_route_get_family(m, &family);
- if (r < 0)
- return r;
- if (af != AF_UNSPEC && af != family)
- continue;
-
- if (!GREEDY_REALLOC0(list, n_allocated, n_list + 1))
- return -ENOMEM;
-
- a = list + n_list;
-
- switch (family) {
- case AF_INET:
- r = sd_netlink_message_read_in_addr(m, RTA_GATEWAY, &a->address.in);
- if (r < 0)
- continue;
-
- break;
- case AF_INET6:
- r = sd_netlink_message_read_in6_addr(m, RTA_GATEWAY, &a->address.in6);
- if (r < 0)
- continue;
-
- break;
- default:
- continue;
- }
-
- sd_netlink_message_read_u32(m, RTA_PRIORITY, &a->metric);
-
- a->ifindex = ifi;
- a->family = family;
-
- n_list++;
- }
-
- if (n_list > 0)
- qsort(list, n_list, sizeof(struct local_address), address_compare);
-
- *ret = list;
- list = NULL;
-
- return (int) n_list;
-}
diff --git a/src/libsystemd/sd-netlink/local-addresses.h b/src/libsystemd/sd-netlink/local-addresses.h
deleted file mode 100644
index 5d0f11a2c..000000000
--- a/src/libsystemd/sd-netlink/local-addresses.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2011 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "sd-netlink.h"
-#include "in-addr-util.h"
-
-struct local_address {
- int family, ifindex;
- unsigned char scope;
- uint32_t metric;
- union in_addr_union address;
-};
-
-int local_addresses(sd_netlink *rtnl, int ifindex, int af, struct local_address **ret);
-
-int local_gateways(sd_netlink *rtnl, int ifindex, int af, struct local_address **ret);
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
deleted file mode 100644
index 482ff6b1c..000000000
--- a/src/libsystemd/sd-netlink/netlink-util.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "sd-netlink.h"
-
-#include "netlink-util.h"
-#include "netlink-internal.h"
-
-int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
- _cleanup_netlink_message_unref_ sd_netlink_message *message = NULL;
- int r;
-
- assert(rtnl);
- assert(ifindex > 0);
- assert(name);
-
- if (!*rtnl) {
- r = sd_netlink_open(rtnl);
- if (r < 0)
- return r;
- }
-
- r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex);
- if (r < 0)
- return r;
-
- r = sd_netlink_message_append_string(message, IFLA_IFNAME, name);
- if (r < 0)
- return r;
-
- r = sd_netlink_call(*rtnl, message, 0, NULL);
- if (r < 0)
- return r;
-
- return 0;
-}
-
-int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
- const struct ether_addr *mac, unsigned mtu) {
- _cleanup_netlink_message_unref_ sd_netlink_message *message = NULL;
- int r;
-
- assert(rtnl);
- assert(ifindex > 0);
-
- if (!alias && !mac && mtu == 0)
- return 0;
-
- if (!*rtnl) {
- r = sd_netlink_open(rtnl);
- if (r < 0)
- return r;
- }
-
- r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex);
- if (r < 0)
- return r;
-
- if (alias) {
- r = sd_netlink_message_append_string(message, IFLA_IFALIAS, alias);
- if (r < 0)
- return r;
- }
-
- if (mac) {
- r = sd_netlink_message_append_ether_addr(message, IFLA_ADDRESS, mac);
- if (r < 0)
- return r;
- }
-
- if (mtu > 0) {
- r = sd_netlink_message_append_u32(message, IFLA_MTU, mtu);
- if (r < 0)
- return r;
- }
-
- r = sd_netlink_call(*rtnl, message, 0, NULL);
- if (r < 0)
- return r;
-
- return 0;
-}
-
-int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_message **ret) {
- struct nlmsgerr *err;
- int r;
-
- assert(error <= 0);
-
- r = message_new(NULL, ret, NLMSG_ERROR);
- if (r < 0)
- return r;
-
- (*ret)->hdr->nlmsg_seq = serial;
-
- err = NLMSG_DATA((*ret)->hdr);
-
- err->error = error;
-
- return 0;
-}
-
-bool rtnl_message_type_is_neigh(uint16_t type) {
- switch (type) {
- case RTM_NEWNEIGH:
- case RTM_GETNEIGH:
- case RTM_DELNEIGH:
- return true;
- default:
- return false;
- }
-}
-
-bool rtnl_message_type_is_route(uint16_t type) {
- switch (type) {
- case RTM_NEWROUTE:
- case RTM_GETROUTE:
- case RTM_DELROUTE:
- return true;
- default:
- return false;
- }
-}
-
-bool rtnl_message_type_is_link(uint16_t type) {
- switch (type) {
- case RTM_NEWLINK:
- case RTM_SETLINK:
- case RTM_GETLINK:
- case RTM_DELLINK:
- return true;
- default:
- return false;
- }
-}
-
-bool rtnl_message_type_is_addr(uint16_t type) {
- switch (type) {
- case RTM_NEWADDR:
- case RTM_GETADDR:
- case RTM_DELADDR:
- return true;
- default:
- return false;
- }
-}
-
-int rtnl_log_parse_error(int r) {
- return log_error_errno(r, "Failed to parse netlink message: %m");
-}
-
-int rtnl_log_create_error(int r) {
- return log_error_errno(r, "Failed to create netlink message: %m");
-}
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
deleted file mode 100644
index 9df0aa28b..000000000
--- a/src/libsystemd/sd-netlink/netlink-util.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "util.h"
-#include "sd-netlink.h"
-
-int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_message **ret);
-uint32_t rtnl_message_get_serial(sd_netlink_message *m);
-void rtnl_message_seal(sd_netlink_message *m);
-
-bool rtnl_message_type_is_link(uint16_t type);
-bool rtnl_message_type_is_addr(uint16_t type);
-bool rtnl_message_type_is_route(uint16_t type);
-bool rtnl_message_type_is_neigh(uint16_t type);
-
-int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
-int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, unsigned mtu);
-
-int rtnl_log_parse_error(int r);
-int rtnl_log_create_error(int r);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_netlink*, sd_netlink_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_netlink_message*, sd_netlink_message_unref);
-
-#define _cleanup_netlink_unref_ _cleanup_(sd_netlink_unrefp)
-#define _cleanup_netlink_message_unref_ _cleanup_(sd_netlink_message_unrefp)
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
deleted file mode 100644
index 60ce4dfc4..000000000
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/socket.h>
-#include <poll.h>
-
-#include "missing.h"
-#include "macro.h"
-#include "util.h"
-#include "hashmap.h"
-
-#include "sd-netlink.h"
-#include "netlink-internal.h"
-#include "netlink-util.h"
-
-static int sd_netlink_new(sd_netlink **ret) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
-
- assert_return(ret, -EINVAL);
-
- rtnl = new0(sd_netlink, 1);
- if (!rtnl)
- return -ENOMEM;
-
- rtnl->n_ref = REFCNT_INIT;
-
- rtnl->fd = -1;
-
- rtnl->sockaddr.nl.nl_family = AF_NETLINK;
-
- rtnl->original_pid = getpid();
-
- LIST_HEAD_INIT(rtnl->match_callbacks);
-
- /* We guarantee that wqueue always has space for at least
- * one entry */
- if (!GREEDY_REALLOC(rtnl->wqueue, rtnl->wqueue_allocated, 1))
- return -ENOMEM;
-
- /* We guarantee that the read buffer has at least space for
- * a message header */
- if (!greedy_realloc((void**)&rtnl->rbuffer, &rtnl->rbuffer_allocated,
- sizeof(struct nlmsghdr), sizeof(uint8_t)))
- return -ENOMEM;
-
- /* Change notification responses have sequence 0, so we must
- * start our request sequence numbers at 1, or we may confuse our
- * responses with notifications from the kernel */
- rtnl->serial = 1;
-
- *ret = rtnl;
- rtnl = NULL;
-
- return 0;
-}
-
-int sd_netlink_new_from_netlink(sd_netlink **ret, int fd) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- socklen_t addrlen;
- int r;
-
- assert_return(ret, -EINVAL);
-
- r = sd_netlink_new(&rtnl);
- if (r < 0)
- return r;
-
- addrlen = sizeof(rtnl->sockaddr);
-
- r = getsockname(fd, &rtnl->sockaddr.sa, &addrlen);
- if (r < 0)
- return -errno;
-
- rtnl->fd = fd;
-
- *ret = rtnl;
- rtnl = NULL;
-
- return 0;
-}
-
-static bool rtnl_pid_changed(sd_netlink *rtnl) {
- assert(rtnl);
-
- /* We don't support people creating an rtnl connection and
- * keeping it around over a fork(). Let's complain. */
-
- return rtnl->original_pid != getpid();
-}
-
-int sd_netlink_open_fd(sd_netlink **ret, int fd) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- socklen_t addrlen;
- int r, one = 1;
-
- assert_return(ret, -EINVAL);
- assert_return(fd >= 0, -EINVAL);
-
- r = sd_netlink_new(&rtnl);
- if (r < 0)
- return r;
-
- r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0)
- return -errno;
-
- r = setsockopt(fd, SOL_NETLINK, NETLINK_PKTINFO, &one, sizeof(one));
- if (r < 0)
- return -errno;
-
- addrlen = sizeof(rtnl->sockaddr);
-
- r = bind(fd, &rtnl->sockaddr.sa, addrlen);
- /* ignore EINVAL to allow opening an already bound socket */
- if (r < 0 && errno != EINVAL)
- return -errno;
-
- r = getsockname(fd, &rtnl->sockaddr.sa, &addrlen);
- if (r < 0)
- return -errno;
-
- rtnl->fd = fd;
-
- *ret = rtnl;
- rtnl = NULL;
-
- return 0;
-}
-
-int sd_netlink_open(sd_netlink **ret) {
- _cleanup_close_ int fd = -1;
- int r;
-
- fd = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_ROUTE);
- if (fd < 0)
- return -errno;
-
- r = sd_netlink_open_fd(ret, fd);
- if (r < 0)
- return r;
-
- fd = -1;
-
- return 0;
-}
-
-static int rtnl_join_broadcast_group(sd_netlink *rtnl, unsigned group) {
- int r;
-
- assert(rtnl);
- assert(rtnl->fd >= 0);
- assert(group > 0);
-
- r = setsockopt(rtnl->fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group, sizeof(group));
- if (r < 0)
- return -errno;
-
- return 0;
-}
-
-int sd_netlink_inc_rcvbuf(const sd_netlink *const rtnl, const int size) {
- return fd_inc_rcvbuf(rtnl->fd, size);
-}
-
-sd_netlink *sd_netlink_ref(sd_netlink *rtnl) {
- assert_return(rtnl, NULL);
- assert_return(!rtnl_pid_changed(rtnl), NULL);
-
- if (rtnl)
- assert_se(REFCNT_INC(rtnl->n_ref) >= 2);
-
- return rtnl;
-}
-
-sd_netlink *sd_netlink_unref(sd_netlink *rtnl) {
- if (!rtnl)
- return NULL;
-
- assert_return(!rtnl_pid_changed(rtnl), NULL);
-
- if (REFCNT_DEC(rtnl->n_ref) == 0) {
- struct match_callback *f;
- unsigned i;
-
- for (i = 0; i < rtnl->rqueue_size; i++)
- sd_netlink_message_unref(rtnl->rqueue[i]);
- free(rtnl->rqueue);
-
- for (i = 0; i < rtnl->rqueue_partial_size; i++)
- sd_netlink_message_unref(rtnl->rqueue_partial[i]);
- free(rtnl->rqueue_partial);
-
- for (i = 0; i < rtnl->wqueue_size; i++)
- sd_netlink_message_unref(rtnl->wqueue[i]);
- free(rtnl->wqueue);
-
- free(rtnl->rbuffer);
-
- hashmap_free_free(rtnl->reply_callbacks);
- prioq_free(rtnl->reply_callbacks_prioq);
-
- sd_event_source_unref(rtnl->io_event_source);
- sd_event_source_unref(rtnl->time_event_source);
- sd_event_source_unref(rtnl->exit_event_source);
- sd_event_unref(rtnl->event);
-
- while ((f = rtnl->match_callbacks)) {
- LIST_REMOVE(match_callbacks, rtnl->match_callbacks, f);
- free(f);
- }
-
- safe_close(rtnl->fd);
- free(rtnl);
- }
-
- return NULL;
-}
-
-static void rtnl_seal_message(sd_netlink *rtnl, sd_netlink_message *m) {
- assert(rtnl);
- assert(!rtnl_pid_changed(rtnl));
- assert(m);
- assert(m->hdr);
-
- /* don't use seq == 0, as that is used for broadcasts, so we
- would get confused by replies to such messages */
- m->hdr->nlmsg_seq = rtnl->serial++ ? : rtnl->serial++;
-
- rtnl_message_seal(m);
-
- return;
-}
-
-int sd_netlink_send(sd_netlink *nl,
- sd_netlink_message *message,
- uint32_t *serial) {
- int r;
-
- assert_return(nl, -EINVAL);
- assert_return(!rtnl_pid_changed(nl), -ECHILD);
- assert_return(message, -EINVAL);
- assert_return(!message->sealed, -EPERM);
-
- rtnl_seal_message(nl, message);
-
- if (nl->wqueue_size <= 0) {
- /* send directly */
- r = socket_write_message(nl, message);
- if (r < 0)
- return r;
- else if (r == 0) {
- /* nothing was sent, so let's put it on
- * the queue */
- nl->wqueue[0] = sd_netlink_message_ref(message);
- nl->wqueue_size = 1;
- }
- } else {
- /* append to queue */
- if (nl->wqueue_size >= RTNL_WQUEUE_MAX) {
- log_debug("rtnl: exhausted the write queue size (%d)", RTNL_WQUEUE_MAX);
- return -ENOBUFS;
- }
-
- if (!GREEDY_REALLOC(nl->wqueue, nl->wqueue_allocated, nl->wqueue_size + 1))
- return -ENOMEM;
-
- nl->wqueue[nl->wqueue_size ++] = sd_netlink_message_ref(message);
- }
-
- if (serial)
- *serial = rtnl_message_get_serial(message);
-
- return 1;
-}
-
-int rtnl_rqueue_make_room(sd_netlink *rtnl) {
- assert(rtnl);
-
- if (rtnl->rqueue_size >= RTNL_RQUEUE_MAX) {
- log_debug("rtnl: exhausted the read queue size (%d)", RTNL_RQUEUE_MAX);
- return -ENOBUFS;
- }
-
- if (!GREEDY_REALLOC(rtnl->rqueue, rtnl->rqueue_allocated, rtnl->rqueue_size + 1))
- return -ENOMEM;
-
- return 0;
-}
-
-int rtnl_rqueue_partial_make_room(sd_netlink *rtnl) {
- assert(rtnl);
-
- if (rtnl->rqueue_partial_size >= RTNL_RQUEUE_MAX) {
- log_debug("rtnl: exhausted the partial read queue size (%d)", RTNL_RQUEUE_MAX);
- return -ENOBUFS;
- }
-
- if (!GREEDY_REALLOC(rtnl->rqueue_partial, rtnl->rqueue_partial_allocated,
- rtnl->rqueue_partial_size + 1))
- return -ENOMEM;
-
- return 0;
-}
-
-static int dispatch_rqueue(sd_netlink *rtnl, sd_netlink_message **message) {
- int r;
-
- assert(rtnl);
- assert(message);
-
- if (rtnl->rqueue_size <= 0) {
- /* Try to read a new message */
- r = socket_read_message(rtnl);
- if (r <= 0)
- return r;
- }
-
- /* Dispatch a queued message */
- *message = rtnl->rqueue[0];
- rtnl->rqueue_size --;
- memmove(rtnl->rqueue, rtnl->rqueue + 1, sizeof(sd_netlink_message*) * rtnl->rqueue_size);
-
- return 1;
-}
-
-static int dispatch_wqueue(sd_netlink *rtnl) {
- int r, ret = 0;
-
- assert(rtnl);
-
- while (rtnl->wqueue_size > 0) {
- r = socket_write_message(rtnl, rtnl->wqueue[0]);
- if (r < 0)
- return r;
- else if (r == 0)
- /* Didn't do anything this time */
- return ret;
- else {
- /* see equivalent in sd-bus.c */
- sd_netlink_message_unref(rtnl->wqueue[0]);
- rtnl->wqueue_size --;
- memmove(rtnl->wqueue, rtnl->wqueue + 1, sizeof(sd_netlink_message*) * rtnl->wqueue_size);
-
- ret = 1;
- }
- }
-
- return ret;
-}
-
-static int process_timeout(sd_netlink *rtnl) {
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL;
- struct reply_callback *c;
- usec_t n;
- int r;
-
- assert(rtnl);
-
- c = prioq_peek(rtnl->reply_callbacks_prioq);
- if (!c)
- return 0;
-
- n = now(CLOCK_MONOTONIC);
- if (c->timeout > n)
- return 0;
-
- r = rtnl_message_new_synthetic_error(-ETIMEDOUT, c->serial, &m);
- if (r < 0)
- return r;
-
- assert_se(prioq_pop(rtnl->reply_callbacks_prioq) == c);
- hashmap_remove(rtnl->reply_callbacks, &c->serial);
-
- r = c->callback(rtnl, m, c->userdata);
- if (r < 0)
- log_debug_errno(r, "sd-netlink: timedout callback failed: %m");
-
- free(c);
-
- return 1;
-}
-
-static int process_reply(sd_netlink *rtnl, sd_netlink_message *m) {
- _cleanup_free_ struct reply_callback *c = NULL;
- uint64_t serial;
- uint16_t type;
- int r;
-
- assert(rtnl);
- assert(m);
-
- serial = rtnl_message_get_serial(m);
- c = hashmap_remove(rtnl->reply_callbacks, &serial);
- if (!c)
- return 0;
-
- if (c->timeout != 0)
- prioq_remove(rtnl->reply_callbacks_prioq, c, &c->prioq_idx);
-
- r = sd_netlink_message_get_type(m, &type);
- if (r < 0)
- return 0;
-
- if (type == NLMSG_DONE)
- m = NULL;
-
- r = c->callback(rtnl, m, c->userdata);
- if (r < 0)
- log_debug_errno(r, "sd-netlink: callback failed: %m");
-
- return 1;
-}
-
-static int process_match(sd_netlink *rtnl, sd_netlink_message *m) {
- struct match_callback *c;
- uint16_t type;
- int r;
-
- assert(rtnl);
- assert(m);
-
- r = sd_netlink_message_get_type(m, &type);
- if (r < 0)
- return r;
-
- LIST_FOREACH(match_callbacks, c, rtnl->match_callbacks) {
- if (type == c->type) {
- r = c->callback(rtnl, m, c->userdata);
- if (r != 0) {
- if (r < 0)
- log_debug_errno(r, "sd-netlink: match callback failed: %m");
-
- break;
- }
- }
- }
-
- return 1;
-}
-
-static int process_running(sd_netlink *rtnl, sd_netlink_message **ret) {
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL;
- int r;
-
- assert(rtnl);
-
- r = process_timeout(rtnl);
- if (r != 0)
- goto null_message;
-
- r = dispatch_wqueue(rtnl);
- if (r != 0)
- goto null_message;
-
- r = dispatch_rqueue(rtnl, &m);
- if (r < 0)
- return r;
- if (!m)
- goto null_message;
-
- if (sd_netlink_message_is_broadcast(m)) {
- r = process_match(rtnl, m);
- if (r != 0)
- goto null_message;
- } else {
- r = process_reply(rtnl, m);
- if (r != 0)
- goto null_message;
- }
-
- if (ret) {
- *ret = m;
- m = NULL;
-
- return 1;
- }
-
- return 1;
-
-null_message:
- if (r >= 0 && ret)
- *ret = NULL;
-
- return r;
-}
-
-int sd_netlink_process(sd_netlink *rtnl, sd_netlink_message **ret) {
- RTNL_DONT_DESTROY(rtnl);
- int r;
-
- assert_return(rtnl, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
- assert_return(!rtnl->processing, -EBUSY);
-
- rtnl->processing = true;
- r = process_running(rtnl, ret);
- rtnl->processing = false;
-
- return r;
-}
-
-static usec_t calc_elapse(uint64_t usec) {
- if (usec == (uint64_t) -1)
- return 0;
-
- if (usec == 0)
- usec = RTNL_DEFAULT_TIMEOUT;
-
- return now(CLOCK_MONOTONIC) + usec;
-}
-
-static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
- struct pollfd p[1] = {};
- struct timespec ts;
- usec_t m = USEC_INFINITY;
- int r, e;
-
- assert(rtnl);
-
- e = sd_netlink_get_events(rtnl);
- if (e < 0)
- return e;
-
- if (need_more)
- /* Caller wants more data, and doesn't care about
- * what's been read or any other timeouts. */
- e |= POLLIN;
- else {
- usec_t until;
- /* Caller wants to process if there is something to
- * process, but doesn't care otherwise */
-
- r = sd_netlink_get_timeout(rtnl, &until);
- if (r < 0)
- return r;
- if (r > 0) {
- usec_t nw;
- nw = now(CLOCK_MONOTONIC);
- m = until > nw ? until - nw : 0;
- }
- }
-
- if (timeout_usec != (uint64_t) -1 && (m == (uint64_t) -1 || timeout_usec < m))
- m = timeout_usec;
-
- p[0].fd = rtnl->fd;
- p[0].events = e;
-
- r = ppoll(p, 1, m == (uint64_t) -1 ? NULL : timespec_store(&ts, m), NULL);
- if (r < 0)
- return -errno;
-
- return r > 0 ? 1 : 0;
-}
-
-int sd_netlink_wait(sd_netlink *nl, uint64_t timeout_usec) {
- assert_return(nl, -EINVAL);
- assert_return(!rtnl_pid_changed(nl), -ECHILD);
-
- if (nl->rqueue_size > 0)
- return 0;
-
- return rtnl_poll(nl, false, timeout_usec);
-}
-
-static int timeout_compare(const void *a, const void *b) {
- const struct reply_callback *x = a, *y = b;
-
- if (x->timeout != 0 && y->timeout == 0)
- return -1;
-
- if (x->timeout == 0 && y->timeout != 0)
- return 1;
-
- if (x->timeout < y->timeout)
- return -1;
-
- if (x->timeout > y->timeout)
- return 1;
-
- return 0;
-}
-
-int sd_netlink_call_async(sd_netlink *nl,
- sd_netlink_message *m,
- sd_netlink_message_handler_t callback,
- void *userdata,
- uint64_t usec,
- uint32_t *serial) {
- struct reply_callback *c;
- uint32_t s;
- int r, k;
-
- assert_return(nl, -EINVAL);
- assert_return(m, -EINVAL);
- assert_return(callback, -EINVAL);
- assert_return(!rtnl_pid_changed(nl), -ECHILD);
-
- r = hashmap_ensure_allocated(&nl->reply_callbacks, &uint64_hash_ops);
- if (r < 0)
- return r;
-
- if (usec != (uint64_t) -1) {
- r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare);
- if (r < 0)
- return r;
- }
-
- c = new0(struct reply_callback, 1);
- if (!c)
- return -ENOMEM;
-
- c->callback = callback;
- c->userdata = userdata;
- c->timeout = calc_elapse(usec);
-
- k = sd_netlink_send(nl, m, &s);
- if (k < 0) {
- free(c);
- return k;
- }
-
- c->serial = s;
-
- r = hashmap_put(nl->reply_callbacks, &c->serial, c);
- if (r < 0) {
- free(c);
- return r;
- }
-
- if (c->timeout != 0) {
- r = prioq_put(nl->reply_callbacks_prioq, c, &c->prioq_idx);
- if (r > 0) {
- c->timeout = 0;
- sd_netlink_call_async_cancel(nl, c->serial);
- return r;
- }
- }
-
- if (serial)
- *serial = s;
-
- return k;
-}
-
-int sd_netlink_call_async_cancel(sd_netlink *nl, uint32_t serial) {
- struct reply_callback *c;
- uint64_t s = serial;
-
- assert_return(nl, -EINVAL);
- assert_return(serial != 0, -EINVAL);
- assert_return(!rtnl_pid_changed(nl), -ECHILD);
-
- c = hashmap_remove(nl->reply_callbacks, &s);
- if (!c)
- return 0;
-
- if (c->timeout != 0)
- prioq_remove(nl->reply_callbacks_prioq, c, &c->prioq_idx);
-
- free(c);
- return 1;
-}
-
-int sd_netlink_call(sd_netlink *rtnl,
- sd_netlink_message *message,
- uint64_t usec,
- sd_netlink_message **ret) {
- usec_t timeout;
- uint32_t serial;
- int r;
-
- assert_return(rtnl, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
- assert_return(message, -EINVAL);
-
- r = sd_netlink_send(rtnl, message, &serial);
- if (r < 0)
- return r;
-
- timeout = calc_elapse(usec);
-
- for (;;) {
- usec_t left;
- unsigned i;
-
- for (i = 0; i < rtnl->rqueue_size; i++) {
- uint32_t received_serial;
-
- received_serial = rtnl_message_get_serial(rtnl->rqueue[i]);
-
- if (received_serial == serial) {
- _cleanup_netlink_message_unref_ sd_netlink_message *incoming = NULL;
- uint16_t type;
-
- incoming = rtnl->rqueue[i];
-
- /* found a match, remove from rqueue and return it */
- memmove(rtnl->rqueue + i,rtnl->rqueue + i + 1,
- sizeof(sd_netlink_message*) * (rtnl->rqueue_size - i - 1));
- rtnl->rqueue_size--;
-
- r = sd_netlink_message_get_errno(incoming);
- if (r < 0)
- return r;
-
- r = sd_netlink_message_get_type(incoming, &type);
- if (r < 0)
- return r;
-
- if (type == NLMSG_DONE) {
- *ret = NULL;
- return 0;
- }
-
- if (ret) {
- *ret = incoming;
- incoming = NULL;
- }
-
- return 1;
- }
- }
-
- r = socket_read_message(rtnl);
- if (r < 0)
- return r;
- if (r > 0)
- /* received message, so try to process straight away */
- continue;
-
- if (timeout > 0) {
- usec_t n;
-
- n = now(CLOCK_MONOTONIC);
- if (n >= timeout)
- return -ETIMEDOUT;
-
- left = timeout - n;
- } else
- left = (uint64_t) -1;
-
- r = rtnl_poll(rtnl, true, left);
- if (r < 0)
- return r;
- else if (r == 0)
- return -ETIMEDOUT;
-
- r = dispatch_wqueue(rtnl);
- if (r < 0)
- return r;
- }
-}
-
-int sd_netlink_flush(sd_netlink *rtnl) {
- int r;
-
- assert_return(rtnl, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
-
- if (rtnl->wqueue_size <= 0)
- return 0;
-
- for (;;) {
- r = dispatch_wqueue(rtnl);
- if (r < 0)
- return r;
-
- if (rtnl->wqueue_size <= 0)
- return 0;
-
- r = rtnl_poll(rtnl, false, (uint64_t) -1);
- if (r < 0)
- return r;
- }
-}
-
-int sd_netlink_get_events(sd_netlink *rtnl) {
- int flags = 0;
-
- assert_return(rtnl, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
-
- if (rtnl->rqueue_size <= 0)
- flags |= POLLIN;
- if (rtnl->wqueue_size > 0)
- flags |= POLLOUT;
-
- return flags;
-}
-
-int sd_netlink_get_timeout(sd_netlink *rtnl, uint64_t *timeout_usec) {
- struct reply_callback *c;
-
- assert_return(rtnl, -EINVAL);
- assert_return(timeout_usec, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
-
- if (rtnl->rqueue_size > 0) {
- *timeout_usec = 0;
- return 1;
- }
-
- c = prioq_peek(rtnl->reply_callbacks_prioq);
- if (!c) {
- *timeout_usec = (uint64_t) -1;
- return 0;
- }
-
- *timeout_usec = c->timeout;
-
- return 1;
-}
-
-static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- sd_netlink *rtnl = userdata;
- int r;
-
- assert(rtnl);
-
- r = sd_netlink_process(rtnl, NULL);
- if (r < 0)
- return r;
-
- return 1;
-}
-
-static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
- sd_netlink *rtnl = userdata;
- int r;
-
- assert(rtnl);
-
- r = sd_netlink_process(rtnl, NULL);
- if (r < 0)
- return r;
-
- return 1;
-}
-
-static int prepare_callback(sd_event_source *s, void *userdata) {
- sd_netlink *rtnl = userdata;
- int r, e;
- usec_t until;
-
- assert(s);
- assert(rtnl);
-
- e = sd_netlink_get_events(rtnl);
- if (e < 0)
- return e;
-
- r = sd_event_source_set_io_events(rtnl->io_event_source, e);
- if (r < 0)
- return r;
-
- r = sd_netlink_get_timeout(rtnl, &until);
- if (r < 0)
- return r;
- if (r > 0) {
- int j;
-
- j = sd_event_source_set_time(rtnl->time_event_source, until);
- if (j < 0)
- return j;
- }
-
- r = sd_event_source_set_enabled(rtnl->time_event_source, r > 0);
- if (r < 0)
- return r;
-
- return 1;
-}
-
-static int exit_callback(sd_event_source *event, void *userdata) {
- sd_netlink *rtnl = userdata;
-
- assert(event);
-
- sd_netlink_flush(rtnl);
-
- return 1;
-}
-
-int sd_netlink_attach_event(sd_netlink *rtnl, sd_event *event, int priority) {
- int r;
-
- assert_return(rtnl, -EINVAL);
- assert_return(!rtnl->event, -EBUSY);
-
- assert(!rtnl->io_event_source);
- assert(!rtnl->time_event_source);
-
- if (event)
- rtnl->event = sd_event_ref(event);
- else {
- r = sd_event_default(&rtnl->event);
- if (r < 0)
- return r;
- }
-
- r = sd_event_add_io(rtnl->event, &rtnl->io_event_source, rtnl->fd, 0, io_callback, rtnl);
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_priority(rtnl->io_event_source, priority);
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_description(rtnl->io_event_source, "rtnl-receive-message");
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_prepare(rtnl->io_event_source, prepare_callback);
- if (r < 0)
- goto fail;
-
- r = sd_event_add_time(rtnl->event, &rtnl->time_event_source, CLOCK_MONOTONIC, 0, 0, time_callback, rtnl);
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_priority(rtnl->time_event_source, priority);
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_description(rtnl->time_event_source, "rtnl-timer");
- if (r < 0)
- goto fail;
-
- r = sd_event_add_exit(rtnl->event, &rtnl->exit_event_source, exit_callback, rtnl);
- if (r < 0)
- goto fail;
-
- r = sd_event_source_set_description(rtnl->exit_event_source, "rtnl-exit");
- if (r < 0)
- goto fail;
-
- return 0;
-
-fail:
- sd_netlink_detach_event(rtnl);
- return r;
-}
-
-int sd_netlink_detach_event(sd_netlink *rtnl) {
- assert_return(rtnl, -EINVAL);
- assert_return(rtnl->event, -ENXIO);
-
- if (rtnl->io_event_source)
- rtnl->io_event_source = sd_event_source_unref(rtnl->io_event_source);
-
- if (rtnl->time_event_source)
- rtnl->time_event_source = sd_event_source_unref(rtnl->time_event_source);
-
- if (rtnl->exit_event_source)
- rtnl->exit_event_source = sd_event_source_unref(rtnl->exit_event_source);
-
- if (rtnl->event)
- rtnl->event = sd_event_unref(rtnl->event);
-
- return 0;
-}
-
-int sd_netlink_add_match(sd_netlink *rtnl,
- uint16_t type,
- sd_netlink_message_handler_t callback,
- void *userdata) {
- _cleanup_free_ struct match_callback *c = NULL;
- int r;
-
- assert_return(rtnl, -EINVAL);
- assert_return(callback, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
-
- c = new0(struct match_callback, 1);
- if (!c)
- return -ENOMEM;
-
- c->callback = callback;
- c->type = type;
- c->userdata = userdata;
-
- switch (type) {
- case RTM_NEWLINK:
- case RTM_SETLINK:
- case RTM_GETLINK:
- case RTM_DELLINK:
- r = rtnl_join_broadcast_group(rtnl, RTNLGRP_LINK);
- if (r < 0)
- return r;
-
- break;
- case RTM_NEWADDR:
- case RTM_GETADDR:
- case RTM_DELADDR:
- r = rtnl_join_broadcast_group(rtnl, RTNLGRP_IPV4_IFADDR);
- if (r < 0)
- return r;
-
- r = rtnl_join_broadcast_group(rtnl, RTNLGRP_IPV6_IFADDR);
- if (r < 0)
- return r;
-
- break;
- default:
- return -EOPNOTSUPP;
- }
-
- LIST_PREPEND(match_callbacks, rtnl->match_callbacks, c);
-
- c = NULL;
-
- return 0;
-}
-
-int sd_netlink_remove_match(sd_netlink *rtnl,
- uint16_t type,
- sd_netlink_message_handler_t callback,
- void *userdata) {
- struct match_callback *c;
-
- assert_return(rtnl, -EINVAL);
- assert_return(callback, -EINVAL);
- assert_return(!rtnl_pid_changed(rtnl), -ECHILD);
-
- /* we should unsubscribe from the broadcast groups at this point, but it is not so
- trivial for a few reasons: the refcounting is a bit of a mess and not obvious
- how it will look like after we add genetlink support, and it is also not possible
- to query what broadcast groups were subscribed to when we inherit the socket to get
- the initial refcount. The latter could indeed be done for the first 32 broadcast
- groups (which incidentally is all we currently support in .socket units anyway),
- but we better not rely on only ever using 32 groups. */
- LIST_FOREACH(match_callbacks, c, rtnl->match_callbacks)
- if (c->callback == callback && c->type == type && c->userdata == userdata) {
- LIST_REMOVE(match_callbacks, rtnl->match_callbacks, c);
- free(c);
-
- return 1;
- }
-
- return 0;
-}
diff --git a/src/libsystemd/sd-netlink/test-local-addresses.c b/src/libsystemd/sd-netlink/test-local-addresses.c
deleted file mode 100644
index 38cbcfbcc..000000000
--- a/src/libsystemd/sd-netlink/test-local-addresses.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "in-addr-util.h"
-#include "local-addresses.h"
-#include "af-list.h"
-
-static void print_local_addresses(struct local_address *a, unsigned n) {
- unsigned i;
-
- for (i = 0; i < n; i++) {
- _cleanup_free_ char *b = NULL;
-
- assert_se(in_addr_to_string(a[i].family, &a[i].address, &b) >= 0);
- printf("%s if%i scope=%i metric=%u address=%s\n", af_to_name(a[i].family), a[i].ifindex, a[i].scope, a[i].metric, b);
- }
-}
-
-int main(int argc, char *argv[]) {
- struct local_address *a;
- int n;
-
- a = NULL;
- n = local_addresses(NULL, 0, AF_UNSPEC, &a);
- assert_se(n >= 0);
-
- printf("Local Addresses:\n");
- print_local_addresses(a, (unsigned) n);
- free(a);
-
- a = NULL;
- n = local_gateways(NULL, 0, AF_UNSPEC, &a);
- assert_se(n >= 0);
-
- printf("Local Gateways:\n");
- print_local_addresses(a, (unsigned) n);
- free(a);
-
- return 0;
-}
diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c
deleted file mode 100644
index 60a4601e7..000000000
--- a/src/libsystemd/sd-netlink/test-netlink.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <netinet/ether.h>
-#include <net/if.h>
-
-#include "util.h"
-#include "macro.h"
-#include "sd-netlink.h"
-#include "socket-util.h"
-#include "netlink-util.h"
-#include "event-util.h"
-#include "missing.h"
-
-static void test_message_link_bridge(sd_netlink *rtnl) {
- _cleanup_netlink_message_unref_ sd_netlink_message *message = NULL;
- uint32_t cost;
-
- assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_NEWLINK, 1) >= 0);
- assert_se(sd_rtnl_message_link_set_family(message, PF_BRIDGE) >= 0);
- assert_se(sd_netlink_message_open_container(message, IFLA_PROTINFO) >= 0);
- assert_se(sd_netlink_message_append_u32(message, IFLA_BRPORT_COST, 10) >= 0);
- assert_se(sd_netlink_message_close_container(message) >= 0);
-
- assert_se(sd_netlink_message_rewind(message) >= 0);
-
- assert_se(sd_netlink_message_enter_container(message, IFLA_PROTINFO) >= 0);
- assert_se(sd_netlink_message_read_u32(message, IFLA_BRPORT_COST, &cost) >= 0);
- assert_se(cost == 10);
- assert_se(sd_netlink_message_exit_container(message) >= 0);
-}
-
-static void test_link_configure(sd_netlink *rtnl, int ifindex) {
- _cleanup_netlink_message_unref_ sd_netlink_message *message = NULL;
- const char *mac = "98:fe:94:3f:c6:18", *name = "test";
- char buffer[ETHER_ADDR_TO_STRING_MAX];
- unsigned int mtu = 1450, mtu_out;
- const char *name_out;
- struct ether_addr mac_out;
-
- /* we'd really like to test NEWLINK, but let's not mess with the running kernel */
- assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_GETLINK, ifindex) >= 0);
- assert_se(sd_netlink_message_append_string(message, IFLA_IFNAME, name) >= 0);
- assert_se(sd_netlink_message_append_ether_addr(message, IFLA_ADDRESS, ether_aton(mac)) >= 0);
- assert_se(sd_netlink_message_append_u32(message, IFLA_MTU, mtu) >= 0);
-
- assert_se(sd_netlink_call(rtnl, message, 0, NULL) == 1);
- assert_se(sd_netlink_message_rewind(message) >= 0);
-
- assert_se(sd_netlink_message_read_string(message, IFLA_IFNAME, &name_out) >= 0);
- assert_se(streq(name, name_out));
-
- assert_se(sd_netlink_message_read_ether_addr(message, IFLA_ADDRESS, &mac_out) >= 0);
- assert_se(streq(mac, ether_addr_to_string(&mac_out, buffer)));
-
- assert_se(sd_netlink_message_read_u32(message, IFLA_MTU, &mtu_out) >= 0);
- assert_se(mtu == mtu_out);
-}
-
-static void test_link_get(sd_netlink *rtnl, int ifindex) {
- sd_netlink_message *m;
- sd_netlink_message *r;
- unsigned int mtu = 1500;
- const char *str_data;
- uint8_t u8_data;
- uint32_t u32_data;
- struct ether_addr eth_data;
-
- assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
- assert_se(m);
-
- /* u8 test cases */
- assert_se(sd_netlink_message_append_u8(m, IFLA_CARRIER, 0) >= 0);
- assert_se(sd_netlink_message_append_u8(m, IFLA_OPERSTATE, 0) >= 0);
- assert_se(sd_netlink_message_append_u8(m, IFLA_LINKMODE, 0) >= 0);
-
- /* u32 test cases */
- assert_se(sd_netlink_message_append_u32(m, IFLA_MTU, mtu) >= 0);
- assert_se(sd_netlink_message_append_u32(m, IFLA_GROUP, 0) >= 0);
- assert_se(sd_netlink_message_append_u32(m, IFLA_TXQLEN, 0) >= 0);
- assert_se(sd_netlink_message_append_u32(m, IFLA_NUM_TX_QUEUES, 0) >= 0);
- assert_se(sd_netlink_message_append_u32(m, IFLA_NUM_RX_QUEUES, 0) >= 0);
-
- assert_se(sd_netlink_call(rtnl, m, -1, &r) == 1);
-
- assert_se(sd_netlink_message_read_string(r, IFLA_IFNAME, &str_data) == 0);
-
- assert_se(sd_netlink_message_read_u8(r, IFLA_CARRIER, &u8_data) == 0);
- assert_se(sd_netlink_message_read_u8(r, IFLA_OPERSTATE, &u8_data) == 0);
- assert_se(sd_netlink_message_read_u8(r, IFLA_LINKMODE, &u8_data) == 0);
-
- assert_se(sd_netlink_message_read_u32(r, IFLA_MTU, &u32_data) == 0);
- assert_se(sd_netlink_message_read_u32(r, IFLA_GROUP, &u32_data) == 0);
- assert_se(sd_netlink_message_read_u32(r, IFLA_TXQLEN, &u32_data) == 0);
- assert_se(sd_netlink_message_read_u32(r, IFLA_NUM_TX_QUEUES, &u32_data) == 0);
- assert_se(sd_netlink_message_read_u32(r, IFLA_NUM_RX_QUEUES, &u32_data) == 0);
-
- assert_se(sd_netlink_message_read_ether_addr(r, IFLA_ADDRESS, &eth_data) == 0);
-
- assert_se(sd_netlink_flush(rtnl) >= 0);
- assert_se((m = sd_netlink_message_unref(m)) == NULL);
- assert_se((r = sd_netlink_message_unref(r)) == NULL);
-}
-
-
-static void test_address_get(sd_netlink *rtnl, int ifindex) {
- sd_netlink_message *m;
- sd_netlink_message *r;
- struct in_addr in_data;
- struct ifa_cacheinfo cache;
- const char *label;
-
- assert_se(sd_rtnl_message_new_addr(rtnl, &m, RTM_GETADDR, ifindex, AF_INET) >= 0);
- assert_se(m);
-
- assert_se(sd_netlink_call(rtnl, m, -1, &r) == 1);
-
- assert_se(sd_netlink_message_read_in_addr(r, IFA_LOCAL, &in_data) == 0);
- assert_se(sd_netlink_message_read_in_addr(r, IFA_ADDRESS, &in_data) == 0);
- assert_se(sd_netlink_message_read_string(r, IFA_LABEL, &label) == 0);
- assert_se(sd_netlink_message_read_cache_info(r, IFA_CACHEINFO, &cache) == 0);
-
- assert_se(sd_netlink_flush(rtnl) >= 0);
- assert_se((m = sd_netlink_message_unref(m)) == NULL);
- assert_se((r = sd_netlink_message_unref(r)) == NULL);
-
-}
-
-static void test_route(void) {
- _cleanup_netlink_message_unref_ sd_netlink_message *req;
- struct in_addr addr, addr_data;
- uint32_t index = 2, u32_data;
- int r;
-
- r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC);
- if (r < 0) {
- log_error_errno(r, "Could not create RTM_NEWROUTE message: %m");
- return;
- }
-
- addr.s_addr = htonl(INADDR_LOOPBACK);
-
- r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &addr);
- if (r < 0) {
- log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m");
- return;
- }
-
- r = sd_netlink_message_append_u32(req, RTA_OIF, index);
- if (r < 0) {
- log_error_errno(r, "Could not append RTA_OIF attribute: %m");
- return;
- }
-
- assert_se(sd_netlink_message_rewind(req) >= 0);
-
- assert_se(sd_netlink_message_read_in_addr(req, RTA_GATEWAY, &addr_data) >= 0);
- assert_se(addr_data.s_addr == addr.s_addr);
-
- assert_se(sd_netlink_message_read_u32(req, RTA_OIF, &u32_data) >= 0);
- assert_se(u32_data == index);
-
- assert_se((req = sd_netlink_message_unref(req)) == NULL);
-}
-
-static void test_multiple(void) {
- sd_netlink *rtnl1, *rtnl2;
-
- assert_se(sd_netlink_open(&rtnl1) >= 0);
- assert_se(sd_netlink_open(&rtnl2) >= 0);
-
- rtnl1 = sd_netlink_unref(rtnl1);
- rtnl2 = sd_netlink_unref(rtnl2);
-}
-
-static int link_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
- char *ifname = userdata;
- const char *data;
-
- assert_se(rtnl);
- assert_se(m);
-
- log_info("got link info about %s", ifname);
- free(ifname);
-
- assert_se(sd_netlink_message_read_string(m, IFLA_IFNAME, &data) >= 0);
- assert_se(streq(data, "lo"));
-
- return 1;
-}
-
-static void test_event_loop(int ifindex) {
- _cleanup_event_unref_ sd_event *event = NULL;
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL;
- char *ifname;
-
- ifname = strdup("lo2");
- assert_se(ifname);
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
- assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
-
- assert_se(sd_netlink_call_async(rtnl, m, &link_handler, ifname, 0, NULL) >= 0);
-
- assert_se(sd_event_default(&event) >= 0);
-
- assert_se(sd_netlink_attach_event(rtnl, event, 0) >= 0);
-
- assert_se(sd_event_run(event, 0) >= 0);
-
- assert_se(sd_netlink_detach_event(rtnl) >= 0);
-
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-}
-
-static int pipe_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
- int *counter = userdata;
- int r;
-
- (*counter) --;
-
- r = sd_netlink_message_get_errno(m);
-
- log_info_errno(r, "%d left in pipe. got reply: %m", *counter);
-
- assert_se(r >= 0);
-
- return 1;
-}
-
-static void test_async(int ifindex) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL, *r = NULL;
- uint32_t serial;
- char *ifname;
-
- ifname = strdup("lo");
- assert_se(ifname);
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
-
- assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
-
- assert_se(sd_netlink_call_async(rtnl, m, &link_handler, ifname, 0, &serial) >= 0);
-
- assert_se(sd_netlink_wait(rtnl, 0) >= 0);
- assert_se(sd_netlink_process(rtnl, &r) >= 0);
-
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-}
-
-static void test_pipe(int ifindex) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
- _cleanup_netlink_message_unref_ sd_netlink_message *m1 = NULL, *m2 = NULL;
- int counter = 0;
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
-
- assert_se(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0);
- assert_se(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0);
-
- counter ++;
- assert_se(sd_netlink_call_async(rtnl, m1, &pipe_handler, &counter, 0, NULL) >= 0);
-
- counter ++;
- assert_se(sd_netlink_call_async(rtnl, m2, &pipe_handler, &counter, 0, NULL) >= 0);
-
- while (counter > 0) {
- assert_se(sd_netlink_wait(rtnl, 0) >= 0);
- assert_se(sd_netlink_process(rtnl, NULL) >= 0);
- }
-
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-}
-
-static void test_container(void) {
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL;
- uint16_t u16_data;
- uint32_t u32_data;
- const char *string_data;
-
- assert_se(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
-
- assert_se(sd_netlink_message_open_container(m, IFLA_LINKINFO) >= 0);
- assert_se(sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "vlan") >= 0);
- assert_se(sd_netlink_message_append_u16(m, IFLA_VLAN_ID, 100) >= 0);
- assert_se(sd_netlink_message_close_container(m) >= 0);
- assert_se(sd_netlink_message_append_string(m, IFLA_INFO_KIND, "vlan") >= 0);
- assert_se(sd_netlink_message_close_container(m) >= 0);
- assert_se(sd_netlink_message_close_container(m) == -EINVAL);
-
- assert_se(sd_netlink_message_rewind(m) >= 0);
-
- assert_se(sd_netlink_message_enter_container(m, IFLA_LINKINFO) >= 0);
- assert_se(sd_netlink_message_read_string(m, IFLA_INFO_KIND, &string_data) >= 0);
- assert_se(streq("vlan", string_data));
-
- assert_se(sd_netlink_message_enter_container(m, IFLA_INFO_DATA) >= 0);
- assert_se(sd_netlink_message_read_u16(m, IFLA_VLAN_ID, &u16_data) >= 0);
- assert_se(sd_netlink_message_exit_container(m) >= 0);
-
- assert_se(sd_netlink_message_read_string(m, IFLA_INFO_KIND, &string_data) >= 0);
- assert_se(streq("vlan", string_data));
- assert_se(sd_netlink_message_exit_container(m) >= 0);
-
- assert_se(sd_netlink_message_read_u32(m, IFLA_LINKINFO, &u32_data) < 0);
-
- assert_se(sd_netlink_message_exit_container(m) == -EINVAL);
-}
-
-static void test_match(void) {
- _cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
-
- assert_se(sd_netlink_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
- assert_se(sd_netlink_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
-
- assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 1);
- assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 1);
- assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 0);
-
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-}
-
-static void test_get_addresses(sd_netlink *rtnl) {
- _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL;
- sd_netlink_message *m;
-
- assert_se(sd_rtnl_message_new_addr(rtnl, &req, RTM_GETADDR, 0, AF_UNSPEC) >= 0);
-
- assert_se(sd_netlink_call(rtnl, req, 0, &reply) >= 0);
-
- for (m = reply; m; m = sd_netlink_message_next(m)) {
- uint16_t type;
- unsigned char scope, flags;
- int family, ifindex;
-
- assert_se(sd_netlink_message_get_type(m, &type) >= 0);
- assert_se(type == RTM_NEWADDR);
-
- assert_se(sd_rtnl_message_addr_get_ifindex(m, &ifindex) >= 0);
- assert_se(sd_rtnl_message_addr_get_family(m, &family) >= 0);
- assert_se(sd_rtnl_message_addr_get_scope(m, &scope) >= 0);
- assert_se(sd_rtnl_message_addr_get_flags(m, &flags) >= 0);
-
- assert_se(ifindex > 0);
- assert_se(family == AF_INET || family == AF_INET6);
-
- log_info("got IPv%u address on ifindex %i", family == AF_INET ? 4: 6, ifindex);
- }
-}
-
-static void test_message(void) {
- _cleanup_netlink_message_unref_ sd_netlink_message *m = NULL;
-
- assert_se(rtnl_message_new_synthetic_error(-ETIMEDOUT, 1, &m) >= 0);
- assert_se(sd_netlink_message_get_errno(m) == -ETIMEDOUT);
-}
-
-int main(void) {
- sd_netlink *rtnl;
- sd_netlink_message *m;
- sd_netlink_message *r;
- const char *string_data;
- int if_loopback;
- uint16_t type;
-
- test_message();
-
- test_match();
-
- test_multiple();
-
- test_route();
-
- test_container();
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
- assert_se(rtnl);
-
- if_loopback = (int) if_nametoindex("lo");
- assert_se(if_loopback > 0);
-
- test_async(if_loopback);
-
- test_pipe(if_loopback);
-
- test_event_loop(if_loopback);
-
- test_link_configure(rtnl, if_loopback);
-
- test_get_addresses(rtnl);
-
- test_message_link_bridge(rtnl);
-
- assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0);
- assert_se(m);
-
- assert_se(sd_netlink_message_get_type(m, &type) >= 0);
- assert_se(type == RTM_GETLINK);
-
- assert_se(sd_netlink_message_read_string(m, IFLA_IFNAME, &string_data) == -EPERM);
-
- assert_se(sd_netlink_call(rtnl, m, 0, &r) == 1);
- assert_se(sd_netlink_message_get_type(r, &type) >= 0);
- assert_se(type == RTM_NEWLINK);
-
- assert_se((r = sd_netlink_message_unref(r)) == NULL);
-
- assert_se(sd_netlink_call(rtnl, m, -1, &r) == -EPERM);
- assert_se((m = sd_netlink_message_unref(m)) == NULL);
- assert_se((r = sd_netlink_message_unref(r)) == NULL);
-
- test_link_get(rtnl, if_loopback);
- test_address_get(rtnl, if_loopback);
-
- assert_se(sd_netlink_flush(rtnl) >= 0);
- assert_se((m = sd_netlink_message_unref(m)) == NULL);
- assert_se((r = sd_netlink_message_unref(r)) == NULL);
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-
- return EXIT_SUCCESS;
-}
diff --git a/src/login/logind.conf b/src/login/elogind.conf
index 6df6f04c7..25edfce6f 100644
--- a/src/login/logind.conf
+++ b/src/login/elogind.conf
@@ -9,7 +9,7 @@
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
-# See logind.conf(5) for details.
+# See elogind.conf(5) for details.
[Login]
#NAutoVTs=6
diff --git a/src/login/logind-button.h b/src/login/logind-button.h
index 80d93c7e6..95bb6a524 100644
--- a/src/login/logind-button.h
+++ b/src/login/logind-button.h
@@ -5,7 +5,7 @@
/***
This file is part of systemd.
- Copyright 2012 Lennart Poettering
+ Copyright 2014 Daniel Mack
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
@@ -21,26 +21,24 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-typedef struct Button Button;
+typedef struct BusEndpoint BusEndpoint;
+typedef struct BusEndpointPolicy BusEndpointPolicy;
-#include "logind.h"
-
-struct Button {
- Manager *manager;
-
- sd_event_source *io_event_source;
- sd_event_source *check_event_source;
+#include "hashmap.h"
+#include "bus-policy.h"
+struct BusEndpointPolicy {
char *name;
- char *seat;
- int fd;
+ BusPolicyAccess access;
+};
- bool lid_closed;
- bool docked;
+struct BusEndpoint {
+ Hashmap *policy_hash;
};
-Button* button_new(Manager *m, const char *name);
-void button_free(Button*b);
-int button_open(Button *b);
-int button_set_seat(Button *b, const char *sn);
-int button_check_switches(Button *b);
+// UNNEEDED int bus_endpoint_new(BusEndpoint **ep);
+void bus_endpoint_free(BusEndpoint *endpoint);
+
+// UNNEEDED int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess access);
+
+int bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep);
diff --git a/src/login/logind.c b/src/login/logind.c
index 73ba53d5b..575bcee5b 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -34,6 +34,7 @@
#include "udev-util.h"
#include "formats-util.h"
#include "label.h"
+#include "label.h"
static void manager_free(Manager *m);
@@ -1123,8 +1124,8 @@ static int manager_run(Manager *m) {
static int manager_parse_config_file(Manager *m) {
assert(m);
- return config_parse_many("/etc/systemd/logind.conf",
- CONF_DIRS_NULSTR("systemd/logind.conf"),
+ return config_parse_many("/etc/elogind/elogind.conf",
+ CONF_DIRS_NULSTR("elogind/elogind.conf"),
"Login\0",
config_item_perf_lookup, logind_gperf_lookup,
false, m);
diff --git a/src/shared/MurmurHash2.c b/src/shared/MurmurHash2.c
deleted file mode 100644
index 2f4149dbe..000000000
--- a/src/shared/MurmurHash2.c
+++ /dev/null
@@ -1,86 +0,0 @@
-//-----------------------------------------------------------------------------
-// MurmurHash2 was written by Austin Appleby, and is placed in the public
-// domain. The author hereby disclaims copyright to this source code.
-
-// Note - This code makes a few assumptions about how your machine behaves -
-
-// 1. We can read a 4-byte value from any address without crashing
-// 2. sizeof(int) == 4
-
-// And it has a few limitations -
-
-// 1. It will not work incrementally.
-// 2. It will not produce the same results on little-endian and big-endian
-// machines.
-
-#include "MurmurHash2.h"
-
-//-----------------------------------------------------------------------------
-// Platform-specific functions and macros
-
-// Microsoft Visual Studio
-
-#if defined(_MSC_VER)
-
-#define BIG_CONSTANT(x) (x)
-
-// Other compilers
-
-#else // defined(_MSC_VER)
-
-#define BIG_CONSTANT(x) (x##LLU)
-
-#endif // !defined(_MSC_VER)
-
-//-----------------------------------------------------------------------------
-
-uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed )
-{
- // 'm' and 'r' are mixing constants generated offline.
- // They're not really 'magic', they just happen to work well.
-
- const uint32_t m = 0x5bd1e995;
- const int r = 24;
-
- // Initialize the hash to a 'random' value
-
- uint32_t h = seed ^ len;
-
- // Mix 4 bytes at a time into the hash
-
- const unsigned char * data = (const unsigned char *)key;
-
- while(len >= 4)
- {
- uint32_t k = *(uint32_t*)data;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- // Handle the last few bytes of the input array
-
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
-
- // Do a few final mixes of the hash to ensure the last few
- // bytes are well-incorporated.
-
- h ^= h >> 13;
- h *= m;
- h ^= h >> 15;
-
- return h;
-}
diff --git a/src/shared/MurmurHash2.h b/src/shared/MurmurHash2.h
deleted file mode 100644
index 93362dd48..000000000
--- a/src/shared/MurmurHash2.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//-----------------------------------------------------------------------------
-// MurmurHash2 was written by Austin Appleby, and is placed in the public
-// domain. The author hereby disclaims copyright to this source code.
-
-#ifndef _MURMURHASH2_H_
-#define _MURMURHASH2_H_
-
-//-----------------------------------------------------------------------------
-// Platform-specific functions and macros
-
-// Microsoft Visual Studio
-
-#if defined(_MSC_VER)
-
-typedef unsigned char uint8_t;
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
-
-// Other compilers
-
-#else // defined(_MSC_VER)
-
-#include <stdint.h>
-
-#endif // !defined(_MSC_VER)
-
-//-----------------------------------------------------------------------------
-
-uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed );
-
-//-----------------------------------------------------------------------------
-
-#endif // _MURMURHASH2_H_
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index bd8c98875..ad0e481b9 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -95,6 +95,8 @@ int calc_acl_mask_if_needed(acl_t *acl_p) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int add_base_acls_if_needed(acl_t *acl_p, const char *path) {
acl_entry_t i;
int r;
@@ -395,3 +397,4 @@ int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl) {
old = NULL;
return 0;
}
+#endif // 0
diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h
index cf612e872..03358b46a 100644
--- a/src/shared/acl-util.h
+++ b/src/shared/acl-util.h
@@ -31,10 +31,10 @@
int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
int calc_acl_mask_if_needed(acl_t *acl_p);
-int add_base_acls_if_needed(acl_t *acl_p, const char *path);
-int acl_search_groups(const char* path, char ***ret_groups);
-int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
-int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl);
+// UNNEEDED int add_base_acls_if_needed(acl_t *acl_p, const char *path);
+// UNNEEDED int acl_search_groups(const char* path, char ***ret_groups);
+// UNNEEDED int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
+// UNNEEDED int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl);
/* acl_free takes multiple argument types.
* Multiple cleanup functions are necessary. */
diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c
deleted file mode 100644
index 64e50401b..000000000
--- a/src/shared/acpi-fpdt.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <util.h>
-#include <fileio.h>
-#include <time-util.h>
-#include <acpi-fpdt.h>
-
-struct acpi_table_header {
- char signature[4];
- uint32_t length;
- uint8_t revision;
- uint8_t checksum;
- char oem_id[6];
- char oem_table_id[8];
- uint32_t oem_revision;
- char asl_compiler_id[4];
- uint32_t asl_compiler_revision;
-};
-
-enum {
- ACPI_FPDT_TYPE_BOOT = 0,
- ACPI_FPDT_TYPE_S3PERF = 1,
-};
-
-struct acpi_fpdt_header {
- uint16_t type;
- uint8_t length;
- uint8_t revision;
- uint8_t reserved[4];
- uint64_t ptr;
-};
-
-struct acpi_fpdt_boot_header {
- char signature[4];
- uint32_t length;
-};
-
-enum {
- ACPI_FPDT_S3PERF_RESUME_REC = 0,
- ACPI_FPDT_S3PERF_SUSPEND_REC = 1,
- ACPI_FPDT_BOOT_REC = 2,
-};
-
-struct acpi_fpdt_boot {
- uint16_t type;
- uint8_t length;
- uint8_t revision;
- uint8_t reserved[4];
- uint64_t reset_end;
- uint64_t load_start;
- uint64_t startup_start;
- uint64_t exit_services_entry;
- uint64_t exit_services_exit;
-};
-
-int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
- _cleanup_free_ char *buf = NULL;
- struct acpi_table_header *tbl;
- size_t l = 0;
- struct acpi_fpdt_header *rec;
- int r;
- uint64_t ptr = 0;
- _cleanup_close_ int fd = -1;
- struct acpi_fpdt_boot_header hbrec;
- struct acpi_fpdt_boot brec;
-
- r = read_full_file("/sys/firmware/acpi/tables/FPDT", &buf, &l);
- if (r < 0)
- return r;
-
- if (l < sizeof(struct acpi_table_header) + sizeof(struct acpi_fpdt_header))
- return -EINVAL;
-
- tbl = (struct acpi_table_header *)buf;
- if (l != tbl->length)
- return -EINVAL;
-
- if (memcmp(tbl->signature, "FPDT", 4) != 0)
- return -EINVAL;
-
- /* find Firmware Basic Boot Performance Pointer Record */
- for (rec = (struct acpi_fpdt_header *)(buf + sizeof(struct acpi_table_header));
- (char *)rec < buf + l;
- rec = (struct acpi_fpdt_header *)((char *)rec + rec->length)) {
- if (rec->length <= 0)
- break;
- if (rec->type != ACPI_FPDT_TYPE_BOOT)
- continue;
- if (rec->length != sizeof(struct acpi_fpdt_header))
- continue;
-
- ptr = rec->ptr;
- break;
- }
-
- if (ptr == 0)
- return -EINVAL;
-
- /* read Firmware Basic Boot Performance Data Record */
- fd = open("/dev/mem", O_CLOEXEC|O_RDONLY);
- if (fd < 0)
- return -errno;
-
- l = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
- if (l != sizeof(struct acpi_fpdt_boot_header))
- return -EINVAL;
-
- if (memcmp(hbrec.signature, "FBPT", 4) != 0)
- return -EINVAL;
-
- if (hbrec.length < sizeof(struct acpi_fpdt_boot_header) + sizeof(struct acpi_fpdt_boot))
- return -EINVAL;
-
- l = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
- if (l != sizeof(struct acpi_fpdt_boot))
- return -EINVAL;
-
- if (brec.length != sizeof(struct acpi_fpdt_boot))
- return -EINVAL;
-
- if (brec.type != ACPI_FPDT_BOOT_REC)
- return -EINVAL;
-
- if (brec.startup_start == 0 || brec.exit_services_exit < brec.startup_start)
- return -EINVAL;
- if (brec.exit_services_exit > NSEC_PER_HOUR)
- return -EINVAL;
-
- if (loader_start)
- *loader_start = brec.startup_start / 1000;
- if (loader_exit)
- *loader_exit = brec.exit_services_exit / 1000;
-
- return 0;
-}
diff --git a/src/shared/acpi-fpdt.h b/src/shared/acpi-fpdt.h
deleted file mode 100644
index fc4fe6f10..000000000
--- a/src/shared/acpi-fpdt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <time-util.h>
-
-int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit);
diff --git a/src/shared/af-list.c b/src/shared/af-list.c
deleted file mode 100644
index f396115a3..000000000
--- a/src/shared/af-list.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/socket.h>
-#include <string.h>
-
-#include "util.h"
-#include "af-list.h"
-
-static const struct af_name* lookup_af(register const char *str, register unsigned int len);
-
-#include "af-to-name.h"
-#include "af-from-name.h"
-
-const char *af_to_name(int id) {
-
- if (id <= 0)
- return NULL;
-
- if (id >= (int) ELEMENTSOF(af_names))
- return NULL;
-
- return af_names[id];
-}
-
-int af_from_name(const char *name) {
- const struct af_name *sc;
-
- assert(name);
-
- sc = lookup_af(name, strlen(name));
- if (!sc)
- return AF_UNSPEC;
-
- return sc->id;
-}
-
-int af_max(void) {
- return ELEMENTSOF(af_names);
-}
diff --git a/src/shared/architecture.c b/src/shared/architecture.c
deleted file mode 100644
index 8e72e7a36..000000000
--- a/src/shared/architecture.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/utsname.h>
-
-#include "architecture.h"
-
-int uname_architecture(void) {
-
- /* Return a sanitized enum identifying the architecture we are
- * running on. This is based on uname(), and the user may
- * hence control what this returns by using
- * personality(). This puts the user in control on systems
- * that can run binaries of multiple architectures.
- *
- * We do not translate the string returned by uname()
- * 1:1. Instead we try to clean it up and break down the
- * confusion on x86 and arm in particular.
- *
- * We do not try to distinguish CPUs not CPU features, but
- * actual architectures, i.e. that have genuinely different
- * code. */
-
- static const struct {
- const char *machine;
- int arch;
- } arch_map[] = {
-#if defined(__x86_64__) || defined(__i386__)
- { "x86_64", ARCHITECTURE_X86_64 },
- { "i686", ARCHITECTURE_X86 },
- { "i586", ARCHITECTURE_X86 },
- { "i486", ARCHITECTURE_X86 },
- { "i386", ARCHITECTURE_X86 },
-#elif defined(__powerpc__) || defined(__powerpc64__)
- { "ppc64", ARCHITECTURE_PPC64 },
- { "ppc64le", ARCHITECTURE_PPC64_LE },
- { "ppc", ARCHITECTURE_PPC },
- { "ppcle", ARCHITECTURE_PPC_LE },
-#elif defined(__ia64__)
- { "ia64", ARCHITECTURE_IA64 },
-#elif defined(__hppa__) || defined(__hppa64__)
- { "parisc64", ARCHITECTURE_PARISC64 },
- { "parisc", ARCHITECTURE_PARISC },
-#elif defined(__s390__) || defined(__s390x__)
- { "s390x", ARCHITECTURE_S390X },
- { "s390", ARCHITECTURE_S390 },
-#elif defined(__sparc__) || defined(__sparc64__)
- { "sparc64", ARCHITECTURE_SPARC64 },
- { "sparc", ARCHITECTURE_SPARC },
-#elif defined(__mips__) || defined(__mips64__)
- { "mips64", ARCHITECTURE_MIPS64 },
- { "mips", ARCHITECTURE_MIPS },
-#elif defined(__alpha__)
- { "alpha" , ARCHITECTURE_ALPHA },
-#elif defined(__arm__) || defined(__aarch64__)
- { "aarch64", ARCHITECTURE_ARM64 },
- { "aarch64_be", ARCHITECTURE_ARM64_BE },
- { "armv4l", ARCHITECTURE_ARM },
- { "armv4b", ARCHITECTURE_ARM_BE },
- { "armv4tl", ARCHITECTURE_ARM },
- { "armv4tb", ARCHITECTURE_ARM_BE },
- { "armv5tl", ARCHITECTURE_ARM },
- { "armv5tb", ARCHITECTURE_ARM_BE },
- { "armv5tel", ARCHITECTURE_ARM },
- { "armv5teb" , ARCHITECTURE_ARM_BE },
- { "armv5tejl", ARCHITECTURE_ARM },
- { "armv5tejb", ARCHITECTURE_ARM_BE },
- { "armv6l", ARCHITECTURE_ARM },
- { "armv6b", ARCHITECTURE_ARM_BE },
- { "armv7l", ARCHITECTURE_ARM },
- { "armv7b", ARCHITECTURE_ARM_BE },
- { "armv7ml", ARCHITECTURE_ARM },
- { "armv7mb", ARCHITECTURE_ARM_BE },
- { "armv4l", ARCHITECTURE_ARM },
- { "armv4b", ARCHITECTURE_ARM_BE },
- { "armv4tl", ARCHITECTURE_ARM },
- { "armv4tb", ARCHITECTURE_ARM_BE },
- { "armv5tl", ARCHITECTURE_ARM },
- { "armv5tb", ARCHITECTURE_ARM_BE },
- { "armv5tel", ARCHITECTURE_ARM },
- { "armv5teb", ARCHITECTURE_ARM_BE },
- { "armv5tejl", ARCHITECTURE_ARM },
- { "armv5tejb", ARCHITECTURE_ARM_BE },
- { "armv6l", ARCHITECTURE_ARM },
- { "armv6b", ARCHITECTURE_ARM_BE },
- { "armv7l", ARCHITECTURE_ARM },
- { "armv7b", ARCHITECTURE_ARM_BE },
- { "armv7ml", ARCHITECTURE_ARM },
- { "armv7mb", ARCHITECTURE_ARM_BE },
- { "armv8l", ARCHITECTURE_ARM },
- { "armv8b", ARCHITECTURE_ARM_BE },
-#elif defined(__sh__) || defined(__sh64__)
- { "sh5", ARCHITECTURE_SH64 },
- { "sh2", ARCHITECTURE_SH },
- { "sh2a", ARCHITECTURE_SH },
- { "sh3", ARCHITECTURE_SH },
- { "sh4", ARCHITECTURE_SH },
- { "sh4a", ARCHITECTURE_SH },
-#elif defined(__m68k__)
- { "m68k", ARCHITECTURE_M68K },
-#elif defined(__tilegx__)
- { "tilegx", ARCHITECTURE_TILEGX },
-#elif defined(__cris__)
- { "crisv32", ARCHITECTURE_CRIS },
-#else
-#error "Please register your architecture here!"
-#endif
- };
-
- static int cached = _ARCHITECTURE_INVALID;
- struct utsname u;
- unsigned i;
-
- if (cached != _ARCHITECTURE_INVALID)
- return cached;
-
- assert_se(uname(&u) >= 0);
-
- for (i = 0; i < ELEMENTSOF(arch_map); i++)
- if (streq(arch_map[i].machine, u.machine))
- return cached = arch_map[i].arch;
-
- assert_not_reached("Couldn't identify architecture. You need to patch systemd.");
- return _ARCHITECTURE_INVALID;
-}
-
-static const char *const architecture_table[_ARCHITECTURE_MAX] = {
- [ARCHITECTURE_X86] = "x86",
- [ARCHITECTURE_X86_64] = "x86-64",
- [ARCHITECTURE_PPC] = "ppc",
- [ARCHITECTURE_PPC_LE] = "ppc-le",
- [ARCHITECTURE_PPC64] = "ppc64",
- [ARCHITECTURE_PPC64_LE] = "ppc64-le",
- [ARCHITECTURE_IA64] = "ia64",
- [ARCHITECTURE_PARISC] = "parisc",
- [ARCHITECTURE_PARISC64] = "parisc64",
- [ARCHITECTURE_S390] = "s390",
- [ARCHITECTURE_S390X] = "s390x",
- [ARCHITECTURE_SPARC] = "sparc",
- [ARCHITECTURE_SPARC64] = "sparc64",
- [ARCHITECTURE_MIPS] = "mips",
- [ARCHITECTURE_MIPS_LE] = "mips-le",
- [ARCHITECTURE_MIPS64] = "mips64",
- [ARCHITECTURE_MIPS64_LE] = "mips64-le",
- [ARCHITECTURE_ALPHA] = "alpha",
- [ARCHITECTURE_ARM] = "arm",
- [ARCHITECTURE_ARM_BE] = "arm-be",
- [ARCHITECTURE_ARM64] = "arm64",
- [ARCHITECTURE_ARM64_BE] = "arm64-be",
- [ARCHITECTURE_SH] = "sh",
- [ARCHITECTURE_SH64] = "sh64",
- [ARCHITECTURE_M68K] = "m68k",
- [ARCHITECTURE_TILEGX] = "tilegx",
- [ARCHITECTURE_CRIS] = "cris",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(architecture, int);
diff --git a/src/shared/arphrd-list.c b/src/shared/arphrd-list.c
deleted file mode 100644
index 284043cd9..000000000
--- a/src/shared/arphrd-list.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <net/if_arp.h>
-#include <string.h>
-
-#include "util.h"
-#include "arphrd-list.h"
-
-static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
-
-#include "arphrd-to-name.h"
-#include "arphrd-from-name.h"
-
-const char *arphrd_to_name(int id) {
-
- if (id <= 0)
- return NULL;
-
- if (id >= (int) ELEMENTSOF(arphrd_names))
- return NULL;
-
- return arphrd_names[id];
-}
-
-int arphrd_from_name(const char *name) {
- const struct arphrd_name *sc;
-
- assert(name);
-
- sc = lookup_arphrd(name, strlen(name));
- if (!sc)
- return 0;
-
- return sc->id;
-}
-
-int arphrd_max(void) {
- return ELEMENTSOF(arphrd_names);
-}
diff --git a/src/shared/arphrd-list.h b/src/shared/arphrd-list.h
deleted file mode 100644
index 5ca182c9e..000000000
--- a/src/shared/arphrd-list.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-const char *arphrd_to_name(int id);
-int arphrd_from_name(const char *name);
-
-int arphrd_max(void);
diff --git a/src/shared/async.c b/src/shared/async.c
deleted file mode 100644
index 7725e6d7d..000000000
--- a/src/shared/async.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <pthread.h>
-#include <unistd.h>
-
-#include "async.h"
-#include "log.h"
-#include "util.h"
-
-int asynchronous_job(void* (*func)(void *p), void *arg) {
- pthread_attr_t a;
- pthread_t t;
- int r;
-
- /* It kinda sucks that we have to resort to threads to
- * implement an asynchronous sync(), but well, such is
- * life.
- *
- * Note that issuing this command right before exiting a
- * process will cause the process to wait for the sync() to
- * complete. This function hence is nicely asynchronous really
- * only in long running processes. */
-
- r = pthread_attr_init(&a);
- if (r > 0)
- return -r;
-
- r = pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
- if (r > 0)
- goto finish;
-
- r = pthread_create(&t, &a, func, arg);
-
-finish:
- pthread_attr_destroy(&a);
- return -r;
-}
-
-static void *sync_thread(void *p) {
- sync();
- return NULL;
-}
-
-int asynchronous_sync(void) {
- log_debug("Spawning new thread for sync");
-
- return asynchronous_job(sync_thread, NULL);
-}
-
-static void *close_thread(void *p) {
- assert_se(close_nointr(PTR_TO_INT(p)) != -EBADF);
- return NULL;
-}
-
-int asynchronous_close(int fd) {
- int r;
-
- /* This is supposed to behave similar to safe_close(), but
- * actually invoke close() asynchronously, so that it will
- * never block. Ideally the kernel would have an API for this,
- * but it doesn't, so we work around it, and hide this as a
- * far away as we can. */
-
- if (fd >= 0) {
- PROTECT_ERRNO;
-
- r = asynchronous_job(close_thread, INT_TO_PTR(fd));
- if (r < 0)
- assert_se(close_nointr(fd) != -EBADF);
- }
-
- return -1;
-}
diff --git a/src/shared/async.h b/src/shared/async.h
deleted file mode 100644
index 7f1ef7953..000000000
--- a/src/shared/async.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-int asynchronous_job(void* (*func)(void *p), void *arg);
-
-int asynchronous_sync(void);
-int asynchronous_close(int fd);
diff --git a/src/shared/barrier.c b/src/shared/barrier.c
deleted file mode 100644
index 436ba9598..000000000
--- a/src/shared/barrier.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/eventfd.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "barrier.h"
-#include "macro.h"
-#include "util.h"
-
-/**
- * Barriers
- * This barrier implementation provides a simple synchronization method based
- * on file-descriptors that can safely be used between threads and processes. A
- * barrier object contains 2 shared counters based on eventfd. Both processes
- * can now place barriers and wait for the other end to reach a random or
- * specific barrier.
- * Barriers are numbered, so you can either wait for the other end to reach any
- * barrier or the last barrier that you placed. This way, you can use barriers
- * for one-way *and* full synchronization. Note that even-though barriers are
- * numbered, these numbers are internal and recycled once both sides reached the
- * same barrier (implemented as a simple signed counter). It is thus not
- * possible to address barriers by their ID.
- *
- * Barrier-API: Both ends can place as many barriers via barrier_place() as
- * they want and each pair of barriers on both sides will be implicitly linked.
- * Each side can use the barrier_wait/sync_*() family of calls to wait for the
- * other side to place a specific barrier. barrier_wait_next() waits until the
- * other side calls barrier_place(). No links between the barriers are
- * considered and this simply serves as most basic asynchronous barrier.
- * barrier_sync_next() is like barrier_wait_next() and waits for the other side
- * to place their next barrier via barrier_place(). However, it only waits for
- * barriers that are linked to a barrier we already placed. If the other side
- * already placed more barriers than we did, barrier_sync_next() returns
- * immediately.
- * barrier_sync() extends barrier_sync_next() and waits until the other end
- * placed as many barriers via barrier_place() as we did. If they already placed
- * as many as we did (or more), it returns immediately.
- *
- * Additionally to basic barriers, an abortion event is available.
- * barrier_abort() places an abortion event that cannot be undone. An abortion
- * immediately cancels all placed barriers and replaces them. Any running and
- * following wait/sync call besides barrier_wait_abortion() will immediately
- * return false on both sides (otherwise, they always return true).
- * barrier_abort() can be called multiple times on both ends and will be a
- * no-op if already called on this side.
- * barrier_wait_abortion() can be used to wait for the other side to call
- * barrier_abort() and is the only wait/sync call that does not return
- * immediately if we aborted outself. It only returns once the other side
- * called barrier_abort().
- *
- * Barriers can be used for in-process and inter-process synchronization.
- * However, for in-process synchronization you could just use mutexes.
- * Therefore, main target is IPC and we require both sides to *not* share the FD
- * table. If that's given, barriers provide target tracking: If the remote side
- * exit()s, an abortion event is implicitly queued on the other side. This way,
- * a sync/wait call will be woken up if the remote side crashed or exited
- * unexpectedly. However, note that these abortion events are only queued if the
- * barrier-queue has been drained. Therefore, it is safe to place a barrier and
- * exit. The other side can safely wait on the barrier even though the exit
- * queued an abortion event. Usually, the abortion event would overwrite the
- * barrier, however, that's not true for exit-abortion events. Those are only
- * queued if the barrier-queue is drained (thus, the receiving side has placed
- * more barriers than the remote side).
- */
-
-/**
- * barrier_create() - Initialize a barrier object
- * @obj: barrier to initialize
- *
- * This initializes a barrier object. The caller is responsible of allocating
- * the memory and keeping it valid. The memory does not have to be zeroed
- * beforehand.
- * Two eventfd objects are allocated for each barrier. If allocation fails, an
- * error is returned.
- *
- * If this function fails, the barrier is reset to an invalid state so it is
- * safe to call barrier_destroy() on the object regardless whether the
- * initialization succeeded or not.
- *
- * The caller is responsible to destroy the object via barrier_destroy() before
- * releasing the underlying memory.
- *
- * Returns: 0 on success, negative error code on failure.
- */
-int barrier_create(Barrier *b) {
- _cleanup_(barrier_destroyp) Barrier *staging = b;
- int r;
-
- assert(b);
-
- b->me = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
- if (b->me < 0)
- return -errno;
-
- b->them = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
- if (b->them < 0)
- return -errno;
-
- r = pipe2(b->pipe, O_CLOEXEC | O_NONBLOCK);
- if (r < 0)
- return -errno;
-
- staging = NULL;
- return 0;
-}
-
-/**
- * barrier_destroy() - Destroy a barrier object
- * @b: barrier to destroy or NULL
- *
- * This destroys a barrier object that has previously been passed to
- * barrier_create(). The object is released and reset to invalid
- * state. Therefore, it is safe to call barrier_destroy() multiple
- * times or even if barrier_create() failed. However, barrier must be
- * always initialized with BARRIER_NULL.
- *
- * If @b is NULL, this is a no-op.
- */
-void barrier_destroy(Barrier *b) {
- if (!b)
- return;
-
- b->me = safe_close(b->me);
- b->them = safe_close(b->them);
- safe_close_pair(b->pipe);
- b->barriers = 0;
-}
-
-/**
- * barrier_set_role() - Set the local role of the barrier
- * @b: barrier to operate on
- * @role: role to set on the barrier
- *
- * This sets the roles on a barrier object. This is needed to know
- * which side of the barrier you're on. Usually, the parent creates
- * the barrier via barrier_create() and then calls fork() or clone().
- * Therefore, the FDs are duplicated and the child retains the same
- * barrier object.
- *
- * Both sides need to call barrier_set_role() after fork() or clone()
- * are done. If this is not done, barriers will not work correctly.
- *
- * Note that barriers could be supported without fork() or clone(). However,
- * this is currently not needed so it hasn't been implemented.
- */
-void barrier_set_role(Barrier *b, unsigned int role) {
- int fd;
-
- assert(b);
- assert(role == BARRIER_PARENT || role == BARRIER_CHILD);
- /* make sure this is only called once */
- assert(b->pipe[0] >= 0 && b->pipe[1] >= 0);
-
- if (role == BARRIER_PARENT)
- b->pipe[1] = safe_close(b->pipe[1]);
- else {
- b->pipe[0] = safe_close(b->pipe[0]);
-
- /* swap me/them for children */
- fd = b->me;
- b->me = b->them;
- b->them = fd;
- }
-}
-
-/* places barrier; returns false if we aborted, otherwise true */
-static bool barrier_write(Barrier *b, uint64_t buf) {
- ssize_t len;
-
- /* prevent new sync-points if we already aborted */
- if (barrier_i_aborted(b))
- return false;
-
- do {
- len = write(b->me, &buf, sizeof(buf));
- } while (len < 0 && IN_SET(errno, EAGAIN, EINTR));
-
- if (len != sizeof(buf))
- goto error;
-
- /* lock if we aborted */
- if (buf >= (uint64_t)BARRIER_ABORTION) {
- if (barrier_they_aborted(b))
- b->barriers = BARRIER_WE_ABORTED;
- else
- b->barriers = BARRIER_I_ABORTED;
- } else if (!barrier_is_aborted(b))
- b->barriers += buf;
-
- return !barrier_i_aborted(b);
-
-error:
- /* If there is an unexpected error, we have to make this fatal. There
- * is no way we can recover from sync-errors. Therefore, we close the
- * pipe-ends and treat this as abortion. The other end will notice the
- * pipe-close and treat it as abortion, too. */
-
- safe_close_pair(b->pipe);
- b->barriers = BARRIER_WE_ABORTED;
- return false;
-}
-
-/* waits for barriers; returns false if they aborted, otherwise true */
-static bool barrier_read(Barrier *b, int64_t comp) {
- if (barrier_they_aborted(b))
- return false;
-
- while (b->barriers > comp) {
- struct pollfd pfd[2] = {
- { .fd = b->pipe[0] >= 0 ? b->pipe[0] : b->pipe[1],
- .events = POLLHUP },
- { .fd = b->them,
- .events = POLLIN }};
- uint64_t buf;
- int r;
-
- r = poll(pfd, 2, -1);
- if (r < 0 && IN_SET(errno, EAGAIN, EINTR))
- continue;
- else if (r < 0)
- goto error;
-
- if (pfd[1].revents) {
- ssize_t len;
-
- /* events on @them signal new data for us */
- len = read(b->them, &buf, sizeof(buf));
- if (len < 0 && IN_SET(errno, EAGAIN, EINTR))
- continue;
-
- if (len != sizeof(buf))
- goto error;
- } else if (pfd[0].revents & (POLLHUP | POLLERR | POLLNVAL))
- /* POLLHUP on the pipe tells us the other side exited.
- * We treat this as implicit abortion. But we only
- * handle it if there's no event on the eventfd. This
- * guarantees that exit-abortions do not overwrite real
- * barriers. */
- buf = BARRIER_ABORTION;
- else
- continue;
-
- /* lock if they aborted */
- if (buf >= (uint64_t)BARRIER_ABORTION) {
- if (barrier_i_aborted(b))
- b->barriers = BARRIER_WE_ABORTED;
- else
- b->barriers = BARRIER_THEY_ABORTED;
- } else if (!barrier_is_aborted(b))
- b->barriers -= buf;
- }
-
- return !barrier_they_aborted(b);
-
-error:
- /* If there is an unexpected error, we have to make this fatal. There
- * is no way we can recover from sync-errors. Therefore, we close the
- * pipe-ends and treat this as abortion. The other end will notice the
- * pipe-close and treat it as abortion, too. */
-
- safe_close_pair(b->pipe);
- b->barriers = BARRIER_WE_ABORTED;
- return false;
-}
-
-/**
- * barrier_place() - Place a new barrier
- * @b: barrier object
- *
- * This places a new barrier on the barrier object. If either side already
- * aborted, this is a no-op and returns "false". Otherwise, the barrier is
- * placed and this returns "true".
- *
- * Returns: true if barrier was placed, false if either side aborted.
- */
-bool barrier_place(Barrier *b) {
- assert(b);
-
- if (barrier_is_aborted(b))
- return false;
-
- barrier_write(b, BARRIER_SINGLE);
- return true;
-}
-
-/**
- * barrier_abort() - Abort the synchronization
- * @b: barrier object to abort
- *
- * This aborts the barrier-synchronization. If barrier_abort() was already
- * called on this side, this is a no-op. Otherwise, the barrier is put into the
- * ABORT-state and will stay there. The other side is notified about the
- * abortion. Any following attempt to place normal barriers or to wait on normal
- * barriers will return immediately as "false".
- *
- * You can wait for the other side to call barrier_abort(), too. Use
- * barrier_wait_abortion() for that.
- *
- * Returns: false if the other side already aborted, true otherwise.
- */
-bool barrier_abort(Barrier *b) {
- assert(b);
-
- barrier_write(b, BARRIER_ABORTION);
- return !barrier_they_aborted(b);
-}
-
-/**
- * barrier_wait_next() - Wait for the next barrier of the other side
- * @b: barrier to operate on
- *
- * This waits until the other side places its next barrier. This is independent
- * of any barrier-links and just waits for any next barrier of the other side.
- *
- * If either side aborted, this returns false.
- *
- * Returns: false if either side aborted, true otherwise.
- */
-bool barrier_wait_next(Barrier *b) {
- assert(b);
-
- if (barrier_is_aborted(b))
- return false;
-
- barrier_read(b, b->barriers - 1);
- return !barrier_is_aborted(b);
-}
-
-/**
- * barrier_wait_abortion() - Wait for the other side to abort
- * @b: barrier to operate on
- *
- * This waits until the other side called barrier_abort(). This can be called
- * regardless whether the local side already called barrier_abort() or not.
- *
- * If the other side has already aborted, this returns immediately.
- *
- * Returns: false if the local side aborted, true otherwise.
- */
-bool barrier_wait_abortion(Barrier *b) {
- assert(b);
-
- barrier_read(b, BARRIER_THEY_ABORTED);
- return !barrier_i_aborted(b);
-}
-
-/**
- * barrier_sync_next() - Wait for the other side to place a next linked barrier
- * @b: barrier to operate on
- *
- * This is like barrier_wait_next() and waits for the other side to call
- * barrier_place(). However, this only waits for linked barriers. That means, if
- * the other side already placed more barriers than (or as much as) we did, this
- * returns immediately instead of waiting.
- *
- * If either side aborted, this returns false.
- *
- * Returns: false if either side aborted, true otherwise.
- */
-bool barrier_sync_next(Barrier *b) {
- assert(b);
-
- if (barrier_is_aborted(b))
- return false;
-
- barrier_read(b, MAX((int64_t)0, b->barriers - 1));
- return !barrier_is_aborted(b);
-}
-
-/**
- * barrier_sync() - Wait for the other side to place as many barriers as we did
- * @b: barrier to operate on
- *
- * This is like barrier_sync_next() but waits for the other side to call
- * barrier_place() as often as we did (in total). If they already placed as much
- * as we did (or more), this returns immediately instead of waiting.
- *
- * If either side aborted, this returns false.
- *
- * Returns: false if either side aborted, true otherwise.
- */
-bool barrier_sync(Barrier *b) {
- assert(b);
-
- if (barrier_is_aborted(b))
- return false;
-
- barrier_read(b, 0);
- return !barrier_is_aborted(b);
-}
diff --git a/src/shared/barrier.h b/src/shared/barrier.h
deleted file mode 100644
index b8954694d..000000000
--- a/src/shared/barrier.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-
-#include "macro.h"
-
-/* See source file for an API description. */
-
-typedef struct Barrier Barrier;
-
-enum {
- BARRIER_SINGLE = 1LL,
- BARRIER_ABORTION = INT64_MAX,
-
- /* bias values to store state; keep @WE < @THEY < @I */
- BARRIER_BIAS = INT64_MIN,
- BARRIER_WE_ABORTED = BARRIER_BIAS + 1LL,
- BARRIER_THEY_ABORTED = BARRIER_BIAS + 2LL,
- BARRIER_I_ABORTED = BARRIER_BIAS + 3LL,
-};
-
-enum {
- BARRIER_PARENT,
- BARRIER_CHILD,
-};
-
-struct Barrier {
- int me;
- int them;
- int pipe[2];
- int64_t barriers;
-};
-
-#define BARRIER_NULL {-1, -1, {-1, -1}, 0}
-
-int barrier_create(Barrier *obj);
-void barrier_destroy(Barrier *b);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(Barrier*, barrier_destroy);
-
-void barrier_set_role(Barrier *b, unsigned int role);
-
-bool barrier_place(Barrier *b);
-bool barrier_abort(Barrier *b);
-
-bool barrier_wait_next(Barrier *b);
-bool barrier_wait_abortion(Barrier *b);
-bool barrier_sync_next(Barrier *b);
-bool barrier_sync(Barrier *b);
-
-static inline bool barrier_i_aborted(Barrier *b) {
- return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_WE_ABORTED;
-}
-
-static inline bool barrier_they_aborted(Barrier *b) {
- return b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED;
-}
-
-static inline bool barrier_we_aborted(Barrier *b) {
- return b->barriers == BARRIER_WE_ABORTED;
-}
-
-static inline bool barrier_is_aborted(Barrier *b) {
- return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED;
-}
-
-static inline bool barrier_place_and_sync(Barrier *b) {
- (void) barrier_place(b);
- return barrier_sync(b);
-}
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
deleted file mode 100644
index ab6fc171b..000000000
--- a/src/shared/base-filesystem.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "base-filesystem.h"
-#include "log.h"
-#include "macro.h"
-#include "util.h"
-
-typedef struct BaseFilesystem {
- const char *dir;
- mode_t mode;
- const char *target;
- const char *exists;
-} BaseFilesystem;
-
-static const BaseFilesystem table[] = {
- { "bin", 0, "usr/bin\0", NULL },
- { "lib", 0, "usr/lib\0", NULL },
- { "root", 0755, NULL, NULL },
- { "sbin", 0, "usr/sbin\0", NULL },
- { "usr", 0755, NULL, NULL },
- { "var", 0755, NULL, NULL },
- { "etc", 0755, NULL, NULL },
-#if defined(__i386__) || defined(__x86_64__)
- { "lib64", 0, "usr/lib/x86_64-linux-gnu\0"
- "usr/lib64\0", "ld-linux-x86-64.so.2" },
-#endif
-};
-
-int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
- _cleanup_close_ int fd = -1;
- unsigned i;
- int r = 0;
-
- fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
- if (fd < 0)
- return log_error_errno(errno, "Failed to open root file system: %m");
-
- for (i = 0; i < ELEMENTSOF(table); i ++) {
- if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
- continue;
-
- if (table[i].target) {
- const char *target = NULL, *s;
-
- /* check if one of the targets exists */
- NULSTR_FOREACH(s, table[i].target) {
- if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
- continue;
-
- /* check if a specific file exists at the target path */
- if (table[i].exists) {
- _cleanup_free_ char *p = NULL;
-
- p = strjoin(s, "/", table[i].exists, NULL);
- if (!p)
- return log_oom();
-
- if (faccessat(fd, p, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
- continue;
- }
-
- target = s;
- break;
- }
-
- if (!target)
- continue;
-
- r = symlinkat(target, fd, table[i].dir);
- if (r < 0 && errno != EEXIST)
- return log_error_errno(errno, "Failed to create symlink at %s/%s: %m", root, table[i].dir);
-
- if (uid != UID_INVALID || gid != UID_INVALID) {
- if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0)
- return log_error_errno(errno, "Failed to chown symlink at %s/%s: %m", root, table[i].dir);
- }
-
- continue;
- }
-
- RUN_WITH_UMASK(0000)
- r = mkdirat(fd, table[i].dir, table[i].mode);
- if (r < 0 && errno != EEXIST)
- return log_error_errno(errno, "Failed to create directory at %s/%s: %m", root, table[i].dir);
-
- if (uid != UID_INVALID || gid != UID_INVALID) {
- if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0)
- return log_error_errno(errno, "Failed to chown directory at %s/%s: %m", root, table[i].dir);
- }
- }
-
- return 0;
-}
diff --git a/src/shared/base-filesystem.h b/src/shared/base-filesystem.h
deleted file mode 100644
index 39a496090..000000000
--- a/src/shared/base-filesystem.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-
-int base_filesystem_create(const char *root, uid_t uid, gid_t gid);
diff --git a/src/shared/build.h b/src/shared/build.h
deleted file mode 100644
index c276154de..000000000
--- a/src/shared/build.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#ifdef HAVE_PAM
-#define _PAM_FEATURE_ "+PAM"
-#else
-#define _PAM_FEATURE_ "-PAM"
-#endif
-
-#ifdef HAVE_SELINUX
-#define _SELINUX_FEATURE_ "+SELINUX"
-#else
-#define _SELINUX_FEATURE_ "-SELINUX"
-#endif
-
-#ifdef HAVE_APPARMOR
-#define _APPARMOR_FEATURE_ "+APPARMOR"
-#else
-#define _APPARMOR_FEATURE_ "-APPARMOR"
-#endif
-
-#ifdef HAVE_SMACK
-#define _SMACK_FEATURE_ "+SMACK"
-#else
-#define _SMACK_FEATURE_ "-SMACK"
-#endif
-
-#ifdef HAVE_ACL
-#define _ACL_FEATURE_ "+ACL"
-#else
-#define _ACL_FEATURE_ "-ACL"
-#endif
-
-#ifdef HAVE_SECCOMP
-#define _SECCOMP_FEATURE_ "+SECCOMP"
-#else
-#define _SECCOMP_FEATURE_ "-SECCOMP"
-#endif
-
-#ifdef HAVE_BLKID
-#define _BLKID_FEATURE_ "+BLKID"
-#else
-#define _BLKID_FEATURE_ "-BLKID"
-#endif
-
-#define SYSTEMD_FEATURES \
- _PAM_FEATURE_ " " \
- _SELINUX_FEATURE_ " " \
- _APPARMOR_FEATURE_ " " \
- _SMACK_FEATURE_ " " \
- _ACL_FEATURE_ " " \
- _SECCOMP_FEATURE_ " " \
- _BLKID_FEATURE_
diff --git a/src/libelogind/sd-bus/bus-util.c b/src/shared/bus-util.c
index 2e4cd572f..d408e70eb 100644
--- a/src/libelogind/sd-bus/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1326,31 +1326,6 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
&u->job_path);
}
-int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error) {
- assert(m);
-
- if (r < 0) {
- if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
- sd_bus_reply_method_errno(m, r, error);
-
- } else if (sd_bus_error_is_set(error)) {
- if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
- sd_bus_reply_method_error(m, error);
- } else
- return r;
-
- log_debug("Failed to process message [type=%s sender=%s path=%s interface=%s member=%s signature=%s]: %s",
- bus_message_type_to_string(m->header->type),
- strna(m->sender),
- strna(m->path),
- strna(m->interface),
- strna(m->member),
- strna(m->root_container.signature),
- bus_error_message(error, r));
-
- return 1;
-}
-
int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignment) {
const char *eq, *field;
int r;
@@ -1886,6 +1861,8 @@ int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) {
return set_put_strdup(d->jobs, path);
}
+/// UNNEEDED by elogind
+#if 0
int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, UnitFileChange **changes, unsigned *n_changes) {
const char *type, *path, *source;
int r;
@@ -1915,6 +1892,7 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
return 0;
}
+#endif // 0
/**
* bus_path_encode_unique() - encode unique object path
@@ -2043,6 +2021,8 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
return 1;
}
+/// UNNEEDED by elogind
+#if 0
bool is_kdbus_wanted(void) {
_cleanup_free_ char *value = NULL;
#ifdef ENABLE_KDBUS
@@ -2076,3 +2056,4 @@ bool is_kdbus_available(void) {
return ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0;
}
+#endif // 0
diff --git a/src/libelogind/sd-bus/bus-util.h b/src/shared/bus-util.h
index 75b842891..da5874da7 100644
--- a/src/libelogind/sd-bus/bus-util.h
+++ b/src/shared/bus-util.h
@@ -181,8 +181,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_track*, sd_bus_track_unref);
SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \
SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags))
-int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
-
int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignment);
typedef struct BusWaitForJobs BusWaitForJobs;
@@ -194,10 +192,10 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet);
DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForJobs*, bus_wait_for_jobs_free);
-int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, UnitFileChange **changes, unsigned *n_changes);
+// UNNEEDED int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, UnitFileChange **changes, unsigned *n_changes);
int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path);
int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external);
-bool is_kdbus_wanted(void);
-bool is_kdbus_available(void);
+// UNNEEDED bool is_kdbus_wanted(void);
+// UNNEEDED bool is_kdbus_available(void);
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
deleted file mode 100644
index 2fde3e107..000000000
--- a/src/shared/calendarspec.c
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "calendarspec.h"
-
-#define BITS_WEEKDAYS 127
-
-static void free_chain(CalendarComponent *c) {
- CalendarComponent *n;
-
- while (c) {
- n = c->next;
- free(c);
- c = n;
- }
-}
-
-void calendar_spec_free(CalendarSpec *c) {
-
- if (!c)
- return;
-
- free_chain(c->year);
- free_chain(c->month);
- free_chain(c->day);
- free_chain(c->hour);
- free_chain(c->minute);
- free_chain(c->second);
-
- free(c);
-}
-
-static int component_compare(const void *_a, const void *_b) {
- CalendarComponent * const *a = _a, * const *b = _b;
-
- if ((*a)->value < (*b)->value)
- return -1;
- if ((*a)->value > (*b)->value)
- return 1;
-
- if ((*a)->repeat < (*b)->repeat)
- return -1;
- if ((*a)->repeat > (*b)->repeat)
- return 1;
-
- return 0;
-}
-
-static void sort_chain(CalendarComponent **c) {
- unsigned n = 0, k;
- CalendarComponent **b, *i, **j, *next;
-
- assert(c);
-
- for (i = *c; i; i = i->next)
- n++;
-
- if (n <= 1)
- return;
-
- j = b = alloca(sizeof(CalendarComponent*) * n);
- for (i = *c; i; i = i->next)
- *(j++) = i;
-
- qsort(b, n, sizeof(CalendarComponent*), component_compare);
-
- b[n-1]->next = NULL;
- next = b[n-1];
-
- /* Drop non-unique entries */
- for (k = n-1; k > 0; k--) {
- if (b[k-1]->value == next->value &&
- b[k-1]->repeat == next->repeat) {
- free(b[k-1]);
- continue;
- }
-
- b[k-1]->next = next;
- next = b[k-1];
- }
-
- *c = next;
-}
-
-static void fix_year(CalendarComponent *c) {
- /* Turns 12 → 2012, 89 → 1989 */
-
- while(c) {
- CalendarComponent *n = c->next;
-
- if (c->value >= 0 && c->value < 70)
- c->value += 2000;
-
- if (c->value >= 70 && c->value < 100)
- c->value += 1900;
-
- c = n;
- }
-}
-
-int calendar_spec_normalize(CalendarSpec *c) {
- assert(c);
-
- if (c->weekdays_bits <= 0 || c->weekdays_bits >= BITS_WEEKDAYS)
- c->weekdays_bits = -1;
-
- fix_year(c->year);
-
- sort_chain(&c->year);
- sort_chain(&c->month);
- sort_chain(&c->day);
- sort_chain(&c->hour);
- sort_chain(&c->minute);
- sort_chain(&c->second);
-
- return 0;
-}
-
-_pure_ static bool chain_valid(CalendarComponent *c, int from, int to) {
- if (!c)
- return true;
-
- if (c->value < from || c->value > to)
- return false;
-
- if (c->value + c->repeat > to)
- return false;
-
- if (c->next)
- return chain_valid(c->next, from, to);
-
- return true;
-}
-
-_pure_ bool calendar_spec_valid(CalendarSpec *c) {
- assert(c);
-
- if (c->weekdays_bits > BITS_WEEKDAYS)
- return false;
-
- if (!chain_valid(c->year, 1970, 2199))
- return false;
-
- if (!chain_valid(c->month, 1, 12))
- return false;
-
- if (!chain_valid(c->day, 1, 31))
- return false;
-
- if (!chain_valid(c->hour, 0, 23))
- return false;
-
- if (!chain_valid(c->minute, 0, 59))
- return false;
-
- if (!chain_valid(c->second, 0, 59))
- return false;
-
- return true;
-}
-
-static void format_weekdays(FILE *f, const CalendarSpec *c) {
- static const char *const days[] = {
- "Mon",
- "Tue",
- "Wed",
- "Thu",
- "Fri",
- "Sat",
- "Sun"
- };
-
- int l, x;
- bool need_colon = false;
-
- assert(f);
- assert(c);
- assert(c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS);
-
- for (x = 0, l = -1; x < (int) ELEMENTSOF(days); x++) {
-
- if (c->weekdays_bits & (1 << x)) {
-
- if (l < 0) {
- if (need_colon)
- fputc(',', f);
- else
- need_colon = true;
-
- fputs(days[x], f);
- l = x;
- }
-
- } else if (l >= 0) {
-
- if (x > l + 1) {
- fputc(x > l + 2 ? '-' : ',', f);
- fputs(days[x-1], f);
- }
-
- l = -1;
- }
- }
-
- if (l >= 0 && x > l + 1) {
- fputc(x > l + 2 ? '-' : ',', f);
- fputs(days[x-1], f);
- }
-}
-
-static void format_chain(FILE *f, int space, const CalendarComponent *c) {
- assert(f);
-
- if (!c) {
- fputc('*', f);
- return;
- }
-
- assert(c->value >= 0);
- fprintf(f, "%0*i", space, c->value);
-
- if (c->repeat > 0)
- fprintf(f, "/%i", c->repeat);
-
- if (c->next) {
- fputc(',', f);
- format_chain(f, space, c->next);
- }
-}
-
-int calendar_spec_to_string(const CalendarSpec *c, char **p) {
- char *buf = NULL;
- size_t sz = 0;
- FILE *f;
-
- assert(c);
- assert(p);
-
- f = open_memstream(&buf, &sz);
- if (!f)
- return -ENOMEM;
-
- if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
- format_weekdays(f, c);
- fputc(' ', f);
- }
-
- format_chain(f, 4, c->year);
- fputc('-', f);
- format_chain(f, 2, c->month);
- fputc('-', f);
- format_chain(f, 2, c->day);
- fputc(' ', f);
- format_chain(f, 2, c->hour);
- fputc(':', f);
- format_chain(f, 2, c->minute);
- fputc(':', f);
- format_chain(f, 2, c->second);
-
- fflush(f);
-
- if (ferror(f)) {
- free(buf);
- fclose(f);
- return -ENOMEM;
- }
-
- fclose(f);
-
- *p = buf;
- return 0;
-}
-
-static int parse_weekdays(const char **p, CalendarSpec *c) {
- static const struct {
- const char *name;
- const int nr;
- } day_nr[] = {
- { "Monday", 0 },
- { "Mon", 0 },
- { "Tuesday", 1 },
- { "Tue", 1 },
- { "Wednesday", 2 },
- { "Wed", 2 },
- { "Thursday", 3 },
- { "Thu", 3 },
- { "Friday", 4 },
- { "Fri", 4 },
- { "Saturday", 5 },
- { "Sat", 5 },
- { "Sunday", 6 },
- { "Sun", 6 }
- };
-
- int l = -1;
- bool first = true;
-
- assert(p);
- assert(*p);
- assert(c);
-
- for (;;) {
- unsigned i;
-
- if (!first && **p == ' ')
- return 0;
-
- for (i = 0; i < ELEMENTSOF(day_nr); i++) {
- size_t skip;
-
- if (!startswith_no_case(*p, day_nr[i].name))
- continue;
-
- skip = strlen(day_nr[i].name);
-
- if ((*p)[skip] != '-' &&
- (*p)[skip] != ',' &&
- (*p)[skip] != ' ' &&
- (*p)[skip] != 0)
- return -EINVAL;
-
- c->weekdays_bits |= 1 << day_nr[i].nr;
-
- if (l >= 0) {
- int j;
-
- if (l > day_nr[i].nr)
- return -EINVAL;
-
- for (j = l + 1; j < day_nr[i].nr; j++)
- c->weekdays_bits |= 1 << j;
- }
-
- *p += skip;
- break;
- }
-
- /* Couldn't find this prefix, so let's assume the
- weekday was not specified and let's continue with
- the date */
- if (i >= ELEMENTSOF(day_nr))
- return first ? 0 : -EINVAL;
-
- /* We reached the end of the string */
- if (**p == 0)
- return 0;
-
- /* We reached the end of the weekday spec part */
- if (**p == ' ') {
- *p += strspn(*p, " ");
- return 0;
- }
-
- if (**p == '-') {
- if (l >= 0)
- return -EINVAL;
-
- l = day_nr[i].nr;
- } else
- l = -1;
-
- *p += 1;
- first = false;
- }
-}
-
-static int prepend_component(const char **p, CalendarComponent **c) {
- unsigned long value, repeat = 0;
- char *e = NULL, *ee = NULL;
- CalendarComponent *cc;
-
- assert(p);
- assert(c);
-
- errno = 0;
- value = strtoul(*p, &e, 10);
- if (errno > 0)
- return -errno;
- if (e == *p)
- return -EINVAL;
- if ((unsigned long) (int) value != value)
- return -ERANGE;
-
- if (*e == '/') {
- repeat = strtoul(e+1, &ee, 10);
- if (errno > 0)
- return -errno;
- if (ee == e+1)
- return -EINVAL;
- if ((unsigned long) (int) repeat != repeat)
- return -ERANGE;
- if (repeat <= 0)
- return -ERANGE;
-
- e = ee;
- }
-
- if (*e != 0 && *e != ' ' && *e != ',' && *e != '-' && *e != ':')
- return -EINVAL;
-
- cc = new0(CalendarComponent, 1);
- if (!cc)
- return -ENOMEM;
-
- cc->value = value;
- cc->repeat = repeat;
- cc->next = *c;
-
- *p = e;
- *c = cc;
-
- if (*e ==',') {
- *p += 1;
- return prepend_component(p, c);
- }
-
- return 0;
-}
-
-static int parse_chain(const char **p, CalendarComponent **c) {
- const char *t;
- CalendarComponent *cc = NULL;
- int r;
-
- assert(p);
- assert(c);
-
- t = *p;
-
- if (t[0] == '*') {
- *p = t + 1;
- *c = NULL;
- return 0;
- }
-
- r = prepend_component(&t, &cc);
- if (r < 0) {
- free_chain(cc);
- return r;
- }
-
- *p = t;
- *c = cc;
- return 0;
-}
-
-static int const_chain(int value, CalendarComponent **c) {
- CalendarComponent *cc = NULL;
-
- assert(c);
-
- cc = new0(CalendarComponent, 1);
- if (!cc)
- return -ENOMEM;
-
- cc->value = value;
- cc->repeat = 0;
- cc->next = *c;
-
- *c = cc;
-
- return 0;
-}
-
-static int parse_date(const char **p, CalendarSpec *c) {
- const char *t;
- int r;
- CalendarComponent *first, *second, *third;
-
- assert(p);
- assert(*p);
- assert(c);
-
- t = *p;
-
- if (*t == 0)
- return 0;
-
- r = parse_chain(&t, &first);
- if (r < 0)
- return r;
-
- /* Already the end? A ':' as separator? In that case this was a time, not a date */
- if (*t == 0 || *t == ':') {
- free_chain(first);
- return 0;
- }
-
- if (*t != '-') {
- free_chain(first);
- return -EINVAL;
- }
-
- t++;
- r = parse_chain(&t, &second);
- if (r < 0) {
- free_chain(first);
- return r;
- }
-
- /* Got two parts, hence it's month and day */
- if (*t == ' ' || *t == 0) {
- *p = t + strspn(t, " ");
- c->month = first;
- c->day = second;
- return 0;
- }
-
- if (*t != '-') {
- free_chain(first);
- free_chain(second);
- return -EINVAL;
- }
-
- t++;
- r = parse_chain(&t, &third);
- if (r < 0) {
- free_chain(first);
- free_chain(second);
- return r;
- }
-
- /* Got tree parts, hence it is year, month and day */
- if (*t == ' ' || *t == 0) {
- *p = t + strspn(t, " ");
- c->year = first;
- c->month = second;
- c->day = third;
- return 0;
- }
-
- free_chain(first);
- free_chain(second);
- free_chain(third);
- return -EINVAL;
-}
-
-static int parse_time(const char **p, CalendarSpec *c) {
- CalendarComponent *h = NULL, *m = NULL, *s = NULL;
- const char *t;
- int r;
-
- assert(p);
- assert(*p);
- assert(c);
-
- t = *p;
-
- if (*t == 0) {
- /* If no time is specified at all, but a date of some
- * kind, then this means 00:00:00 */
- if (c->day || c->weekdays_bits > 0)
- goto null_hour;
-
- goto finish;
- }
-
- r = parse_chain(&t, &h);
- if (r < 0)
- goto fail;
-
- if (*t != ':') {
- r = -EINVAL;
- goto fail;
- }
-
- t++;
- r = parse_chain(&t, &m);
- if (r < 0)
- goto fail;
-
- /* Already at the end? Then it's hours and minutes, and seconds are 0 */
- if (*t == 0) {
- if (m != NULL)
- goto null_second;
-
- goto finish;
- }
-
- if (*t != ':') {
- r = -EINVAL;
- goto fail;
- }
-
- t++;
- r = parse_chain(&t, &s);
- if (r < 0)
- goto fail;
-
- /* At the end? Then it's hours, minutes and seconds */
- if (*t == 0)
- goto finish;
-
- r = -EINVAL;
- goto fail;
-
-null_hour:
- r = const_chain(0, &h);
- if (r < 0)
- goto fail;
-
- r = const_chain(0, &m);
- if (r < 0)
- goto fail;
-
-null_second:
- r = const_chain(0, &s);
- if (r < 0)
- goto fail;
-
-finish:
- *p = t;
- c->hour = h;
- c->minute = m;
- c->second = s;
- return 0;
-
-fail:
- free_chain(h);
- free_chain(m);
- free_chain(s);
- return r;
-}
-
-int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
- CalendarSpec *c;
- int r;
-
- assert(p);
- assert(spec);
-
- if (isempty(p))
- return -EINVAL;
-
- c = new0(CalendarSpec, 1);
- if (!c)
- return -ENOMEM;
-
- if (strcaseeq(p, "minutely")) {
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "hourly")) {
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "daily")) {
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "monthly")) {
- r = const_chain(1, &c->day);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "annually") ||
- strcaseeq(p, "yearly") ||
- strcaseeq(p, "anually") /* backwards compatibility */ ) {
-
- r = const_chain(1, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(1, &c->day);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "weekly")) {
-
- c->weekdays_bits = 1;
-
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "quarterly")) {
-
- r = const_chain(1, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(4, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(7, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(10, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(1, &c->day);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else if (strcaseeq(p, "biannually") ||
- strcaseeq(p, "bi-annually") ||
- strcaseeq(p, "semiannually") ||
- strcaseeq(p, "semi-annually")) {
-
- r = const_chain(1, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(7, &c->month);
- if (r < 0)
- goto fail;
- r = const_chain(1, &c->day);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->hour);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->minute);
- if (r < 0)
- goto fail;
- r = const_chain(0, &c->second);
- if (r < 0)
- goto fail;
-
- } else {
- r = parse_weekdays(&p, c);
- if (r < 0)
- goto fail;
-
- r = parse_date(&p, c);
- if (r < 0)
- goto fail;
-
- r = parse_time(&p, c);
- if (r < 0)
- goto fail;
-
- if (*p != 0) {
- r = -EINVAL;
- goto fail;
- }
- }
-
- r = calendar_spec_normalize(c);
- if (r < 0)
- goto fail;
-
- if (!calendar_spec_valid(c)) {
- r = -EINVAL;
- goto fail;
- }
-
- *spec = c;
- return 0;
-
-fail:
- calendar_spec_free(c);
- return r;
-}
-
-static int find_matching_component(const CalendarComponent *c, int *val) {
- const CalendarComponent *n;
- int d = -1;
- bool d_set = false;
- int r;
-
- assert(val);
-
- if (!c)
- return 0;
-
- while (c) {
- n = c->next;
-
- if (c->value >= *val) {
-
- if (!d_set || c->value < d) {
- d = c->value;
- d_set = true;
- }
-
- } else if (c->repeat > 0) {
- int k;
-
- k = c->value + c->repeat * ((*val - c->value + c->repeat -1) / c->repeat);
-
- if (!d_set || k < d) {
- d = k;
- d_set = true;
- }
- }
-
- c = n;
- }
-
- if (!d_set)
- return -ENOENT;
-
- r = *val != d;
- *val = d;
- return r;
-}
-
-static bool tm_out_of_bounds(const struct tm *tm) {
- struct tm t;
- assert(tm);
-
- t = *tm;
-
- if (mktime(&t) == (time_t) -1)
- return true;
-
- /* Did any normalization take place? If so, it was out of bounds before */
- return
- t.tm_year != tm->tm_year ||
- t.tm_mon != tm->tm_mon ||
- t.tm_mday != tm->tm_mday ||
- t.tm_hour != tm->tm_hour ||
- t.tm_min != tm->tm_min ||
- t.tm_sec != tm->tm_sec;
-}
-
-static bool matches_weekday(int weekdays_bits, const struct tm *tm) {
- struct tm t;
- int k;
-
- if (weekdays_bits < 0 || weekdays_bits >= BITS_WEEKDAYS)
- return true;
-
- t = *tm;
- if (mktime(&t) == (time_t) -1)
- return false;
-
- k = t.tm_wday == 0 ? 6 : t.tm_wday - 1;
- return (weekdays_bits & (1 << k));
-}
-
-static int find_next(const CalendarSpec *spec, struct tm *tm) {
- struct tm c;
- int r;
-
- assert(spec);
- assert(tm);
-
- c = *tm;
-
- for (;;) {
- /* Normalize the current date */
- mktime(&c);
- c.tm_isdst = -1;
-
- c.tm_year += 1900;
- r = find_matching_component(spec->year, &c.tm_year);
- c.tm_year -= 1900;
-
- if (r > 0) {
- c.tm_mon = 0;
- c.tm_mday = 1;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- }
- if (r < 0 || tm_out_of_bounds(&c))
- return r;
-
- c.tm_mon += 1;
- r = find_matching_component(spec->month, &c.tm_mon);
- c.tm_mon -= 1;
-
- if (r > 0) {
- c.tm_mday = 1;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- }
- if (r < 0 || tm_out_of_bounds(&c)) {
- c.tm_year ++;
- c.tm_mon = 0;
- c.tm_mday = 1;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- continue;
- }
-
- r = find_matching_component(spec->day, &c.tm_mday);
- if (r > 0)
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- if (r < 0 || tm_out_of_bounds(&c)) {
- c.tm_mon ++;
- c.tm_mday = 1;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- continue;
- }
-
- if (!matches_weekday(spec->weekdays_bits, &c)) {
- c.tm_mday++;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- continue;
- }
-
- r = find_matching_component(spec->hour, &c.tm_hour);
- if (r > 0)
- c.tm_min = c.tm_sec = 0;
- if (r < 0 || tm_out_of_bounds(&c)) {
- c.tm_mday ++;
- c.tm_hour = c.tm_min = c.tm_sec = 0;
- continue;
- }
-
- r = find_matching_component(spec->minute, &c.tm_min);
- if (r > 0)
- c.tm_sec = 0;
- if (r < 0 || tm_out_of_bounds(&c)) {
- c.tm_hour ++;
- c.tm_min = c.tm_sec = 0;
- continue;
- }
-
- r = find_matching_component(spec->second, &c.tm_sec);
- if (r < 0 || tm_out_of_bounds(&c)) {
- c.tm_min ++;
- c.tm_sec = 0;
- continue;
- }
-
-
- *tm = c;
- return 0;
- }
-}
-
-int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next) {
- struct tm tm;
- time_t t;
- int r;
-
- assert(spec);
- assert(next);
-
- t = (time_t) (usec / USEC_PER_SEC) + 1;
- assert_se(localtime_r(&t, &tm));
-
- r = find_next(spec, &tm);
- if (r < 0)
- return r;
-
- t = mktime(&tm);
- if (t == (time_t) -1)
- return -EINVAL;
-
- *next = (usec_t) t * USEC_PER_SEC;
- return 0;
-}
diff --git a/src/shared/cap-list.c b/src/shared/cap-list.c
deleted file mode 100644
index bd5bffbfa..000000000
--- a/src/shared/cap-list.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-
-#include "util.h"
-#include "cap-list.h"
-#include "missing.h"
-
-static const struct capability_name* lookup_capability(register const char *str, register unsigned int len);
-
-#include "cap-to-name.h"
-#include "cap-from-name.h"
-
-const char *capability_to_name(int id) {
-
- if (id < 0)
- return NULL;
-
- if (id >= (int) ELEMENTSOF(capability_names))
- return NULL;
-
- return capability_names[id];
-}
-
-int capability_from_name(const char *name) {
- const struct capability_name *sc;
- int r, i;
-
- assert(name);
-
- /* Try to parse numeric capability */
- r = safe_atoi(name, &i);
- if (r >= 0 && i >= 0)
- return i;
-
- /* Try to parse string capability */
- sc = lookup_capability(name, strlen(name));
- if (!sc)
- return -EINVAL;
-
- return sc->id;
-}
-
-int capability_list_length(void) {
- return (int) ELEMENTSOF(capability_names);
-}
diff --git a/src/shared/cap-list.h b/src/shared/cap-list.h
deleted file mode 100644
index 9824fad70..000000000
--- a/src/shared/cap-list.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-const char *capability_to_name(int id);
-int capability_from_name(const char *name);
-int capability_list_length(void);
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 8ff9be876..530e6f250 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -261,6 +261,8 @@ int show_cgroup_and_extra(const char *controller, const char *path, const char *
return show_extra_pids(controller, path, prefix, n_columns, extra_pids, n_extra_pids, flags);
}
+/// UNNEEDED by elogind
+#if 0
int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned n_columns, bool kernel_threads, const pid_t extra_pids[], unsigned n_extra_pids, OutputFlags flags) {
_cleanup_free_ char *controller = NULL, *path = NULL;
int r;
@@ -273,3 +275,4 @@ int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned
return show_cgroup_and_extra(controller, path, prefix, n_columns, kernel_threads, extra_pids, n_extra_pids, flags);
}
+#endif // 0
diff --git a/src/shared/cgroup-show.h b/src/shared/cgroup-show.h
index aa832454b..8afe05736 100644
--- a/src/shared/cgroup-show.h
+++ b/src/shared/cgroup-show.h
@@ -28,5 +28,5 @@
int show_cgroup_by_path(const char *path, const char *prefix, unsigned columns, bool kernel_threads, OutputFlags flags);
int show_cgroup(const char *controller, const char *path, const char *prefix, unsigned columns, bool kernel_threads, OutputFlags flags);
-int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned n_columns, bool kernel_threads, const pid_t extra_pids[], unsigned n_extra_pids, OutputFlags flags);
+// UNNEEDED int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned n_columns, bool kernel_threads, const pid_t extra_pids[], unsigned n_extra_pids, OutputFlags flags);
int show_cgroup_and_extra(const char *controller, const char *path, const char *prefix, unsigned n_columns, bool kernel_threads, const pid_t extra_pids[], unsigned n_extra_pids, OutputFlags flags);
diff --git a/src/shared/clock-util.c b/src/shared/clock-util.c
deleted file mode 100644
index e4e03df1e..000000000
--- a/src/shared/clock-util.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2010-2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <linux/rtc.h>
-
-#include "macro.h"
-#include "util.h"
-#include "clock-util.h"
-
-int clock_get_hwclock(struct tm *tm) {
- _cleanup_close_ int fd = -1;
-
- assert(tm);
-
- fd = open("/dev/rtc", O_RDONLY|O_CLOEXEC);
- if (fd < 0)
- return -errno;
-
- /* This leaves the timezone fields of struct tm
- * uninitialized! */
- if (ioctl(fd, RTC_RD_TIME, tm) < 0)
- return -errno;
-
- /* We don't know daylight saving, so we reset this in order not
- * to confuse mktime(). */
- tm->tm_isdst = -1;
-
- return 0;
-}
-
-int clock_set_hwclock(const struct tm *tm) {
- _cleanup_close_ int fd = -1;
-
- assert(tm);
-
- fd = open("/dev/rtc", O_RDONLY|O_CLOEXEC);
- if (fd < 0)
- return -errno;
-
- if (ioctl(fd, RTC_SET_TIME, tm) < 0)
- return -errno;
-
- return 0;
-}
-
-int clock_is_localtime(void) {
- _cleanup_fclose_ FILE *f;
-
- /*
- * The third line of adjtime is "UTC" or "LOCAL" or nothing.
- * # /etc/adjtime
- * 0.0 0 0
- * 0
- * UTC
- */
- f = fopen("/etc/adjtime", "re");
- if (f) {
- char line[LINE_MAX];
- bool b;
-
- b = fgets(line, sizeof(line), f) &&
- fgets(line, sizeof(line), f) &&
- fgets(line, sizeof(line), f);
- if (!b)
- return -EIO;
-
- truncate_nl(line);
- return streq(line, "LOCAL");
-
- } else if (errno != ENOENT)
- return -errno;
-
- return 0;
-}
-
-int clock_set_timezone(int *min) {
- const struct timeval *tv_null = NULL;
- struct timespec ts;
- struct tm *tm;
- int minutesdelta;
- struct timezone tz;
-
- assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0);
- assert_se(tm = localtime(&ts.tv_sec));
- minutesdelta = tm->tm_gmtoff / 60;
-
- tz.tz_minuteswest = -minutesdelta;
- tz.tz_dsttime = 0; /* DST_NONE */
-
- /*
- * If the RTC does not run in UTC but in local time, the very first
- * call to settimeofday() will set the kernel's timezone and will warp the
- * system clock, so that it runs in UTC instead of the local time we
- * have read from the RTC.
- */
- if (settimeofday(tv_null, &tz) < 0)
- return -errno;
- if (min)
- *min = minutesdelta;
- return 0;
-}
-
-int clock_reset_timewarp(void) {
- const struct timeval *tv_null = NULL;
- struct timezone tz;
-
- tz.tz_minuteswest = 0;
- tz.tz_dsttime = 0; /* DST_NONE */
-
- /*
- * The very first call to settimeofday() does time warp magic. Do a
- * dummy call here, so the time warping is sealed and all later calls
- * behave as expected.
- */
- if (settimeofday(tv_null, &tz) < 0)
- return -errno;
-
- return 0;
-}
diff --git a/src/shared/clock-util.h b/src/shared/clock-util.h
deleted file mode 100644
index 8c2d23543..000000000
--- a/src/shared/clock-util.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2010-2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-int clock_is_localtime(void);
-int clock_set_timezone(int *min);
-int clock_reset_timewarp(void);
-int clock_get_hwclock(struct tm *tm);
-int clock_set_hwclock(const struct tm *tm);
diff --git a/src/shared/condition.h b/src/shared/condition.h
index 0780e7812..42fb9646d 100644
--- a/src/shared/condition.h
+++ b/src/shared/condition.h
@@ -77,7 +77,7 @@ typedef struct Condition {
LIST_FIELDS(struct Condition, conditions);
} Condition;
-Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate);
+// UNNEEDED Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate);
void condition_free(Condition *c);
Condition* condition_free_list(Condition *c);
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 7370c786f..b01aadcd7 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -487,6 +487,8 @@ int config_parse_iec_size(const char* unit,
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int config_parse_si_size(const char* unit,
const char *filename,
unsigned line,
@@ -544,6 +546,7 @@ int config_parse_iec_off(const char* unit,
return 0;
}
+#endif // 0
int config_parse_bool(const char* unit,
const char *filename,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 6152ee33b..6769db3cb 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -107,8 +107,8 @@ int config_parse_long(const char *unit, const char *filename, unsigned line, con
int config_parse_uint64(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_double(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_iec_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_si_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_iec_off(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+// UNNEEDED int config_parse_si_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+// UNNEEDED int config_parse_iec_off(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_bool(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_path(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
diff --git a/src/shared/device-nodes.c b/src/shared/device-nodes.c
deleted file mode 100644
index 9d5af72d2..000000000
--- a/src/shared/device-nodes.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2011 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdio.h>
-
-#include "device-nodes.h"
-#include "utf8.h"
-
-int whitelisted_char_for_devnode(char c, const char *white) {
-
- if ((c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') ||
- strchr("#+-.:=@_", c) != NULL ||
- (white != NULL && strchr(white, c) != NULL))
- return 1;
-
- return 0;
-}
-
-int encode_devnode_name(const char *str, char *str_enc, size_t len) {
- size_t i, j;
-
- if (str == NULL || str_enc == NULL)
- return -EINVAL;
-
- for (i = 0, j = 0; str[i] != '\0'; i++) {
- int seqlen;
-
- seqlen = utf8_encoded_valid_unichar(&str[i]);
- if (seqlen > 1) {
-
- if (len-j < (size_t)seqlen)
- return -EINVAL;
-
- memcpy(&str_enc[j], &str[i], seqlen);
- j += seqlen;
- i += (seqlen-1);
-
- } else if (str[i] == '\\' || !whitelisted_char_for_devnode(str[i], NULL)) {
-
- if (len-j < 4)
- return -EINVAL;
-
- sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]);
- j += 4;
-
- } else {
- if (len-j < 1)
- return -EINVAL;
-
- str_enc[j] = str[i];
- j++;
- }
- }
-
- if (len-j < 1)
- return -EINVAL;
-
- str_enc[j] = '\0';
- return 0;
-}
diff --git a/src/shared/env-util.c b/src/shared/env-util.c
deleted file mode 100644
index ac7bbdc71..000000000
--- a/src/shared/env-util.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <limits.h>
-#include <unistd.h>
-
-#include "strv.h"
-#include "utf8.h"
-#include "util.h"
-#include "env-util.h"
-#include "def.h"
-
-#define VALID_CHARS_ENV_NAME \
- DIGITS LETTERS \
- "_"
-
-#ifndef ARG_MAX
-#define ARG_MAX ((size_t) sysconf(_SC_ARG_MAX))
-#endif
-
-static bool env_name_is_valid_n(const char *e, size_t n) {
- const char *p;
-
- if (!e)
- return false;
-
- if (n <= 0)
- return false;
-
- if (e[0] >= '0' && e[0] <= '9')
- return false;
-
- /* POSIX says the overall size of the environment block cannot
- * be > ARG_MAX, an individual assignment hence cannot be
- * either. Discounting the equal sign and trailing NUL this
- * hence leaves ARG_MAX-2 as longest possible variable
- * name. */
- if (n > ARG_MAX - 2)
- return false;
-
- for (p = e; p < e + n; p++)
- if (!strchr(VALID_CHARS_ENV_NAME, *p))
- return false;
-
- return true;
-}
-
-bool env_name_is_valid(const char *e) {
- if (!e)
- return false;
-
- return env_name_is_valid_n(e, strlen(e));
-}
-
-bool env_value_is_valid(const char *e) {
- if (!e)
- return false;
-
- if (!utf8_is_valid(e))
- return false;
-
- /* bash allows tabs in environment variables, and so should
- * we */
- if (string_has_cc(e, "\t"))
- return false;
-
- /* POSIX says the overall size of the environment block cannot
- * be > ARG_MAX, an individual assignment hence cannot be
- * either. Discounting the shortest possible variable name of
- * length 1, the equal sign and trailing NUL this hence leaves
- * ARG_MAX-3 as longest possible variable value. */
- if (strlen(e) > ARG_MAX - 3)
- return false;
-
- return true;
-}
-
-bool env_assignment_is_valid(const char *e) {
- const char *eq;
-
- eq = strchr(e, '=');
- if (!eq)
- return false;
-
- if (!env_name_is_valid_n(e, eq - e))
- return false;
-
- if (!env_value_is_valid(eq + 1))
- return false;
-
- /* POSIX says the overall size of the environment block cannot
- * be > ARG_MAX, hence the individual variable assignments
- * cannot be either, but let's leave room for one trailing NUL
- * byte. */
- if (strlen(e) > ARG_MAX - 1)
- return false;
-
- return true;
-}
-
-bool strv_env_is_valid(char **e) {
- char **p, **q;
-
- STRV_FOREACH(p, e) {
- size_t k;
-
- if (!env_assignment_is_valid(*p))
- return false;
-
- /* Check if there are duplicate assginments */
- k = strcspn(*p, "=");
- STRV_FOREACH(q, p + 1)
- if (strneq(*p, *q, k) && (*q)[k] == '=')
- return false;
- }
-
- return true;
-}
-
-bool strv_env_name_or_assignment_is_valid(char **l) {
- char **p, **q;
-
- STRV_FOREACH(p, l) {
- if (!env_assignment_is_valid(*p) && !env_name_is_valid(*p))
- return false;
-
- STRV_FOREACH(q, p + 1)
- if (streq(*p, *q))
- return false;
- }
-
- return true;
-}
-
-static int env_append(char **r, char ***k, char **a) {
- assert(r);
- assert(k);
-
- if (!a)
- return 0;
-
- /* Add the entries of a to *k unless they already exist in *r
- * in which case they are overridden instead. This assumes
- * there is enough space in the r array. */
-
- for (; *a; a++) {
- char **j;
- size_t n;
-
- n = strcspn(*a, "=");
-
- if ((*a)[n] == '=')
- n++;
-
- for (j = r; j < *k; j++)
- if (strneq(*j, *a, n))
- break;
-
- if (j >= *k)
- (*k)++;
- else
- free(*j);
-
- *j = strdup(*a);
- if (!*j)
- return -ENOMEM;
- }
-
- return 0;
-}
-
-char **strv_env_merge(unsigned n_lists, ...) {
- size_t n = 0;
- char **l, **k, **r;
- va_list ap;
- unsigned i;
-
- /* Merges an arbitrary number of environment sets */
-
- va_start(ap, n_lists);
- for (i = 0; i < n_lists; i++) {
- l = va_arg(ap, char**);
- n += strv_length(l);
- }
- va_end(ap);
-
- r = new(char*, n+1);
- if (!r)
- return NULL;
-
- k = r;
-
- va_start(ap, n_lists);
- for (i = 0; i < n_lists; i++) {
- l = va_arg(ap, char**);
- if (env_append(r, &k, l) < 0)
- goto fail;
- }
- va_end(ap);
-
- *k = NULL;
-
- return r;
-
-fail:
- va_end(ap);
- strv_free(r);
-
- return NULL;
-}
-
-_pure_ static bool env_match(const char *t, const char *pattern) {
- assert(t);
- assert(pattern);
-
- /* pattern a matches string a
- * a matches a=
- * a matches a=b
- * a= matches a=
- * a=b matches a=b
- * a= does not match a
- * a=b does not match a=
- * a=b does not match a
- * a=b does not match a=c */
-
- if (streq(t, pattern))
- return true;
-
- if (!strchr(pattern, '=')) {
- size_t l = strlen(pattern);
-
- return strneq(t, pattern, l) && t[l] == '=';
- }
-
- return false;
-}
-
-char **strv_env_delete(char **x, unsigned n_lists, ...) {
- size_t n, i = 0;
- char **k, **r;
- va_list ap;
-
- /* Deletes every entry from x that is mentioned in the other
- * string lists */
-
- n = strv_length(x);
-
- r = new(char*, n+1);
- if (!r)
- return NULL;
-
- STRV_FOREACH(k, x) {
- unsigned v;
-
- va_start(ap, n_lists);
- for (v = 0; v < n_lists; v++) {
- char **l, **j;
-
- l = va_arg(ap, char**);
- STRV_FOREACH(j, l)
- if (env_match(*k, *j))
- goto skip;
- }
- va_end(ap);
-
- r[i] = strdup(*k);
- if (!r[i]) {
- strv_free(r);
- return NULL;
- }
-
- i++;
- continue;
-
- skip:
- va_end(ap);
- }
-
- r[i] = NULL;
-
- assert(i <= n);
-
- return r;
-}
-
-char **strv_env_unset(char **l, const char *p) {
-
- char **f, **t;
-
- if (!l)
- return NULL;
-
- assert(p);
-
- /* Drops every occurrence of the env var setting p in the
- * string list. Edits in-place. */
-
- for (f = t = l; *f; f++) {
-
- if (env_match(*f, p)) {
- free(*f);
- continue;
- }
-
- *(t++) = *f;
- }
-
- *t = NULL;
- return l;
-}
-
-char **strv_env_unset_many(char **l, ...) {
-
- char **f, **t;
-
- if (!l)
- return NULL;
-
- /* Like strv_env_unset() but applies many at once. Edits in-place. */
-
- for (f = t = l; *f; f++) {
- bool found = false;
- const char *p;
- va_list ap;
-
- va_start(ap, l);
-
- while ((p = va_arg(ap, const char*))) {
- if (env_match(*f, p)) {
- found = true;
- break;
- }
- }
-
- va_end(ap);
-
- if (found) {
- free(*f);
- continue;
- }
-
- *(t++) = *f;
- }
-
- *t = NULL;
- return l;
-}
-
-char **strv_env_set(char **x, const char *p) {
-
- char **k, **r;
- char* m[2] = { (char*) p, NULL };
-
- /* Overrides the env var setting of p, returns a new copy */
-
- r = new(char*, strv_length(x)+2);
- if (!r)
- return NULL;
-
- k = r;
- if (env_append(r, &k, x) < 0)
- goto fail;
-
- if (env_append(r, &k, m) < 0)
- goto fail;
-
- *k = NULL;
-
- return r;
-
-fail:
- strv_free(r);
- return NULL;
-}
-
-char *strv_env_get_n(char **l, const char *name, size_t k) {
- char **i;
-
- assert(name);
-
- if (k <= 0)
- return NULL;
-
- STRV_FOREACH(i, l)
- if (strneq(*i, name, k) &&
- (*i)[k] == '=')
- return *i + k + 1;
-
- return NULL;
-}
-
-char *strv_env_get(char **l, const char *name) {
- assert(name);
-
- return strv_env_get_n(l, name, strlen(name));
-}
-
-char **strv_env_clean_with_callback(char **e, void (*invalid_callback)(const char *p, void *userdata), void *userdata) {
- char **p, **q;
- int k = 0;
-
- STRV_FOREACH(p, e) {
- size_t n;
- bool duplicate = false;
-
- if (!env_assignment_is_valid(*p)) {
- if (invalid_callback)
- invalid_callback(*p, userdata);
- free(*p);
- continue;
- }
-
- n = strcspn(*p, "=");
- STRV_FOREACH(q, p + 1)
- if (strneq(*p, *q, n) && (*q)[n] == '=') {
- duplicate = true;
- break;
- }
-
- if (duplicate) {
- free(*p);
- continue;
- }
-
- e[k++] = *p;
- }
-
- if (e)
- e[k] = NULL;
-
- return e;
-}
-
-char *replace_env(const char *format, char **env) {
- enum {
- WORD,
- CURLY,
- VARIABLE
- } state = WORD;
-
- const char *e, *word = format;
- char *r = NULL, *k;
-
- assert(format);
-
- for (e = format; *e; e ++) {
-
- switch (state) {
-
- case WORD:
- if (*e == '$')
- state = CURLY;
- break;
-
- case CURLY:
- if (*e == '{') {
- k = strnappend(r, word, e-word-1);
- if (!k)
- goto fail;
-
- free(r);
- r = k;
-
- word = e-1;
- state = VARIABLE;
-
- } else if (*e == '$') {
- k = strnappend(r, word, e-word);
- if (!k)
- goto fail;
-
- free(r);
- r = k;
-
- word = e+1;
- state = WORD;
- } else
- state = WORD;
- break;
-
- case VARIABLE:
- if (*e == '}') {
- const char *t;
-
- t = strempty(strv_env_get_n(env, word+2, e-word-2));
-
- k = strappend(r, t);
- if (!k)
- goto fail;
-
- free(r);
- r = k;
-
- word = e+1;
- state = WORD;
- }
- break;
- }
- }
-
- k = strnappend(r, word, e-word);
- if (!k)
- goto fail;
-
- free(r);
- return k;
-
-fail:
- free(r);
- return NULL;
-}
-
-char **replace_env_argv(char **argv, char **env) {
- char **ret, **i;
- unsigned k = 0, l = 0;
-
- l = strv_length(argv);
-
- ret = new(char*, l+1);
- if (!ret)
- return NULL;
-
- STRV_FOREACH(i, argv) {
-
- /* If $FOO appears as single word, replace it by the split up variable */
- if ((*i)[0] == '$' && (*i)[1] != '{') {
- char *e;
- char **w, **m = NULL;
- unsigned q;
-
- e = strv_env_get(env, *i+1);
- if (e) {
- int r;
-
- r = strv_split_quoted(&m, e, UNQUOTE_RELAX);
- if (r < 0) {
- ret[k] = NULL;
- strv_free(ret);
- return NULL;
- }
- } else
- m = NULL;
-
- q = strv_length(m);
- l = l + q - 1;
-
- w = realloc(ret, sizeof(char*) * (l+1));
- if (!w) {
- ret[k] = NULL;
- strv_free(ret);
- strv_free(m);
- return NULL;
- }
-
- ret = w;
- if (m) {
- memcpy(ret + k, m, q * sizeof(char*));
- free(m);
- }
-
- k += q;
- continue;
- }
-
- /* If ${FOO} appears as part of a word, replace it by the variable as-is */
- ret[k] = replace_env(*i, env);
- if (!ret[k]) {
- strv_free(ret);
- return NULL;
- }
- k++;
- }
-
- ret[k] = NULL;
- return ret;
-}
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c
deleted file mode 100644
index c09efdd2c..000000000
--- a/src/shared/exit-status.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-
-#include "exit-status.h"
-#include "set.h"
-#include "macro.h"
-
-const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
-
- /* We cast to int here, so that -Wenum doesn't complain that
- * EXIT_SUCCESS/EXIT_FAILURE aren't in the enum */
-
- switch ((int) status) {
-
- case EXIT_SUCCESS:
- return "SUCCESS";
-
- case EXIT_FAILURE:
- return "FAILURE";
- }
-
-
- if (level == EXIT_STATUS_SYSTEMD || level == EXIT_STATUS_LSB) {
- switch ((int) status) {
-
- case EXIT_CHDIR:
- return "CHDIR";
-
- case EXIT_NICE:
- return "NICE";
-
- case EXIT_FDS:
- return "FDS";
-
- case EXIT_EXEC:
- return "EXEC";
-
- case EXIT_MEMORY:
- return "MEMORY";
-
- case EXIT_LIMITS:
- return "LIMITS";
-
- case EXIT_OOM_ADJUST:
- return "OOM_ADJUST";
-
- case EXIT_SIGNAL_MASK:
- return "SIGNAL_MASK";
-
- case EXIT_STDIN:
- return "STDIN";
-
- case EXIT_STDOUT:
- return "STDOUT";
-
- case EXIT_CHROOT:
- return "CHROOT";
-
- case EXIT_IOPRIO:
- return "IOPRIO";
-
- case EXIT_TIMERSLACK:
- return "TIMERSLACK";
-
- case EXIT_SECUREBITS:
- return "SECUREBITS";
-
- case EXIT_SETSCHEDULER:
- return "SETSCHEDULER";
-
- case EXIT_CPUAFFINITY:
- return "CPUAFFINITY";
-
- case EXIT_GROUP:
- return "GROUP";
-
- case EXIT_USER:
- return "USER";
-
- case EXIT_CAPABILITIES:
- return "CAPABILITIES";
-
- case EXIT_CGROUP:
- return "CGROUP";
-
- case EXIT_SETSID:
- return "SETSID";
-
- case EXIT_CONFIRM:
- return "CONFIRM";
-
- case EXIT_STDERR:
- return "STDERR";
-
- case EXIT_PAM:
- return "PAM";
-
- case EXIT_NETWORK:
- return "NETWORK";
-
- case EXIT_NAMESPACE:
- return "NAMESPACE";
-
- case EXIT_NO_NEW_PRIVILEGES:
- return "NO_NEW_PRIVILEGES";
-
- case EXIT_SECCOMP:
- return "SECCOMP";
-
- case EXIT_SELINUX_CONTEXT:
- return "SELINUX_CONTEXT";
-
- case EXIT_PERSONALITY:
- return "PERSONALITY";
-
- case EXIT_APPARMOR_PROFILE:
- return "APPARMOR";
-
- case EXIT_ADDRESS_FAMILIES:
- return "ADDRESS_FAMILIES";
-
- case EXIT_RUNTIME_DIRECTORY:
- return "RUNTIME_DIRECTORY";
-
- case EXIT_CHOWN:
- return "CHOWN";
-
- case EXIT_MAKE_STARTER:
- return "MAKE_STARTER";
-
- case EXIT_BUS_ENDPOINT:
- return "BUS_ENDPOINT";
- }
- }
-
- if (level == EXIT_STATUS_LSB) {
- switch ((int) status) {
-
- case EXIT_INVALIDARGUMENT:
- return "INVALIDARGUMENT";
-
- case EXIT_NOTIMPLEMENTED:
- return "NOTIMPLEMENTED";
-
- case EXIT_NOPERMISSION:
- return "NOPERMISSION";
-
- case EXIT_NOTINSTALLED:
- return "NOTINSTALLED";
-
- case EXIT_NOTCONFIGURED:
- return "NOTCONFIGURED";
-
- case EXIT_NOTRUNNING:
- return "NOTRUNNING";
- }
- }
-
- return NULL;
-}
-
-
-bool is_clean_exit(int code, int status, ExitStatusSet *success_status) {
-
- if (code == CLD_EXITED)
- return status == 0 ||
- (success_status &&
- set_contains(success_status->status, INT_TO_PTR(status)));
-
- /* If a daemon does not implement handlers for some of the
- * signals that's not considered an unclean shutdown */
- if (code == CLD_KILLED)
- return
- status == SIGHUP ||
- status == SIGINT ||
- status == SIGTERM ||
- status == SIGPIPE ||
- (success_status &&
- set_contains(success_status->signal, INT_TO_PTR(status)));
-
- return false;
-}
-
-bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status) {
-
- if (is_clean_exit(code, status, success_status))
- return true;
-
- return
- code == CLD_EXITED &&
- (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
-}
-
-void exit_status_set_free(ExitStatusSet *x) {
- assert(x);
-
- set_free(x->status);
- set_free(x->signal);
- x->status = x->signal = NULL;
-}
-
-bool exit_status_set_is_empty(ExitStatusSet *x) {
- if (!x)
- return true;
-
- return set_isempty(x->status) && set_isempty(x->signal);
-}
-
-bool exit_status_set_test(ExitStatusSet *x, int code, int status) {
-
- if (exit_status_set_is_empty(x))
- return false;
-
- if (code == CLD_EXITED && set_contains(x->status, INT_TO_PTR(status)))
- return true;
-
- if (IN_SET(code, CLD_KILLED, CLD_DUMPED) && set_contains(x->signal, INT_TO_PTR(status)))
- return true;
-
- return false;
-}
diff --git a/src/shared/fdset.c b/src/shared/fdset.c
deleted file mode 100644
index a4823e665..000000000
--- a/src/shared/fdset.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <dirent.h>
-#include <fcntl.h>
-
-#include "set.h"
-#include "util.h"
-#include "macro.h"
-#include "fdset.h"
-#include "sd-daemon.h"
-
-#define MAKE_SET(s) ((Set*) s)
-#define MAKE_FDSET(s) ((FDSet*) s)
-
-/* Make sure we can distinguish fd 0 and NULL */
-#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
-#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
-
-FDSet *fdset_new(void) {
- return MAKE_FDSET(set_new(NULL));
-}
-
-int fdset_new_array(FDSet **ret, int *fds, unsigned n_fds) {
- unsigned i;
- FDSet *s;
- int r;
-
- assert(ret);
-
- s = fdset_new();
- if (!s)
- return -ENOMEM;
-
- for (i = 0; i < n_fds; i++) {
-
- r = fdset_put(s, fds[i]);
- if (r < 0) {
- set_free(MAKE_SET(s));
- return r;
- }
- }
-
- *ret = s;
- return 0;
-}
-
-FDSet* fdset_free(FDSet *s) {
- void *p;
-
- while ((p = set_steal_first(MAKE_SET(s)))) {
- /* Valgrind's fd might have ended up in this set here,
- * due to fdset_new_fill(). We'll ignore all failures
- * here, so that the EBADFD that valgrind will return
- * us on close() doesn't influence us */
-
- /* When reloading duplicates of the private bus
- * connection fds and suchlike are closed here, which
- * has no effect at all, since they are only
- * duplicates. So don't be surprised about these log
- * messages. */
-
- log_debug("Closing left-over fd %i", PTR_TO_FD(p));
- close_nointr(PTR_TO_FD(p));
- }
-
- set_free(MAKE_SET(s));
- return NULL;
-}
-
-int fdset_put(FDSet *s, int fd) {
- assert(s);
- assert(fd >= 0);
-
- return set_put(MAKE_SET(s), FD_TO_PTR(fd));
-}
-
-int fdset_consume(FDSet *s, int fd) {
- int r;
-
- assert(s);
- assert(fd >= 0);
-
- r = fdset_put(s, fd);
- if (r <= 0)
- safe_close(fd);
-
- return r;
-}
-
-int fdset_put_dup(FDSet *s, int fd) {
- int copy, r;
-
- assert(s);
- assert(fd >= 0);
-
- copy = fcntl(fd, F_DUPFD_CLOEXEC, 3);
- if (copy < 0)
- return -errno;
-
- r = fdset_put(s, copy);
- if (r < 0) {
- safe_close(copy);
- return r;
- }
-
- return copy;
-}
-
-bool fdset_contains(FDSet *s, int fd) {
- assert(s);
- assert(fd >= 0);
-
- return !!set_get(MAKE_SET(s), FD_TO_PTR(fd));
-}
-
-int fdset_remove(FDSet *s, int fd) {
- assert(s);
- assert(fd >= 0);
-
- return set_remove(MAKE_SET(s), FD_TO_PTR(fd)) ? fd : -ENOENT;
-}
-
-int fdset_new_fill(FDSet **_s) {
- _cleanup_closedir_ DIR *d = NULL;
- struct dirent *de;
- int r = 0;
- FDSet *s;
-
- assert(_s);
-
- /* Creates an fdset and fills in all currently open file
- * descriptors. */
-
- d = opendir("/proc/self/fd");
- if (!d)
- return -errno;
-
- s = fdset_new();
- if (!s) {
- r = -ENOMEM;
- goto finish;
- }
-
- while ((de = readdir(d))) {
- int fd = -1;
-
- if (hidden_file(de->d_name))
- continue;
-
- r = safe_atoi(de->d_name, &fd);
- if (r < 0)
- goto finish;
-
- if (fd < 3)
- continue;
-
- if (fd == dirfd(d))
- continue;
-
- r = fdset_put(s, fd);
- if (r < 0)
- goto finish;
- }
-
- r = 0;
- *_s = s;
- s = NULL;
-
-finish:
- /* We won't close the fds here! */
- if (s)
- set_free(MAKE_SET(s));
-
- return r;
-}
-
-int fdset_cloexec(FDSet *fds, bool b) {
- Iterator i;
- void *p;
- int r;
-
- assert(fds);
-
- SET_FOREACH(p, MAKE_SET(fds), i)
- if ((r = fd_cloexec(PTR_TO_FD(p), b)) < 0)
- return r;
-
- return 0;
-}
-
-int fdset_new_listen_fds(FDSet **_s, bool unset) {
- int n, fd, r;
- FDSet *s;
-
- assert(_s);
-
- /* Creates an fdset and fills in all passed file descriptors */
-
- s = fdset_new();
- if (!s) {
- r = -ENOMEM;
- goto fail;
- }
-
- n = sd_listen_fds(unset);
- for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) {
- r = fdset_put(s, fd);
- if (r < 0)
- goto fail;
- }
-
- *_s = s;
- return 0;
-
-
-fail:
- if (s)
- set_free(MAKE_SET(s));
-
- return r;
-}
-
-int fdset_close_others(FDSet *fds) {
- void *e;
- Iterator i;
- int *a;
- unsigned j, m;
-
- j = 0, m = fdset_size(fds);
- a = alloca(sizeof(int) * m);
- SET_FOREACH(e, MAKE_SET(fds), i)
- a[j++] = PTR_TO_FD(e);
-
- assert(j == m);
-
- return close_all_fds(a, j);
-}
-
-unsigned fdset_size(FDSet *fds) {
- return set_size(MAKE_SET(fds));
-}
-
-bool fdset_isempty(FDSet *fds) {
- return set_isempty(MAKE_SET(fds));
-}
-
-int fdset_iterate(FDSet *s, Iterator *i) {
- void *p;
-
- if (!set_iterate(MAKE_SET(s), i, &p))
- return -ENOENT;
-
- return PTR_TO_FD(p);
-}
-
-int fdset_steal_first(FDSet *fds) {
- void *p;
-
- p = set_steal_first(MAKE_SET(fds));
- if (!p)
- return -ENOENT;
-
- return PTR_TO_FD(p);
-}
diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c
deleted file mode 100644
index effc6e8e7..000000000
--- a/src/shared/firewall-util.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
-#include <linux/netfilter/nf_nat.h>
-#include <linux/netfilter/xt_addrtype.h>
-#include <libiptc/libiptc.h>
-
-#include "util.h"
-#include "firewall-util.h"
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct xtc_handle*, iptc_free);
-
-static int entry_fill_basics(
- struct ipt_entry *entry,
- int protocol,
- const char *in_interface,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const char *out_interface,
- const union in_addr_union *destination,
- unsigned destination_prefixlen) {
-
- assert(entry);
-
- if (out_interface && strlen(out_interface) >= IFNAMSIZ)
- return -EINVAL;
-
- if (in_interface && strlen(in_interface) >= IFNAMSIZ)
- return -EINVAL;
-
- entry->ip.proto = protocol;
-
- if (in_interface) {
- strcpy(entry->ip.iniface, in_interface);
- memset(entry->ip.iniface_mask, 0xFF, strlen(in_interface)+1);
- }
- if (source) {
- entry->ip.src = source->in;
- in_addr_prefixlen_to_netmask(&entry->ip.smsk, source_prefixlen);
- }
-
- if (out_interface) {
- strcpy(entry->ip.outiface, out_interface);
- memset(entry->ip.outiface_mask, 0xFF, strlen(out_interface)+1);
- }
- if (destination) {
- entry->ip.dst = destination->in;
- in_addr_prefixlen_to_netmask(&entry->ip.dmsk, destination_prefixlen);
- }
-
- return 0;
-}
-
-int fw_add_masquerade(
- bool add,
- int af,
- int protocol,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const char *out_interface,
- const union in_addr_union *destination,
- unsigned destination_prefixlen) {
-
- _cleanup_(iptc_freep) struct xtc_handle *h = NULL;
- struct ipt_entry *entry, *mask;
- struct ipt_entry_target *t;
- size_t sz;
- struct nf_nat_ipv4_multi_range_compat *mr;
- int r;
-
- if (af != AF_INET)
- return -EOPNOTSUPP;
-
- if (protocol != 0 && protocol != IPPROTO_TCP && protocol != IPPROTO_UDP)
- return -EOPNOTSUPP;
-
- h = iptc_init("nat");
- if (!h)
- return -errno;
-
- sz = XT_ALIGN(sizeof(struct ipt_entry)) +
- XT_ALIGN(sizeof(struct ipt_entry_target)) +
- XT_ALIGN(sizeof(struct nf_nat_ipv4_multi_range_compat));
-
- /* Put together the entry we want to add or remove */
- entry = alloca0(sz);
- entry->next_offset = sz;
- entry->target_offset = XT_ALIGN(sizeof(struct ipt_entry));
- r = entry_fill_basics(entry, protocol, NULL, source, source_prefixlen, out_interface, destination, destination_prefixlen);
- if (r < 0)
- return r;
-
- /* Fill in target part */
- t = ipt_get_target(entry);
- t->u.target_size =
- XT_ALIGN(sizeof(struct ipt_entry_target)) +
- XT_ALIGN(sizeof(struct nf_nat_ipv4_multi_range_compat));
- strncpy(t->u.user.name, "MASQUERADE", sizeof(t->u.user.name));
- mr = (struct nf_nat_ipv4_multi_range_compat*) t->data;
- mr->rangesize = 1;
-
- /* Create a search mask entry */
- mask = alloca(sz);
- memset(mask, 0xFF, sz);
-
- if (add) {
- if (iptc_check_entry("POSTROUTING", entry, (unsigned char*) mask, h))
- return 0;
- if (errno != ENOENT) /* if other error than not existing yet, fail */
- return -errno;
-
- if (!iptc_insert_entry("POSTROUTING", entry, 0, h))
- return -errno;
- } else {
- if (!iptc_delete_entry("POSTROUTING", entry, (unsigned char*) mask, h)) {
- if (errno == ENOENT) /* if it's already gone, all is good! */
- return 0;
-
- return -errno;
- }
- }
-
- if (!iptc_commit(h))
- return -errno;
-
- return 0;
-}
-
-int fw_add_local_dnat(
- bool add,
- int af,
- int protocol,
- const char *in_interface,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const union in_addr_union *destination,
- unsigned destination_prefixlen,
- uint16_t local_port,
- const union in_addr_union *remote,
- uint16_t remote_port,
- const union in_addr_union *previous_remote) {
-
-
- _cleanup_(iptc_freep) struct xtc_handle *h = NULL;
- struct ipt_entry *entry, *mask;
- struct ipt_entry_target *t;
- struct ipt_entry_match *m;
- struct xt_addrtype_info_v1 *at;
- struct nf_nat_ipv4_multi_range_compat *mr;
- size_t sz, msz;
- int r;
-
- assert(add || !previous_remote);
-
- if (af != AF_INET)
- return -EOPNOTSUPP;
-
- if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP)
- return -EOPNOTSUPP;
-
- if (local_port <= 0)
- return -EINVAL;
-
- if (remote_port <= 0)
- return -EINVAL;
-
- h = iptc_init("nat");
- if (!h)
- return -errno;
-
- sz = XT_ALIGN(sizeof(struct ipt_entry)) +
- XT_ALIGN(sizeof(struct ipt_entry_match)) +
- XT_ALIGN(sizeof(struct xt_addrtype_info_v1)) +
- XT_ALIGN(sizeof(struct ipt_entry_target)) +
- XT_ALIGN(sizeof(struct nf_nat_ipv4_multi_range_compat));
-
- if (protocol == IPPROTO_TCP)
- msz = XT_ALIGN(sizeof(struct ipt_entry_match)) +
- XT_ALIGN(sizeof(struct xt_tcp));
- else
- msz = XT_ALIGN(sizeof(struct ipt_entry_match)) +
- XT_ALIGN(sizeof(struct xt_udp));
-
- sz += msz;
-
- /* Fill in basic part */
- entry = alloca0(sz);
- entry->next_offset = sz;
- entry->target_offset =
- XT_ALIGN(sizeof(struct ipt_entry)) +
- XT_ALIGN(sizeof(struct ipt_entry_match)) +
- XT_ALIGN(sizeof(struct xt_addrtype_info_v1)) +
- msz;
- r = entry_fill_basics(entry, protocol, in_interface, source, source_prefixlen, NULL, destination, destination_prefixlen);
- if (r < 0)
- return r;
-
- /* Fill in first match */
- m = (struct ipt_entry_match*) ((uint8_t*) entry + XT_ALIGN(sizeof(struct ipt_entry)));
- m->u.match_size = msz;
- if (protocol == IPPROTO_TCP) {
- struct xt_tcp *tcp;
-
- strncpy(m->u.user.name, "tcp", sizeof(m->u.user.name));
- tcp = (struct xt_tcp*) m->data;
- tcp->dpts[0] = tcp->dpts[1] = local_port;
- tcp->spts[0] = 0;
- tcp->spts[1] = 0xFFFF;
-
- } else {
- struct xt_udp *udp;
-
- strncpy(m->u.user.name, "udp", sizeof(m->u.user.name));
- udp = (struct xt_udp*) m->data;
- udp->dpts[0] = udp->dpts[1] = local_port;
- udp->spts[0] = 0;
- udp->spts[1] = 0xFFFF;
- }
-
- /* Fill in second match */
- m = (struct ipt_entry_match*) ((uint8_t*) entry + XT_ALIGN(sizeof(struct ipt_entry)) + msz);
- m->u.match_size =
- XT_ALIGN(sizeof(struct ipt_entry_match)) +
- XT_ALIGN(sizeof(struct xt_addrtype_info_v1));
- strncpy(m->u.user.name, "addrtype", sizeof(m->u.user.name));
- m->u.user.revision = 1;
- at = (struct xt_addrtype_info_v1*) m->data;
- at->dest = XT_ADDRTYPE_LOCAL;
-
- /* Fill in target part */
- t = ipt_get_target(entry);
- t->u.target_size =
- XT_ALIGN(sizeof(struct ipt_entry_target)) +
- XT_ALIGN(sizeof(struct nf_nat_ipv4_multi_range_compat));
- strncpy(t->u.user.name, "DNAT", sizeof(t->u.user.name));
- mr = (struct nf_nat_ipv4_multi_range_compat*) t->data;
- mr->rangesize = 1;
- mr->range[0].flags = NF_NAT_RANGE_PROTO_SPECIFIED|NF_NAT_RANGE_MAP_IPS;
- mr->range[0].min_ip = mr->range[0].max_ip = remote->in.s_addr;
- if (protocol == IPPROTO_TCP)
- mr->range[0].min.tcp.port = mr->range[0].max.tcp.port = htons(remote_port);
- else
- mr->range[0].min.udp.port = mr->range[0].max.udp.port = htons(remote_port);
-
- mask = alloca0(sz);
- memset(mask, 0xFF, sz);
-
- if (add) {
- /* Add the PREROUTING rule, if it is missing so far */
- if (!iptc_check_entry("PREROUTING", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -EINVAL;
-
- if (!iptc_insert_entry("PREROUTING", entry, 0, h))
- return -errno;
- }
-
- /* If a previous remote is set, remove its entry */
- if (previous_remote && previous_remote->in.s_addr != remote->in.s_addr) {
- mr->range[0].min_ip = mr->range[0].max_ip = previous_remote->in.s_addr;
-
- if (!iptc_delete_entry("PREROUTING", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -errno;
- }
-
- mr->range[0].min_ip = mr->range[0].max_ip = remote->in.s_addr;
- }
-
- /* Add the OUTPUT rule, if it is missing so far */
- if (!in_interface) {
-
- /* Don't apply onto loopback addresses */
- if (!destination) {
- entry->ip.dst.s_addr = htobe32(0x7F000000);
- entry->ip.dmsk.s_addr = htobe32(0xFF000000);
- entry->ip.invflags = IPT_INV_DSTIP;
- }
-
- if (!iptc_check_entry("OUTPUT", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -errno;
-
- if (!iptc_insert_entry("OUTPUT", entry, 0, h))
- return -errno;
- }
-
- /* If a previous remote is set, remove its entry */
- if (previous_remote && previous_remote->in.s_addr != remote->in.s_addr) {
- mr->range[0].min_ip = mr->range[0].max_ip = previous_remote->in.s_addr;
-
- if (!iptc_delete_entry("OUTPUT", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -errno;
- }
- }
- }
- } else {
- if (!iptc_delete_entry("PREROUTING", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -errno;
- }
-
- if (!in_interface) {
- if (!destination) {
- entry->ip.dst.s_addr = htobe32(0x7F000000);
- entry->ip.dmsk.s_addr = htobe32(0xFF000000);
- entry->ip.invflags = IPT_INV_DSTIP;
- }
-
- if (!iptc_delete_entry("OUTPUT", entry, (unsigned char*) mask, h)) {
- if (errno != ENOENT)
- return -errno;
- }
- }
- }
-
- if (!iptc_commit(h))
- return -errno;
-
- return 0;
-}
diff --git a/src/shared/firewall-util.h b/src/shared/firewall-util.h
deleted file mode 100644
index 93152e397..000000000
--- a/src/shared/firewall-util.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "in-addr-util.h"
-
-#ifdef HAVE_LIBIPTC
-
-int fw_add_masquerade(
- bool add,
- int af,
- int protocol,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const char *out_interface,
- const union in_addr_union *destination,
- unsigned destination_prefixlen);
-
-int fw_add_local_dnat(
- bool add,
- int af,
- int protocol,
- const char *in_interface,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const union in_addr_union *destination,
- unsigned destination_prefixlen,
- uint16_t local_port,
- const union in_addr_union *remote,
- uint16_t remote_port,
- const union in_addr_union *previous_remote);
-
-#else
-
-static inline int fw_add_masquerade(
- bool add,
- int af,
- int protocol,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const char *out_interface,
- const union in_addr_union *destination,
- unsigned destination_prefixlen) {
- return -EOPNOTSUPP;
-}
-
-static inline int fw_add_local_dnat(
- bool add,
- int af,
- int protocol,
- const char *in_interface,
- const union in_addr_union *source,
- unsigned source_prefixlen,
- const union in_addr_union *destination,
- unsigned destination_prefixlen,
- uint16_t local_port,
- const union in_addr_union *remote,
- uint16_t remote_port,
- const union in_addr_union *previous_remote) {
- return -EOPNOTSUPP;
-}
-
-#endif
diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c
deleted file mode 100644
index e231a0ff8..000000000
--- a/src/shared/fstab-util.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Zbigniew Jędrzejewski-Szmek
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "fstab-util.h"
-#include "strv.h"
-#include "util.h"
-
-int fstab_filter_options(const char *opts, const char *names,
- const char **namefound, char **value, char **filtered) {
- const char *name, *n = NULL, *x;
- _cleanup_strv_free_ char **stor = NULL;
- _cleanup_free_ char *v = NULL, **strv = NULL;
-
- assert(names && *names);
-
- if (!opts)
- goto answer;
-
- /* If !value and !filtered, this function is not allowed to fail. */
-
- if (!filtered) {
- const char *word, *state;
- size_t l;
-
- FOREACH_WORD_SEPARATOR(word, l, opts, ",", state)
- NULSTR_FOREACH(name, names) {
- if (l < strlen(name))
- continue;
- if (!strneq(word, name, strlen(name)))
- continue;
-
- /* we know that the string is NUL
- * terminated, so *x is valid */
- x = word + strlen(name);
- if (IN_SET(*x, '\0', '=', ',')) {
- n = name;
- if (value) {
- free(v);
- if (IN_SET(*x, '\0', ','))
- v = NULL;
- else {
- assert(*x == '=');
- x++;
- v = strndup(x, l - strlen(name) - 1);
- if (!v)
- return -ENOMEM;
- }
- }
- }
- }
- } else {
- char **t, **s;
-
- stor = strv_split(opts, ",");
- if (!stor)
- return -ENOMEM;
- strv = memdup(stor, sizeof(char*) * (strv_length(stor) + 1));
- if (!strv)
- return -ENOMEM;
-
- for (s = t = strv; *s; s++) {
- NULSTR_FOREACH(name, names) {
- x = startswith(*s, name);
- if (x && IN_SET(*x, '\0', '='))
- goto found;
- }
-
- *t = *s;
- t++;
- continue;
- found:
- /* Keep the last occurence found */
- n = name;
- if (value) {
- free(v);
- if (*x == '\0')
- v = NULL;
- else {
- assert(*x == '=');
- x++;
- v = strdup(x);
- if (!v)
- return -ENOMEM;
- }
- }
- }
- *t = NULL;
- }
-
-answer:
- if (namefound)
- *namefound = n;
- if (filtered) {
- char *f;
-
- f = strv_join(strv, ",");
- if (!f)
- return -ENOMEM;
-
- *filtered = f;
- }
- if (value) {
- *value = v;
- v = NULL;
- }
-
- return !!n;
-}
-
-int fstab_extract_values(const char *opts, const char *name, char ***values) {
- _cleanup_strv_free_ char **optsv = NULL, **res = NULL;
- char **s;
-
- assert(opts);
- assert(name);
- assert(values);
-
- optsv = strv_split(opts, ",");
- if (!optsv)
- return -ENOMEM;
-
- STRV_FOREACH(s, optsv) {
- char *arg;
- int r;
-
- arg = startswith(*s, name);
- if (!arg || *arg != '=')
- continue;
- r = strv_extend(&res, arg + 1);
- if (r < 0)
- return r;
- }
-
- *values = res;
- res = NULL;
-
- return !!*values;
-}
-
-int fstab_find_pri(const char *options, int *ret) {
- _cleanup_free_ char *opt = NULL;
- int r;
- unsigned pri;
-
- assert(ret);
-
- r = fstab_filter_options(options, "pri\0", NULL, &opt, NULL);
- if (r < 0)
- return r;
- if (r == 0 || !opt)
- return 0;
-
- r = safe_atou(opt, &pri);
- if (r < 0)
- return r;
-
- if ((int) pri < 0)
- return -ERANGE;
-
- *ret = (int) pri;
- return 1;
-}
diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h
deleted file mode 100644
index 387c562a9..000000000
--- a/src/shared/fstab-util.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Zbigniew Jędrzejewski-Szmek
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include <stddef.h>
-#include "macro.h"
-
-int fstab_filter_options(const char *opts, const char *names,
- const char **namefound, char **value, char **filtered);
-
-int fstab_extract_values(const char *opts, const char *name, char ***values);
-
-static inline bool fstab_test_option(const char *opts, const char *names) {
- return !!fstab_filter_options(opts, names, NULL, NULL, NULL);
-}
-
-int fstab_find_pri(const char *options, int *ret);
-
-static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no) {
- int r;
- const char *opt;
-
- /* If first name given is last, return 1.
- * If second name given is last or neither is found, return 0. */
-
- r = fstab_filter_options(opts, yes_no, &opt, NULL, NULL);
- assert(r >= 0);
-
- return opt == yes_no;
-}
diff --git a/src/shared/ima-util.c b/src/shared/ima-util.c
deleted file mode 100644
index 6c1954bbf..000000000
--- a/src/shared/ima-util.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-
-#include "ima-util.h"
-
-static int use_ima_cached = -1;
-
-bool use_ima(void) {
-
- if (use_ima_cached < 0)
- use_ima_cached = access("/sys/kernel/security/ima/", F_OK) >= 0;
-
- return use_ima_cached;
-}
diff --git a/src/shared/import-util.c b/src/shared/import-util.c
deleted file mode 100644
index 001a8a37e..000000000
--- a/src/shared/import-util.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "util.h"
-#include "import-util.h"
-
-int import_url_last_component(const char *url, char **ret) {
- const char *e, *p;
- char *s;
-
- e = strchrnul(url, '?');
-
- while (e > url && e[-1] == '/')
- e--;
-
- p = e;
- while (p > url && p[-1] != '/')
- p--;
-
- if (e <= p)
- return -EINVAL;
-
- s = strndup(p, e - p);
- if (!s)
- return -ENOMEM;
-
- *ret = s;
- return 0;
-}
-
-
-int import_url_change_last_component(const char *url, const char *suffix, char **ret) {
- const char *e;
- char *s;
-
- assert(url);
- assert(ret);
-
- e = strchrnul(url, '?');
-
- while (e > url && e[-1] == '/')
- e--;
-
- while (e > url && e[-1] != '/')
- e--;
-
- if (e <= url)
- return -EINVAL;
-
- s = new(char, (e - url) + strlen(suffix) + 1);
- if (!s)
- return -ENOMEM;
-
- strcpy(mempcpy(s, url, e - url), suffix);
- *ret = s;
- return 0;
-}
-
-static const char* const import_verify_table[_IMPORT_VERIFY_MAX] = {
- [IMPORT_VERIFY_NO] = "no",
- [IMPORT_VERIFY_CHECKSUM] = "checksum",
- [IMPORT_VERIFY_SIGNATURE] = "signature",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(import_verify, ImportVerify);
-
-int tar_strip_suffixes(const char *name, char **ret) {
- const char *e;
- char *s;
-
- e = endswith(name, ".tar");
- if (!e)
- e = endswith(name, ".tar.xz");
- if (!e)
- e = endswith(name, ".tar.gz");
- if (!e)
- e = endswith(name, ".tar.bz2");
- if (!e)
- e = endswith(name, ".tgz");
- if (!e)
- e = strchr(name, 0);
-
- if (e <= name)
- return -EINVAL;
-
- s = strndup(name, e - name);
- if (!s)
- return -ENOMEM;
-
- *ret = s;
- return 0;
-}
-
-int raw_strip_suffixes(const char *p, char **ret) {
-
- static const char suffixes[] =
- ".xz\0"
- ".gz\0"
- ".bz2\0"
- ".raw\0"
- ".qcow2\0"
- ".img\0"
- ".bin\0";
-
- _cleanup_free_ char *q = NULL;
-
- q = strdup(p);
- if (!q)
- return -ENOMEM;
-
- for (;;) {
- const char *sfx;
- bool changed = false;
-
- NULSTR_FOREACH(sfx, suffixes) {
- char *e;
-
- e = endswith(q, sfx);
- if (e) {
- *e = 0;
- changed = true;
- }
- }
-
- if (!changed)
- break;
- }
-
- *ret = q;
- q = NULL;
-
- return 0;
-}
-
-bool dkr_digest_is_valid(const char *digest) {
- /* 7 chars for prefix, 64 chars for the digest itself */
- if (strlen(digest) != 71)
- return false;
-
- return startswith(digest, "sha256:") && in_charset(digest + 7, "0123456789abcdef");
-}
-
-bool dkr_ref_is_valid(const char *ref) {
- const char *colon;
-
- if (isempty(ref))
- return false;
-
- colon = strchr(ref, ':');
- if (!colon)
- return filename_is_valid(ref);
-
- return dkr_digest_is_valid(ref);
-}
-
-bool dkr_name_is_valid(const char *name) {
- const char *slash, *p;
-
- if (isempty(name))
- return false;
-
- slash = strchr(name, '/');
- if (!slash)
- return false;
-
- if (!filename_is_valid(slash + 1))
- return false;
-
- p = strndupa(name, slash - name);
- if (!filename_is_valid(p))
- return false;
-
- return true;
-}
-
-bool dkr_id_is_valid(const char *id) {
-
- if (!filename_is_valid(id))
- return false;
-
- if (!in_charset(id, "0123456789abcdef"))
- return false;
-
- return true;
-}
diff --git a/src/shared/import-util.h b/src/shared/import-util.h
deleted file mode 100644
index 7bf7d4ca4..000000000
--- a/src/shared/import-util.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-
-#include "macro.h"
-
-typedef enum ImportVerify {
- IMPORT_VERIFY_NO,
- IMPORT_VERIFY_CHECKSUM,
- IMPORT_VERIFY_SIGNATURE,
- _IMPORT_VERIFY_MAX,
- _IMPORT_VERIFY_INVALID = -1,
-} ImportVerify;
-
-int import_url_last_component(const char *url, char **ret);
-int import_url_change_last_component(const char *url, const char *suffix, char **ret);
-
-const char* import_verify_to_string(ImportVerify v) _const_;
-ImportVerify import_verify_from_string(const char *s) _pure_;
-
-int tar_strip_suffixes(const char *name, char **ret);
-int raw_strip_suffixes(const char *name, char **ret);
-
-bool dkr_name_is_valid(const char *name);
-bool dkr_id_is_valid(const char *id);
-bool dkr_ref_is_valid(const char *ref);
-bool dkr_digest_is_valid(const char *digest);
-#define dkr_tag_is_valid(tag) filename_is_valid(tag)
diff --git a/src/shared/in-addr-util.c b/src/shared/in-addr-util.c
deleted file mode 100644
index d88864b59..000000000
--- a/src/shared/in-addr-util.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <arpa/inet.h>
-
-#include "in-addr-util.h"
-
-int in_addr_is_null(int family, const union in_addr_union *u) {
- assert(u);
-
- if (family == AF_INET)
- return u->in.s_addr == 0;
-
- if (family == AF_INET6)
- return
- u->in6.s6_addr32[0] == 0 &&
- u->in6.s6_addr32[1] == 0 &&
- u->in6.s6_addr32[2] == 0 &&
- u->in6.s6_addr32[3] == 0;
-
- return -EAFNOSUPPORT;
-}
-
-int in_addr_is_link_local(int family, const union in_addr_union *u) {
- assert(u);
-
- if (family == AF_INET)
- return (be32toh(u->in.s_addr) & 0xFFFF0000) == (169U << 24 | 254U << 16);
-
- if (family == AF_INET6)
- return IN6_IS_ADDR_LINKLOCAL(&u->in6);
-
- return -EAFNOSUPPORT;
-}
-
-int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
- assert(a);
- assert(b);
-
- if (family == AF_INET)
- return a->in.s_addr == b->in.s_addr;
-
- if (family == AF_INET6)
- return
- a->in6.s6_addr32[0] == b->in6.s6_addr32[0] &&
- a->in6.s6_addr32[1] == b->in6.s6_addr32[1] &&
- a->in6.s6_addr32[2] == b->in6.s6_addr32[2] &&
- a->in6.s6_addr32[3] == b->in6.s6_addr32[3];
-
- return -EAFNOSUPPORT;
-}
-
-int in_addr_prefix_intersect(
- int family,
- const union in_addr_union *a,
- unsigned aprefixlen,
- const union in_addr_union *b,
- unsigned bprefixlen) {
-
- unsigned m;
-
- assert(a);
- assert(b);
-
- /* Checks whether there are any addresses that are in both
- * networks */
-
- m = MIN(aprefixlen, bprefixlen);
-
- if (family == AF_INET) {
- uint32_t x, nm;
-
- x = be32toh(a->in.s_addr ^ b->in.s_addr);
- nm = (m == 0) ? 0 : 0xFFFFFFFFUL << (32 - m);
-
- return (x & nm) == 0;
- }
-
- if (family == AF_INET6) {
- unsigned i;
-
- if (m > 128)
- m = 128;
-
- for (i = 0; i < 16; i++) {
- uint8_t x, nm;
-
- x = a->in6.s6_addr[i] ^ b->in6.s6_addr[i];
-
- if (m < 8)
- nm = 0xFF << (8 - m);
- else
- nm = 0xFF;
-
- if ((x & nm) != 0)
- return 0;
-
- if (m > 8)
- m -= 8;
- else
- m = 0;
- }
-
- return 1;
- }
-
- return -EAFNOSUPPORT;
-}
-
-int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen) {
- assert(u);
-
- /* Increases the network part of an address by one. Returns
- * positive it that succeeds, or 0 if this overflows. */
-
- if (prefixlen <= 0)
- return 0;
-
- if (family == AF_INET) {
- uint32_t c, n;
-
- if (prefixlen > 32)
- prefixlen = 32;
-
- c = be32toh(u->in.s_addr);
- n = c + (1UL << (32 - prefixlen));
- if (n < c)
- return 0;
- n &= 0xFFFFFFFFUL << (32 - prefixlen);
-
- u->in.s_addr = htobe32(n);
- return 1;
- }
-
- if (family == AF_INET6) {
- struct in6_addr add = {}, result;
- uint8_t overflow = 0;
- unsigned i;
-
- if (prefixlen > 128)
- prefixlen = 128;
-
- /* First calculate what we have to add */
- add.s6_addr[(prefixlen-1) / 8] = 1 << (7 - (prefixlen-1) % 8);
-
- for (i = 16; i > 0; i--) {
- unsigned j = i - 1;
-
- result.s6_addr[j] = u->in6.s6_addr[j] + add.s6_addr[j] + overflow;
- overflow = (result.s6_addr[j] < u->in6.s6_addr[j]);
- }
-
- if (overflow)
- return 0;
-
- u->in6 = result;
- return 1;
- }
-
- return -EAFNOSUPPORT;
-}
-
-int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
- char *x;
- size_t l;
-
- assert(u);
- assert(ret);
-
- if (family == AF_INET)
- l = INET_ADDRSTRLEN;
- else if (family == AF_INET6)
- l = INET6_ADDRSTRLEN;
- else
- return -EAFNOSUPPORT;
-
- x = new(char, l);
- if (!x)
- return -ENOMEM;
-
- errno = 0;
- if (!inet_ntop(family, u, x, l)) {
- free(x);
- return errno ? -errno : -EINVAL;
- }
-
- *ret = x;
- return 0;
-}
-
-int in_addr_from_string(int family, const char *s, union in_addr_union *ret) {
-
- assert(s);
- assert(ret);
-
- if (!IN_SET(family, AF_INET, AF_INET6))
- return -EAFNOSUPPORT;
-
- errno = 0;
- if (inet_pton(family, s, ret) <= 0)
- return errno ? -errno : -EINVAL;
-
- return 0;
-}
-
-int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *ret) {
- int r;
-
- assert(s);
- assert(family);
- assert(ret);
-
- r = in_addr_from_string(AF_INET, s, ret);
- if (r >= 0) {
- *family = AF_INET;
- return 0;
- }
-
- r = in_addr_from_string(AF_INET6, s, ret);
- if (r >= 0) {
- *family = AF_INET6;
- return 0;
- }
-
- return -EINVAL;
-}
-
-unsigned char in_addr_netmask_to_prefixlen(const struct in_addr *addr) {
- assert(addr);
-
- return 32 - u32ctz(be32toh(addr->s_addr));
-}
-
-struct in_addr* in_addr_prefixlen_to_netmask(struct in_addr *addr, unsigned char prefixlen) {
- assert(addr);
- assert(prefixlen <= 32);
-
- /* Shifting beyond 32 is not defined, handle this specially. */
- if (prefixlen == 0)
- addr->s_addr = 0;
- else
- addr->s_addr = htobe32((0xffffffff << (32 - prefixlen)) & 0xffffffff);
-
- return addr;
-}
-
-int in_addr_default_prefixlen(const struct in_addr *addr, unsigned char *prefixlen) {
- uint8_t msb_octet = *(uint8_t*) addr;
-
- /* addr may not be aligned, so make sure we only access it byte-wise */
-
- assert(addr);
- assert(prefixlen);
-
- if (msb_octet < 128)
- /* class A, leading bits: 0 */
- *prefixlen = 8;
- else if (msb_octet < 192)
- /* class B, leading bits 10 */
- *prefixlen = 16;
- else if (msb_octet < 224)
- /* class C, leading bits 110 */
- *prefixlen = 24;
- else
- /* class D or E, no default prefixlen */
- return -ERANGE;
-
- return 0;
-}
-
-int in_addr_default_subnet_mask(const struct in_addr *addr, struct in_addr *mask) {
- unsigned char prefixlen;
- int r;
-
- assert(addr);
- assert(mask);
-
- r = in_addr_default_prefixlen(addr, &prefixlen);
- if (r < 0)
- return r;
-
- in_addr_prefixlen_to_netmask(mask, prefixlen);
- return 0;
-}
-
-int in_addr_mask(int family, union in_addr_union *addr, unsigned char prefixlen) {
- assert(addr);
-
- if (family == AF_INET) {
- struct in_addr mask;
-
- if (!in_addr_prefixlen_to_netmask(&mask, prefixlen))
- return -EINVAL;
-
- addr->in.s_addr &= mask.s_addr;
- return 0;
- }
-
- if (family == AF_INET6) {
- unsigned i;
-
- for (i = 0; i < 16; i++) {
- uint8_t mask;
-
- if (prefixlen >= 8) {
- mask = 0xFF;
- prefixlen -= 8;
- } else {
- mask = 0xFF << (8 - prefixlen);
- prefixlen = 0;
- }
-
- addr->in6.s6_addr[i] &= mask;
- }
-
- return 0;
- }
-
- return -EAFNOSUPPORT;
-}
diff --git a/src/shared/in-addr-util.h b/src/shared/in-addr-util.h
deleted file mode 100644
index 51af08868..000000000
--- a/src/shared/in-addr-util.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <netinet/in.h>
-
-#include "macro.h"
-#include "util.h"
-
-union in_addr_union {
- struct in_addr in;
- struct in6_addr in6;
-};
-
-int in_addr_is_null(int family, const union in_addr_union *u);
-int in_addr_is_link_local(int family, const union in_addr_union *u);
-int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b);
-int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
-int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);
-int in_addr_to_string(int family, const union in_addr_union *u, char **ret);
-int in_addr_from_string(int family, const char *s, union in_addr_union *ret);
-int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *ret);
-unsigned char in_addr_netmask_to_prefixlen(const struct in_addr *addr);
-struct in_addr* in_addr_prefixlen_to_netmask(struct in_addr *addr, unsigned char prefixlen);
-int in_addr_default_prefixlen(const struct in_addr *addr, unsigned char *prefixlen);
-int in_addr_default_subnet_mask(const struct in_addr *addr, struct in_addr *mask);
-int in_addr_mask(int family, union in_addr_union *addr, unsigned char prefixlen);
-
-static inline size_t FAMILY_ADDRESS_SIZE(int family) {
- assert(family == AF_INET || family == AF_INET6);
- return family == AF_INET6 ? 16 : 4;
-}
-
-#define IN_ADDR_NULL ((union in_addr_union) {})
diff --git a/src/shared/json.c b/src/shared/json.c
deleted file mode 100644
index be40a0d20..000000000
--- a/src/shared/json.c
+++ /dev/null
@@ -1,866 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-#include <math.h>
-#include "macro.h"
-#include "utf8.h"
-#include "json.h"
-
-int json_variant_new(JsonVariant **ret, JsonVariantType type) {
- JsonVariant *v;
-
- v = new0(JsonVariant, 1);
- if (!v)
- return -ENOMEM;
- v->type = type;
- *ret = v;
- return 0;
-}
-
-static int json_variant_deep_copy(JsonVariant *ret, JsonVariant *variant) {
- int r;
-
- assert(ret);
- assert(variant);
-
- ret->type = variant->type;
- ret->size = variant->size;
-
- if (variant->type == JSON_VARIANT_STRING) {
- ret->string = memdup(variant->string, variant->size+1);
- if (!ret->string)
- return -ENOMEM;
- } else if (variant->type == JSON_VARIANT_ARRAY || variant->type == JSON_VARIANT_OBJECT) {
- size_t i;
-
- ret->objects = new0(JsonVariant, variant->size);
- if (!ret->objects)
- return -ENOMEM;
-
- for (i = 0; i < variant->size; ++i) {
- r = json_variant_deep_copy(&ret->objects[i], &variant->objects[i]);
- if (r < 0)
- return r;
- }
- } else
- ret->value = variant->value;
-
- return 0;
-}
-
-static JsonVariant *json_object_unref(JsonVariant *variant);
-
-static JsonVariant *json_variant_unref_inner(JsonVariant *variant) {
- if (!variant)
- return NULL;
-
- if (variant->type == JSON_VARIANT_ARRAY || variant->type == JSON_VARIANT_OBJECT)
- return json_object_unref(variant);
- else if (variant->type == JSON_VARIANT_STRING)
- free(variant->string);
-
- return NULL;
-}
-
-static JsonVariant *json_raw_unref(JsonVariant *variant, size_t size) {
- if (!variant)
- return NULL;
-
- for (size_t i = 0; i < size; ++i)
- json_variant_unref_inner(&variant[i]);
-
- free(variant);
- return NULL;
-}
-
-static JsonVariant *json_object_unref(JsonVariant *variant) {
- size_t i;
-
- assert(variant);
-
- if (!variant->objects)
- return NULL;
-
- for (i = 0; i < variant->size; ++i)
- json_variant_unref_inner(&variant->objects[i]);
-
- free(variant->objects);
- return NULL;
-}
-
-static JsonVariant **json_variant_array_unref(JsonVariant **variant) {
- size_t i = 0;
- JsonVariant *p = NULL;
-
- if (!variant)
- return NULL;
-
- while((p = (variant[i++])) != NULL) {
- if (p->type == JSON_VARIANT_STRING)
- free(p->string);
- free(p);
- }
-
- free(variant);
-
- return NULL;
-}
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(JsonVariant **, json_variant_array_unref);
-
-JsonVariant *json_variant_unref(JsonVariant *variant) {
- if (!variant)
- return NULL;
-
- if (variant->type == JSON_VARIANT_ARRAY || variant->type == JSON_VARIANT_OBJECT)
- json_object_unref(variant);
- else if (variant->type == JSON_VARIANT_STRING)
- free(variant->string);
-
- free(variant);
-
- return NULL;
-}
-
-char *json_variant_string(JsonVariant *variant){
- assert(variant);
- assert(variant->type == JSON_VARIANT_STRING);
-
- return variant->string;
-}
-
-bool json_variant_bool(JsonVariant *variant) {
- assert(variant);
- assert(variant->type == JSON_VARIANT_BOOLEAN);
-
- return variant->value.boolean;
-}
-
-intmax_t json_variant_integer(JsonVariant *variant) {
- assert(variant);
- assert(variant->type == JSON_VARIANT_INTEGER);
-
- return variant->value.integer;
-}
-
-double json_variant_real(JsonVariant *variant) {
- assert(variant);
- assert(variant->type == JSON_VARIANT_REAL);
-
- return variant->value.real;
-}
-
-JsonVariant *json_variant_element(JsonVariant *variant, unsigned index) {
- assert(variant);
- assert(variant->type == JSON_VARIANT_ARRAY || variant->type == JSON_VARIANT_OBJECT);
- assert(index < variant->size);
- assert(variant->objects);
-
- return &variant->objects[index];
-}
-
-JsonVariant *json_variant_value(JsonVariant *variant, const char *key) {
- size_t i;
-
- assert(variant);
- assert(variant->type == JSON_VARIANT_OBJECT);
- assert(variant->objects);
-
- for (i = 0; i < variant->size; i += 2) {
- JsonVariant *p = &variant->objects[i];
- if (p->type == JSON_VARIANT_STRING && streq(key, p->string))
- return &variant->objects[i + 1];
- }
-
- return NULL;
-}
-
-static void inc_lines(unsigned *line, const char *s, size_t n) {
- const char *p = s;
-
- if (!line)
- return;
-
- for (;;) {
- const char *f;
-
- f = memchr(p, '\n', n);
- if (!f)
- return;
-
- n -= (f - p) + 1;
- p = f + 1;
- (*line)++;
- }
-}
-
-static int unhex_ucs2(const char *c, uint16_t *ret) {
- int aa, bb, cc, dd;
- uint16_t x;
-
- assert(c);
- assert(ret);
-
- aa = unhexchar(c[0]);
- if (aa < 0)
- return -EINVAL;
-
- bb = unhexchar(c[1]);
- if (bb < 0)
- return -EINVAL;
-
- cc = unhexchar(c[2]);
- if (cc < 0)
- return -EINVAL;
-
- dd = unhexchar(c[3]);
- if (dd < 0)
- return -EINVAL;
-
- x = ((uint16_t) aa << 12) |
- ((uint16_t) bb << 8) |
- ((uint16_t) cc << 4) |
- ((uint16_t) dd);
-
- if (x <= 0)
- return -EINVAL;
-
- *ret = x;
-
- return 0;
-}
-
-static int json_parse_string(const char **p, char **ret) {
- _cleanup_free_ char *s = NULL;
- size_t n = 0, allocated = 0;
- const char *c;
-
- assert(p);
- assert(*p);
- assert(ret);
-
- c = *p;
-
- if (*c != '"')
- return -EINVAL;
-
- c++;
-
- for (;;) {
- int len;
-
- /* Check for EOF */
- if (*c == 0)
- return -EINVAL;
-
- /* Check for control characters 0x00..0x1f */
- if (*c > 0 && *c < ' ')
- return -EINVAL;
-
- /* Check for control character 0x7f */
- if (*c == 0x7f)
- return -EINVAL;
-
- if (*c == '"') {
- if (!s) {
- s = strdup("");
- if (!s)
- return -ENOMEM;
- } else
- s[n] = 0;
-
- *p = c + 1;
-
- *ret = s;
- s = NULL;
- return JSON_STRING;
- }
-
- if (*c == '\\') {
- char ch = 0;
- c++;
-
- if (*c == 0)
- return -EINVAL;
-
- if (IN_SET(*c, '"', '\\', '/'))
- ch = *c;
- else if (*c == 'b')
- ch = '\b';
- else if (*c == 'f')
- ch = '\f';
- else if (*c == 'n')
- ch = '\n';
- else if (*c == 'r')
- ch = '\r';
- else if (*c == 't')
- ch = '\t';
- else if (*c == 'u') {
- uint16_t x;
- int r;
-
- r = unhex_ucs2(c + 1, &x);
- if (r < 0)
- return r;
-
- c += 5;
-
- if (!GREEDY_REALLOC(s, allocated, n + 4))
- return -ENOMEM;
-
- if (!utf16_is_surrogate(x))
- n += utf8_encode_unichar(s + n, x);
- else if (utf16_is_trailing_surrogate(x))
- return -EINVAL;
- else {
- uint16_t y;
-
- if (c[0] != '\\' || c[1] != 'u')
- return -EINVAL;
-
- r = unhex_ucs2(c + 2, &y);
- if (r < 0)
- return r;
-
- c += 6;
-
- if (!utf16_is_trailing_surrogate(y))
- return -EINVAL;
-
- n += utf8_encode_unichar(s + n, utf16_surrogate_pair_to_unichar(x, y));
- }
-
- continue;
- } else
- return -EINVAL;
-
- if (!GREEDY_REALLOC(s, allocated, n + 2))
- return -ENOMEM;
-
- s[n++] = ch;
- c ++;
- continue;
- }
-
- len = utf8_encoded_valid_unichar(c);
- if (len < 0)
- return len;
-
- if (!GREEDY_REALLOC(s, allocated, n + len + 1))
- return -ENOMEM;
-
- memcpy(s + n, c, len);
- n += len;
- c += len;
- }
-}
-
-static int json_parse_number(const char **p, union json_value *ret) {
- bool negative = false, exponent_negative = false, is_double = false;
- double x = 0.0, y = 0.0, exponent = 0.0, shift = 1.0;
- intmax_t i = 0;
- const char *c;
-
- assert(p);
- assert(*p);
- assert(ret);
-
- c = *p;
-
- if (*c == '-') {
- negative = true;
- c++;
- }
-
- if (*c == '0')
- c++;
- else {
- if (!strchr("123456789", *c) || *c == 0)
- return -EINVAL;
-
- do {
- if (!is_double) {
- int64_t t;
-
- t = 10 * i + (*c - '0');
- if (t < i) /* overflow */
- is_double = false;
- else
- i = t;
- }
-
- x = 10.0 * x + (*c - '0');
- c++;
- } while (strchr("0123456789", *c) && *c != 0);
- }
-
- if (*c == '.') {
- is_double = true;
- c++;
-
- if (!strchr("0123456789", *c) || *c == 0)
- return -EINVAL;
-
- do {
- y = 10.0 * y + (*c - '0');
- shift = 10.0 * shift;
- c++;
- } while (strchr("0123456789", *c) && *c != 0);
- }
-
- if (*c == 'e' || *c == 'E') {
- is_double = true;
- c++;
-
- if (*c == '-') {
- exponent_negative = true;
- c++;
- } else if (*c == '+')
- c++;
-
- if (!strchr("0123456789", *c) || *c == 0)
- return -EINVAL;
-
- do {
- exponent = 10.0 * exponent + (*c - '0');
- c++;
- } while (strchr("0123456789", *c) && *c != 0);
- }
-
- *p = c;
-
- if (is_double) {
- ret->real = ((negative ? -1.0 : 1.0) * (x + (y / shift))) * exp10((exponent_negative ? -1.0 : 1.0) * exponent);
- return JSON_REAL;
- } else {
- ret->integer = negative ? -i : i;
- return JSON_INTEGER;
- }
-}
-
-int json_tokenize(
- const char **p,
- char **ret_string,
- union json_value *ret_value,
- void **state,
- unsigned *line) {
-
- const char *c;
- int t;
- int r;
-
- enum {
- STATE_NULL,
- STATE_VALUE,
- STATE_VALUE_POST,
- };
-
- assert(p);
- assert(*p);
- assert(ret_string);
- assert(ret_value);
- assert(state);
-
- t = PTR_TO_INT(*state);
- c = *p;
-
- if (t == STATE_NULL) {
- if (line)
- *line = 1;
- t = STATE_VALUE;
- }
-
- for (;;) {
- const char *b;
-
- b = c + strspn(c, WHITESPACE);
- if (*b == 0)
- return JSON_END;
-
- inc_lines(line, c, b - c);
- c = b;
-
- switch (t) {
-
- case STATE_VALUE:
-
- if (*c == '{') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE);
- return JSON_OBJECT_OPEN;
-
- } else if (*c == '}') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_OBJECT_CLOSE;
-
- } else if (*c == '[') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE);
- return JSON_ARRAY_OPEN;
-
- } else if (*c == ']') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_ARRAY_CLOSE;
-
- } else if (*c == '"') {
- r = json_parse_string(&c, ret_string);
- if (r < 0)
- return r;
-
- *ret_value = JSON_VALUE_NULL;
- *p = c;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return r;
-
- } else if (strchr("-0123456789", *c)) {
- r = json_parse_number(&c, ret_value);
- if (r < 0)
- return r;
-
- *ret_string = NULL;
- *p = c;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return r;
-
- } else if (startswith(c, "true")) {
- *ret_string = NULL;
- ret_value->boolean = true;
- *p = c + 4;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_BOOLEAN;
-
- } else if (startswith(c, "false")) {
- *ret_string = NULL;
- ret_value->boolean = false;
- *p = c + 5;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_BOOLEAN;
-
- } else if (startswith(c, "null")) {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 4;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_NULL;
-
- } else
- return -EINVAL;
-
- case STATE_VALUE_POST:
-
- if (*c == ':') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE);
- return JSON_COLON;
- } else if (*c == ',') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE);
- return JSON_COMMA;
- } else if (*c == '}') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_OBJECT_CLOSE;
- } else if (*c == ']') {
- *ret_string = NULL;
- *ret_value = JSON_VALUE_NULL;
- *p = c + 1;
- *state = INT_TO_PTR(STATE_VALUE_POST);
- return JSON_ARRAY_CLOSE;
- } else
- return -EINVAL;
- }
-
- }
-}
-
-static bool json_is_value(JsonVariant *var) {
- assert(var);
-
- return var->type != JSON_VARIANT_CONTROL;
-}
-
-static int json_scoped_parse(JsonVariant **tokens, size_t *i, size_t n, JsonVariant *scope) {
- bool arr = scope->type == JSON_VARIANT_ARRAY;
- int terminator = arr ? JSON_ARRAY_CLOSE : JSON_OBJECT_CLOSE;
- size_t allocated = 0, size = 0;
- JsonVariant *key = NULL, *value = NULL, *var = NULL, *items = NULL;
- enum {
- STATE_KEY,
- STATE_COLON,
- STATE_COMMA,
- STATE_VALUE
- } state = arr ? STATE_VALUE : STATE_KEY;
-
- assert(tokens);
- assert(i);
- assert(scope);
-
- while((var = *i < n ? tokens[(*i)++] : NULL) != NULL) {
- bool stopper;
- int r;
-
- stopper = !json_is_value(var) && var->value.integer == terminator;
-
- if (stopper) {
- if (state != STATE_COMMA && size > 0)
- goto error;
-
- goto out;
- }
-
- if (state == STATE_KEY) {
- if (var->type != JSON_VARIANT_STRING)
- goto error;
- else {
- key = var;
- state = STATE_COLON;
- }
- }
- else if (state == STATE_COLON) {
- if (key == NULL)
- goto error;
-
- if (json_is_value(var))
- goto error;
-
- if (var->value.integer != JSON_COLON)
- goto error;
-
- state = STATE_VALUE;
- }
- else if (state == STATE_VALUE) {
- _cleanup_json_variant_unref_ JsonVariant *v = NULL;
- size_t toadd = arr ? 1 : 2;
-
- if (!json_is_value(var)) {
- int type = (var->value.integer == JSON_ARRAY_OPEN) ? JSON_VARIANT_ARRAY : JSON_VARIANT_OBJECT;
-
- r = json_variant_new(&v, type);
- if (r < 0)
- goto error;
-
- r = json_scoped_parse(tokens, i, n, v);
- if (r < 0)
- goto error;
-
- value = v;
- }
- else
- value = var;
-
- if(!GREEDY_REALLOC(items, allocated, size + toadd))
- goto error;
-
- if (arr) {
- r = json_variant_deep_copy(&items[size], value);
- if (r < 0)
- goto error;
- } else {
- r = json_variant_deep_copy(&items[size], key);
- if (r < 0)
- goto error;
-
- r = json_variant_deep_copy(&items[size+1], value);
- if (r < 0)
- goto error;
- }
-
- size += toadd;
- state = STATE_COMMA;
- }
- else if (state == STATE_COMMA) {
- if (json_is_value(var))
- goto error;
-
- if (var->value.integer != JSON_COMMA)
- goto error;
-
- key = NULL;
- value = NULL;
-
- state = arr ? STATE_VALUE : STATE_KEY;
- }
- }
-
-error:
- json_raw_unref(items, size);
- return -EBADMSG;
-
-out:
- scope->size = size;
- scope->objects = items;
-
- return scope->type;
-}
-
-static int json_parse_tokens(JsonVariant **tokens, size_t ntokens, JsonVariant **rv) {
- size_t it = 0;
- int r;
- JsonVariant *e;
- _cleanup_json_variant_unref_ JsonVariant *p = NULL;
-
- assert(tokens);
- assert(ntokens);
-
- e = tokens[it++];
- r = json_variant_new(&p, JSON_VARIANT_OBJECT);
- if (r < 0)
- return r;
-
- if (e->type != JSON_VARIANT_CONTROL && e->value.integer != JSON_OBJECT_OPEN)
- return -EBADMSG;
-
- r = json_scoped_parse(tokens, &it, ntokens, p);
- if (r < 0)
- return r;
-
- *rv = p;
- p = NULL;
-
- return 0;
-}
-
-static int json_tokens(const char *string, size_t size, JsonVariant ***tokens, size_t *n) {
- _cleanup_free_ char *buf = NULL;
- _cleanup_(json_variant_array_unrefp) JsonVariant **items = NULL;
- union json_value v = {};
- void *json_state = NULL;
- const char *p;
- int t, r;
- size_t allocated = 0, s = 0;
-
- assert(string);
- assert(n);
-
- if (size <= 0)
- return -EBADMSG;
-
- buf = strndup(string, size);
- if (!buf)
- return -ENOMEM;
-
- p = buf;
- for (;;) {
- _cleanup_json_variant_unref_ JsonVariant *var = NULL;
- _cleanup_free_ char *rstr = NULL;
-
- t = json_tokenize(&p, &rstr, &v, &json_state, NULL);
-
- if (t < 0)
- return t;
- else if (t == JSON_END)
- break;
-
- if (t <= JSON_ARRAY_CLOSE) {
- r = json_variant_new(&var, JSON_VARIANT_CONTROL);
- if (r < 0)
- return r;
- var->value.integer = t;
- } else {
- switch (t) {
- case JSON_STRING:
- r = json_variant_new(&var, JSON_VARIANT_STRING);
- if (r < 0)
- return r;
- var->size = strlen(rstr);
- var->string = strdup(rstr);
- if (!var->string) {
- return -ENOMEM;
- }
- break;
- case JSON_INTEGER:
- r = json_variant_new(&var, JSON_VARIANT_INTEGER);
- if (r < 0)
- return r;
- var->value = v;
- break;
- case JSON_REAL:
- r = json_variant_new(&var, JSON_VARIANT_REAL);
- if (r < 0)
- return r;
- var->value = v;
- break;
- case JSON_BOOLEAN:
- r = json_variant_new(&var, JSON_VARIANT_BOOLEAN);
- if (r < 0)
- return r;
- var->value = v;
- break;
- case JSON_NULL:
- r = json_variant_new(&var, JSON_VARIANT_NULL);
- if (r < 0)
- return r;
- break;
- }
- }
-
- if (!GREEDY_REALLOC(items, allocated, s+2))
- return -ENOMEM;
-
- items[s++] = var;
- items[s] = NULL;
- var = NULL;
- }
-
- *n = s;
- *tokens = items;
- items = NULL;
-
- return 0;
-}
-
-int json_parse(const char *string, JsonVariant **rv) {
- _cleanup_(json_variant_array_unrefp) JsonVariant **s = NULL;
- JsonVariant *v = NULL;
- size_t n = 0;
- int r;
-
- assert(string);
- assert(rv);
-
- r = json_tokens(string, strlen(string), &s, &n);
- if (r < 0)
- return r;
-
- r = json_parse_tokens(s, n, &v);
- if (r < 0)
- return r;
-
- *rv = v;
- return 0;
-}
diff --git a/src/shared/json.h b/src/shared/json.h
deleted file mode 100644
index e0b4d810b..000000000
--- a/src/shared/json.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include "util.h"
-
-enum {
- JSON_END,
- JSON_COLON,
- JSON_COMMA,
- JSON_OBJECT_OPEN,
- JSON_OBJECT_CLOSE,
- JSON_ARRAY_OPEN,
- JSON_ARRAY_CLOSE,
- JSON_STRING,
- JSON_REAL,
- JSON_INTEGER,
- JSON_BOOLEAN,
- JSON_NULL,
-};
-
-typedef enum {
- JSON_VARIANT_CONTROL,
- JSON_VARIANT_STRING,
- JSON_VARIANT_INTEGER,
- JSON_VARIANT_BOOLEAN,
- JSON_VARIANT_REAL,
- JSON_VARIANT_ARRAY,
- JSON_VARIANT_OBJECT,
- JSON_VARIANT_NULL
-} JsonVariantType;
-
-union json_value {
- bool boolean;
- double real;
- intmax_t integer;
-};
-
-typedef struct JsonVariant {
- JsonVariantType type;
- size_t size;
- union {
- char *string;
- struct JsonVariant *objects;
- union json_value value;
- };
-} JsonVariant;
-
-int json_variant_new(JsonVariant **ret, JsonVariantType type);
-JsonVariant *json_variant_unref(JsonVariant *v);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(JsonVariant *, json_variant_unref);
-#define _cleanup_json_variant_unref_ _cleanup_(json_variant_unrefp)
-
-char *json_variant_string(JsonVariant *v);
-bool json_variant_bool(JsonVariant *v);
-intmax_t json_variant_integer(JsonVariant *v);
-double json_variant_real(JsonVariant *v);
-
-JsonVariant *json_variant_element(JsonVariant *v, unsigned index);
-JsonVariant *json_variant_value(JsonVariant *v, const char *key);
-
-#define JSON_VALUE_NULL ((union json_value) {})
-
-int json_tokenize(const char **p, char **ret_string, union json_value *ret_value, void **state, unsigned *line);
-
-int json_parse(const char *string, JsonVariant **rv);
-int json_parse_measure(const char *string, size_t *size);
diff --git a/src/shared/linux/Makefile b/src/shared/linux/Makefile
deleted file mode 120000
index d0b0e8e00..000000000
--- a/src/shared/linux/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file
diff --git a/src/shared/locale-util.c b/src/shared/locale-util.c
deleted file mode 100644
index 61db9a812..000000000
--- a/src/shared/locale-util.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/mman.h>
-
-#include "set.h"
-#include "util.h"
-#include "utf8.h"
-#include "strv.h"
-
-#include "locale-util.h"
-
-static int add_locales_from_archive(Set *locales) {
- /* Stolen from glibc... */
-
- struct locarhead {
- uint32_t magic;
- /* Serial number. */
- uint32_t serial;
- /* Name hash table. */
- uint32_t namehash_offset;
- uint32_t namehash_used;
- uint32_t namehash_size;
- /* String table. */
- uint32_t string_offset;
- uint32_t string_used;
- uint32_t string_size;
- /* Table with locale records. */
- uint32_t locrectab_offset;
- uint32_t locrectab_used;
- uint32_t locrectab_size;
- /* MD5 sum hash table. */
- uint32_t sumhash_offset;
- uint32_t sumhash_used;
- uint32_t sumhash_size;
- };
-
- struct namehashent {
- /* Hash value of the name. */
- uint32_t hashval;
- /* Offset of the name in the string table. */
- uint32_t name_offset;
- /* Offset of the locale record. */
- uint32_t locrec_offset;
- };
-
- const struct locarhead *h;
- const struct namehashent *e;
- const void *p = MAP_FAILED;
- _cleanup_close_ int fd = -1;
- size_t sz = 0;
- struct stat st;
- unsigned i;
- int r;
-
- fd = open("/usr/lib/locale/locale-archive", O_RDONLY|O_NOCTTY|O_CLOEXEC);
- if (fd < 0)
- return errno == ENOENT ? 0 : -errno;
-
- if (fstat(fd, &st) < 0)
- return -errno;
-
- if (!S_ISREG(st.st_mode))
- return -EBADMSG;
-
- if (st.st_size < (off_t) sizeof(struct locarhead))
- return -EBADMSG;
-
- p = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (p == MAP_FAILED)
- return -errno;
-
- h = (const struct locarhead *) p;
- if (h->magic != 0xde020109 ||
- h->namehash_offset + h->namehash_size > st.st_size ||
- h->string_offset + h->string_size > st.st_size ||
- h->locrectab_offset + h->locrectab_size > st.st_size ||
- h->sumhash_offset + h->sumhash_size > st.st_size) {
- r = -EBADMSG;
- goto finish;
- }
-
- e = (const struct namehashent*) ((const uint8_t*) p + h->namehash_offset);
- for (i = 0; i < h->namehash_size; i++) {
- char *z;
-
- if (e[i].locrec_offset == 0)
- continue;
-
- if (!utf8_is_valid((char*) p + e[i].name_offset))
- continue;
-
- z = strdup((char*) p + e[i].name_offset);
- if (!z) {
- r = -ENOMEM;
- goto finish;
- }
-
- r = set_consume(locales, z);
- if (r < 0)
- goto finish;
- }
-
- r = 0;
-
- finish:
- if (p != MAP_FAILED)
- munmap((void*) p, sz);
-
- return r;
-}
-
-static int add_locales_from_libdir (Set *locales) {
- _cleanup_closedir_ DIR *dir = NULL;
- struct dirent *entry;
- int r;
-
- dir = opendir("/usr/lib/locale");
- if (!dir)
- return errno == ENOENT ? 0 : -errno;
-
- FOREACH_DIRENT(entry, dir, return -errno) {
- char *z;
-
- if (entry->d_type != DT_DIR)
- continue;
-
- z = strdup(entry->d_name);
- if (!z)
- return -ENOMEM;
-
- r = set_consume(locales, z);
- if (r < 0 && r != -EEXIST)
- return r;
- }
-
- return 0;
-}
-
-int get_locales(char ***ret) {
- _cleanup_set_free_ Set *locales = NULL;
- _cleanup_strv_free_ char **l = NULL;
- int r;
-
- locales = set_new(&string_hash_ops);
- if (!locales)
- return -ENOMEM;
-
- r = add_locales_from_archive(locales);
- if (r < 0 && r != -ENOENT)
- return r;
-
- r = add_locales_from_libdir(locales);
- if (r < 0)
- return r;
-
- l = set_get_strv(locales);
- if (!l)
- return -ENOMEM;
-
- strv_sort(l);
-
- *ret = l;
- l = NULL;
-
- return 0;
-}
-
-bool locale_is_valid(const char *name) {
-
- if (isempty(name))
- return false;
-
- if (strlen(name) >= 128)
- return false;
-
- if (!utf8_is_valid(name))
- return false;
-
- if (!filename_is_valid(name))
- return false;
-
- if (!string_is_safe(name))
- return false;
-
- return true;
-}
-
-static const char * const locale_variable_table[_VARIABLE_LC_MAX] = {
- [VARIABLE_LANG] = "LANG",
- [VARIABLE_LANGUAGE] = "LANGUAGE",
- [VARIABLE_LC_CTYPE] = "LC_CTYPE",
- [VARIABLE_LC_NUMERIC] = "LC_NUMERIC",
- [VARIABLE_LC_TIME] = "LC_TIME",
- [VARIABLE_LC_COLLATE] = "LC_COLLATE",
- [VARIABLE_LC_MONETARY] = "LC_MONETARY",
- [VARIABLE_LC_MESSAGES] = "LC_MESSAGES",
- [VARIABLE_LC_PAPER] = "LC_PAPER",
- [VARIABLE_LC_NAME] = "LC_NAME",
- [VARIABLE_LC_ADDRESS] = "LC_ADDRESS",
- [VARIABLE_LC_TELEPHONE] = "LC_TELEPHONE",
- [VARIABLE_LC_MEASUREMENT] = "LC_MEASUREMENT",
- [VARIABLE_LC_IDENTIFICATION] = "LC_IDENTIFICATION"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(locale_variable, LocaleVariable);
diff --git a/src/shared/locale-util.h b/src/shared/locale-util.h
deleted file mode 100644
index e48aa3d9a..000000000
--- a/src/shared/locale-util.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-
-#include "macro.h"
-
-typedef enum LocaleVariable {
- /* We don't list LC_ALL here on purpose. People should be
- * using LANG instead. */
-
- VARIABLE_LANG,
- VARIABLE_LANGUAGE,
- VARIABLE_LC_CTYPE,
- VARIABLE_LC_NUMERIC,
- VARIABLE_LC_TIME,
- VARIABLE_LC_COLLATE,
- VARIABLE_LC_MONETARY,
- VARIABLE_LC_MESSAGES,
- VARIABLE_LC_PAPER,
- VARIABLE_LC_NAME,
- VARIABLE_LC_ADDRESS,
- VARIABLE_LC_TELEPHONE,
- VARIABLE_LC_MEASUREMENT,
- VARIABLE_LC_IDENTIFICATION,
- _VARIABLE_LC_MAX,
- _VARIABLE_LC_INVALID = -1
-} LocaleVariable;
-
-int get_locales(char ***l);
-bool locale_is_valid(const char *name);
-
-const char* locale_variable_to_string(LocaleVariable i) _const_;
-LocaleVariable locale_variable_from_string(const char *s) _pure_;
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 13f03e798..b2635740f 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -152,6 +152,8 @@ bool pager_have(void) {
return pager_pid > 0;
}
+/// UNNEEDED by elogind
+#if 0
int show_man_page(const char *desc, bool null_stdio) {
const char *args[4] = { "man", NULL, NULL, NULL };
char *e = NULL;
@@ -206,3 +208,4 @@ int show_man_page(const char *desc, bool null_stdio) {
log_debug("Exit code %i status %i", status.si_code, status.si_status);
return status.si_status;
}
+#endif // 0
diff --git a/src/shared/pager.h b/src/shared/pager.h
index 9288f44e1..6eb1f439f 100644
--- a/src/shared/pager.h
+++ b/src/shared/pager.h
@@ -21,8 +21,12 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "sd-bus.h"
+#include <stdbool.h>
-extern const sd_bus_vtable bus_snapshot_vtable[];
+#include "macro.h"
-int bus_snapshot_method_remove(sd_bus_message *message, void *userdata, sd_bus_error *error);
+int pager_open(bool jump_to_end);
+void pager_close(void);
+bool pager_have(void) _pure_;
+
+// UNNEEDED int show_man_page(const char *page, bool null_stdio);
diff --git a/src/shared/pty.c b/src/shared/pty.c
deleted file mode 100644
index a87b3ce6f..000000000
--- a/src/shared/pty.c
+++ /dev/null
@@ -1,635 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-/*
- * PTY
- * A PTY object represents a single PTY connection between a master and a
- * child. The child process is fork()ed so the caller controls what program
- * will be run.
- *
- * Programs like /bin/login tend to perform a vhangup() on their TTY
- * before running the login procedure. This also causes the pty master
- * to get a EPOLLHUP event as long as no client has the TTY opened.
- * This means, we cannot use the TTY connection as reliable way to track
- * the client. Instead, we _must_ rely on the PID of the client to track
- * them.
- * However, this has the side effect that if the client forks and the
- * parent exits, we loose them and restart the client. But this seems to
- * be the expected behavior so we implement it here.
- *
- * Unfortunately, epoll always polls for EPOLLHUP so as long as the
- * vhangup() is ongoing, we will _always_ get EPOLLHUP and cannot sleep.
- * This gets worse if the client closes the TTY but doesn't exit.
- * Therefore, the fd must be edge-triggered in the epoll-set so we
- * only get the events once they change.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/epoll.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <sys/wait.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "barrier.h"
-#include "macro.h"
-#include "ring.h"
-#include "util.h"
-#include "signal-util.h"
-#include "pty.h"
-
-#define PTY_BUFSIZE 4096
-
-enum {
- PTY_ROLE_UNKNOWN,
- PTY_ROLE_PARENT,
- PTY_ROLE_CHILD,
-};
-
-struct Pty {
- unsigned long ref;
- Barrier barrier;
- int fd;
- pid_t child;
- sd_event_source *fd_source;
- sd_event_source *child_source;
-
- char in_buf[PTY_BUFSIZE];
- Ring out_buf;
-
- pty_event_t event_fn;
- void *event_fn_userdata;
-
- bool needs_requeue : 1;
- unsigned int role : 2;
-};
-
-int pty_new(Pty **out) {
- _pty_unref_ Pty *pty = NULL;
- int r;
-
- assert_return(out, -EINVAL);
-
- pty = new0(Pty, 1);
- if (!pty)
- return -ENOMEM;
-
- pty->ref = 1;
- pty->fd = -1;
- pty->barrier = (Barrier) BARRIER_NULL;
-
- pty->fd = posix_openpt(O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK);
- if (pty->fd < 0)
- return -errno;
-
- /*
- * The slave-node is initialized to uid/gid of the caller of
- * posix_openpt(). Only if devpts is mounted with fixed uid/gid this is
- * skipped. In that case, grantpt() can overwrite these, but then you
- * have to be root to use chown() (or a pt_chown helper has to be
- * present). In those cases grantpt() really does something,
- * otherwise it's a no-op. We call grantpt() here to try supporting
- * those cases, even though no-one uses that, I guess. If you need other
- * access-rights, set them yourself after this call returns (no, this is
- * not racy, it looks racy, but races regarding your own UID are never
- * important as an attacker could ptrace you; and the slave-pty is also
- * still locked).
- */
- r = grantpt(pty->fd);
- if (r < 0)
- return -errno;
-
- r = barrier_create(&pty->barrier);
- if (r < 0)
- return r;
-
- *out = pty;
- pty = NULL;
- return 0;
-}
-
-Pty *pty_ref(Pty *pty) {
- if (!pty || pty->ref < 1)
- return NULL;
-
- ++pty->ref;
- return pty;
-}
-
-Pty *pty_unref(Pty *pty) {
- if (!pty || pty->ref < 1 || --pty->ref > 0)
- return NULL;
-
- pty_close(pty);
- pty->child_source = sd_event_source_unref(pty->child_source);
- barrier_destroy(&pty->barrier);
- ring_clear(&pty->out_buf);
- free(pty);
-
- return NULL;
-}
-
-Barrier *pty_get_barrier(Pty *pty) {
- assert(pty);
- return &pty->barrier;
-}
-
-bool pty_is_unknown(Pty *pty) {
- return pty && pty->role == PTY_ROLE_UNKNOWN;
-}
-
-bool pty_is_parent(Pty *pty) {
- return pty && pty->role == PTY_ROLE_PARENT;
-}
-
-bool pty_is_child(Pty *pty) {
- return pty && pty->role == PTY_ROLE_CHILD;
-}
-
-bool pty_has_child(Pty *pty) {
- return pty_is_parent(pty) && pty->child > 0;
-}
-
-pid_t pty_get_child(Pty *pty) {
- return pty_has_child(pty) ? pty->child : -ECHILD;
-}
-
-bool pty_is_open(Pty *pty) {
- return pty && pty->fd >= 0;
-}
-
-int pty_get_fd(Pty *pty) {
- assert_return(pty, -EINVAL);
-
- return pty_is_open(pty) ? pty->fd : -EPIPE;
-}
-
-int pty_make_child(Pty *pty) {
- _cleanup_free_ char *slave_name = NULL;
- int r, fd;
-
- assert_return(pty, -EINVAL);
- assert_return(pty_is_unknown(pty), -EALREADY);
-
- r = ptsname_malloc(pty->fd, &slave_name);
- if (r < 0)
- return -errno;
-
- fd = open(slave_name, O_RDWR | O_CLOEXEC | O_NOCTTY);
- if (fd < 0)
- return -errno;
-
- safe_close(pty->fd);
- pty->fd = fd;
- pty->child = getpid();
- pty->role = PTY_ROLE_CHILD;
- barrier_set_role(&pty->barrier, BARRIER_CHILD);
-
- return 0;
-}
-
-int pty_make_parent(Pty *pty, pid_t child) {
- assert_return(pty, -EINVAL);
- assert_return(pty_is_unknown(pty), -EALREADY);
-
- pty->child = child;
- pty->role = PTY_ROLE_PARENT;
-
- return 0;
-}
-
-int pty_unlock(Pty *pty) {
- assert_return(pty, -EINVAL);
- assert_return(pty_is_unknown(pty) || pty_is_parent(pty), -EINVAL);
- assert_return(pty_is_open(pty), -ENODEV);
-
- return unlockpt(pty->fd) < 0 ? -errno : 0;
-}
-
-int pty_setup_child(Pty *pty) {
- struct termios attr;
- pid_t pid;
- int r;
-
- assert_return(pty, -EINVAL);
- assert_return(pty_is_child(pty), -EINVAL);
- assert_return(pty_is_open(pty), -EALREADY);
-
- r = reset_signal_mask();
- if (r < 0)
- return r;
-
- r = reset_all_signal_handlers();
- if (r < 0)
- return r;
-
- pid = setsid();
- if (pid < 0 && errno != EPERM)
- return -errno;
-
- r = ioctl(pty->fd, TIOCSCTTY, 0);
- if (r < 0)
- return -errno;
-
- r = tcgetattr(pty->fd, &attr);
- if (r < 0)
- return -errno;
-
- /* erase character should be normal backspace, PLEASEEE! */
- attr.c_cc[VERASE] = 010;
- /* always set UTF8 flag */
- attr.c_iflag |= IUTF8;
-
- r = tcsetattr(pty->fd, TCSANOW, &attr);
- if (r < 0)
- return -errno;
-
- if (dup2(pty->fd, STDIN_FILENO) != STDIN_FILENO ||
- dup2(pty->fd, STDOUT_FILENO) != STDOUT_FILENO ||
- dup2(pty->fd, STDERR_FILENO) != STDERR_FILENO)
- return -errno;
-
- /* only close FD if it's not a std-fd */
- pty->fd = (pty->fd > 2) ? safe_close(pty->fd) : -1;
-
- return 0;
-}
-
-void pty_close(Pty *pty) {
- if (!pty_is_open(pty))
- return;
-
- pty->fd_source = sd_event_source_unref(pty->fd_source);
- pty->fd = safe_close(pty->fd);
-}
-
-/*
- * Drain input-queue and dispatch data via the event-handler. Returns <0 on
- * error, 0 if queue is empty and 1 if we couldn't empty the input queue fast
- * enough and there's still data left.
- */
-static int pty_dispatch_read(Pty *pty) {
- unsigned int i;
- ssize_t len;
- int r;
-
- /*
- * We're edge-triggered, means we need to read the whole queue. This,
- * however, might cause us to stall if the writer is faster than we
- * are. Therefore, try reading as much as 8 times (32KiB) and only
- * bail out then.
- */
-
- for (i = 0; i < 8; ++i) {
- len = read(pty->fd, pty->in_buf, sizeof(pty->in_buf) - 1);
- if (len < 0) {
- if (errno == EINTR)
- continue;
-
- return (errno == EAGAIN) ? 0 : -errno;
- } else if (len == 0) {
- continue;
- }
-
- /* set terminating zero for debugging safety */
- pty->in_buf[len] = 0;
- r = pty->event_fn(pty, pty->event_fn_userdata, PTY_DATA, pty->in_buf, len);
- if (r < 0)
- return r;
- }
-
- /* still data left, make sure we're queued again */
- pty->needs_requeue = true;
-
- return 1;
-}
-
-/*
- * Drain output-queue by writing data to the pty. Returns <0 on error, 0 if the
- * output queue is empty now and 1 if we couldn't empty the output queue fast
- * enough and there's still data left.
- */
-static int pty_dispatch_write(Pty *pty) {
- struct iovec vec[2];
- unsigned int i;
- ssize_t len;
- size_t num;
-
- /*
- * Same as pty_dispatch_read(), we're edge-triggered so we need to call
- * write() until either all data is written or it returns EAGAIN. We
- * call it twice and if it still writes successfully, we reschedule.
- */
-
- for (i = 0; i < 2; ++i) {
- num = ring_peek(&pty->out_buf, vec);
- if (num < 1)
- return 0;
-
- len = writev(pty->fd, vec, (int)num);
- if (len < 0) {
- if (errno == EINTR)
- continue;
-
- return (errno == EAGAIN) ? 1 : -errno;
- } else if (len == 0) {
- continue;
- }
-
- ring_pull(&pty->out_buf, (size_t)len);
- }
-
- /* still data left, make sure we're queued again */
- if (ring_get_size(&pty->out_buf) > 0) {
- pty->needs_requeue = true;
- return 1;
- }
-
- return 0;
-}
-
-static int pty_fd_fn(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- Pty *pty = userdata;
- int r_hup = 0, r_write = 0, r_read = 0, r;
-
- /*
- * Whenever we encounter I/O errors, we have to make sure to drain the
- * input queue first, before we handle any HUP. A child might send us
- * a message and immediately close the queue. We must not handle the
- * HUP first or we loose data.
- * Therefore, if we read a message successfully, we always return
- * success and wait for the next event-loop iteration. Furthermore,
- * whenever there is a write-error, we must try reading from the input
- * queue even if EPOLLIN is not set. The input might have arrived in
- * between epoll_wait() and write(). Therefore, write-errors are only
- * ever handled if the input-queue is empty. In all other cases they
- * are ignored until either reading fails or the input queue is empty.
- */
-
- if (revents & (EPOLLHUP | EPOLLERR))
- r_hup = -EPIPE;
-
- if (revents & EPOLLOUT)
- r_write = pty_dispatch_write(pty);
-
- /* Awesome! Kernel signals HUP without IN but queues are not empty.. */
- if ((revents & EPOLLIN) || r_hup < 0 || r_write < 0) {
- r_read = pty_dispatch_read(pty);
- if (r_read > 0)
- return 0; /* still data left to fetch next round */
- }
-
- if (r_hup < 0 || r_write < 0 || r_read < 0) {
- /* PTY closed and input-queue drained */
- pty_close(pty);
- r = pty->event_fn(pty, pty->event_fn_userdata, PTY_HUP, NULL, 0);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
-static int pty_fd_prepare_fn(sd_event_source *source, void *userdata) {
- Pty *pty = userdata;
- int r;
-
- if (pty->needs_requeue) {
- /*
- * We're edge-triggered. In case we couldn't handle all events
- * or in case new write-data is queued, we set needs_requeue.
- * Before going asleep, we set the io-events *again*. sd-event
- * notices that we're edge-triggered and forwards the call to
- * the kernel even if the events didn't change. The kernel will
- * check the events and re-queue us on the ready queue in case
- * an event is pending.
- */
- r = sd_event_source_set_io_events(source, EPOLLHUP | EPOLLERR | EPOLLIN | EPOLLOUT | EPOLLET);
- if (r >= 0)
- pty->needs_requeue = false;
- }
-
- return 0;
-}
-
-static int pty_child_fn(sd_event_source *source, const siginfo_t *si, void *userdata) {
- Pty *pty = userdata;
- int r;
-
- pty->child = 0;
-
- r = pty->event_fn(pty, pty->event_fn_userdata, PTY_CHILD, si, sizeof(*si));
- if (r < 0)
- return r;
-
- return 0;
-}
-
-int pty_attach_event(Pty *pty, sd_event *event, pty_event_t event_fn, void *event_fn_userdata) {
- int r;
-
- assert_return(pty, -EINVAL);
- assert_return(event, -EINVAL);
- assert_return(event_fn, -EINVAL);
- assert_return(pty_is_parent(pty), -EINVAL);
-
- pty_detach_event(pty);
-
- if (pty_is_open(pty)) {
- r = sd_event_add_io(event,
- &pty->fd_source,
- pty->fd,
- EPOLLHUP | EPOLLERR | EPOLLIN | EPOLLOUT | EPOLLET,
- pty_fd_fn,
- pty);
- if (r < 0)
- goto error;
-
- r = sd_event_source_set_prepare(pty->fd_source, pty_fd_prepare_fn);
- if (r < 0)
- goto error;
- }
-
- if (pty_has_child(pty)) {
- r = sd_event_add_child(event,
- &pty->child_source,
- pty->child,
- WEXITED,
- pty_child_fn,
- pty);
- if (r < 0)
- goto error;
- }
-
- pty->event_fn = event_fn;
- pty->event_fn_userdata = event_fn_userdata;
-
- return 0;
-
-error:
- pty_detach_event(pty);
- return r;
-}
-
-void pty_detach_event(Pty *pty) {
- if (!pty)
- return;
-
- pty->child_source = sd_event_source_unref(pty->child_source);
- pty->fd_source = sd_event_source_unref(pty->fd_source);
- pty->event_fn = NULL;
- pty->event_fn_userdata = NULL;
-}
-
-int pty_write(Pty *pty, const void *buf, size_t size) {
- bool was_empty;
- int r;
-
- assert_return(pty, -EINVAL);
- assert_return(pty_is_open(pty), -ENODEV);
- assert_return(pty_is_parent(pty), -ENODEV);
-
- if (size < 1)
- return 0;
-
- /*
- * Push @buf[0..@size] into the output ring-buffer. In case the
- * ring-buffer wasn't empty beforehand, we're already waiting for
- * EPOLLOUT and we're done. If it was empty, we have to re-queue the
- * FD for EPOLLOUT as we're edge-triggered and wouldn't get any new
- * EPOLLOUT event.
- */
-
- was_empty = ring_get_size(&pty->out_buf) < 1;
-
- r = ring_push(&pty->out_buf, buf, size);
- if (r < 0)
- return r;
-
- if (was_empty)
- pty->needs_requeue = true;
-
- return 0;
-}
-
-int pty_signal(Pty *pty, int sig) {
- assert_return(pty, -EINVAL);
- assert_return(pty_is_open(pty), -ENODEV);
- assert_return(pty_is_parent(pty), -ENODEV);
-
- return ioctl(pty->fd, TIOCSIG, sig) < 0 ? -errno : 0;
-}
-
-int pty_resize(Pty *pty, unsigned short term_width, unsigned short term_height) {
- struct winsize ws = {
- .ws_col = term_width,
- .ws_row = term_height,
- };
-
- assert_return(pty, -EINVAL);
- assert_return(pty_is_open(pty), -ENODEV);
- assert_return(pty_is_parent(pty), -ENODEV);
-
- /*
- * This will send SIGWINCH to the pty slave foreground process group.
- * We will also get one, but we don't need it.
- */
- return ioctl(pty->fd, TIOCSWINSZ, &ws) < 0 ? -errno : 0;
-}
-
-pid_t pty_fork(Pty **out, sd_event *event, pty_event_t event_fn, void *event_fn_userdata, unsigned short initial_term_width, unsigned short initial_term_height) {
- _pty_unref_ Pty *pty = NULL;
- int r;
- pid_t pid;
-
- assert_return(out, -EINVAL);
- assert_return((event && event_fn) || (!event && !event_fn), -EINVAL);
-
- r = pty_new(&pty);
- if (r < 0)
- return r;
-
- r = pty_unlock(pty);
- if (r < 0)
- return r;
-
- pid = fork();
- if (pid < 0)
- return -errno;
-
- if (pid == 0) {
- /* child */
-
- r = pty_make_child(pty);
- if (r < 0)
- _exit(-r);
-
- r = pty_setup_child(pty);
- if (r < 0)
- _exit(-r);
-
- /* sync with parent */
- if (!barrier_place_and_sync(&pty->barrier))
- _exit(1);
-
- /* fallthrough and return the child's PTY object */
- } else {
- /* parent */
-
- r = pty_make_parent(pty, pid);
- if (r < 0)
- goto parent_error;
-
- r = pty_resize(pty, initial_term_width, initial_term_height);
- if (r < 0)
- goto parent_error;
-
- if (event) {
- r = pty_attach_event(pty, event, event_fn, event_fn_userdata);
- if (r < 0)
- goto parent_error;
- }
-
- /* sync with child */
- if (!barrier_place_and_sync(&pty->barrier)) {
- r = -ECHILD;
- goto parent_error;
- }
-
- /* fallthrough and return the parent's PTY object */
- }
-
- *out = pty;
- pty = NULL;
- return pid;
-
-parent_error:
- barrier_abort(&pty->barrier);
- waitpid(pty->child, NULL, 0);
- pty->child = 0;
- return r;
-}
diff --git a/src/shared/pty.h b/src/shared/pty.h
deleted file mode 100644
index 63c7db283..000000000
--- a/src/shared/pty.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include <unistd.h>
-
-#include "barrier.h"
-#include "macro.h"
-#include "sd-event.h"
-
-typedef struct Pty Pty;
-
-enum {
- PTY_CHILD,
- PTY_HUP,
- PTY_DATA,
-};
-
-typedef int (*pty_event_t) (Pty *pty, void *userdata, unsigned int event, const void *ptr, size_t size);
-
-int pty_new(Pty **out);
-Pty *pty_ref(Pty *pty);
-Pty *pty_unref(Pty *pty);
-
-#define _pty_unref_ _cleanup_(pty_unrefp)
-DEFINE_TRIVIAL_CLEANUP_FUNC(Pty*, pty_unref);
-
-Barrier *pty_get_barrier(Pty *pty);
-
-bool pty_is_unknown(Pty *pty);
-bool pty_is_parent(Pty *pty);
-bool pty_is_child(Pty *pty);
-bool pty_has_child(Pty *pty);
-pid_t pty_get_child(Pty *pty);
-
-bool pty_is_open(Pty *pty);
-int pty_get_fd(Pty *pty);
-
-int pty_make_child(Pty *pty);
-int pty_make_parent(Pty *pty, pid_t child);
-int pty_unlock(Pty *pty);
-int pty_setup_child(Pty *pty);
-void pty_close(Pty *pty);
-
-int pty_attach_event(Pty *pty, sd_event *event, pty_event_t event_fn, void *event_fn_userdata);
-void pty_detach_event(Pty *pty);
-
-int pty_write(Pty *pty, const void *buf, size_t size);
-int pty_signal(Pty *pty, int sig);
-int pty_resize(Pty *pty, unsigned short term_width, unsigned short term_height);
-
-pid_t pty_fork(Pty **out, sd_event *event, pty_event_t event_fn, void *event_fn_userdata, unsigned short initial_term_width, unsigned short initial_term_height);
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
deleted file mode 100644
index 789f217ef..000000000
--- a/src/shared/ptyfwd.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2010-2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/epoll.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <termios.h>
-
-#include "util.h"
-#include "ptyfwd.h"
-
-struct PTYForward {
- sd_event *event;
-
- int master;
-
- sd_event_source *stdin_event_source;
- sd_event_source *stdout_event_source;
- sd_event_source *master_event_source;
-
- sd_event_source *sigwinch_event_source;
-
- struct termios saved_stdin_attr;
- struct termios saved_stdout_attr;
-
- bool read_only:1;
-
- bool saved_stdin:1;
- bool saved_stdout:1;
-
- bool stdin_readable:1;
- bool stdin_hangup:1;
- bool stdout_writable:1;
- bool stdout_hangup:1;
- bool master_readable:1;
- bool master_writable:1;
- bool master_hangup:1;
-
- /* Continue reading after hangup? */
- bool ignore_vhangup:1;
-
- bool last_char_set:1;
- char last_char;
-
- char in_buffer[LINE_MAX], out_buffer[LINE_MAX];
- size_t in_buffer_full, out_buffer_full;
-
- usec_t escape_timestamp;
- unsigned escape_counter;
-};
-
-#define ESCAPE_USEC (1*USEC_PER_SEC)
-
-static bool look_for_escape(PTYForward *f, const char *buffer, size_t n) {
- const char *p;
-
- assert(f);
- assert(buffer);
- assert(n > 0);
-
- for (p = buffer; p < buffer + n; p++) {
-
- /* Check for ^] */
- if (*p == 0x1D) {
- usec_t nw = now(CLOCK_MONOTONIC);
-
- if (f->escape_counter == 0 || nw > f->escape_timestamp + ESCAPE_USEC) {
- f->escape_timestamp = nw;
- f->escape_counter = 1;
- } else {
- (f->escape_counter)++;
-
- if (f->escape_counter >= 3)
- return true;
- }
- } else {
- f->escape_timestamp = 0;
- f->escape_counter = 0;
- }
- }
-
- return false;
-}
-
-static int shovel(PTYForward *f) {
- ssize_t k;
-
- assert(f);
-
- while ((f->stdin_readable && f->in_buffer_full <= 0) ||
- (f->master_writable && f->in_buffer_full > 0) ||
- (f->master_readable && f->out_buffer_full <= 0) ||
- (f->stdout_writable && f->out_buffer_full > 0)) {
-
- if (f->stdin_readable && f->in_buffer_full < LINE_MAX) {
-
- k = read(STDIN_FILENO, f->in_buffer + f->in_buffer_full, LINE_MAX - f->in_buffer_full);
- if (k < 0) {
-
- if (errno == EAGAIN)
- f->stdin_readable = false;
- else if (errno == EIO || errno == EPIPE || errno == ECONNRESET) {
- f->stdin_readable = false;
- f->stdin_hangup = true;
-
- f->stdin_event_source = sd_event_source_unref(f->stdin_event_source);
- } else {
- log_error_errno(errno, "read(): %m");
- return sd_event_exit(f->event, EXIT_FAILURE);
- }
- } else if (k == 0) {
- /* EOF on stdin */
- f->stdin_readable = false;
- f->stdin_hangup = true;
-
- f->stdin_event_source = sd_event_source_unref(f->stdin_event_source);
- } else {
- /* Check if ^] has been
- * pressed three times within
- * one second. If we get this
- * we quite immediately. */
- if (look_for_escape(f, f->in_buffer + f->in_buffer_full, k))
- return sd_event_exit(f->event, EXIT_FAILURE);
-
- f->in_buffer_full += (size_t) k;
- }
- }
-
- if (f->master_writable && f->in_buffer_full > 0) {
-
- k = write(f->master, f->in_buffer, f->in_buffer_full);
- if (k < 0) {
-
- if (errno == EAGAIN || errno == EIO)
- f->master_writable = false;
- else if (errno == EPIPE || errno == ECONNRESET) {
- f->master_writable = f->master_readable = false;
- f->master_hangup = true;
-
- f->master_event_source = sd_event_source_unref(f->master_event_source);
- } else {
- log_error_errno(errno, "write(): %m");
- return sd_event_exit(f->event, EXIT_FAILURE);
- }
- } else {
- assert(f->in_buffer_full >= (size_t) k);
- memmove(f->in_buffer, f->in_buffer + k, f->in_buffer_full - k);
- f->in_buffer_full -= k;
- }
- }
-
- if (f->master_readable && f->out_buffer_full < LINE_MAX) {
-
- k = read(f->master, f->out_buffer + f->out_buffer_full, LINE_MAX - f->out_buffer_full);
- if (k < 0) {
-
- /* Note that EIO on the master device
- * might be caused by vhangup() or
- * temporary closing of everything on
- * the other side, we treat it like
- * EAGAIN here and try again, unless
- * ignore_vhangup is off. */
-
- if (errno == EAGAIN || (errno == EIO && f->ignore_vhangup))
- f->master_readable = false;
- else if (errno == EPIPE || errno == ECONNRESET || errno == EIO) {
- f->master_readable = f->master_writable = false;
- f->master_hangup = true;
-
- f->master_event_source = sd_event_source_unref(f->master_event_source);
- } else {
- log_error_errno(errno, "read(): %m");
- return sd_event_exit(f->event, EXIT_FAILURE);
- }
- } else
- f->out_buffer_full += (size_t) k;
- }
-
- if (f->stdout_writable && f->out_buffer_full > 0) {
-
- k = write(STDOUT_FILENO, f->out_buffer, f->out_buffer_full);
- if (k < 0) {
-
- if (errno == EAGAIN)
- f->stdout_writable = false;
- else if (errno == EIO || errno == EPIPE || errno == ECONNRESET) {
- f->stdout_writable = false;
- f->stdout_hangup = true;
- f->stdout_event_source = sd_event_source_unref(f->stdout_event_source);
- } else {
- log_error_errno(errno, "write(): %m");
- return sd_event_exit(f->event, EXIT_FAILURE);
- }
-
- } else {
-
- if (k > 0) {
- f->last_char = f->out_buffer[k-1];
- f->last_char_set = true;
- }
-
- assert(f->out_buffer_full >= (size_t) k);
- memmove(f->out_buffer, f->out_buffer + k, f->out_buffer_full - k);
- f->out_buffer_full -= k;
- }
- }
- }
-
- if (f->stdin_hangup || f->stdout_hangup || f->master_hangup) {
- /* Exit the loop if any side hung up and if there's
- * nothing more to write or nothing we could write. */
-
- if ((f->out_buffer_full <= 0 || f->stdout_hangup) &&
- (f->in_buffer_full <= 0 || f->master_hangup))
- return sd_event_exit(f->event, EXIT_SUCCESS);
- }
-
- return 0;
-}
-
-static int on_master_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
-
- assert(f);
- assert(e);
- assert(e == f->master_event_source);
- assert(fd >= 0);
- assert(fd == f->master);
-
- if (revents & (EPOLLIN|EPOLLHUP))
- f->master_readable = true;
-
- if (revents & (EPOLLOUT|EPOLLHUP))
- f->master_writable = true;
-
- return shovel(f);
-}
-
-static int on_stdin_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
-
- assert(f);
- assert(e);
- assert(e == f->stdin_event_source);
- assert(fd >= 0);
- assert(fd == STDIN_FILENO);
-
- if (revents & (EPOLLIN|EPOLLHUP))
- f->stdin_readable = true;
-
- return shovel(f);
-}
-
-static int on_stdout_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
-
- assert(f);
- assert(e);
- assert(e == f->stdout_event_source);
- assert(fd >= 0);
- assert(fd == STDOUT_FILENO);
-
- if (revents & (EPOLLOUT|EPOLLHUP))
- f->stdout_writable = true;
-
- return shovel(f);
-}
-
-static int on_sigwinch_event(sd_event_source *e, const struct signalfd_siginfo *si, void *userdata) {
- PTYForward *f = userdata;
- struct winsize ws;
-
- assert(f);
- assert(e);
- assert(e == f->sigwinch_event_source);
-
- /* The window size changed, let's forward that. */
- if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) >= 0)
- (void) ioctl(f->master, TIOCSWINSZ, &ws);
-
- return 0;
-}
-
-int pty_forward_new(
- sd_event *event,
- int master,
- bool ignore_vhangup,
- bool read_only,
- PTYForward **ret) {
-
- _cleanup_(pty_forward_freep) PTYForward *f = NULL;
- struct winsize ws;
- int r;
-
- f = new0(PTYForward, 1);
- if (!f)
- return -ENOMEM;
-
- f->read_only = read_only;
- f->ignore_vhangup = ignore_vhangup;
-
- if (event)
- f->event = sd_event_ref(event);
- else {
- r = sd_event_default(&f->event);
- if (r < 0)
- return r;
- }
-
- if (!read_only) {
- r = fd_nonblock(STDIN_FILENO, true);
- if (r < 0)
- return r;
-
- r = fd_nonblock(STDOUT_FILENO, true);
- if (r < 0)
- return r;
- }
-
- r = fd_nonblock(master, true);
- if (r < 0)
- return r;
-
- f->master = master;
-
- if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) >= 0)
- (void) ioctl(master, TIOCSWINSZ, &ws);
-
- if (!read_only) {
- if (tcgetattr(STDIN_FILENO, &f->saved_stdin_attr) >= 0) {
- struct termios raw_stdin_attr;
-
- f->saved_stdin = true;
-
- raw_stdin_attr = f->saved_stdin_attr;
- cfmakeraw(&raw_stdin_attr);
- raw_stdin_attr.c_oflag = f->saved_stdin_attr.c_oflag;
- tcsetattr(STDIN_FILENO, TCSANOW, &raw_stdin_attr);
- }
-
- if (tcgetattr(STDOUT_FILENO, &f->saved_stdout_attr) >= 0) {
- struct termios raw_stdout_attr;
-
- f->saved_stdout = true;
-
- raw_stdout_attr = f->saved_stdout_attr;
- cfmakeraw(&raw_stdout_attr);
- raw_stdout_attr.c_iflag = f->saved_stdout_attr.c_iflag;
- raw_stdout_attr.c_lflag = f->saved_stdout_attr.c_lflag;
- tcsetattr(STDOUT_FILENO, TCSANOW, &raw_stdout_attr);
- }
-
- r = sd_event_add_io(f->event, &f->stdin_event_source, STDIN_FILENO, EPOLLIN|EPOLLET, on_stdin_event, f);
- if (r < 0 && r != -EPERM)
- return r;
- }
-
- r = sd_event_add_io(f->event, &f->stdout_event_source, STDOUT_FILENO, EPOLLOUT|EPOLLET, on_stdout_event, f);
- if (r == -EPERM)
- /* stdout without epoll support. Likely redirected to regular file. */
- f->stdout_writable = true;
- else if (r < 0)
- return r;
-
- r = sd_event_add_io(f->event, &f->master_event_source, master, EPOLLIN|EPOLLOUT|EPOLLET, on_master_event, f);
- if (r < 0)
- return r;
-
- r = sd_event_add_signal(f->event, &f->sigwinch_event_source, SIGWINCH, on_sigwinch_event, f);
- if (r < 0)
- return r;
-
- *ret = f;
- f = NULL;
-
- return 0;
-}
-
-PTYForward *pty_forward_free(PTYForward *f) {
-
- if (f) {
- sd_event_source_unref(f->stdin_event_source);
- sd_event_source_unref(f->stdout_event_source);
- sd_event_source_unref(f->master_event_source);
- sd_event_unref(f->event);
-
- if (f->saved_stdout)
- tcsetattr(STDOUT_FILENO, TCSANOW, &f->saved_stdout_attr);
- if (f->saved_stdin)
- tcsetattr(STDIN_FILENO, TCSANOW, &f->saved_stdin_attr);
-
- free(f);
- }
-
- /* STDIN/STDOUT should not be nonblocking normally, so let's
- * unconditionally reset it */
- fd_nonblock(STDIN_FILENO, false);
- fd_nonblock(STDOUT_FILENO, false);
-
- return NULL;
-}
-
-int pty_forward_get_last_char(PTYForward *f, char *ch) {
- assert(f);
- assert(ch);
-
- if (!f->last_char_set)
- return -ENXIO;
-
- *ch = f->last_char;
- return 0;
-}
-
-int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup) {
- int r;
-
- assert(f);
-
- if (f->ignore_vhangup == ignore_vhangup)
- return 0;
-
- f->ignore_vhangup = ignore_vhangup;
- if (!f->ignore_vhangup) {
-
- /* We shall now react to vhangup()s? Let's check
- * immediately if we might be in one */
-
- f->master_readable = true;
- r = shovel(f);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
-int pty_forward_get_ignore_vhangup(PTYForward *f) {
- assert(f);
-
- return f->ignore_vhangup;
-}
diff --git a/src/shared/ptyfwd.h b/src/shared/ptyfwd.h
deleted file mode 100644
index 6f84e4036..000000000
--- a/src/shared/ptyfwd.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2010-2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-
-#include "sd-event.h"
-
-typedef struct PTYForward PTYForward;
-
-int pty_forward_new(sd_event *event, int master, bool ignore_vhangup, bool read_only, PTYForward **f);
-PTYForward *pty_forward_free(PTYForward *f);
-
-int pty_forward_get_last_char(PTYForward *f, char *ch);
-
-int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
-int pty_forward_get_ignore_vhangup(PTYForward *f);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);
diff --git a/src/shared/ratelimit.c b/src/shared/ratelimit.c
deleted file mode 100644
index 81fc9c19f..000000000
--- a/src/shared/ratelimit.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "ratelimit.h"
-
-/* Modelled after Linux' lib/ratelimit.c by Dave Young
- * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
-
-bool ratelimit_test(RateLimit *r) {
- usec_t ts;
-
- assert(r);
-
- if (r->interval <= 0 || r->burst <= 0)
- return true;
-
- ts = now(CLOCK_MONOTONIC);
-
- if (r->begin <= 0 ||
- r->begin + r->interval < ts) {
- r->begin = ts;
-
- /* Reset counter */
- r->num = 0;
- goto good;
- }
-
- if (r->num < r->burst)
- goto good;
-
- return false;
-
-good:
- r->num++;
- return true;
-}
diff --git a/src/shared/replace-var.c b/src/shared/replace-var.c
deleted file mode 100644
index 478fc43a3..000000000
--- a/src/shared/replace-var.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-
-#include "macro.h"
-#include "util.h"
-#include "replace-var.h"
-#include "def.h"
-
-/*
- * Generic infrastructure for replacing @FOO@ style variables in
- * strings. Will call a callback for each replacement.
- */
-
-static int get_variable(const char *b, char **r) {
- size_t k;
- char *t;
-
- assert(b);
- assert(r);
-
- if (*b != '@')
- return 0;
-
- k = strspn(b + 1, UPPERCASE_LETTERS "_");
- if (k <= 0 || b[k+1] != '@')
- return 0;
-
- t = strndup(b + 1, k);
- if (!t)
- return -ENOMEM;
-
- *r = t;
- return 1;
-}
-
-char *replace_var(const char *text, char *(*lookup)(const char *variable, void*userdata), void *userdata) {
- char *r, *t;
- const char *f;
- size_t l;
-
- assert(text);
- assert(lookup);
-
- l = strlen(text);
- r = new(char, l+1);
- if (!r)
- return NULL;
-
- f = text;
- t = r;
- while (*f) {
- _cleanup_free_ char *v = NULL, *n = NULL;
- char *a;
- int k;
- size_t skip, d, nl;
-
- k = get_variable(f, &v);
- if (k < 0)
- goto oom;
- if (k == 0) {
- *(t++) = *(f++);
- continue;
- }
-
- n = lookup(v, userdata);
- if (!n)
- goto oom;
-
- skip = strlen(v) + 2;
-
- d = t - r;
- nl = l - skip + strlen(n);
- a = realloc(r, nl + 1);
- if (!a)
- goto oom;
-
- l = nl;
- r = a;
- t = r + d;
-
- t = stpcpy(t, n);
- f += skip;
- }
-
- *t = 0;
- return r;
-
-oom:
- free(r);
- return NULL;
-}
diff --git a/src/shared/replace-var.h b/src/shared/replace-var.h
deleted file mode 100644
index 7eaee93a3..000000000
--- a/src/shared/replace-var.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-char *replace_var(const char *text, char *(*lookup)(const char *variable, void*userdata), void *userdata);
diff --git a/src/shared/ring.c b/src/shared/ring.c
deleted file mode 100644
index 681491846..000000000
--- a/src/shared/ring.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/uio.h>
-#include "macro.h"
-#include "ring.h"
-
-#define RING_MASK(_r, _v) ((_v) & ((_r)->size - 1))
-
-void ring_flush(Ring *r) {
- assert(r);
-
- r->start = 0;
- r->used = 0;
-}
-
-void ring_clear(Ring *r) {
- assert(r);
-
- free(r->buf);
- zero(*r);
-}
-
-/*
- * Get data pointers for current ring-buffer data. @vec must be an array of 2
- * iovec objects. They are filled according to the data available in the
- * ring-buffer. 0, 1 or 2 is returned according to the number of iovec objects
- * that were filled (0 meaning buffer is empty).
- *
- * Hint: "struct iovec" is defined in <sys/uio.h> and looks like this:
- * struct iovec {
- * void *iov_base;
- * size_t iov_len;
- * };
- */
-size_t ring_peek(Ring *r, struct iovec *vec) {
- assert(r);
-
- if (r->used == 0) {
- return 0;
- } else if (r->start + r->used <= r->size) {
- if (vec) {
- vec[0].iov_base = &r->buf[r->start];
- vec[0].iov_len = r->used;
- }
- return 1;
- } else {
- if (vec) {
- vec[0].iov_base = &r->buf[r->start];
- vec[0].iov_len = r->size - r->start;
- vec[1].iov_base = r->buf;
- vec[1].iov_len = r->used - (r->size - r->start);
- }
- return 2;
- }
-}
-
-/*
- * Copy data from the ring buffer into the linear external buffer @buf. Copy
- * at most @size bytes. If the ring buffer size is smaller, copy less bytes and
- * return the number of bytes copied.
- */
-size_t ring_copy(Ring *r, void *buf, size_t size) {
- size_t l;
-
- assert(r);
- assert(buf);
-
- if (size > r->used)
- size = r->used;
-
- if (size > 0) {
- l = r->size - r->start;
- if (size <= l) {
- memcpy(buf, &r->buf[r->start], size);
- } else {
- memcpy(buf, &r->buf[r->start], l);
- memcpy((uint8_t*)buf + l, r->buf, size - l);
- }
- }
-
- return size;
-}
-
-/*
- * Resize ring-buffer to size @nsize. @nsize must be a power-of-2, otherwise
- * ring operations will behave incorrectly.
- */
-static int ring_resize(Ring *r, size_t nsize) {
- uint8_t *buf;
- size_t l;
-
- assert(r);
- assert(nsize > 0);
-
- buf = malloc(nsize);
- if (!buf)
- return -ENOMEM;
-
- if (r->used > 0) {
- l = r->size - r->start;
- if (r->used <= l) {
- memcpy(buf, &r->buf[r->start], r->used);
- } else {
- memcpy(buf, &r->buf[r->start], l);
- memcpy(&buf[l], r->buf, r->used - l);
- }
- }
-
- free(r->buf);
- r->buf = buf;
- r->size = nsize;
- r->start = 0;
-
- return 0;
-}
-
-/*
- * Resize ring-buffer to provide enough room for @add bytes of new data. This
- * resizes the buffer if it is too small. It returns -ENOMEM on OOM and 0 on
- * success.
- */
-static int ring_grow(Ring *r, size_t add) {
- size_t need;
-
- assert(r);
-
- if (r->size - r->used >= add)
- return 0;
-
- need = r->used + add;
- if (need <= r->used)
- return -ENOMEM;
- else if (need < 4096)
- need = 4096;
-
- need = ALIGN_POWER2(need);
- if (need == 0)
- return -ENOMEM;
-
- return ring_resize(r, need);
-}
-
-/*
- * Push @len bytes from @u8 into the ring buffer. The buffer is resized if it
- * is too small. -ENOMEM is returned on OOM, 0 on success.
- */
-int ring_push(Ring *r, const void *u8, size_t size) {
- int err;
- size_t pos, l;
-
- assert(r);
- assert(u8);
-
- if (size == 0)
- return 0;
-
- err = ring_grow(r, size);
- if (err < 0)
- return err;
-
- pos = RING_MASK(r, r->start + r->used);
- l = r->size - pos;
- if (l >= size) {
- memcpy(&r->buf[pos], u8, size);
- } else {
- memcpy(&r->buf[pos], u8, l);
- memcpy(r->buf, (const uint8_t*)u8 + l, size - l);
- }
-
- r->used += size;
-
- return 0;
-}
-
-/*
- * Remove @len bytes from the start of the ring-buffer. Note that we protect
- * against overflows so removing more bytes than available is safe.
- */
-void ring_pull(Ring *r, size_t size) {
- assert(r);
-
- if (size > r->used)
- size = r->used;
-
- r->start = RING_MASK(r, r->start + size);
- r->used -= size;
-}
diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c
new file mode 100644
index 000000000..46cecc8e2
--- /dev/null
+++ b/src/shared/seccomp-util.c
@@ -0,0 +1,92 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Lennart Poettering
+
+ systemd 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.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <seccomp.h>
+
+#include "util.h"
+#include "seccomp-util.h"
+
+const char* seccomp_arch_to_string(uint32_t c) {
+
+ if (c == SCMP_ARCH_NATIVE)
+ return "native";
+ if (c == SCMP_ARCH_X86)
+ return "x86";
+ if (c == SCMP_ARCH_X86_64)
+ return "x86-64";
+ if (c == SCMP_ARCH_X32)
+ return "x32";
+ if (c == SCMP_ARCH_ARM)
+ return "arm";
+
+ return NULL;
+}
+
+/// UNNEEDED by elogind
+#if 0
+int seccomp_arch_from_string(const char *n, uint32_t *ret) {
+ if (!n)
+ return -EINVAL;
+
+ assert(ret);
+
+ if (streq(n, "native"))
+ *ret = SCMP_ARCH_NATIVE;
+ else if (streq(n, "x86"))
+ *ret = SCMP_ARCH_X86;
+ else if (streq(n, "x86-64"))
+ *ret = SCMP_ARCH_X86_64;
+ else if (streq(n, "x32"))
+ *ret = SCMP_ARCH_X32;
+ else if (streq(n, "arm"))
+ *ret = SCMP_ARCH_ARM;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+#endif // 0
+
+int seccomp_add_secondary_archs(scmp_filter_ctx *c) {
+
+#if defined(__i386__) || defined(__x86_64__)
+ int r;
+
+ /* Add in all possible secondary archs we are aware of that
+ * this kernel might support. */
+
+ r = seccomp_arch_add(c, SCMP_ARCH_X86);
+ if (r < 0 && r != -EEXIST)
+ return r;
+
+ r = seccomp_arch_add(c, SCMP_ARCH_X86_64);
+ if (r < 0 && r != -EEXIST)
+ return r;
+
+ r = seccomp_arch_add(c, SCMP_ARCH_X32);
+ if (r < 0 && r != -EEXIST)
+ return r;
+
+#endif
+
+ return 0;
+
+}
diff --git a/src/shared/af-list.h b/src/shared/seccomp-util.h
index e346ab87f..b59f3fc20 100644
--- a/src/shared/af-list.h
+++ b/src/shared/seccomp-util.h
@@ -21,7 +21,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-const char *af_to_name(int id);
-int af_from_name(const char *name);
+#include <seccomp.h>
-int af_max(void);
+const char* seccomp_arch_to_string(uint32_t c);
+// UNNEEDED int seccomp_arch_from_string(const char *n, uint32_t *ret);
+
+int seccomp_add_secondary_archs(scmp_filter_ctx *c);
diff --git a/src/shared/sigbus.c b/src/shared/sigbus.c
deleted file mode 100644
index 0108603fe..000000000
--- a/src/shared/sigbus.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <signal.h>
-#include <sys/mman.h>
-
-#include "macro.h"
-#include "util.h"
-#include "sigbus.h"
-
-#define SIGBUS_QUEUE_MAX 64
-
-static struct sigaction old_sigaction;
-static unsigned n_installed = 0;
-
-/* We maintain a fixed size list of page addresses that triggered a
- SIGBUS. We access with list with atomic operations, so that we
- don't have to deal with locks between signal handler and main
- programs in possibly multiple threads. */
-
-static void* volatile sigbus_queue[SIGBUS_QUEUE_MAX];
-static volatile sig_atomic_t n_sigbus_queue = 0;
-
-static void sigbus_push(void *addr) {
- unsigned u;
-
- assert(addr);
-
- /* Find a free place, increase the number of entries and leave, if we can */
- for (u = 0; u < SIGBUS_QUEUE_MAX; u++)
- if (__sync_bool_compare_and_swap(&sigbus_queue[u], NULL, addr)) {
- __sync_fetch_and_add(&n_sigbus_queue, 1);
- return;
- }
-
- /* If we can't, make sure the queue size is out of bounds, to
- * mark it as overflow */
- for (;;) {
- unsigned c;
-
- __sync_synchronize();
- c = n_sigbus_queue;
-
- if (c > SIGBUS_QUEUE_MAX) /* already overflow */
- return;
-
- if (__sync_bool_compare_and_swap(&n_sigbus_queue, c, c + SIGBUS_QUEUE_MAX))
- return;
- }
-}
-
-int sigbus_pop(void **ret) {
- assert(ret);
-
- for (;;) {
- unsigned u, c;
-
- __sync_synchronize();
- c = n_sigbus_queue;
-
- if (_likely_(c == 0))
- return 0;
-
- if (_unlikely_(c >= SIGBUS_QUEUE_MAX))
- return -EOVERFLOW;
-
- for (u = 0; u < SIGBUS_QUEUE_MAX; u++) {
- void *addr;
-
- addr = sigbus_queue[u];
- if (!addr)
- continue;
-
- if (__sync_bool_compare_and_swap(&sigbus_queue[u], addr, NULL)) {
- __sync_fetch_and_sub(&n_sigbus_queue, 1);
- *ret = addr;
- return 1;
- }
- }
- }
-}
-
-static void sigbus_handler(int sn, siginfo_t *si, void *data) {
- unsigned long ul;
- void *aligned;
-
- assert(sn == SIGBUS);
- assert(si);
-
- if (si->si_code != BUS_ADRERR || !si->si_addr) {
- assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
- raise(SIGBUS);
- return;
- }
-
- ul = (unsigned long) si->si_addr;
- ul = ul / page_size();
- ul = ul * page_size();
- aligned = (void*) ul;
-
- /* Let's remember which address failed */
- sigbus_push(aligned);
-
- /* Replace mapping with an anonymous page, so that the
- * execution can continue, however with a zeroed out page */
- assert_se(mmap(aligned, page_size(), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0) == aligned);
-}
-
-void sigbus_install(void) {
- struct sigaction sa = {
- .sa_sigaction = sigbus_handler,
- .sa_flags = SA_SIGINFO,
- };
-
- n_installed++;
-
- if (n_installed == 1)
- assert_se(sigaction(SIGBUS, &sa, &old_sigaction) == 0);
-
- return;
-}
-
-void sigbus_reset(void) {
-
- if (n_installed <= 0)
- return;
-
- n_installed--;
-
- if (n_installed == 0)
- assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
-
- return;
-}
diff --git a/src/shared/sigbus.h b/src/shared/sigbus.h
deleted file mode 100644
index 23edc6d9c..000000000
--- a/src/shared/sigbus.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#pragma once
-
-void sigbus_install(void);
-void sigbus_reset(void);
-
-int sigbus_pop(void **ret);
diff --git a/src/shared/strbuf.c b/src/shared/strbuf.c
deleted file mode 100644
index 01a076c2b..000000000
--- a/src/shared/strbuf.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Kay Sievers <kay@vrfy.org>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "util.h"
-#include "strbuf.h"
-
-/*
- * Strbuf stores given strings in a single continuous allocated memory
- * area. Identical strings are de-duplicated and return the same offset
- * as the first string stored. If the tail of a string already exists
- * in the buffer, the tail is returned.
- *
- * A trie (http://en.wikipedia.org/wiki/Trie) is used to maintain the
- * information about the stored strings.
- *
- * Example of udev rules:
- * $ ./udevadm test .
- * ...
- * read rules file: /usr/lib/udev/rules.d/99-systemd.rules
- * rules contain 196608 bytes tokens (16384 * 12 bytes), 39742 bytes strings
- * 23939 strings (207859 bytes), 20404 de-duplicated (171653 bytes), 3536 trie nodes used
- * ...
- */
-
-struct strbuf *strbuf_new(void) {
- struct strbuf *str;
-
- str = new0(struct strbuf, 1);
- if (!str)
- return NULL;
-
- str->buf = new0(char, 1);
- if (!str->buf)
- goto err;
- str->len = 1;
-
- str->root = new0(struct strbuf_node, 1);
- if (!str->root)
- goto err;
- str->nodes_count = 1;
- return str;
-err:
- free(str->buf);
- free(str->root);
- free(str);
- return NULL;
-}
-
-static void strbuf_node_cleanup(struct strbuf_node *node) {
- size_t i;
-
- for (i = 0; i < node->children_count; i++)
- strbuf_node_cleanup(node->children[i].child);
- free(node->children);
- free(node);
-}
-
-/* clean up trie data, leave only the string buffer */
-void strbuf_complete(struct strbuf *str) {
- if (!str)
- return;
- if (str->root)
- strbuf_node_cleanup(str->root);
- str->root = NULL;
-}
-
-/* clean up everything */
-void strbuf_cleanup(struct strbuf *str) {
- if (!str)
- return;
- if (str->root)
- strbuf_node_cleanup(str->root);
- free(str->buf);
- free(str);
-}
-
-static int strbuf_children_cmp(const struct strbuf_child_entry *n1,
- const struct strbuf_child_entry *n2) {
- return n1->c - n2->c;
-}
-
-static void bubbleinsert(struct strbuf_node *node,
- uint8_t c,
- struct strbuf_node *node_child) {
-
- struct strbuf_child_entry new = {
- .c = c,
- .child = node_child,
- };
- int left = 0, right = node->children_count;
-
- while (right > left) {
- int middle = (right + left) / 2 ;
- if (strbuf_children_cmp(&node->children[middle], &new) <= 0)
- left = middle + 1;
- else
- right = middle;
- }
-
- memmove(node->children + left + 1, node->children + left,
- sizeof(struct strbuf_child_entry) * (node->children_count - left));
- node->children[left] = new;
-
- node->children_count ++;
-}
-
-/* add string, return the index/offset into the buffer */
-ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
- uint8_t c;
- struct strbuf_node *node;
- size_t depth;
- char *buf_new;
- struct strbuf_child_entry *child;
- struct strbuf_node *node_child;
- ssize_t off;
-
- if (!str->root)
- return -EINVAL;
-
- /* search string; start from last character to find possibly matching tails */
- if (len == 0)
- return 0;
- str->in_count++;
- str->in_len += len;
-
- node = str->root;
- c = s[len-1];
- for (depth = 0; depth <= len; depth++) {
- struct strbuf_child_entry search;
-
- /* match against current node */
- off = node->value_off + node->value_len - len;
- if (depth == len || (node->value_len >= len && memcmp(str->buf + off, s, len) == 0)) {
- str->dedup_len += len;
- str->dedup_count++;
- return off;
- }
-
- /* lookup child node */
- c = s[len - 1 - depth];
- search.c = c;
- child = bsearch(&search, node->children, node->children_count,
- sizeof(struct strbuf_child_entry),
- (__compar_fn_t) strbuf_children_cmp);
- if (!child)
- break;
- node = child->child;
- }
-
- /* add new string */
- buf_new = realloc(str->buf, str->len + len+1);
- if (!buf_new)
- return -ENOMEM;
- str->buf = buf_new;
- off = str->len;
- memcpy(str->buf + off, s, len);
- str->len += len;
- str->buf[str->len++] = '\0';
-
- /* new node */
- node_child = new0(struct strbuf_node, 1);
- if (!node_child)
- return -ENOMEM;
- node_child->value_off = off;
- node_child->value_len = len;
-
- /* extend array, add new entry, sort for bisection */
- child = realloc(node->children, (node->children_count + 1) * sizeof(struct strbuf_child_entry));
- if (!child) {
- free(node_child);
- return -ENOMEM;
- }
-
- str->nodes_count++;
-
- node->children = child;
- bubbleinsert(node, c, node_child);
-
- return off;
-}
diff --git a/src/shared/strbuf.h b/src/shared/strbuf.h
deleted file mode 100644
index fbc4e5f2a..000000000
--- a/src/shared/strbuf.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Kay Sievers <kay@vrfy.org>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdint.h>
-
-struct strbuf {
- char *buf;
- size_t len;
- struct strbuf_node *root;
-
- size_t nodes_count;
- size_t in_count;
- size_t in_len;
- size_t dedup_len;
- size_t dedup_count;
-};
-
-struct strbuf_node {
- size_t value_off;
- size_t value_len;
-
- struct strbuf_child_entry *children;
- uint8_t children_count;
-};
-
-struct strbuf_child_entry {
- uint8_t c;
- struct strbuf_node *child;
-};
-
-struct strbuf *strbuf_new(void);
-ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
-void strbuf_complete(struct strbuf *str);
-void strbuf_cleanup(struct strbuf *str);
diff --git a/src/shared/strxcpyx.c b/src/shared/strxcpyx.c
deleted file mode 100644
index 6542c0abf..000000000
--- a/src/shared/strxcpyx.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-/*
- * Concatenates/copies strings. In any case, terminates in all cases
- * with '\0' * and moves the @dest pointer forward to the added '\0'.
- * Returns the * remaining size, and 0 if the string was truncated.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "strxcpyx.h"
-
-size_t strpcpy(char **dest, size_t size, const char *src) {
- size_t len;
-
- len = strlen(src);
- if (len >= size) {
- if (size > 1)
- *dest = mempcpy(*dest, src, size-1);
- size = 0;
- } else {
- if (len > 0) {
- *dest = mempcpy(*dest, src, len);
- size -= len;
- }
- }
- *dest[0] = '\0';
- return size;
-}
-
-size_t strpcpyf(char **dest, size_t size, const char *src, ...) {
- va_list va;
- int i;
-
- va_start(va, src);
- i = vsnprintf(*dest, size, src, va);
- if (i < (int)size) {
- *dest += i;
- size -= i;
- } else {
- *dest += size;
- size = 0;
- }
- va_end(va);
- *dest[0] = '\0';
- return size;
-}
-
-size_t strpcpyl(char **dest, size_t size, const char *src, ...) {
- va_list va;
-
- va_start(va, src);
- do {
- size = strpcpy(dest, size, src);
- src = va_arg(va, char *);
- } while (src != NULL);
- va_end(va);
- return size;
-}
-
-size_t strscpy(char *dest, size_t size, const char *src) {
- char *s;
-
- s = dest;
- return strpcpy(&s, size, src);
-}
-
-size_t strscpyl(char *dest, size_t size, const char *src, ...) {
- va_list va;
- char *s;
-
- va_start(va, src);
- s = dest;
- do {
- size = strpcpy(&s, size, src);
- src = va_arg(va, char *);
- } while (src != NULL);
- va_end(va);
-
- return size;
-}
diff --git a/src/shared/strxcpyx.h b/src/shared/strxcpyx.h
deleted file mode 100644
index ccc7e52f3..000000000
--- a/src/shared/strxcpyx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Kay Sievers
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-
-#include "macro.h"
-
-size_t strpcpy(char **dest, size_t size, const char *src);
-size_t strpcpyf(char **dest, size_t size, const char *src, ...) _printf_(3, 4);
-size_t strpcpyl(char **dest, size_t size, const char *src, ...) _sentinel_;
-size_t strscpy(char *dest, size_t size, const char *src);
-size_t strscpyl(char *dest, size_t size, const char *src, ...) _sentinel_;
diff --git a/src/shared/sysctl-util.h b/src/shared/sysctl-util.h
deleted file mode 100644
index 2ee6454e5..000000000
--- a/src/shared/sysctl-util.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2011 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-char *sysctl_normalize(char *s);
-int sysctl_read(const char *property, char **value);
-int sysctl_write(const char *property, const char *value);
-
diff --git a/src/shared/uid-range.c b/src/shared/uid-range.c
deleted file mode 100644
index 4794ff45b..000000000
--- a/src/shared/uid-range.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "util.h"
-#include "uid-range.h"
-
-static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) {
- assert(range);
-
- return range->start <= start + nr &&
- range->start + range->nr >= start;
-}
-
-static void uid_range_coalesce(UidRange **p, unsigned *n) {
- unsigned i, j;
-
- assert(p);
- assert(n);
-
- for (i = 0; i < *n; i++) {
- for (j = i + 1; j < *n; j++) {
- UidRange *x = (*p)+i, *y = (*p)+j;
-
- if (uid_range_intersect(x, y->start, y->nr)) {
- uid_t begin, end;
-
- begin = MIN(x->start, y->start);
- end = MAX(x->start + x->nr, y->start + y->nr);
-
- x->start = begin;
- x->nr = end - begin;
-
- if (*n > j+1)
- memmove(y, y+1, sizeof(UidRange) * (*n - j -1));
-
- (*n) --;
- j--;
- }
- }
- }
-
-}
-
-static int uid_range_compare(const void *a, const void *b) {
- const UidRange *x = a, *y = b;
-
- if (x->start < y->start)
- return -1;
- if (x->start > y->start)
- return 1;
-
- if (x->nr < y->nr)
- return -1;
- if (x->nr > y->nr)
- return 1;
-
- return 0;
-}
-
-int uid_range_add(UidRange **p, unsigned *n, uid_t start, uid_t nr) {
- bool found = false;
- UidRange *x;
- unsigned i;
-
- assert(p);
- assert(n);
-
- if (nr <= 0)
- return 0;
-
- for (i = 0; i < *n; i++) {
- x = (*p) + i;
- if (uid_range_intersect(x, start, nr)) {
- found = true;
- break;
- }
- }
-
- if (found) {
- uid_t begin, end;
-
- begin = MIN(x->start, start);
- end = MAX(x->start + x->nr, start + nr);
-
- x->start = begin;
- x->nr = end - begin;
- } else {
- UidRange *t;
-
- t = realloc(*p, sizeof(UidRange) * (*n + 1));
- if (!t)
- return -ENOMEM;
-
- *p = t;
- x = t + ((*n) ++);
-
- x->start = start;
- x->nr = nr;
- }
-
- qsort(*p, *n, sizeof(UidRange), uid_range_compare);
- uid_range_coalesce(p, n);
-
- return *n;
-}
-
-int uid_range_add_str(UidRange **p, unsigned *n, const char *s) {
- uid_t start, nr;
- const char *t;
- int r;
-
- assert(p);
- assert(n);
- assert(s);
-
- t = strchr(s, '-');
- if (t) {
- char *b;
- uid_t end;
-
- b = strndupa(s, t - s);
- r = parse_uid(b, &start);
- if (r < 0)
- return r;
-
- r = parse_uid(t+1, &end);
- if (r < 0)
- return r;
-
- if (end < start)
- return -EINVAL;
-
- nr = end - start + 1;
- } else {
- r = parse_uid(s, &start);
- if (r < 0)
- return r;
-
- nr = 1;
- }
-
- return uid_range_add(p, n, start, nr);
-}
-
-int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid) {
- uid_t closest = UID_INVALID, candidate;
- unsigned i;
-
- assert(p);
- assert(uid);
-
- candidate = *uid - 1;
-
- for (i = 0; i < n; i++) {
- uid_t begin, end;
-
- begin = p[i].start;
- end = p[i].start + p[i].nr - 1;
-
- if (candidate >= begin && candidate <= end) {
- *uid = candidate;
- return 1;
- }
-
- if (end < candidate)
- closest = end;
- }
-
- if (closest == UID_INVALID)
- return -EBUSY;
-
- *uid = closest;
- return 1;
-}
-
-bool uid_range_contains(const UidRange *p, unsigned n, uid_t uid) {
- unsigned i;
-
- assert(p);
- assert(uid);
-
- for (i = 0; i < n; i++)
- if (uid >= p[i].start && uid < p[i].start + p[i].nr)
- return true;
-
- return false;
-}
diff --git a/src/shared/uid-range.h b/src/shared/uid-range.h
deleted file mode 100644
index 45335e939..000000000
--- a/src/shared/uid-range.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-typedef struct UidRange {
- uid_t start, nr;
-} UidRange;
-
-int uid_range_add(UidRange **p, unsigned *n, uid_t start, uid_t nr);
-int uid_range_add_str(UidRange **p, unsigned *n, const char *s);
-
-int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid);
-bool uid_range_contains(const UidRange *p, unsigned n, uid_t uid);
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
deleted file mode 100644
index 9d39beb34..000000000
--- a/src/shared/watchdog.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <linux/watchdog.h>
-
-#include "watchdog.h"
-#include "log.h"
-
-static int watchdog_fd = -1;
-static usec_t watchdog_timeout = USEC_INFINITY;
-
-static int update_timeout(void) {
- int r;
-
- if (watchdog_fd < 0)
- return 0;
-
- if (watchdog_timeout == USEC_INFINITY)
- return 0;
- else if (watchdog_timeout == 0) {
- int flags;
-
- flags = WDIOS_DISABLECARD;
- r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0)
- return log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
- } else {
- int sec, flags;
- char buf[FORMAT_TIMESPAN_MAX];
-
- sec = (int) ((watchdog_timeout + USEC_PER_SEC - 1) / USEC_PER_SEC);
- r = ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec);
- if (r < 0)
- return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
-
- watchdog_timeout = (usec_t) sec * USEC_PER_SEC;
- log_info("Set hardware watchdog to %s.", format_timespan(buf, sizeof(buf), watchdog_timeout, 0));
-
- flags = WDIOS_ENABLECARD;
- r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0) {
- /* ENOTTY means the watchdog is always enabled so we're fine */
- log_full(errno == ENOTTY ? LOG_DEBUG : LOG_WARNING,
- "Failed to enable hardware watchdog: %m");
- if (errno != ENOTTY)
- return -errno;
- }
-
- r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
- if (r < 0)
- return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
- }
-
- return 0;
-}
-
-static int open_watchdog(void) {
- struct watchdog_info ident;
-
- if (watchdog_fd >= 0)
- return 0;
-
- watchdog_fd = open("/dev/watchdog", O_WRONLY|O_CLOEXEC);
- if (watchdog_fd < 0)
- return -errno;
-
- if (ioctl(watchdog_fd, WDIOC_GETSUPPORT, &ident) >= 0)
- log_info("Hardware watchdog '%s', version %x",
- ident.identity,
- ident.firmware_version);
-
- return update_timeout();
-}
-
-int watchdog_set_timeout(usec_t *usec) {
- int r;
-
- watchdog_timeout = *usec;
-
- /* If we didn't open the watchdog yet and didn't get any
- * explicit timeout value set, don't do anything */
- if (watchdog_fd < 0 && watchdog_timeout == USEC_INFINITY)
- return 0;
-
- if (watchdog_fd < 0)
- r = open_watchdog();
- else
- r = update_timeout();
-
- *usec = watchdog_timeout;
-
- return r;
-}
-
-int watchdog_ping(void) {
- int r;
-
- if (watchdog_fd < 0) {
- r = open_watchdog();
- if (r < 0)
- return r;
- }
-
- r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
- if (r < 0)
- return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
-
- return 0;
-}
-
-void watchdog_close(bool disarm) {
- int r;
-
- if (watchdog_fd < 0)
- return;
-
- if (disarm) {
- int flags;
-
- /* Explicitly disarm it */
- flags = WDIOS_DISABLECARD;
- r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0)
- log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
-
- /* To be sure, use magic close logic, too */
- for (;;) {
- static const char v = 'V';
-
- if (write(watchdog_fd, &v, 1) > 0)
- break;
-
- if (errno != EINTR) {
- log_error_errno(errno, "Failed to disarm watchdog timer: %m");
- break;
- }
- }
- }
-
- watchdog_fd = safe_close(watchdog_fd);
-}
diff --git a/src/shared/watchdog.h b/src/shared/watchdog.h
deleted file mode 100644
index b748b1585..000000000
--- a/src/shared/watchdog.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "util.h"
-
-int watchdog_set_timeout(usec_t *usec);
-int watchdog_ping(void);
-void watchdog_close(bool disarm);
diff --git a/src/shared/xml.c b/src/shared/xml.c
deleted file mode 100644
index 15c629b18..000000000
--- a/src/shared/xml.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <string.h>
-
-#include "util.h"
-#include "xml.h"
-
-enum {
- STATE_NULL,
- STATE_TEXT,
- STATE_TAG,
- STATE_ATTRIBUTE,
-};
-
-static void inc_lines(unsigned *line, const char *s, size_t n) {
- const char *p = s;
-
- if (!line)
- return;
-
- for (;;) {
- const char *f;
-
- f = memchr(p, '\n', n);
- if (!f)
- return;
-
- n -= (f - p) + 1;
- p = f + 1;
- (*line)++;
- }
-}
-
-/* We don't actually do real XML here. We only read a simplistic
- * subset, that is a bit less strict that XML and lacks all the more
- * complex features, like entities, or namespaces. However, we do
- * support some HTML5-like simplifications */
-
-int xml_tokenize(const char **p, char **name, void **state, unsigned *line) {
- const char *c, *e, *b;
- char *ret;
- int t;
-
- assert(p);
- assert(*p);
- assert(name);
- assert(state);
-
- t = PTR_TO_INT(*state);
- c = *p;
-
- if (t == STATE_NULL) {
- if (line)
- *line = 1;
- t = STATE_TEXT;
- }
-
- for (;;) {
- if (*c == 0)
- return XML_END;
-
- switch (t) {
-
- case STATE_TEXT: {
- int x;
-
- e = strchrnul(c, '<');
- if (e > c) {
- /* More text... */
- ret = strndup(c, e - c);
- if (!ret)
- return -ENOMEM;
-
- inc_lines(line, c, e - c);
-
- *name = ret;
- *p = e;
- *state = INT_TO_PTR(STATE_TEXT);
-
- return XML_TEXT;
- }
-
- assert(*e == '<');
- b = c + 1;
-
- if (startswith(b, "!--")) {
- /* A comment */
- e = strstr(b + 3, "-->");
- if (!e)
- return -EINVAL;
-
- inc_lines(line, b, e + 3 - b);
-
- c = e + 3;
- continue;
- }
-
- if (*b == '?') {
- /* Processing instruction */
-
- e = strstr(b + 1, "?>");
- if (!e)
- return -EINVAL;
-
- inc_lines(line, b, e + 2 - b);
-
- c = e + 2;
- continue;
- }
-
- if (*b == '!') {
- /* DTD */
-
- e = strchr(b + 1, '>');
- if (!e)
- return -EINVAL;
-
- inc_lines(line, b, e + 1 - b);
-
- c = e + 1;
- continue;
- }
-
- if (*b == '/') {
- /* A closing tag */
- x = XML_TAG_CLOSE;
- b++;
- } else
- x = XML_TAG_OPEN;
-
- e = strpbrk(b, WHITESPACE "/>");
- if (!e)
- return -EINVAL;
-
- ret = strndup(b, e - b);
- if (!ret)
- return -ENOMEM;
-
- *name = ret;
- *p = e;
- *state = INT_TO_PTR(STATE_TAG);
-
- return x;
- }
-
- case STATE_TAG:
-
- b = c + strspn(c, WHITESPACE);
- if (*b == 0)
- return -EINVAL;
-
- inc_lines(line, c, b - c);
-
- e = b + strcspn(b, WHITESPACE "=/>");
- if (e > b) {
- /* An attribute */
-
- ret = strndup(b, e - b);
- if (!ret)
- return -ENOMEM;
-
- *name = ret;
- *p = e;
- *state = INT_TO_PTR(STATE_ATTRIBUTE);
-
- return XML_ATTRIBUTE_NAME;
- }
-
- if (startswith(b, "/>")) {
- /* An empty tag */
-
- *name = NULL; /* For empty tags we return a NULL name, the caller must be prepared for that */
- *p = b + 2;
- *state = INT_TO_PTR(STATE_TEXT);
-
- return XML_TAG_CLOSE_EMPTY;
- }
-
- if (*b != '>')
- return -EINVAL;
-
- c = b + 1;
- t = STATE_TEXT;
- continue;
-
- case STATE_ATTRIBUTE:
-
- if (*c == '=') {
- c++;
-
- if (*c == '\'' || *c == '\"') {
- /* Tag with a quoted value */
-
- e = strchr(c+1, *c);
- if (!e)
- return -EINVAL;
-
- inc_lines(line, c, e - c);
-
- ret = strndup(c+1, e - c - 1);
- if (!ret)
- return -ENOMEM;
-
- *name = ret;
- *p = e + 1;
- *state = INT_TO_PTR(STATE_TAG);
-
- return XML_ATTRIBUTE_VALUE;
-
- }
-
- /* Tag with a value without quotes */
-
- b = strpbrk(c, WHITESPACE ">");
- if (!b)
- b = c;
-
- ret = strndup(c, b - c);
- if (!ret)
- return -ENOMEM;
-
- *name = ret;
- *p = b;
- *state = INT_TO_PTR(STATE_TAG);
- return XML_ATTRIBUTE_VALUE;
- }
-
- t = STATE_TAG;
- continue;
- }
-
- }
-
- assert_not_reached("Bad state");
-}
diff --git a/src/shared/xml.h b/src/shared/xml.h
deleted file mode 100644
index b256b0ba1..000000000
--- a/src/shared/xml.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-enum {
- XML_END,
- XML_TEXT,
- XML_TAG_OPEN,
- XML_TAG_CLOSE,
- XML_TAG_CLOSE_EMPTY,
- XML_ATTRIBUTE_NAME,
- XML_ATTRIBUTE_VALUE,
-};
-
-int xml_tokenize(const char **p, char **name, void **state, unsigned *line);
diff --git a/src/systemctl/systemd-sysv-install.SKELETON b/src/systemctl/systemd-sysv-install.SKELETON
deleted file mode 100755
index a53a3e622..000000000
--- a/src/systemctl/systemd-sysv-install.SKELETON
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-# This script is called by "systemctl enable/disable" when the given unit is a
-# SysV init.d script. It needs to call the distribution's mechanism for
-# enabling/disabling those, such as chkconfig, update-rc.d, or similar. This
-# can optionally take a --root argument for enabling a SysV init script
-# in a chroot or similar.
-set -e
-
-usage() {
- echo "Usage: $0 [--root=path] enable|disable|is-enabled <sysv script name>" >&2
- exit 1
-}
-
-# parse options
-eval set -- "$(getopt -o r: --long root: -- "$@")"
-while true; do
- case "$1" in
- -r|--root)
- ROOT="$2"
- shift 2 ;;
- --) shift ; break ;;
- *) usage ;;
- esac
-done
-
-NAME="$2"
-[ -n "$NAME" ] || usage
-
-case "$1" in
- enable)
- # call the command to enable SysV init script $NAME here
- # (consider optional $ROOT)
- echo "IMPLEMENT ME: enabling SysV init.d script $NAME"
- ;;
- disable)
- # call the command to disable SysV init script $NAME here
- # (consider optional $ROOT)
- echo "IMPLEMENT ME: disabling SysV init.d script $NAME"
- ;;
- is-enabled)
- # exit with 0 if $NAME is enabled, non-zero if it is disabled
- # (consider optional $ROOT)
- echo "IMPLEMENT ME: checking SysV init.d script $NAME"
- ;;
- *)
- usage ;;
-esac
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 5439a1903..4ed197e59 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -127,27 +127,27 @@ int sd_bus_new(sd_bus **ret);
int sd_bus_set_address(sd_bus *bus, const char *address);
int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd);
-int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
-int sd_bus_get_address(sd_bus *bus, const char **address);
-int sd_bus_set_bus_client(sd_bus *bus, int b);
-int sd_bus_is_bus_client(sd_bus *bus);
+// UNNEEDED int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
+// UNNEEDED int sd_bus_get_address(sd_bus *bus, const char **address);
+// UNNEEDED int sd_bus_set_bus_client(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_is_bus_client(sd_bus *bus);
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t bus_id);
-int sd_bus_is_server(sd_bus *bus);
-int sd_bus_set_anonymous(sd_bus *bus, int b);
-int sd_bus_is_anonymous(sd_bus *bus);
-int sd_bus_set_trusted(sd_bus *bus, int b);
-int sd_bus_is_trusted(sd_bus *bus);
-int sd_bus_set_monitor(sd_bus *bus, int b);
-int sd_bus_is_monitor(sd_bus *bus);
-int sd_bus_set_description(sd_bus *bus, const char *description);
-int sd_bus_get_description(sd_bus *bus, const char **description);
+// UNNEEDED int sd_bus_is_server(sd_bus *bus);
+// UNNEEDED int sd_bus_set_anonymous(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_is_anonymous(sd_bus *bus);
+// UNNEEDED int sd_bus_set_trusted(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_is_trusted(sd_bus *bus);
+// UNNEEDED int sd_bus_set_monitor(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_is_monitor(sd_bus *bus);
+// UNNEEDED int sd_bus_set_description(sd_bus *bus, const char *description);
+// UNNEEDED int sd_bus_get_description(sd_bus *bus, const char **description);
int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t creds_mask);
-int sd_bus_negotiate_timestamp(sd_bus *bus, int b);
-int sd_bus_negotiate_fds(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_negotiate_timestamp(sd_bus *bus, int b);
+// UNNEEDED int sd_bus_negotiate_fds(sd_bus *bus, int b);
int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *creds_mask);
+// UNNEEDED int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *creds_mask);
int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b);
-int sd_bus_get_allow_interactive_authorization(sd_bus *bus);
+// UNNEEDED int sd_bus_get_allow_interactive_authorization(sd_bus *bus);
int sd_bus_start(sd_bus *ret);
@@ -156,13 +156,12 @@ void sd_bus_close(sd_bus *bus);
sd_bus *sd_bus_ref(sd_bus *bus);
sd_bus *sd_bus_unref(sd_bus *bus);
-sd_bus *sd_bus_flush_close_unref(sd_bus *bus);
-int sd_bus_is_open(sd_bus *bus);
+// UNNEEDED int sd_bus_is_open(sd_bus *bus);
-int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
-int sd_bus_get_scope(sd_bus *bus, const char **scope);
-int sd_bus_get_tid(sd_bus *bus, pid_t *tid);
+// UNNEEDED int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
+// UNNEEDED int sd_bus_get_scope(sd_bus *bus, const char **scope);
+// UNNEEDED int sd_bus_get_tid(sd_bus *bus, pid_t *tid);
int sd_bus_get_owner_creds(sd_bus *bus, uint64_t creds_mask, sd_bus_creds **ret);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie);
@@ -174,11 +173,11 @@ int sd_bus_get_fd(sd_bus *bus);
int sd_bus_get_events(sd_bus *bus);
int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec);
int sd_bus_process(sd_bus *bus, sd_bus_message **r);
-int sd_bus_process_priority(sd_bus *bus, int64_t max_priority, sd_bus_message **r);
+// UNNEEDED int sd_bus_process_priority(sd_bus *bus, int64_t max_priority, sd_bus_message **r);
int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
int sd_bus_flush(sd_bus *bus);
-sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus);
+// UNNEEDED sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus);
sd_bus_message* sd_bus_get_current_message(sd_bus *bus);
sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus);
void* sd_bus_get_current_userdata(sd_bus *bus);
@@ -194,22 +193,22 @@ int sd_bus_add_fallback(sd_bus *bus, sd_bus_slot **slot, const char *prefix, sd_
int sd_bus_add_object_vtable(sd_bus *bus, sd_bus_slot **slot, const char *path, const char *interface, const sd_bus_vtable *vtable, void *userdata);
int sd_bus_add_fallback_vtable(sd_bus *bus, sd_bus_slot **slot, const char *prefix, const char *interface, const sd_bus_vtable *vtable, sd_bus_object_find_t find, void *userdata);
int sd_bus_add_node_enumerator(sd_bus *bus, sd_bus_slot **slot, const char *path, sd_bus_node_enumerator_t callback, void *userdata);
-int sd_bus_add_object_manager(sd_bus *bus, sd_bus_slot **slot, const char *path);
+// UNNEEDED int sd_bus_add_object_manager(sd_bus *bus, sd_bus_slot **slot, const char *path);
/* Slot object */
sd_bus_slot* sd_bus_slot_ref(sd_bus_slot *slot);
sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot);
-sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot);
-void *sd_bus_slot_get_userdata(sd_bus_slot *slot);
-void *sd_bus_slot_set_userdata(sd_bus_slot *slot, void *userdata);
-int sd_bus_slot_set_description(sd_bus_slot *slot, const char *description);
-int sd_bus_slot_get_description(sd_bus_slot *slot, const char **description);
+// UNNEEDED sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot);
+// UNNEEDED void *sd_bus_slot_get_userdata(sd_bus_slot *slot);
+// UNNEEDED void *sd_bus_slot_set_userdata(sd_bus_slot *slot, void *userdata);
+// UNNEEDED int sd_bus_slot_set_description(sd_bus_slot *slot, const char *description);
+// UNNEEDED int sd_bus_slot_get_description(sd_bus_slot *slot, char **description);
-sd_bus_message* sd_bus_slot_get_current_message(sd_bus_slot *slot);
-sd_bus_message_handler_t sd_bus_slot_get_current_handler(sd_bus_slot *bus);
-void *sd_bus_slot_get_current_userdata(sd_bus_slot *slot);
+// UNNEEDED sd_bus_message* sd_bus_slot_get_current_message(sd_bus_slot *slot);
+// UNNEEDED sd_bus_message_handler_t sd_bus_slot_get_current_handler(sd_bus_slot *bus);
+// UNNEEDED void *sd_bus_slot_get_current_userdata(sd_bus_slot *slot);
/* Message object */
@@ -219,18 +218,18 @@ int sd_bus_message_new_method_return(sd_bus_message *call, sd_bus_message **m);
int sd_bus_message_new_method_error(sd_bus_message *call, sd_bus_message **m, const sd_bus_error *e);
int sd_bus_message_new_method_errorf(sd_bus_message *call, sd_bus_message **m, const char *name, const char *format, ...) _sd_printf_(4, 5);
int sd_bus_message_new_method_errno(sd_bus_message *call, sd_bus_message **m, int error, const sd_bus_error *e);
-int sd_bus_message_new_method_errnof(sd_bus_message *call, sd_bus_message **m, int error, const char *format, ...) _sd_printf_(4, 5);
+// UNNEEDED int sd_bus_message_new_method_errnof(sd_bus_message *call, sd_bus_message **m, int error, const char *format, ...) _sd_printf_(4, 5);
sd_bus_message* sd_bus_message_ref(sd_bus_message *m);
sd_bus_message* sd_bus_message_unref(sd_bus_message *m);
-int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type);
-int sd_bus_message_get_cookie(sd_bus_message *m, uint64_t *cookie);
-int sd_bus_message_get_reply_cookie(sd_bus_message *m, uint64_t *cookie);
-int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority);
+// UNNEEDED int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type);
+// UNNEEDED int sd_bus_message_get_cookie(sd_bus_message *m, uint64_t *cookie);
+// UNNEEDED int sd_bus_message_get_reply_cookie(sd_bus_message *m, uint64_t *cookie);
+// UNNEEDED int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority);
-int sd_bus_message_get_expect_reply(sd_bus_message *m);
-int sd_bus_message_get_auto_start(sd_bus_message *m);
+// UNNEEDED int sd_bus_message_get_expect_reply(sd_bus_message *m);
+// UNNEEDED int sd_bus_message_get_auto_start(sd_bus_message *m);
int sd_bus_message_get_allow_interactive_authorization(sd_bus_message *m);
const char *sd_bus_message_get_signature(sd_bus_message *m, int complete);
@@ -242,35 +241,35 @@ const char *sd_bus_message_get_sender(sd_bus_message *m);
const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m);
int sd_bus_message_get_errno(sd_bus_message *m);
-int sd_bus_message_get_monotonic_usec(sd_bus_message *m, uint64_t *usec);
-int sd_bus_message_get_realtime_usec(sd_bus_message *m, uint64_t *usec);
-int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
+// UNNEEDED int sd_bus_message_get_monotonic_usec(sd_bus_message *m, uint64_t *usec);
+// UNNEEDED int sd_bus_message_get_realtime_usec(sd_bus_message *m, uint64_t *usec);
+// UNNEEDED int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
sd_bus* sd_bus_message_get_bus(sd_bus_message *m);
sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m); /* do not unref the result */
-int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
+// UNNEEDED int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
-int sd_bus_message_is_empty(sd_bus_message *m);
-int sd_bus_message_has_signature(sd_bus_message *m, const char *signature);
+// UNNEEDED int sd_bus_message_is_empty(sd_bus_message *m);
+// UNNEEDED int sd_bus_message_has_signature(sd_bus_message *m, const char *signature);
-int sd_bus_message_set_expect_reply(sd_bus_message *m, int b);
+// UNNEEDED int sd_bus_message_set_expect_reply(sd_bus_message *m, int b);
int sd_bus_message_set_auto_start(sd_bus_message *m, int b);
-int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *m, int b);
+// UNNEEDED int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *m, int b);
int sd_bus_message_set_destination(sd_bus_message *m, const char *destination);
-int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority);
+// UNNEEDED int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority);
int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
int sd_bus_message_append_basic(sd_bus_message *m, char type, const void *p);
int sd_bus_message_append_array(sd_bus_message *m, char type, const void *ptr, size_t size);
int sd_bus_message_append_array_space(sd_bus_message *m, char type, size_t size, void **ptr);
-int sd_bus_message_append_array_iovec(sd_bus_message *m, char type, const struct iovec *iov, unsigned n);
-int sd_bus_message_append_array_memfd(sd_bus_message *m, char type, int memfd, uint64_t offset, uint64_t size);
+// UNNEEDED int sd_bus_message_append_array_iovec(sd_bus_message *m, char type, const struct iovec *iov, unsigned n);
+// UNNEEDED int sd_bus_message_append_array_memfd(sd_bus_message *m, char type, int memfd, uint64_t offset, uint64_t size);
int sd_bus_message_append_string_space(sd_bus_message *m, size_t size, char **s);
-int sd_bus_message_append_string_iovec(sd_bus_message *m, const struct iovec *iov, unsigned n);
-int sd_bus_message_append_string_memfd(sd_bus_message *m, int memfd, uint64_t offset, uint64_t size);
+// UNNEEDED int sd_bus_message_append_string_iovec(sd_bus_message *m, const struct iovec *iov, unsigned n);
+// UNNEEDED int sd_bus_message_append_string_memfd(sd_bus_message *m, int memfd, uint64_t offset, uint64_t size);
int sd_bus_message_append_strv(sd_bus_message *m, char **l);
int sd_bus_message_open_container(sd_bus_message *m, char type, const char *contents);
int sd_bus_message_close_container(sd_bus_message *m);
@@ -284,8 +283,8 @@ int sd_bus_message_skip(sd_bus_message *m, const char *types);
int sd_bus_message_enter_container(sd_bus_message *m, char type, const char *contents);
int sd_bus_message_exit_container(sd_bus_message *m);
int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char **contents);
-int sd_bus_message_verify_type(sd_bus_message *m, char type, const char *contents);
-int sd_bus_message_at_end(sd_bus_message *m, int complete);
+// UNNEEDED int sd_bus_message_verify_type(sd_bus_message *m, char type, const char *contents);
+// UNNEEDED int sd_bus_message_at_end(sd_bus_message *m, int complete);
int sd_bus_message_rewind(sd_bus_message *m, int complete);
/* Bus management */
@@ -295,23 +294,23 @@ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags);
int sd_bus_release_name(sd_bus *bus, const char *name);
int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatable); /* free the results */
int sd_bus_get_name_creds(sd_bus *bus, const char *name, uint64_t mask, sd_bus_creds **creds); /* unref the result! */
-int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machine);
+// UNNEEDED int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machine);
/* Convenience calls */
int sd_bus_call_method(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *types, ...);
-int sd_bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...);
+// UNNEEDED int sd_bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...);
int sd_bus_get_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *type);
-int sd_bus_get_property_trivial(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char type, void *ret_ptr);
+// UNNEEDED int sd_bus_get_property_trivial(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char type, void *ret_ptr);
int sd_bus_get_property_string(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char **ret); /* free the result! */
-int sd_bus_get_property_strv(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char ***ret); /* free the result! */
-int sd_bus_set_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, const char *type, ...);
+// UNNEEDED int sd_bus_get_property_strv(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char ***ret); /* free the result! */
+// UNNEEDED int sd_bus_set_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, const char *type, ...);
int sd_bus_reply_method_return(sd_bus_message *call, const char *types, ...);
int sd_bus_reply_method_error(sd_bus_message *call, const sd_bus_error *e);
int sd_bus_reply_method_errorf(sd_bus_message *call, const char *name, const char *format, ...) _sd_printf_(3, 4);
int sd_bus_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *e);
-int sd_bus_reply_method_errnof(sd_bus_message *call, int error, const char *format, ...) _sd_printf_(3, 4);
+// UNNEEDED int sd_bus_reply_method_errnof(sd_bus_message *call, int error, const char *format, ...) _sd_printf_(3, 4);
int sd_bus_emit_signal(sd_bus *bus, const char *path, const char *interface, const char *member, const char *types, ...);
@@ -319,7 +318,7 @@ int sd_bus_emit_properties_changed_strv(sd_bus *bus, const char *path, const cha
int sd_bus_emit_properties_changed(sd_bus *bus, const char *path, const char *interface, const char *name, ...) _sd_sentinel_;
int sd_bus_emit_object_added(sd_bus *bus, const char *path);
-int sd_bus_emit_object_removed(sd_bus *bus, const char *path);
+// UNNEEDED int sd_bus_emit_object_removed(sd_bus *bus, const char *path);
int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, char **interfaces);
int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const char *interface, ...) _sd_sentinel_;
int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path, char **interfaces);
@@ -330,46 +329,46 @@ int sd_bus_query_sender_privilege(sd_bus_message *call, int capability);
/* Credential handling */
-int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t creds_mask);
+// UNNEEDED int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t creds_mask);
sd_bus_creds *sd_bus_creds_ref(sd_bus_creds *c);
sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c);
-uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c);
+// UNNEEDED uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c);
uint64_t sd_bus_creds_get_augmented_mask(const sd_bus_creds *c);
int sd_bus_creds_get_pid(sd_bus_creds *c, pid_t *pid);
-int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid);
+// UNNEEDED int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid);
int sd_bus_creds_get_tid(sd_bus_creds *c, pid_t *tid);
int sd_bus_creds_get_uid(sd_bus_creds *c, uid_t *uid);
int sd_bus_creds_get_euid(sd_bus_creds *c, uid_t *euid);
-int sd_bus_creds_get_suid(sd_bus_creds *c, uid_t *suid);
-int sd_bus_creds_get_fsuid(sd_bus_creds *c, uid_t *fsuid);
-int sd_bus_creds_get_gid(sd_bus_creds *c, gid_t *gid);
+// UNNEEDED int sd_bus_creds_get_suid(sd_bus_creds *c, uid_t *suid);
+// UNNEEDED int sd_bus_creds_get_fsuid(sd_bus_creds *c, uid_t *fsuid);
+// UNNEEDED int sd_bus_creds_get_gid(sd_bus_creds *c, gid_t *gid);
int sd_bus_creds_get_egid(sd_bus_creds *c, gid_t *egid);
-int sd_bus_creds_get_sgid(sd_bus_creds *c, gid_t *sgid);
-int sd_bus_creds_get_fsgid(sd_bus_creds *c, gid_t *fsgid);
-int sd_bus_creds_get_supplementary_gids(sd_bus_creds *c, const gid_t **gids);
-int sd_bus_creds_get_comm(sd_bus_creds *c, const char **comm);
-int sd_bus_creds_get_tid_comm(sd_bus_creds *c, const char **comm);
-int sd_bus_creds_get_exe(sd_bus_creds *c, const char **exe);
+// UNNEEDED int sd_bus_creds_get_sgid(sd_bus_creds *c, gid_t *sgid);
+// UNNEEDED int sd_bus_creds_get_fsgid(sd_bus_creds *c, gid_t *fsgid);
+// UNNEEDED int sd_bus_creds_get_supplementary_gids(sd_bus_creds *c, const gid_t **gids);
+// UNNEEDED int sd_bus_creds_get_comm(sd_bus_creds *c, const char **comm);
+// UNNEEDED int sd_bus_creds_get_tid_comm(sd_bus_creds *c, const char **comm);
+// UNNEEDED int sd_bus_creds_get_exe(sd_bus_creds *c, const char **exe);
int sd_bus_creds_get_cmdline(sd_bus_creds *c, char ***cmdline);
-int sd_bus_creds_get_cgroup(sd_bus_creds *c, const char **cgroup);
-int sd_bus_creds_get_unit(sd_bus_creds *c, const char **unit);
-int sd_bus_creds_get_slice(sd_bus_creds *c, const char **slice);
-int sd_bus_creds_get_user_unit(sd_bus_creds *c, const char **unit);
-int sd_bus_creds_get_user_slice(sd_bus_creds *c, const char **slice);
+// UNNEEDED int sd_bus_creds_get_cgroup(sd_bus_creds *c, const char **cgroup);
+// UNNEEDED int sd_bus_creds_get_unit(sd_bus_creds *c, const char **unit);
+// UNNEEDED int sd_bus_creds_get_slice(sd_bus_creds *c, const char **slice);
+// UNNEEDED int sd_bus_creds_get_user_unit(sd_bus_creds *c, const char **unit);
+// UNNEEDED int sd_bus_creds_get_user_slice(sd_bus_creds *c, const char **slice);
int sd_bus_creds_get_session(sd_bus_creds *c, const char **session);
int sd_bus_creds_get_owner_uid(sd_bus_creds *c, uid_t *uid);
int sd_bus_creds_has_effective_cap(sd_bus_creds *c, int capability);
-int sd_bus_creds_has_permitted_cap(sd_bus_creds *c, int capability);
-int sd_bus_creds_has_inheritable_cap(sd_bus_creds *c, int capability);
-int sd_bus_creds_has_bounding_cap(sd_bus_creds *c, int capability);
+// UNNEEDED int sd_bus_creds_has_permitted_cap(sd_bus_creds *c, int capability);
+// UNNEEDED int sd_bus_creds_has_inheritable_cap(sd_bus_creds *c, int capability);
+// UNNEEDED int sd_bus_creds_has_bounding_cap(sd_bus_creds *c, int capability);
int sd_bus_creds_get_selinux_context(sd_bus_creds *c, const char **context);
-int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessionid);
+// UNNEEDED int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessionid);
int sd_bus_creds_get_audit_login_uid(sd_bus_creds *c, uid_t *loginuid);
int sd_bus_creds_get_tty(sd_bus_creds *c, const char **tty);
-int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **name);
-int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***names);
-int sd_bus_creds_get_description(sd_bus_creds *c, const char **name);
+// UNNEEDED int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **name);
+// UNNEEDED int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***names);
+// UNNEEDED int sd_bus_creds_get_description(sd_bus_creds *c, const char **name);
/* Error structures */
@@ -417,8 +416,8 @@ int sd_bus_error_add_map(const sd_bus_error_map *map);
/* Label escaping */
-int sd_bus_path_encode(const char *prefix, const char *external_id, char **ret_path);
-int sd_bus_path_decode(const char *path, const char *prefix, char **ret_external_id);
+// UNNEEDED int sd_bus_path_encode(const char *prefix, const char *external_id, char **ret_path);
+// UNNEEDED int sd_bus_path_decode(const char *path, const char *prefix, char **ret_external_id);
/* Tracking peers */
@@ -427,8 +426,8 @@ sd_bus_track* sd_bus_track_ref(sd_bus_track *track);
sd_bus_track* sd_bus_track_unref(sd_bus_track *track);
sd_bus* sd_bus_track_get_bus(sd_bus_track *track);
-void *sd_bus_track_get_userdata(sd_bus_track *track);
-void *sd_bus_track_set_userdata(sd_bus_track *track, void *userdata);
+// UNNEEDED void *sd_bus_track_get_userdata(sd_bus_track *track);
+// UNNEEDED void *sd_bus_track_set_userdata(sd_bus_track *track, void *userdata);
int sd_bus_track_add_sender(sd_bus_track *track, sd_bus_message *m);
int sd_bus_track_remove_sender(sd_bus_track *track, sd_bus_message *m);
diff --git a/src/systemd/sd-daemon.h b/src/systemd/sd-daemon.h
index 8fcb6968d..861dc8f1f 100644
--- a/src/systemd/sd-daemon.h
+++ b/src/systemd/sd-daemon.h
@@ -147,6 +147,16 @@ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port
int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length);
/*
+ Helper call for identifying a passed file descriptor. Returns 1 if
+ the file descriptor is a POSIX Message Queue of the specified name,
+ 0 otherwise. If path is NULL a message queue name check is not
+ done. Returns a negative errno style error code on failure.
+
+ See sd_is_mq(3) for more information.
+*/
+int sd_is_mq(int fd, const char *path);
+
+/*
Informs systemd about changed daemon state. This takes a number of
newline separated environment-style variable assignments in a
string. The following variables are known:
diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h
deleted file mode 100644
index 38cb2a110..000000000
--- a/src/systemd/sd-device.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosddevicehfoo
-#define foosddevicehfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
- Copyright 2014-2015 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-#include <stdint.h>
-
-#include "_sd-common.h"
-
-_SD_BEGIN_DECLARATIONS;
-
-typedef struct sd_device sd_device;
-typedef struct sd_device_enumerator sd_device_enumerator;
-
-/* device */
-
-sd_device *sd_device_ref(sd_device *device);
-sd_device *sd_device_unref(sd_device *device);
-
-int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
-int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
-int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
-int sd_device_new_from_device_id(sd_device **ret, const char *id);
-
-int sd_device_get_parent(sd_device *child, sd_device **ret);
-int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
-
-int sd_device_get_syspath(sd_device *device, const char **ret);
-int sd_device_get_subsystem(sd_device *device, const char **ret);
-int sd_device_get_devtype(sd_device *device, const char **ret);
-int sd_device_get_devnum(sd_device *device, dev_t *devnum);
-int sd_device_get_ifindex(sd_device *device, int *ifindex);
-int sd_device_get_driver(sd_device *device, const char **ret);
-int sd_device_get_devpath(sd_device *device, const char **ret);
-int sd_device_get_devname(sd_device *device, const char **ret);
-int sd_device_get_sysname(sd_device *device, const char **ret);
-int sd_device_get_sysnum(sd_device *device, const char **ret);
-
-int sd_device_get_is_initialized(sd_device *device, int *initialized);
-int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
-
-const char *sd_device_get_tag_first(sd_device *device);
-const char *sd_device_get_tag_next(sd_device *device);
-const char *sd_device_get_devlink_first(sd_device *device);
-const char *sd_device_get_devlink_next(sd_device *device);
-const char *sd_device_get_property_first(sd_device *device, const char **value);
-const char *sd_device_get_property_next(sd_device *device, const char **value);
-const char *sd_device_get_sysattr_first(sd_device *device);
-const char *sd_device_get_sysattr_next(sd_device *device);
-
-int sd_device_has_tag(sd_device *device, const char *tag);
-int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
-int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
-
-int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value);
-
-/* device enumerator */
-
-int sd_device_enumerator_new(sd_device_enumerator **ret);
-sd_device_enumerator *sd_device_enumerator_ref(sd_device_enumerator *enumerator);
-sd_device_enumerator *sd_device_enumerator_unref(sd_device_enumerator *enumerator);
-
-sd_device *sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator);
-sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator);
-sd_device *sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator);
-sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator);
-
-int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enumerator, const char *subsystem, int match);
-int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match);
-int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value);
-int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname);
-int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag);
-int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent);
-int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator);
-
-_SD_END_DECLARATIONS;
-
-#endif
diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h
deleted file mode 100644
index 951662e56..000000000
--- a/src/systemd/sd-dhcp-client.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosddhcpclienthfoo
-#define foosddhcpclienthfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Intel Corporation. All rights reserved.
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <netinet/in.h>
-#include <net/ethernet.h>
-
-#include "sd-event.h"
-#include "sd-dhcp-lease.h"
-
-enum {
- DHCP_EVENT_STOP = 0,
- DHCP_EVENT_IP_ACQUIRE = 1,
- DHCP_EVENT_IP_CHANGE = 2,
- DHCP_EVENT_EXPIRED = 3,
- DHCP_EVENT_RENEW = 4,
-};
-
-typedef struct sd_dhcp_client sd_dhcp_client;
-
-typedef void (*sd_dhcp_client_cb_t)(sd_dhcp_client *client, int event,
- void *userdata);
-int sd_dhcp_client_set_callback(sd_dhcp_client *client, sd_dhcp_client_cb_t cb,
- void *userdata);
-
-
-int sd_dhcp_client_set_request_option(sd_dhcp_client *client, uint8_t option);
-int sd_dhcp_client_set_request_address(sd_dhcp_client *client,
- const struct in_addr *last_address);
-int sd_dhcp_client_set_request_broadcast(sd_dhcp_client *client, int broadcast);
-int sd_dhcp_client_set_index(sd_dhcp_client *client, int interface_index);
-int sd_dhcp_client_set_mac(sd_dhcp_client *client, const uint8_t *addr,
- size_t addr_len, uint16_t arp_type);
-int sd_dhcp_client_set_client_id(sd_dhcp_client *client, uint8_t type,
- const uint8_t *data, size_t data_len);
-int sd_dhcp_client_get_client_id(sd_dhcp_client *client, uint8_t *type,
- const uint8_t **data, size_t *data_len);
-int sd_dhcp_client_set_mtu(sd_dhcp_client *client, uint32_t mtu);
-int sd_dhcp_client_set_hostname(sd_dhcp_client *client, const char *hostname);
-int sd_dhcp_client_set_vendor_class_identifier(sd_dhcp_client *client, const char *vci);
-int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret);
-
-int sd_dhcp_client_stop(sd_dhcp_client *client);
-int sd_dhcp_client_start(sd_dhcp_client *client);
-
-sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
-sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
-
-int sd_dhcp_client_new(sd_dhcp_client **ret);
-
-int sd_dhcp_client_attach_event(sd_dhcp_client *client, sd_event *event, int priority);
-int sd_dhcp_client_detach_event(sd_dhcp_client *client);
-sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
-
-#endif
diff --git a/src/systemd/sd-dhcp-lease.h b/src/systemd/sd-dhcp-lease.h
deleted file mode 100644
index 4296b91d8..000000000
--- a/src/systemd/sd-dhcp-lease.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosddhcpleasehfoo
-#define foosddhcpleasehfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Intel Corporation. All rights reserved.
- Copyright (C) 2014 Tom Gundersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <netinet/in.h>
-#include <net/ethernet.h>
-
-typedef struct sd_dhcp_lease sd_dhcp_lease;
-struct sd_dhcp_route;
-
-sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
-sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
-
-int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
-int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime);
-int sd_dhcp_lease_get_netmask(sd_dhcp_lease *lease, struct in_addr *addr);
-int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, struct in_addr *addr);
-int sd_dhcp_lease_get_next_server(sd_dhcp_lease *lease, struct in_addr *addr);
-int sd_dhcp_lease_get_server_identifier(sd_dhcp_lease *lease, struct in_addr *addr);
-int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
-int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
-int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu);
-int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname);
-int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname);
-int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path);
-int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routesgn);
-int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const uint8_t **client_id,
- size_t *client_id_len);
-
-int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
-int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);
-
-#endif
diff --git a/src/systemd/sd-dhcp-server.h b/src/systemd/sd-dhcp-server.h
deleted file mode 100644
index 9af3b6532..000000000
--- a/src/systemd/sd-dhcp-server.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosddhcpserverhfoo
-#define foosddhcpserverhfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2013 Intel Corporation. All rights reserved.
- Copyright (C) 2014 Tom Gundersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include <netinet/in.h>
-
-#include "sd-event.h"
-
-typedef struct sd_dhcp_server sd_dhcp_server;
-
-sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server);
-sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server);
-
-int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex);
-
-int sd_dhcp_server_attach_event(sd_dhcp_server *client, sd_event *event, int priority);
-int sd_dhcp_server_detach_event(sd_dhcp_server *client);
-sd_event *sd_dhcp_server_get_event(sd_dhcp_server *client);
-
-bool sd_dhcp_server_is_running(sd_dhcp_server *server);
-
-int sd_dhcp_server_start(sd_dhcp_server *server);
-int sd_dhcp_server_stop(sd_dhcp_server *server);
-
-int sd_dhcp_server_set_address(sd_dhcp_server *server, struct in_addr *address, unsigned char prefixlen);
-int sd_dhcp_server_set_lease_pool(sd_dhcp_server *server, struct in_addr *start, size_t size);
-
-int sd_dhcp_server_forcerenew(sd_dhcp_server *server);
-#endif
diff --git a/src/systemd/sd-dhcp6-client.h b/src/systemd/sd-dhcp6-client.h
deleted file mode 100644
index e9663c0c7..000000000
--- a/src/systemd/sd-dhcp6-client.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosddhcp6clienthfoo
-#define foosddhcp6clienthfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2014 Intel Corporation. All rights reserved.
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <net/ethernet.h>
-
-#include "sd-event.h"
-
-#include "sd-dhcp6-lease.h"
-
-enum {
- DHCP6_EVENT_STOP = 0,
- DHCP6_EVENT_RESEND_EXPIRE = 10,
- DHCP6_EVENT_RETRANS_MAX = 11,
- DHCP6_EVENT_IP_ACQUIRE = 12,
- DHCP6_EVENT_INFORMATION_REQUEST = 13,
-};
-
-typedef struct sd_dhcp6_client sd_dhcp6_client;
-
-typedef void (*sd_dhcp6_client_cb_t)(sd_dhcp6_client *client, int event,
- void *userdata);
-int sd_dhcp6_client_set_callback(sd_dhcp6_client *client,
- sd_dhcp6_client_cb_t cb, void *userdata);
-
-int sd_dhcp6_client_set_index(sd_dhcp6_client *client, int interface_index);
-int sd_dhcp6_client_set_mac(sd_dhcp6_client *client, const uint8_t *addr,
- size_t addr_len, uint16_t arp_type);
-int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *duid,
- size_t duid_len);
-int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client,
- bool enabled);
-int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client,
- bool *enabled);
-int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client,
- uint16_t option);
-
-int sd_dhcp6_client_get_lease(sd_dhcp6_client *client, sd_dhcp6_lease **ret);
-
-int sd_dhcp6_client_stop(sd_dhcp6_client *client);
-int sd_dhcp6_client_start(sd_dhcp6_client *client);
-int sd_dhcp6_client_attach_event(sd_dhcp6_client *client, sd_event *event,
- int priority);
-int sd_dhcp6_client_detach_event(sd_dhcp6_client *client);
-sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client);
-sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
-sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
-int sd_dhcp6_client_new(sd_dhcp6_client **ret);
-
-#endif
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index 565de5495..3cf7661fd 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -90,45 +90,45 @@ int sd_event_prepare(sd_event *e);
int sd_event_wait(sd_event *e, uint64_t timeout);
int sd_event_dispatch(sd_event *e);
int sd_event_run(sd_event *e, uint64_t timeout);
-int sd_event_loop(sd_event *e);
+// UNNEEDED int sd_event_loop(sd_event *e);
int sd_event_exit(sd_event *e, int code);
-int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec);
+// UNNEEDED int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec);
-int sd_event_get_fd(sd_event *e);
+// UNNEEDED int sd_event_get_fd(sd_event *e);
int sd_event_get_state(sd_event *e);
int sd_event_get_tid(sd_event *e, pid_t *tid);
int sd_event_get_exit_code(sd_event *e, int *code);
int sd_event_set_watchdog(sd_event *e, int b);
-int sd_event_get_watchdog(sd_event *e);
+// UNNEEDED int sd_event_get_watchdog(sd_event *e);
-sd_event_source* sd_event_source_ref(sd_event_source *s);
+// UNNEEDED sd_event_source* sd_event_source_ref(sd_event_source *s);
sd_event_source* sd_event_source_unref(sd_event_source *s);
sd_event *sd_event_source_get_event(sd_event_source *s);
-void* sd_event_source_get_userdata(sd_event_source *s);
-void* sd_event_source_set_userdata(sd_event_source *s, void *userdata);
+// UNNEEDED void* sd_event_source_get_userdata(sd_event_source *s);
+// UNNEEDED void* sd_event_source_set_userdata(sd_event_source *s, void *userdata);
int sd_event_source_set_description(sd_event_source *s, const char *description);
-int sd_event_source_get_description(sd_event_source *s, const char **description);
+// UNNEEDED int sd_event_source_get_description(sd_event_source *s, const char **description);
int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t callback);
-int sd_event_source_get_pending(sd_event_source *s);
-int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);
+// UNNEEDED int sd_event_source_get_pending(sd_event_source *s);
+// UNNEEDED int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);
int sd_event_source_set_priority(sd_event_source *s, int64_t priority);
-int sd_event_source_get_enabled(sd_event_source *s, int *enabled);
+// UNNEEDED int sd_event_source_get_enabled(sd_event_source *s, int *enabled);
int sd_event_source_set_enabled(sd_event_source *s, int enabled);
-int sd_event_source_get_io_fd(sd_event_source *s);
+// UNNEEDED int sd_event_source_get_io_fd(sd_event_source *s);
int sd_event_source_set_io_fd(sd_event_source *s, int fd);
-int sd_event_source_get_io_events(sd_event_source *s, uint32_t* events);
+// UNNEEDED int sd_event_source_get_io_events(sd_event_source *s, uint32_t* events);
int sd_event_source_set_io_events(sd_event_source *s, uint32_t events);
-int sd_event_source_get_io_revents(sd_event_source *s, uint32_t* revents);
+// UNNEEDED int sd_event_source_get_io_revents(sd_event_source *s, uint32_t* revents);
int sd_event_source_get_time(sd_event_source *s, uint64_t *usec);
int sd_event_source_set_time(sd_event_source *s, uint64_t usec);
-int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec);
-int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec);
-int sd_event_source_get_time_clock(sd_event_source *s, clockid_t *clock);
-int sd_event_source_get_signal(sd_event_source *s);
-int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
+// UNNEEDED int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec);
+// UNNEEDED int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec);
+// UNNEEDED int sd_event_source_get_time_clock(sd_event_source *s, clockid_t *clock);
+// UNNEEDED int sd_event_source_get_signal(sd_event_source *s);
+// UNNEEDED int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
_SD_END_DECLARATIONS;
diff --git a/src/systemd/sd-hwdb.h b/src/systemd/sd-hwdb.h
deleted file mode 100644
index 3c44b981d..000000000
--- a/src/systemd/sd-hwdb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdhwdbhfoo
-#define foosdhwdbhfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
- Copyright 2014 Tom Gundersen <teg@jklm.no>
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "_sd-common.h"
-
-_SD_BEGIN_DECLARATIONS;
-
-typedef struct sd_hwdb sd_hwdb;
-
-sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb);
-sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb);
-
-int sd_hwdb_new(sd_hwdb **ret);
-
-int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **value);
-
-int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias);
-int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value);
-
-/* the inverse condition avoids ambiguity of danling 'else' after the macro */
-#define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \
- if (sd_hwdb_seek(hwdb, modalias) < 0) { } \
- else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0)
-
-#endif
diff --git a/src/systemd/sd-icmp6-nd.h b/src/systemd/sd-icmp6-nd.h
deleted file mode 100644
index 79b407470..000000000
--- a/src/systemd/sd-icmp6-nd.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdicmp6ndfoo
-#define foosdicmp6ndfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2014 Intel Corporation. All rights reserved.
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <net/ethernet.h>
-
-#include "sd-event.h"
-
-enum {
- ICMP6_EVENT_ROUTER_ADVERTISMENT_NONE = 0,
- ICMP6_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
- ICMP6_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
- ICMP6_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
- ICMP6_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED = 4,
-};
-
-typedef struct sd_icmp6_nd sd_icmp6_nd;
-
-typedef void(*sd_icmp6_nd_callback_t)(sd_icmp6_nd *nd, int event,
- void *userdata);
-
-int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t cb,
- void *userdata);
-int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index);
-int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr);
-
-int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority);
-int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd);
-sd_event *sd_icmp6_nd_get_event(sd_icmp6_nd *nd);
-
-sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd);
-sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd);
-int sd_icmp6_nd_new(sd_icmp6_nd **ret);
-
-int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
- struct in6_addr *addr);
-
-int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu);
-int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
- uint8_t *prefixlen);
-int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr,
- uint8_t *prefixlen);
-
-int sd_icmp6_nd_stop(sd_icmp6_nd *nd);
-int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd);
-
-#define SD_ICMP6_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
-
-#define SD_ICMP6_ADDRESS_FORMAT_VAL(address) \
- be16toh((address).s6_addr16[0]), \
- be16toh((address).s6_addr16[1]), \
- be16toh((address).s6_addr16[2]), \
- be16toh((address).s6_addr16[3]), \
- be16toh((address).s6_addr16[4]), \
- be16toh((address).s6_addr16[5]), \
- be16toh((address).s6_addr16[6]), \
- be16toh((address).s6_addr16[7])
-
-#endif
diff --git a/src/systemd/sd-ipv4ll.h b/src/systemd/sd-ipv4ll.h
deleted file mode 100644
index d01715815..000000000
--- a/src/systemd/sd-ipv4ll.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdipv4llfoo
-#define foosdipv4llfoo
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2014 Axis Communications AB. All rights reserved.
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <stdbool.h>
-#include <netinet/in.h>
-#include <net/ethernet.h>
-
-#include "sd-event.h"
-
-enum {
- IPV4LL_EVENT_STOP = 0,
- IPV4LL_EVENT_BIND = 1,
- IPV4LL_EVENT_CONFLICT = 2,
-};
-
-typedef struct sd_ipv4ll sd_ipv4ll;
-typedef void (*sd_ipv4ll_cb_t)(sd_ipv4ll *ll, int event, void *userdata);
-
-int sd_ipv4ll_detach_event(sd_ipv4ll *ll);
-int sd_ipv4ll_attach_event(sd_ipv4ll *ll, sd_event *event, int priority);
-int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address);
-int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_cb_t cb, void *userdata);
-int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr);
-int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index);
-int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint8_t seed[8]);
-bool sd_ipv4ll_is_running(sd_ipv4ll *ll);
-int sd_ipv4ll_start(sd_ipv4ll *ll);
-int sd_ipv4ll_stop(sd_ipv4ll *ll);
-sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll);
-sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll);
-int sd_ipv4ll_new (sd_ipv4ll **ret);
-
-#endif
diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h
deleted file mode 100644
index 700146aba..000000000
--- a/src/systemd/sd-lldp.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright (C) 2014 Tom Gundersen
- Copyright (C) 2014 Susant Sahani
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#pragma once
-
-#include "sd-event.h"
-
-typedef struct sd_lldp sd_lldp;
-
-typedef void (*sd_lldp_cb_t)(sd_lldp *lldp, int event, void *userdata);
-
-enum {
- UPDATE_INFO = 10,
-};
-
-typedef enum LLDPPortStatus {
- LLDP_PORT_STATUS_NONE,
- LLDP_PORT_STATUS_ENABLED,
- LLDP_PORT_STATUS_DISABLED,
- _LLDP_PORT_STATUS_MAX,
- _LLDP_PORT_STATUS_INVALID = -1,
-} LLDPPortStatus;
-
-int sd_lldp_new(int ifindex, const char *ifname, const struct ether_addr *mac, sd_lldp **ret);
-void sd_lldp_free(sd_lldp *lldp);
-
-int sd_lldp_start(sd_lldp *lldp);
-int sd_lldp_stop(sd_lldp *lldp);
-
-int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int priority);
-int sd_lldp_detach_event(sd_lldp *lldp);
-
-int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_cb_t cb, void *userdata);
-int sd_lldp_save(sd_lldp *lldp, const char *file);
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
deleted file mode 100644
index 4d96c867d..000000000
--- a/src/systemd/sd-network.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdnetworkhfoo
-#define foosdnetworkhfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2011 Lennart Poettering
- Copyright 2014 Tom Gundersen
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-#include <inttypes.h>
-
-#include "_sd-common.h"
-
-/*
- * A few points:
- *
- * Instead of returning an empty string array or empty integer array, we
- * may return NULL.
- *
- * Free the data the library returns with libc free(). String arrays
- * are NULL terminated, and you need to free the array itself in
- * addition to the strings contained.
- *
- * We return error codes as negative errno, kernel-style. On success, we
- * return 0 or positive.
- *
- * These functions access data in /run. This is a virtual file system;
- * therefore, accesses are relatively cheap.
- *
- * See sd-network(3) for more information.
- */
-
-_SD_BEGIN_DECLARATIONS;
-
-/* Get overall operational state
- * Possible states: down, up, dormant, carrier, degraded, routable
- * Possible return codes:
- * -ENODATA: networkd is not aware of any links
- */
-int sd_network_get_operational_state(char **state);
-
-/* Get DNS entries for all links. These are string representations of
- * IP addresses */
-int sd_network_get_dns(char ***dns);
-
-/* Get NTP entries for all links. These are domain names or string
- * representations of IP addresses */
-int sd_network_get_ntp(char ***ntp);
-
-/* Get the search/routing domains for all links. */
-int sd_network_get_domains(char ***domains);
-
-/* Get setup state from ifindex.
- * Possible states:
- * pending: udev is still processing the link, we don't yet know if we will manage it
- * failed: networkd failed to manage the link
- * configuring: in the process of retrieving configuration or configuring the link
- * configured: link configured successfully
- * unmanaged: networkd is not handling the link
- * linger: the link is gone, but has not yet been dropped by networkd
- * Possible return codes:
- * -ENODATA: networkd is not aware of the link
- */
-int sd_network_link_get_setup_state(int ifindex, char **state);
-
-/* Get operational state from ifindex.
- * Possible states:
- * off: the device is powered down
- * no-carrier: the device is powered up, but it does not yet have a carrier
- * dormant: the device has a carrier, but is not yet ready for normal traffic
- * carrier: the link has a carrier
- * degraded: the link has carrier and addresses valid on the local link configured
- * routable: the link has carrier and routable address configured
- * Possible return codes:
- * -ENODATA: networkd is not aware of the link
- */
-int sd_network_link_get_operational_state(int ifindex, char **state);
-
-/* Get path to .network file applied to link */
-int sd_network_link_get_network_file(int ifindex, char **filename);
-
-/* Get DNS entries for a given link. These are string representations of
- * IP addresses */
-int sd_network_link_get_dns(int ifindex, char ***addr);
-
-/* Get NTP entries for a given link. These are domain names or string
- * representations of IP addresses */
-int sd_network_link_get_ntp(int ifindex, char ***addr);
-
-/* Indicates whether or not LLMNR should be enabled for the link
- * Possible levels of support: yes, no, resolve
- * Possible return codes:
- * -ENODATA: networkd is not aware of the link
- */
-int sd_network_link_get_llmnr(int ifindex, char **llmnr);
-
-int sd_network_link_get_lldp(int ifindex, char **lldp);
-
-/* Get the DNS domain names for a given link. */
-int sd_network_link_get_domains(int ifindex, char ***domains);
-
-/* Get the CARRIERS to which current link is bound to. */
-int sd_network_link_get_carrier_bound_to(int ifindex, char ***carriers);
-
-/* Get the CARRIERS that are bound to current link. */
-int sd_network_link_get_carrier_bound_by(int ifindex, char ***carriers);
-
-/* Returns whether or not domains that don't match any link should be resolved
- * on this link. 1 for yes, 0 for no and negative value for error */
-int sd_network_link_get_wildcard_domain(int ifindex);
-
-/* Monitor object */
-typedef struct sd_network_monitor sd_network_monitor;
-
-/* Create a new monitor. Category must be NULL, "links" or "leases". */
-int sd_network_monitor_new(sd_network_monitor **ret, const char *category);
-
-/* Destroys the passed monitor. Returns NULL. */
-sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
-
-/* Flushes the monitor */
-int sd_network_monitor_flush(sd_network_monitor *m);
-
-/* Get FD from monitor */
-int sd_network_monitor_get_fd(sd_network_monitor *m);
-
-/* Get poll() mask to monitor */
-int sd_network_monitor_get_events(sd_network_monitor *m);
-
-/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
-int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
-
-_SD_END_DECLARATIONS;
-
-#endif
diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h
deleted file mode 100644
index 36cedcd6b..000000000
--- a/src/systemd/sd-resolve.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdresolvehfoo
-#define foosdresolvehfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2005-2014 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-#include "_sd-common.h"
-#include "sd-event.h"
-
-_SD_BEGIN_DECLARATIONS;
-
-/* An opaque sd-resolve session structure */
-typedef struct sd_resolve sd_resolve;
-
-/* An opaque sd-resolve query structure */
-typedef struct sd_resolve_query sd_resolve_query;
-
-/* A callback on completion */
-typedef int (*sd_resolve_getaddrinfo_handler_t)(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata);
-typedef int (*sd_resolve_getnameinfo_handler_t)(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata);
-typedef int (*sd_resolve_res_handler_t)(sd_resolve_query* q, int ret, unsigned char *answer, void *userdata);
-
-enum {
- SD_RESOLVE_GET_HOST = 1ULL,
- SD_RESOLVE_GET_SERVICE = 2ULL,
- SD_RESOLVE_GET_BOTH = 3ULL
-};
-
-int sd_resolve_default(sd_resolve **ret);
-
-/* Allocate a new sd-resolve session. */
-int sd_resolve_new(sd_resolve **ret);
-
-/* Free a sd-resolve session. This destroys all attached
- * sd_resolve_query objects automatically. */
-sd_resolve* sd_resolve_unref(sd_resolve *resolve);
-sd_resolve* sd_resolve_ref(sd_resolve *resolve);
-
-/* Return the UNIX file descriptor to poll() for events on. Use this
- * function to integrate sd-resolve with your custom main loop. */
-int sd_resolve_get_fd(sd_resolve *resolve);
-
-/* Return the poll() events (a combination of flags like POLLIN,
- * POLLOUT, ...) to check for. */
-int sd_resolve_get_events(sd_resolve *resolve);
-
-/* Return the poll() timeout to pass. Returns (uint64_t) -1 as
- * timeout if no timeout is needed. */
-int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *timeout_usec);
-
-/* Process pending responses. After this function is called, you can
- * get the next completed query object(s) using
- * sd_resolve_get_next(). */
-int sd_resolve_process(sd_resolve *resolve);
-
-/* Wait for a resolve event to complete. */
-int sd_resolve_wait(sd_resolve *resolve, uint64_t timeout_usec);
-
-int sd_resolve_get_tid(sd_resolve *resolve, pid_t *tid);
-
-int sd_resolve_attach_event(sd_resolve *resolve, sd_event *e, int priority);
-int sd_resolve_detach_event(sd_resolve *resolve);
-sd_event *sd_resolve_get_event(sd_resolve *resolve);
-
-/* Issue a name-to-address query on the specified session. The
- * arguments are compatible with those of libc's
- * getaddrinfo(3). The function returns a new query object. When the
- * query is completed, you may retrieve the results using
- * sd_resolve_getaddrinfo_done(). */
-int sd_resolve_getaddrinfo(sd_resolve *resolve, sd_resolve_query **q, const char *node, const char *service, const struct addrinfo *hints, sd_resolve_getaddrinfo_handler_t callback, void *userdata);
-
-/* Issue an address-to-name query on the specified session. The
- * arguments are compatible with those of libc's
- * getnameinfo(3). The function returns a new query object. When the
- * query is completed, you may retrieve the results using
- * sd_resolve_getnameinfo_done(). Set gethost (resp. getserv) to non-zero
- * if you want to query the hostname (resp. the service name). */
-int sd_resolve_getnameinfo(sd_resolve *resolve, sd_resolve_query **q, const struct sockaddr *sa, socklen_t salen, int flags, uint64_t get, sd_resolve_getnameinfo_handler_t callback, void *userdata);
-
-/* Issue a resolver query on the specified session. The arguments are
- * compatible with those of libc's res_query(3). The function returns a new
- * query object. When the query is completed, you may retrieve the results using
- * sd_resolve_res_done(). */
-int sd_resolve_res_query(sd_resolve *resolve, sd_resolve_query **q, const char *dname, int clazz, int type, sd_resolve_res_handler_t callback, void *userdata);
-
-/* Issue a resolver query on the specified session. The arguments are
- * compatible with those of libc's res_search(3). The function returns a new
- * query object. When the query is completed, you may retrieve the results using
- * sd_resolve_res_done(). */
-int sd_resolve_res_search(sd_resolve *resolve, sd_resolve_query **q, const char *dname, int clazz, int type, sd_resolve_res_handler_t callback, void *userdata);
-
-sd_resolve_query *sd_resolve_query_ref(sd_resolve_query* q);
-sd_resolve_query *sd_resolve_query_unref(sd_resolve_query* q);
-
-/* Returns non-zero when the query operation specified by q has been completed. */
-int sd_resolve_query_is_done(sd_resolve_query*q);
-
-void *sd_resolve_query_get_userdata(sd_resolve_query *q);
-void *sd_resolve_query_set_userdata(sd_resolve_query *q, void *userdata);
-
-sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q);
-
-_SD_END_DECLARATIONS;
-
-#endif
diff --git a/src/systemd/sd-utf8.h b/src/systemd/sd-utf8.h
deleted file mode 100644
index 205ee4221..000000000
--- a/src/systemd/sd-utf8.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdutf8hfoo
-#define foosdutf8hfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "_sd-common.h"
-
-_SD_BEGIN_DECLARATIONS;
-
-_sd_pure_ const char *sd_utf8_is_valid(const char *s);
-_sd_pure_ const char *sd_ascii_is_valid(const char *s);
-
-_SD_END_DECLARATIONS;
-
-#endif
diff --git a/src/test/test-firewall-util.c b/src/test/test-firewall-util.c
deleted file mode 100644
index d636e427c..000000000
--- a/src/test/test-firewall-util.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2015 Lennart Poettering
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "log.h"
-#include "firewall-util.h"
-
-#define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))}
-
-int main(int argc, char *argv[]) {
- int r;
- log_set_max_level(LOG_DEBUG);
-
- r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, &MAKE_IN_ADDR_UNION(1, 2, 3, 4));
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- r = fw_add_local_dnat(false, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, NULL);
- if (r < 0)
- log_error_errno(r, "Failed to modify firewall: %m");
-
- return 0;
-}
diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c
deleted file mode 100644
index 149843297..000000000
--- a/src/test/test-netlink-manual.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
- This file is part of systemd.
-
- Copyright 2014 Susant Sahani
-
- systemd 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.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <linux/ip.h>
-#include <linux/if_tunnel.h>
-#include <libkmod.h>
-
-#include "util.h"
-#include "macro.h"
-#include "sd-netlink.h"
-
-static int load_module(const char *mod_name) {
- struct kmod_ctx *ctx;
- struct kmod_list *list = NULL, *l;
- int r;
-
- ctx = kmod_new(NULL, NULL);
- if (!ctx) {
- kmod_unref(ctx);
- return -ENOMEM;
- }
-
- r = kmod_module_new_from_lookup(ctx, mod_name, &list);
- if (r < 0)
- return -1;
-
- kmod_list_foreach(l, list) {
- struct kmod_module *mod = kmod_module_get_module(l);
-
- r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
- if (r >= 0)
- r = 0;
- else
- r = -1;
-
- kmod_module_unref(mod);
- }
-
- kmod_module_unref_list(list);
- kmod_unref(ctx);
-
- return r;
-}
-
-static int test_tunnel_configure(sd_netlink *rtnl) {
- int r;
- sd_netlink_message *m, *n;
- struct in_addr local, remote;
-
- /* skip test if module cannot be loaded */
- r = load_module("ipip");
- if(r < 0)
- return EXIT_TEST_SKIP;
-
- if(getuid() != 0)
- return EXIT_TEST_SKIP;
-
- /* IPIP tunnel */
- assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0);
- assert_se(m);
-
- assert_se(sd_netlink_message_append_string(m, IFLA_IFNAME, "ipip-tunnel") >= 0);
- assert_se(sd_netlink_message_append_u32(m, IFLA_MTU, 1234)>= 0);
-
- assert_se(sd_netlink_message_open_container(m, IFLA_LINKINFO) >= 0);
-
- assert_se(sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "ipip") >= 0);
-
- inet_pton(AF_INET, "192.168.21.1", &local.s_addr);
- assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_LOCAL, local.s_addr) >= 0);
-
- inet_pton(AF_INET, "192.168.21.2", &remote.s_addr);
- assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0);
-
- assert_se(sd_netlink_message_close_container(m) >= 0);
- assert_se(sd_netlink_message_close_container(m) >= 0);
-
- assert_se(sd_netlink_call(rtnl, m, -1, 0) == 1);
-
- assert_se((m = sd_netlink_message_unref(m)) == NULL);
-
- r = load_module("sit");
- if(r < 0)
- return EXIT_TEST_SKIP;
-
- /* sit */
- assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0);
- assert_se(n);
-
- assert_se(sd_netlink_message_append_string(n, IFLA_IFNAME, "sit-tunnel") >= 0);
- assert_se(sd_netlink_message_append_u32(n, IFLA_MTU, 1234)>= 0);
-
- assert_se(sd_netlink_message_open_container(n, IFLA_LINKINFO) >= 0);
-
- assert_se(sd_netlink_message_open_container_union(n, IFLA_INFO_DATA, "sit") >= 0);
-
- assert_se(sd_netlink_message_append_u8(n, IFLA_IPTUN_PROTO, IPPROTO_IPIP) >= 0);
-
- inet_pton(AF_INET, "192.168.21.3", &local.s_addr);
- assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_LOCAL, local.s_addr) >= 0);
-
- inet_pton(AF_INET, "192.168.21.4", &remote.s_addr);
- assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0);
-
- assert_se(sd_netlink_message_close_container(n) >= 0);
- assert_se(sd_netlink_message_close_container(n) >= 0);
-
- assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1);
-
- assert_se((m = sd_netlink_message_unref(n)) == NULL);
-
- return EXIT_SUCCESS;
-}
-
-int main(int argc, char *argv[]) {
- sd_netlink *rtnl;
- int r;
-
- assert_se(sd_netlink_open(&rtnl) >= 0);
- assert_se(rtnl);
-
- r = test_tunnel_configure(rtnl);
-
- assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
-
- return r;
-}