Compare commits

...

532 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 97a6085912 Version 247.1 2020-12-01 10:55:58 +01:00
Zbigniew Jędrzejewski-Szmek 9bf9a317b6 Move container networkd config to -networkd subpackage
-container subpackage is for container *management*. Those files are
used *in* the container.
2020-12-01 10:31:51 +01:00
Zbigniew Jędrzejewski-Szmek 8bb6dc993a Version 247 2020-11-26 19:53:39 +01:00
Zbigniew Jędrzejewski-Szmek afdd35ec48 Really ignore test failure 2020-11-12 15:07:11 +01:00
Zbigniew Jędrzejewski-Szmek d9fc59f9a9 Ignore one test failure 2020-11-12 14:31:27 +01:00
Zbigniew Jędrzejewski-Szmek bca98cfc50 Compile with oomd 2020-11-12 13:08:11 +01:00
Zbigniew Jędrzejewski-Szmek 39bdda8d19 Pull in perl for tests 2020-11-12 12:56:08 +01:00
Zbigniew Jędrzejewski-Szmek f28a96e50a Version 247-rc2 2020-11-12 12:56:08 +01:00
Zbigniew Jędrzejewski-Szmek 5bf2aac8b4 Stop creating resolv.conf symlink in more circumstances 2020-11-12 12:56:08 +01:00
Zbigniew Jędrzejewski-Szmek a734fa3ff3 Add workaround for selinux preventing use of selinux status page 2020-11-12 12:56:08 +01:00
Zbigniew Jędrzejewski-Szmek b6a8363c43 Use normal scriptlets for systemd-networkd 2020-11-12 12:56:08 +01:00
Zbigniew Jędrzejewski-Szmek 550422fe1b Version 247-rc1 2020-11-12 12:56:08 +01:00
Robert Scheck 5acb5c4c08 Harmonize networkd description/summary with other sub-packages 2020-10-20 17:15:42 +00:00
Zbigniew Jędrzejewski-Szmek 96b7895b99 Do not touch resolv.conf if it is a mountpoint
https://bugzilla.redhat.com/show_bug.cgi?id=1885101
2020-10-08 11:52:07 +02:00
Zbigniew Jędrzejewski-Szmek 14b2fafb36 resolve: remove the fallback dns server list
DNS questions (which necessarilly include IP addresses) are personally
indentifying information in the sense of GDPR
(https://gdpr.eu/eu-gdpr-personal-data/ explicitly lists IP address as
PII). Sending those packets to Google or Cloudflare is "forwarding"
this PII to them. GDPR says that information which is not enough to
identify individuals still needs to be protected because it may be
combined with other information or processed with improved technology
later. So even though the information in DNS alone it not very big, it
may be interpreted as protected information in various scenarios.

When Fedora is installed by an end-user, they must have the reasonable
expectation that Fedora will contant Fedora servers for updates and
status checks and such. But the case of DNS packets is different,
because the dns servers are not under our control. While most of the
time the information leak through DNS is negligible, we can't rule out
scenarios where it could be considered more important.

Another thing to consider is that ISP and other local internet access
mechanisms are probably worse overall for privacy compared to google and
cloudflare dns servers. Nevertheless, they are more obvious to users and
fit better in the regulatory framework, because there are local laws
that govern them and implicitic or explicit agreements for their use.
Whereas US-based servers are foreign and are covered by different rules.

The fallback DNS servers don't matter most of the time because
NetworkManager will include the servers from a DHCP lease. So
hopefully users will not see any effect from the change done in this
patch. Right now I think it is better to avoid the legal and privacy
risk. If it turns out this change causes noticable problems, we might
want to reconsider. In particular we could use the fallback servers
only in containers and such which are not "personal" machines and there
is no particular person attached to them.

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/3C4KESHIMZDB6XCFO4EOBEDV4Q2AVVQ5/

I think we could provide a default dns server list more reasonably if
there was some kind of privacy policy published by Fedora and users
could at least learn about those defaults. Sadly, we don't have any
relevant privacy policy (https://pagure.io/Fedora-Council/tickets/issue/53).
2020-10-06 14:09:53 +02:00
Dusty Mabe 283a994776 split-files: break out more files into networkd subpackage
There were some things left in the main package that should have
been in the sub package (including networkd.conf). This is an attempt
to make the list of files in the networkd package more correct.

It explicitly tries to leave sytemd-network-generator and the network
targets in the main package.
2020-10-01 09:14:06 +02:00
Zbigniew Jędrzejewski-Szmek 7d7120d566 Only create resolv.conf symlink if sd-resolved.service is enabled
This way, if one wants to opt-out of resolved, installing a preset
that disables the service is enough. Previously that would only disable
the service, but a dangling symlink would be created.
2020-09-30 23:12:12 +02:00
Zbigniew Jędrzejewski-Szmek 3905512117 Upgrades: only replace NM /etc/resolv.conf if NM is enabled 2020-09-29 18:30:47 +02:00
Zbigniew Jędrzejewski-Szmek ce6da66f61 Pull in libfido2-devel
fido2 support in homed was actually unavailable.
2020-09-27 14:03:41 +02:00
Zbigniew Jędrzejewski-Szmek 147b753f29 Fix permissions on libsystemd-shared.abignore 2020-09-27 14:03:41 +02:00
Zbigniew Jędrzejewski-Szmek f10da8ae84 Add option to disable lto
This makes the build noticably faster.
2020-09-27 14:03:41 +02:00
Zbigniew Jędrzejewski-Szmek b36512ad8f Make main package Conflicts+Obsoletes with -standalone- subpackages
I'm not entirely sure if this is the right form...
Is Conflicts? useful when we have Obsoletes?

Seem to work OK. I tested:
dnf --installroot=... install x86_64/systemd-standalone-sysusers-246.6-2.fc34.x86_64.rpm  x86_64/systemd-standalone-tmpfiles-246.6-2.fc34.x86_64.rpm
→ succeeds with a new installation
→ fails if the installroot already had systemd installed
dnf --installroot=... install x86_64/systemd{,-libs,-pam}-246.6-2.fc34.x86_64.rpm noarch/systemd-noarch-246.6-2.fc34.noarch.rpm
→ uninstalls the two standalone packages
2020-09-27 14:01:34 +02:00
Filipe Brandenburger b50e9d7f29 Create separate standalone packages for tmpfiles and sysusers
These packages include binaries that link to a static version of
libsystemd-shared, so they don't depend on the systemd-libs package at
runtime.

These packages are intended to expose systemd-tmpfiles and systemd-sysusers
to non-systemd systems, such as container images.

Note that static linking only pulls in the small subset of functions from
libsystemd-shared that are actually used by the binaries, so the total size of
a statically linked binary is much smaller than the sum of the shared binary
with the shared library. The resulting binaries on an x86_64 build have 272KB
(tmpfiles) and 180KB (sysusers).

This commit relies on the -Dstandalone-binaries=true build configuration that
was pushed upstream in PR 16061 and released in systemd v246.
2020-09-26 21:00:25 +02:00
Christian Glombek f455b2249a Split out networkd sub-package
And add it to main package as recommended dependency.
2020-09-26 20:43:40 +02:00
Zbigniew Jędrzejewski-Szmek 043ff2e2f0 Add patch for kernel bug 2020-09-20 13:11:35 +02:00
Zbigniew Jędrzejewski-Szmek f74b957328 Version 246.6 2020-09-20 13:10:31 +02:00
Zbigniew Jędrzejewski-Szmek de06d8e22c Rework patches for test-path 2020-09-14 10:03:26 +02:00
Zbigniew Jędrzejewski-Szmek 81cd8d4bcf Fix patch numbering 2020-09-14 09:26:12 +02:00
Zbigniew Jędrzejewski-Szmek 269358bd5e One more debugging patch 2020-09-14 09:19:02 +02:00
Zbigniew Jędrzejewski-Szmek 04b6e059f7 Force creation of /etc/resolv.conf symlink during installation
https://bugzilla.redhat.com/show_bug.cgi?id=1873856#c14
2020-09-13 11:03:33 +02:00
Zbigniew Jędrzejewski-Szmek 0345c83b50 Version 246.5 2020-09-13 11:02:40 +02:00
Zbigniew Jędrzejewski-Szmek 764adb18da Don't complain if /dev/urandom is unavailable 2020-09-02 12:35:56 +02:00
Zbigniew Jędrzejewski-Szmek 1ebf8dd816 Version 246.4 2020-09-02 12:12:42 +02:00
Zbigniew Jędrzejewski-Szmek 5a70c03b7f Let avahi handle mdns requests
We need to disable it by default in resolved so that it doesn't fight
with avahi for the port when both are started up in parallel.

I also moved nss-files before nss-resolve. This is unfortunate because
resolved cached files and with the move, the file will be re-read on each
query. Nevertheless, we want nss-files to have higher priority than nss-mdns
to honour local config. Fortunately, only some people put lots of entries
in /etc/hosts, so the inefficiency incurred by this isn't important for
most users.

nss-myhostname is moved after nss-files, following the change in
upstream recommendations.
2020-09-02 10:52:43 +02:00
Zbigniew Jędrzejewski-Szmek d01d537e93 Create /etc/resolv.conf symlink upon installation 2020-09-02 10:22:03 +02:00
Petr Lautrbach 16c37db4fd Improve tests structure
- rename test-reboot.yml to tests-reboot.yml so that it's run by CI directly
- drop unnecessary tests.yml
- add mandatory test.log, see
  https://docs.fedoraproject.org/en-US/ci/standard-test-interface/#_invocation
- improve results.yml format
- drop avc.err.log and log everything AVC related to avc.log
2020-08-27 08:13:25 +02:00
Zbigniew Jędrzejewski-Szmek 98b9113655 Version 246.3 2020-08-26 14:50:44 +02:00
Zbigniew Jędrzejewski-Szmek d5c1247285 Version 246.2 2020-08-17 19:15:12 +02:00
Zbigniew Jędrzejewski-Szmek 27ec459b7b Add patch to ingnore test failure on s390x 2020-08-08 09:27:46 +02:00
Zbigniew Jędrzejewski-Szmek eee99e6ccc Add patch to debug test failure on s390x 2020-08-07 18:56:37 +02:00
Zbigniew Jędrzejewski-Szmek 84fad5038a Let's not try to define to triggers
error: line 639: Trigger fired by the same package is already defined in spec file: %post libs
It's not clear what rpm is complaining about here, but the two %triggerun's
for the same package seem to be the most likely offender.

I wanted to avoid applying to preset reset twice, alas.
2020-08-07 17:40:27 +02:00
Zbigniew Jędrzejewski-Szmek c8f86d89ba Version 246.1 2020-08-07 17:33:19 +02:00
Zbigniew Jędrzejewski-Szmek 0eabb3de75 Two more patches for a test that randomly fails in koji 2020-07-31 11:01:07 +02:00
Zbigniew Jędrzejewski-Szmek 7445a298df Actually update version :) 2020-07-30 21:21:06 +02:00
Zbigniew Jędrzejewski-Szmek 30273d3292 Release v246 2020-07-30 21:19:54 +02:00
Zbigniew Jędrzejewski-Szmek 65221f861e Increase timeout in another test 2020-07-27 16:11:20 +02:00
Zbigniew Jędrzejewski-Szmek 35e6dd7b1a Increase timeout in test 2020-07-27 15:18:39 +02:00
Zbigniew Jędrzejewski-Szmek 437a7b8c4f Add patch for failing test 2020-07-27 13:54:40 +02:00
Zbigniew Jędrzejewski-Szmek abd738eddc Pull in coreutils during build
/bin/true is used by test-path ;)
2020-07-27 12:10:55 +02:00
Zbigniew Jędrzejewski-Szmek a5acceb904 Force preset of systemd-resolved on package upgrade
Just changing /etc/nsswitch.conf is pointless without this.
2020-07-26 16:27:03 +02:00
Zbigniew Jędrzejewski-Szmek 11b1c53b97 Make /tmp large again 2020-07-26 15:50:33 +02:00
Zbigniew Jędrzejewski-Szmek 5bf170b999 Update to v246-rc2 2020-07-24 09:28:35 +02:00
Zbigniew Jędrzejewski-Szmek 5eb772cfb3 Add scriptlet to enable nss-resolve
The default line is
> hosts: files dns myhostname
Some people might insert mymachines, most likely as:
> hosts: mymachines files dns myhostname
The scriptlet for nss-mdns inserts mdns before dns:
> hosts: ... files mdns4_minimal [NOTFOUND=return] dns ...

The scriptlet replaces 'files dns myhostname' with
> resolve [!UNAVAIL=return] myhostname files dns
This follows the upstream recommendation. myhostname is ordered earlier
because
a) it's more trustworthy than files or especially dns
b) resolve synthetizes the same answers as myhostname, so it doesn't
   make much sense to have myhostname at any other place than directly
   after resolve, so that if resolve is not available, we get answers for
   the names that myhostname is able to synthesize with the same priority.

See https://fedoraproject.org/wiki/Changes/systemd-resolved.
2020-07-14 21:16:00 +02:00
Zbigniew Jędrzejewski-Szmek 0a6ab0825d Update defaults to dnssec=no, mdns,llmnr=resolve 2020-07-14 21:16:00 +02:00
Zbigniew Jędrzejewski-Szmek 778a3758dd Drop patch to avoid creation of /etc/resolv.conf symlink 2020-07-12 22:55:01 +02:00
Zbigniew Jędrzejewski-Szmek 6fd99c397b Drop scriptlet for nss-myhostname
The glibc default has nss-myhostname since mid-2018, bug #1581809.
2020-07-12 22:55:00 +02:00
Zbigniew Jędrzejewski-Szmek 65984c876a Make sure zstd is enabled during configuration
Let's not rely on autodetection.
2020-07-12 22:55:00 +02:00
Zbigniew Jędrzejewski-Szmek 9488c31cc1 changelog: add bug numbers 2020-07-09 10:48:24 +02:00
Zbigniew Jędrzejewski-Szmek 4f458499a5 Print error logs if tests fail 2020-07-09 09:54:04 +02:00
Zbigniew Jędrzejewski-Szmek c432921859 Enable zstd compression 2020-07-09 08:56:03 +02:00
Zbigniew Jędrzejewski-Szmek ca9af1e8a8 We don't really need git nowadays
Buildroot is broken, let's try without git.
2020-07-09 08:56:03 +02:00
Zbigniew Jędrzejewski-Szmek 0688d7a091 Also include systemd-homed.service in the uninstall scriptlets 2020-07-09 08:56:03 +02:00
Zbigniew Jędrzejewski-Szmek 55abe5f0ba Update to 246-rc1 2020-07-09 08:56:03 +02:00
Petr Lautrbach 9d2435f184 Add a basic sanity reboot test collecting AVCs
From time to time there's systemd update with new features which could break an
SELinux enabled system. In order to minimize possible damage on composes we need
to be sure that a system can boot with new systemd and it doesn't generate any
AVC denial.

This test reboots a machine and collects AVC, USER_AVC and SELINUX_ERR audit
messages into avc.log file which is propagated as test artifact.
2020-06-30 11:11:57 +02:00
Bastien Nocera 6eb8bcde28 + systemd-245.6-3
Set fallback-hostname to fedora so that unset hostnames are still
  recognisable (#1392925)
2020-06-24 15:50:16 +02:00
Zbigniew Jędrzejewski-Szmek ec562b2272 Add self-obsoletes to fix upgrades from F31
Debugged and fixed by adamw!

$ rpmdiff systemd-udev-245.6-[12]*
removed     OBSOLETES systemd < 229-5
added       OBSOLETES systemd < 245.6-1
...
2020-06-02 09:29:56 +02:00
Zbigniew Jędrzejewski-Szmek 6dead14ceb Add two bug numbers 2020-05-31 12:45:44 +02:00
Zbigniew Jędrzejewski-Szmek fb22f2a640 Update to v245.6 2020-05-31 11:45:46 +02:00
Christian Glombek 493f6fa66b sysusers.generate-pre.sh: Fix parsing files that don't end with newline 2020-05-11 12:52:13 +02:00
Björn Esser 265d91aff5 Disable bootstrap build 2020-04-21 19:51:17 +02:00
Björn Esser 282e088f13 Bootstrapping for json-c SONAME bump 2020-04-21 19:47:09 +02:00
Björn Esser f983169655 Bump release and update %changelog 2020-04-21 19:46:02 +02:00
Björn Esser b5c68a76ce Add explicit BuildRequires: acl
The acl package is not present in the buildroots when building
in bootstrap mode, but test-acl-util needs /usr/bin/getfacl.

Thus it should be an explicit build-time dependency.
2020-04-19 17:05:54 +02:00
Zbigniew Jędrzejewski-Szmek b80d007386 Update to v245.5 2020-04-17 15:22:25 +02:00
Björn Esser 63698f5ea0 Add bootstrap option to break circular deps on cryptsetup 2020-04-16 13:17:47 +02:00
Zbigniew Jędrzejewski-Szmek 80532792aa Move Provides:u2f-hidraw-policy to -udev subpackage
https://bugzilla.redhat.com/show_bug.cgi?id=1823002#c2
2020-04-11 11:06:07 +02:00
Zbigniew Jędrzejewski-Szmek 6238d479ae gitignore: add emacs backup files 2020-04-11 10:38:12 +02:00
Zbigniew Jędrzejewski-Szmek 8a34ce7dca Add abignore file to make abigail happy 2020-04-11 10:37:42 +02:00
Zbigniew Jędrzejewski-Szmek be4317e8bf Fix some rpmlint issues and add filter for others 2020-04-01 23:39:32 +02:00
Zbigniew Jędrzejewski-Szmek 91fd7acc9e Update to v245.4 2020-04-01 22:06:48 +02:00
Zbigniew Jędrzejewski-Szmek 24d7f17342 Remove %{shortcommit} reference in %description
Nowadays most builds happen from stable releases, so %shortcommit is not defined,
which rpmlint justly warns about.
2020-04-01 22:06:48 +02:00
Zbigniew Jędrzejewski-Szmek 48edd5b3a5 Move man pages for pam_systemd and pam_systemd_home to -pam subpackage
Fixes rpmlint: systemd-pam.x86_64: W: no-documentation
2020-04-01 22:06:48 +02:00
Zbigniew Jędrzejewski-Szmek bb79fb7387 Update to v245.3 2020-03-26 14:52:00 +01:00
Zbigniew Jędrzejewski-Szmek 7ceda13192 Update to v245.2 2020-03-18 20:41:58 +01:00
Zbigniew Jędrzejewski-Szmek 86b1777f9b Remove tab use 2020-03-08 12:12:39 +01:00
Zbigniew Jędrzejewski-Szmek 8f2e234d97 Update to v245 2020-03-06 14:25:45 +01:00
Zbigniew Jędrzejewski-Szmek a4507efa4e systemd-udev: downgrade Recommends→Suggests for systemd-bootchart
It gets installed on Fedora workstation, and I don't think we want
it there.
2020-03-06 13:47:09 +01:00
Zbigniew Jędrzejewski-Szmek 788f973eab Bump test timeout once more
The tests fail on s390x with timeouts.
2020-03-03 13:52:44 +01:00
Zbigniew Jędrzejewski-Szmek 111b3c5a31 Don't require /proc to be mounted for systemd-sysusers to work 2020-03-03 13:51:43 +01:00
Zbigniew Jędrzejewski-Szmek ab2423caa9 Update to 245-rc2 2020-03-03 09:11:51 +01:00
Zbigniew Jędrzejewski-Szmek a4e7f2840f Fix typo in udev rule 2020-03-02 21:28:38 +01:00
Zbigniew Jędrzejewski-Szmek 61de05c228 Add forgotten bug number 2020-03-02 21:26:47 +01:00
Zbigniew Jędrzejewski-Szmek db1cfc0955 Move a bunch more stuff to systemd-udev.rpm 2020-03-02 21:26:47 +01:00
Zbigniew Jędrzejewski-Szmek aed5718c3a Move boot-related files to -udev subpackage 2020-03-02 21:26:47 +01:00
Zbigniew Jędrzejewski-Szmek 933c039e04 Add --without tests option for quicker builds 2020-03-02 21:26:47 +01:00
Zbigniew Jędrzejewski-Szmek 01e2d8a982 "Upgrade" dependency on kbd package from Recommends to Requires 2020-03-02 21:26:47 +01:00
Filipe Brandenburger 529ae77811 Fix spurious `if` line in fallback for upgrade from v239 2020-02-28 09:54:59 -08:00
Filipe Brandenburger 5c5a95ecb4 Update kill -TERM fallback to check that systemd is PID 1
Also only execute the fallback when we're upgrading the RPM package.

Add a comment to indicate the actual bug in systemd v239 we're trying to
fix with this fallback.

Tested: Upgraded from v239 on a machine and confirmed that running
`sudo systemctl status` was working as expected after the upgrade, rather
than failing with "Access denied."
2020-02-28 12:16:24 +01:00
Zbigniew Jędrzejewski-Szmek 437cd52f28 Modify the downstream udev rule to use bfq to only apply to disks 2020-02-26 22:33:08 +01:00
Zbigniew Jędrzejewski-Szmek a8129e0964 Fix scriptlet to not kill non-systemd pid1 (#1803240) 2020-02-26 16:12:36 +01:00
Adam Williamson 3620ae5f58 Fix plymouth etc. running when they shouldn't (#1803293) 2020-02-18 09:02:08 -08:00
Zbigniew Jędrzejewski-Szmek 3666983037 Run tests with a timeout multiplier
Tests fail to pass on s390x, and this seems to be just a timeout.
2020-02-11 14:16:34 +01:00
Zbigniew Jędrzejewski-Szmek 6aa6d755fb Revert patch to udev rules causing regression with usb hubs 2020-02-10 17:23:40 +01:00
Zbigniew Jędrzejewski-Szmek ced9237a14 Add the sysusers compat parts 2020-02-10 17:19:18 +01:00
Zbigniew Jędrzejewski-Szmek 9434e617a6 Add default 'disable *' preset for user units 2020-02-07 13:41:19 +01:00
Zbigniew Jędrzejewski-Szmek d1a1f09895 #1798414 already fixed in v243 2020-02-05 18:24:23 +01:00
Zbigniew Jędrzejewski-Szmek 513853f320 Update to v245-rc1 2020-02-05 13:21:04 +01:00
Fedora Release Engineering d9b9454de8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-31 00:58:58 +00:00
Anita Zhang 58b22cf334 Resort to `kill -TERM 1` to re-exec the daemon
This might be more reliable when upgrading from an older systemd package. The
systemctl call to reexec will occasionally fail with "Access denied" when we
upgrade from a much older version (like 2-3 versions older). However, sending
PID 1 a SIGTERM is documented to be mostly the same and fixes it 100% of the
times.

Signed-off-by: Anita Zhang <the.anitazha@gmail.com>
Signed-off-by: Filipe Brandenburger <filbranden@gmail.com>
2020-01-29 15:24:36 -08:00
Zbigniew Jędrzejewski-Szmek 2ccb3a9dee Disable service watchdogs (for systemd units) 2019-12-21 19:01:15 +01:00
Zbigniew Jędrzejewski-Szmek 4cd9bf575b Adjust patches
0002-Revert-units-set-NoNewPrivileges-for-all-long-runnin.patch was added exactly
a year ago because selinux policy needed to be updated. I think we can drop the
patch now.

Also drop part of 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch:
the service runs as unprivileged user, so the creation cannot succeed. The other
part of the patch is kept.
2019-12-15 13:25:15 +01:00
Zbigniew Jędrzejewski-Szmek 51ab4bc42e Update to v244.1 2019-12-15 13:22:28 +01:00
Zbigniew Jędrzejewski-Szmek ed1ff6f641 Update to v244 2019-11-29 18:01:38 +01:00
Zbigniew Jędrzejewski-Szmek 8964873178 Obsolete u2f-hidraw-policy
systemd package numbering is completely different than
u2f-hidraw-policy, so I'm using a fixed number. "-40" is supposed to
be sufficiently high so that we stay higher and preserve the upgrade
path even if the package is updated in older releases.
2019-11-22 15:15:01 +01:00
Zbigniew Jędrzejewski-Szmek a746962e75 Update to v244-rc1 2019-11-22 15:15:01 +01:00
Zbigniew Jędrzejewski-Szmek da9dae21d7 Update to v243.4 2019-11-19 13:27:41 +01:00
Zbigniew Jędrzejewski-Szmek 5abc564f03 Remove recommendation to use %{?systemd_requires}
https://pagure.io/packaging-committee/issue/921
2019-10-20 11:57:02 +02:00
Adam Williamson ec1d7bb8af Backport PR #13792 to fix nomodeset+BIOS CanGraphical bug (#1728240) 2019-10-18 19:09:45 -07:00
Zbigniew Jędrzejewski-Szmek 82d2fa2f16 Fix typo in %changelog
https://bugzilla.redhat.com/show_bug.cgi?id=1745600
2019-10-17 23:34:23 +02:00
Zbigniew Jędrzejewski-Szmek a556e1f3e2 Various minor documentation and error message cleanups 2019-10-10 15:38:52 +02:00
Zbigniew Jędrzejewski-Szmek a760231337 Obsolete timedatex package 2019-09-22 00:13:41 +02:00
Zbigniew Jędrzejewski-Szmek 7aa63f3164 First batch of post-v243 fixes 2019-09-22 00:13:41 +02:00
Zbigniew Jędrzejewski-Szmek 1f0a2f0802 Remove reference to removed patch 2019-09-03 12:06:49 +02:00
Zbigniew Jędrzejewski-Szmek 090a9d035f Update to v243 2019-09-03 12:02:32 +02:00
Adam Williamson 07b358f168 Backport PR #13406 to solve PATH ordering issue (#1744059) 2019-08-26 11:44:02 -07:00
Zbigniew Jędrzejewski-Szmek 37d9de1fcf Fix typo in %changelog
https://bugzilla.redhat.com/show_bug.cgi?id=1745600
2019-08-26 15:32:00 +02:00
Zbigniew Jędrzejewski-Szmek d7b2d46533 Update to v243-rc2 2019-08-22 14:01:31 +02:00
Adam Williamson 07f0cd95cf Backport PR #1737362 so we own /etc/systemd/system again (#1737362) 2019-08-07 08:03:26 -07:00
Zbigniew Jędrzejewski-Szmek f1413ea879 Update to v243-rc1 2019-07-30 22:06:53 +02:00
Fedora Release Engineering bf71ff0b85 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-27 00:54:19 +00:00
Zbigniew Jędrzejewski-Szmek 8848319ef8 Another patch backport 2019-07-20 19:41:24 +02:00
Björn Esser 1c4be10032
Rebuilt (libqrencode.so.4) 2019-06-26 00:49:11 +02:00
Miro Hrončok d15ab16efa Rebuilt for iptables update (libip4tc.so.2) 2019-06-25 13:05:58 +02:00
Zbigniew Jędrzejewski-Szmek b9896dc2ce Also copy the %description for -stable to rawhide 2019-04-26 13:14:59 +02:00
Zbigniew Jędrzejewski-Szmek 6dff989abd First batch of post-v242 fixes 2019-04-26 11:21:52 +02:00
Adam Williamson a419fcc3bd Rebuild with Meson fix for #1699099 2019-04-16 12:55:58 -07:00
Zbigniew Jędrzejewski-Szmek 4480cada02 Update to v242 2019-04-11 18:54:17 +02:00
Zbigniew Jędrzejewski-Szmek 89aa08197f Make scriptlets non-failing and skip udevadm reload if no udev
sysctl, binfmt, and other rules are collected from multiple packages
and we don't want to see a report that systemd %triggerin failed.
So let's not silence the output, but use "|| :" to the trigger is
not reported as failed.

Also, adjust the udevadm check. In containers udevd might not be
running, even if systemd is, and we'd get:
Failed to send reload request: No such file or directory

https://bugzilla.redhat.com/show_bug.cgi?id=1698391
2019-04-11 16:04:25 +02:00
Zbigniew Jędrzejewski-Szmek 4c67e1cb51 Upload sources 2019-04-09 13:40:12 +02:00
Zbigniew Jędrzejewski-Szmek c7ac97585c Update to v242-rc4 2019-04-09 12:33:28 +02:00
Zbigniew Jędrzejewski-Szmek 77ab9b5088 Update to v242-rc3 2019-04-04 18:22:04 +02:00
Zbigniew Jędrzejewski-Szmek 5fb495cb03 Add patches to fix build on arm64 2019-04-03 16:45:51 +02:00
Zbigniew Jędrzejewski-Szmek 2379dd06da Update to v242-rc2 2019-04-03 11:05:37 +02:00
Zbigniew Jędrzejewski-Szmek 836fcf414a Drop some old units from scriptlet
default.target is now symlinked in /usr/lib, no need to touch /etc.
readahead units are long gone.
2019-04-03 11:05:37 +02:00
Zbigniew Jędrzejewski-Szmek 1d22340882 Update sources 2019-03-29 16:11:55 +01:00
Zbigniew Jędrzejewski-Szmek b61052552e 241-4: backport patches 2019-03-29 16:06:48 +01:00
Zbigniew Jędrzejewski-Szmek cf6cab52f2 Disable NDEBUG in builds
In principle systemd supports building without assertions for production,
but we want the assertions to be enabled to catch as many errors early as possible.

Also, let's remove the obsolete work-around for meson not showing logs. This
is already reverted upstream, but apparently not in the version of macros that
Fedora has.
2019-03-29 14:51:04 +01:00
Zbigniew Jędrzejewski-Szmek 484de996fc Revert "Skip dhcp[6]-client tests"
This reverts commit 94a4908748.
2019-03-29 14:50:59 +01:00
Zbigniew Jędrzejewski-Szmek 21fe449c94 Call cat /etc/machine-id just once in %post scriptlet 2019-03-29 14:50:53 +01:00
Zbigniew Jędrzejewski-Szmek 94a4908748 Skip dhcp[6]-client tests 2019-03-15 00:11:29 +01:00
Zbigniew Jędrzejewski-Szmek 32a6a004db Declare hyperv and framebuffer devices master-of-seat again 2019-03-14 23:08:46 +01:00
Zbigniew Jędrzejewski-Szmek cda068c40d Patches for CVE-2019-6454 2019-02-20 17:32:50 +01:00
Zbigniew Jędrzejewski-Szmek 922e5d4fa4 Revert "Skip failing part of test-json"
This reverts commit 79a1c5f8e8.

The issue was fixed upstream.
2019-02-14 11:37:19 +01:00
Zbigniew Jędrzejewski-Szmek 6af7b47648 Update to v241 2019-02-14 11:36:57 +01:00
Zbigniew Jędrzejewski-Szmek 660962e17a Turn LTO back on
This makes the package smaller:
-rw-rw-r--. 3840040 Feb  9 14:53 x86_64/systemd-241~rc2-1.fc30.x86_64.rpm
-rw-rw-r--. 3794532 Feb  9 15:58 x86_64/systemd-241~rc2-2.fc30.x86_64.rpm

Important binaries like systemd and libsystemd-shared.so are about
10% smaller.
2019-02-09 17:04:59 +01:00
Zbigniew Jędrzejewski-Szmek 79a1c5f8e8 Skip failing part of test-json 2019-02-06 10:27:03 +01:00
Zbigniew Jędrzejewski-Szmek 5df67cdae8 Drop patch that was merged upstream 2019-02-05 23:56:09 +01:00
Zbigniew Jędrzejewski-Szmek 442c8d41a9 Update to v241-rc2 2019-02-05 23:49:50 +01:00
Zbigniew Jędrzejewski-Szmek edaa157918 Override the version tag using the new functionality 2019-02-05 23:43:35 +01:00
Fedora Release Engineering 8d4a0946d1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-03 09:19:03 +00:00
Yu Watanabe ee8fc244d8 backport a patch for kernel-install 2019-01-27 17:59:32 +01:00
Zbigniew Jędrzejewski-Szmek 0eab21cb2b Update to v241-rc1 2019-01-26 17:51:43 +01:00
Zbigniew Jędrzejewski-Szmek a787811921 Add a work-around for #1663040 2019-01-15 11:20:43 +01:00
Björn Esser 3eb9903ba0
Rebuilt for libcrypt.so.2 (#1666033) 2019-01-14 18:53:39 +01:00
Zbigniew Jędrzejewski-Szmek 4557ee0872 Add a work-around for selinux issue on live images 2019-01-11 14:27:13 +01:00
Zbigniew Jędrzejewski-Szmek 0214da5fc8 Patches for the journal CVEs and various other fixes 2019-01-11 13:37:03 +01:00
Zbigniew Jędrzejewski-Szmek ea91d39bdd Bump release 2018-12-22 17:40:14 +01:00
Zbigniew Jędrzejewski-Szmek 7d37aab780 Actually commit the patches 2018-12-22 17:38:56 +01:00
Zbigniew Jędrzejewski-Szmek 9a32090cc2 Two more patches for udevd problems during boot
With debugging enabled, lvm devices wouldn't come up.
2018-12-22 17:38:05 +01:00
Yu Watanabe d644e8032c timesync: DynamicUser= is disabled now for timesyncd 2018-12-22 16:20:22 +01:00
Zbigniew Jędrzejewski-Szmek b80d668d9e Fix previous patch and revert the change that requires selinux policy update 2018-12-22 11:12:35 +01:00
Zbigniew Jędrzejewski-Szmek 4100d92c45 Add patch to fix build on arm32 2018-12-21 23:08:20 +01:00
Zbigniew Jędrzejewski-Szmek 47d443ea5d Update to v240 2018-12-21 20:08:58 +01:00
Zbigniew Jędrzejewski-Szmek 3a45ccbeb1 More patches including revert of resume= check 2018-12-18 00:43:46 +01:00
Zbigniew Jędrzejewski-Szmek 85e1a222f7 Add call to 'authselect check'
See https://src.fedoraproject.org/rpms/systemd/pull-request/12#comment-18052.
2018-12-06 14:49:27 +01:00
Zbigniew Jędrzejewski-Szmek 4ba08126b1 Adjust scriptlets to modify /etc/authselect/user-nsswitch.conf
With input from Pavel Březina.

The guard in install scriptlet was borked. The grep call was supposed
to skip the sed call if the file already had correct contents. But the
condition was always true. Added by me in back in 37de5dfe28 ;(
2018-12-05 13:57:25 +01:00
Zbigniew Jędrzejewski-Szmek 8bc4ef61e5 Drop scriptlet that removes /.readahead
Readahead was removed a long time ago.
2018-12-05 13:57:25 +01:00
Zbigniew Jędrzejewski-Szmek 9977ebc5d7 Drop scriptlet for pre-F19 entires in /etc/fstab 2018-12-05 13:57:25 +01:00
Zbigniew Jędrzejewski-Szmek cda71799e7 Drop scriptlet to tweak nss-resolve config
This was added in da15385b06, November 2016, after
nss-resolve was modified to return a special value. When nss-resolve is added to
new installations, it should be configured in this way already, and we shouldn't
modify configuration. Let's drop this too.
2018-11-29 14:36:25 +01:00
Zbigniew Jędrzejewski-Szmek b3c65ffbe3 Drop scriptlet to disable nss-mymachines
The scriptlet to *add* it was removed in 38d93ea79f,
November 2015. We only care about upgrades from previous two releases, so it is
long overdue to remove this.
2018-11-29 14:33:11 +01:00
Zbigniew Jędrzejewski-Szmek 07e98bcf32 Update description a bit
Parts of the package became inaccurate when stuff was moved to -container
subpackage.
2018-11-27 16:08:28 +01:00
Alejandro Domínguez Muñoz 9a0025413c Fix changelog typo 2018-11-19 12:29:29 +00:00
Alejandro Domínguez Muñoz b2165dc717 Remove link creation for rsyslog.service
It is already handled by rsyslog.rpm, as indicated in this BugZilla report: https://bugzilla.redhat.com/show_bug.cgi?id=1343132
2018-11-18 16:29:47 +00:00
Adam Williamson 8510cadb34 Go back to using systemctl preset-all in %post (#1647172, #1118740)
We tried this back in 2016 and it didn't go so well, because at
that time, preset-all was badly broken. See
https://bugzilla.redhat.com/show_bug.cgi?id=1363858 for the
history there. It seems that the bugs in preset-all were fixed
quite soon after that, but for whatever reason, the change to
%post was not re-applied (probably it just got forgotten).

We've now run into a bug in Rawhide where dbus-daemon is getting
installed before systemd despite having a dependency that should
make that not happen:
https://bugzilla.redhat.com/show_bug.cgi?id=1647172
this is apparently because there are very complex dependency
loops during initial install that rpm cannot find a single
clearly correct 'answer' for, so it does not always choose to
honor this dependency. We can take a look at breaking up those
loops, but we also figured it can't hurt to resurrect this change
to help with such cases: this way if some service with a preset
*does* happen to get installed before systemd, and so its attempt
to apply the preset in its own %post fails, that will be fixed up
here.
2018-11-08 16:35:11 -08:00
Adam Williamson 71e781a096 Requires(post) openssl-libs to fix live build machine-id issue 2018-11-05 12:18:32 -08:00
Yu Watanabe d15bd12f49 Set attributes to private directories
The attributes of private directories are maintained by pid1.
But, when creating os image, tools like mkosi, may complain the
wrong attributes.
2018-11-05 14:26:56 +09:00
Yu Watanabe db19323db2 Drop check for triggers
As we do not use the upstream provided trigger file.
2018-11-05 14:19:05 +09:00
Zbigniew Jędrzejewski-Szmek e394248861 Make macros package noarch 2018-11-02 11:53:19 +01:00
Zbigniew Jędrzejewski-Szmek c9030f045b Split out the rpm macros into systemd-rpm-macros subpackage 2018-11-02 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 59823848fc Remove patches already included in the tarball 2018-11-02 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 6a3bb3f641 Use modern github URLs
Also shorten macro names while at it.
2018-11-02 11:46:47 +01:00
Zbigniew Jędrzejewski-Szmek 6714fc2555 Backport a bunch of fixes 2018-10-29 01:53:24 +01:00
Jan Synacek d8d2ff965e Fix line_begins() to accept word matching full string (#1631840)
Resolves: #1631840
2018-10-03 13:50:02 +02:00
Jan Synacek 1f6dfb7453 Fix meson using -Ddebug, which results in FTBFS 2018-10-03 13:48:52 +02:00
Colin Walters 48ac1cebde spec: Test for /var being writable before making /var/log/journal
rpm-ostree has `/var` be read-only during package installs, because
a whole part of the "transactional update" model is that your system's
data stays untouched, and `/var` is system data.

See e.g. https://src.fedoraproject.org/rpms/mock/pull-request/2
and the tracker https://bugzilla.redhat.com/show_bug.cgi?id=1352154

Just to squash some error spew during tree composes.
2018-09-11 09:23:16 +02:00
Zbigniew Jędrzejewski-Szmek 184871e826 Move /etc/yum/protected.d/systemd.conf to /etc/dnf/ 2018-09-10 11:58:35 +02:00
Zbigniew Jędrzejewski-Szmek 5306894742 Backport patch for statx conflict
https://bugzilla.redhat.com/show_bug.cgi?id=1602812
2018-07-18 17:55:08 +02:00
Zbigniew Jędrzejewski-Szmek e7883a3ff9 Ignore return value from systemd-binfmt in scriptlet 2018-07-18 13:36:02 +02:00
Zbigniew Jędrzejewski-Szmek 07b77042bc Use %autosetup to apply patches
Automatic application of patches should work just as well nowadays.
2018-07-18 13:35:09 +02:00
Filipe Brandenburger 05bb389ca4 Override systemd-user PAM config in %install and not %prep
This makes it possible to build RPMs from a git tree using
`rpmbuild --build-in-place --noprep` and have resulting RPMs
that will preserve the override of the PAM config file.

This needs to commit to HAVE_SELINUX being defined (since there
is no longer an m4 step to make that stanza conditional), but
that should be acceptable since the %build step calls Meson
with -Dselinux=true.

Tested:

- Chdir into a checkout of github.com/systemd/systemd tree and run:

  $ rpmbuild -bb --build-in-place --noprep \
        --define "gitcommit $(git rev-parse HEAD)" \
        --define "_sourcedir $HOME/fedorarpms/systemd" \
        ~/fedorarpms/systemd/systemd.spec

- Inspect the contents of systemd-user in the generated RPM package:

  $ rpm2cpio ~/rpmbuild/RPMS/x86_64/systemd-239-3.git99352de.fc29.x86_64.rpm \
        | cpio -i --to-stdout --quiet ./etc/pam.d/systemd-user
  ...
  account  include system-auth
  ...
  session  include system-auth
2018-07-15 01:08:07 -07:00
Fedora Release Engineering ad150b1fc6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-14 07:12:29 +00:00
Zbigniew Jędrzejewski-Szmek a2b05050f9 Rebuild for Python 3.7 again 2018-06-25 23:19:55 +02:00
Zbigniew Jędrzejewski-Szmek eb80e67908 Update to v239 2018-06-22 13:22:47 +02:00
Miro Hrončok c8d1507e04 Rebuilt for Python 3.7 2018-06-19 11:28:13 +02:00
Zbigniew Jędrzejewski-Szmek b59ff1a2fc Backport a bunch of patches
Existing patches moved to the systemd-stable tarball, with the exception
of 0991-core-fix-resetting-of-Delegate-and-properly-ignore-i.patch,
which was partially reverted upstream and is just removed.
2018-05-11 12:30:10 +02:00
Zbigniew Jędrzejewski-Szmek 6a5d5d666c Add patch from broken gpg headers 2018-04-18 23:51:01 +02:00
Zbigniew Jędrzejewski-Szmek bb3fb8bc57 Allow fake Delegate= setting on slices 2018-04-18 20:25:58 +02:00
Zbigniew Jędrzejewski-Szmek b05aec5ee0 Add patch to fix build on rawhide 2018-03-28 09:39:33 +02:00
Zbigniew Jędrzejewski-Szmek e8a9546241 Fix quoting 2018-03-28 08:57:12 +02:00
Zbigniew Jędrzejewski-Szmek 3c9433d7cf Move udev transfiletriggers to the right package
A redo of b5fa4adf after the rewrite to shell.
2018-03-28 08:53:37 +02:00
Zbigniew Jędrzejewski-Szmek a818a9f2ca Merge remote-tracking branch 'origin/f28' 2018-03-28 08:50:55 +02:00
Colin Walters dc46312de2 Use shell for triggers; see https://github.com/systemd/systemd/pull/8550
This fixes compatibility with rpm-ostree.
2018-03-27 20:38:45 +00:00
Colin Walters 8e6b39457b Use shell for triggers; see https://github.com/systemd/systemd/pull/8550
This fixes compatibility with rpm-ostree.
2018-03-27 20:37:29 +00:00
Zbigniew Jędrzejewski-Szmek f770414d95 Backport patch to revert inadvertent change of "predictable" interface name 2018-03-20 09:31:28 +01:00
Zbigniew Jędrzejewski-Szmek b5fa4adf3f Move udev transfiletriggers to the right package 2018-03-18 14:43:39 +01:00
Zbigniew Jędrzejewski-Szmek 176a1807d2 Add patch for Reload bug 2018-03-16 23:22:34 +01:00
Zbigniew Jędrzejewski-Szmek d4d36e6a87 Two patches
2018-03-06 23:21:31,835 INFO pylorax.dnfhelper: Performing post-installation setup tasks
2018-03-06 23:22:41,901 WARNING pylorax.dnfhelper: Non-fatal POSTTRANS scriptlet failure in rpm package kernel-core

warning: %posttrans(kernel-core-4.16.0-0.rc4.git0.1.fc29.x86_6 scriptlet failed, exit status 1
Please specify the kernel command line in /etc/kernel/cmdline!
Could not determine the kernel command line parameters
/usr/lib/kernel/install.d/90-loaderentry.install: line 53: /proc/cmdline: No such file or directory
2018-03-08 01:04:39 +01:00
Yu Watanabe d10793d82b Fix wrong version in changelog 2018-03-06 08:07:30 +01:00
Yu Watanabe 792370f28d Fix transfiletrigger script 2018-03-06 08:07:12 +01:00
Zbigniew Jędrzejewski-Szmek 77f7c6f491 Add patch which hopefully will fix build in koji 2018-03-06 00:05:31 +01:00
Zbigniew Jędrzejewski-Szmek 98ea23b9ac Update to v238 2018-03-05 23:29:40 +01:00
Javier Martinez Canillas fd0679e1ff
Add patch to install kernel images for GRUB BootLoaderSpec support
GRUB now has BootLoaderSpec support, the user can choose to use this by
setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup,
grubby isn't used to generate the kernel modules dependencies, instead
the depmod install script could be used.

But the BLS support in GRUB uses the config snippets that are generated
at build time and included in the kernel package, so the loaderentry
install script shouldn't be executed when using GRUB.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-02-28 10:39:11 +01:00
Zbigniew Jędrzejewski-Szmek 885c28c248 Create /etc/systemd in %post libs if necessary 2018-02-24 09:31:09 +01:00
Adam Williamson f5d69da27a zbyszek: use : not touch to create file in -libs %%post 2018-02-23 14:01:32 -08:00
Zbigniew Jędrzejewski-Szmek 273dc0fda0 Replace touch by :, add "|| :"
touch is from coreutils, and : is built into the shell.
2018-02-22 14:06:19 +01:00
Patrick Uiterwijk a88494686e Add typecasting patches for usb IDs
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
2018-02-22 12:46:30 +01:00
Patrick Uiterwijk 6f5e81a1a0 Add dep for coreutils to -libs %post
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
2018-02-22 11:32:18 +01:00
Zbigniew Jędrzejewski-Szmek 6eaf251a9e Bump release 2018-02-21 16:40:50 +01:00
Zbigniew Jędrzejewski-Szmek 388cd917f1 Add purge-nobody-user 2018-02-21 15:23:30 +01:00
Zbigniew Jędrzejewski-Szmek 3e18b458fc Actually change the nobody mapping
I added this to the changelog, but forgot to commit the change
itself. Also fix scriptlet definition.
2018-02-20 23:52:08 +01:00
Zbigniew Jędrzejewski-Szmek 8dc92a4da2 Backport more patches, update ldconfig macros, check for nobody 2018-02-20 23:32:22 +01:00
Zbigniew Jędrzejewski-Szmek c8ec349ecc Revert one patch from the first stable snapshot 2018-02-09 17:42:33 +01:00
Zbigniew Jędrzejewski-Szmek aadfe52dca A few more patches for the first stable snapshot 2018-02-09 17:17:55 +01:00
Zbigniew Jędrzejewski-Szmek 339b0245df Disable lto as a temporary workaround
https://bugzilla.redhat.com/show_bug.cgi?id=1543912
2018-02-09 16:58:00 +01:00
Zbigniew Jędrzejewski-Szmek 7ffa9232c4 First stable snapshot 2018-02-09 15:47:17 +01:00
Zbigniew Jędrzejewski-Szmek fb4de3a52a Slight simplification 2018-02-09 14:50:35 +01:00
Zbigniew Jędrzejewski-Szmek e3edeed65d Update to v237 2018-01-28 17:16:50 +01:00
Zbigniew Jędrzejewski-Szmek d13ecfd07d Fix mode on %ghost dirs in /etc
If the directory does not exist in %buildroot, rpm very usefully defaults
to access mask of 0. When the directory is created in the file system, of
course it has some other mode, and rpm -V reports the directory as changed.
2018-01-25 11:00:30 +01:00
Björn Esser 3595fb5110
Add patch to include <crypt.h> if needed 2018-01-21 15:35:40 +01:00
Björn Esser af29920ddf
Rebuilt for switch to libxcrypt 2018-01-20 23:14:09 +01:00
Zbigniew Jędrzejewski-Szmek 38d7cff9f6 Backport a bunch of patches 2018-01-11 11:14:11 +01:00
Zbigniew Jędrzejewski-Szmek 1eeb98d33d Update to v236 2017-12-15 09:36:03 +01:00
Zbigniew Jędrzejewski-Szmek f314ba8790 Add BR: gcc, gcc-c++
gcc is usually present in the buildroot, but let's require it since
the guidelines require that. gcc-c++ is used for some tests.
2017-12-15 09:22:20 +01:00
Yu Watanabe e0aa12142f update scriptlet for migrating to DynamicUser=
The directory /var/lib/systemd/journal-upload must not exist.
If both private and non-private directory exist, then
systemd cannot create link to private directory, and
the service fails to start.
This makes the script try to remove the non-private directory.
2017-12-13 12:37:04 +09:00
Zbigniew Jędrzejewski-Szmek 2125b9b134 Update %changelog 2017-12-12 09:41:54 +01:00
Yu Watanabe f59138540e add scriptlet to migrate private directory 2017-12-12 09:06:13 +01:00
Yu Watanabe e92fe49e42 remove white space at the end of line 2017-12-12 09:02:43 +01:00
Yu Watanabe 219c026dc0 remove unused files 2017-12-12 09:02:40 +01:00
Yu Watanabe dc44a1da74 use libidn2 2017-12-12 09:01:10 +01:00
Yu Watanabe db8b8fe77c create render group, remove groups for timesync, journal-gateway and journal-upload 2017-12-12 09:00:38 +01:00
Yu Watanabe a8ba7b15a2 bump required meson to 0.43 2017-12-12 08:52:11 +01:00
Yu Watanabe 9653e125fd update split-files.py and list of ghost files 2017-12-12 08:52:06 +01:00
Zbigniew Jędrzejewski-Szmek 17a6f382d1 Update to snapshot, use generated lists of files
Previous method was untenable, because rpm doesn't have a concept of
put those files here, and the rest in there. So for every positive
pattern that was added, we had to add an %exclude line somewhere else.
So let's generate the lists using pattern matching. This is a bit messy
too, but should not require updates when files are added or removed.
(Sometimes it'll be necessary to add a new pattern if the new files
should not land in the main binary package.)

There's some intentional changes:
- man pages are more consistently included with the files they describe
- shell completion scripts similarly
- various kernel-install and modules-load related files are moved
  to -udev subpackage
2017-12-12 01:04:08 +01:00
Zbigniew Jędrzejewski-Szmek f00d23638b Rebuild for cryptsetup-2.0.0-0.2.fc28 2017-11-07 17:07:34 +01:00
Zbigniew Jędrzejewski-Szmek 35bb94669a Backport a bunch of patches, including LP#172535 2017-10-25 16:25:53 +02:00
Zbigniew Jędrzejewski-Szmek ca246f98ec Patches for cryptsetup _netdev 2017-10-18 15:25:44 +02:00
Zbigniew Jędrzejewski-Szmek 8a752251c4 Fix patch 2017-10-06 18:03:54 +02:00
Zbigniew Jędrzejewski-Szmek a46c781ba7 Skip tests when cg_pid_get_path fails 2017-10-06 17:26:09 +02:00
Zbigniew Jędrzejewski-Szmek 3cb1145229 Update to v235 2017-10-06 16:50:13 +02:00
Nathaniel McCallum ac49c72d1e Backport /etc/crypttab _netdev feature from upstream 2017-09-26 10:48:54 -04:00
Michal Sekletar 1d5166b9df Make sure to remove all device units sharing the same sysfs path
Resolves: #1475570
2017-09-21 00:56:48 +02:00
Zbigniew Jędrzejewski-Szmek 8b20c798c7 Bump xslt recursion limit for libxslt-1.30 2017-09-18 17:12:43 +02:00
Zbigniew Jędrzejewski-Szmek 27bd1bd49f Backport some patches 2017-07-31 15:52:44 -04:00
Fedora Release Engineering 8d4133f998 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-27 19:52:30 +00:00
Zbigniew Jędrzejewski-Szmek d044ab56d6 Backport some patches 2017-07-17 19:34:13 -04:00
Zbigniew Jędrzejewski-Szmek f3e3e4d477 Fix typo in dev-kvm-mode option 2017-07-13 11:35:31 -04:00
Zbigniew Jędrzejewski-Szmek 84e7848871 Create kvm group
Thanks to Yu Watanabe.
2017-07-13 09:44:43 -04:00
Zbigniew Jędrzejewski-Szmek 22eb6688a2 Spec file cleanups
Thanks to Yu Watanabe.
2017-07-13 09:26:43 -04:00
Zbigniew Jędrzejewski-Szmek 5bf44923db Update to v234 2017-07-12 22:02:53 -04:00
Zbigniew Jędrzejewski-Szmek c2bfa7b218 Use libidn again for now 2017-07-12 01:58:23 -04:00
Zbigniew Jędrzejewski-Szmek 83f115d68f Build with meson again 2017-07-11 01:29:55 -04:00
Zbigniew Jędrzejewski-Szmek 4ebba8aac1 Recommend kbd for udev to configure vconsole properly 2017-07-11 01:29:55 -04:00
Zbigniew Jędrzejewski-Szmek 61120120a0 Tweak the patches a bit more 2017-06-27 17:31:48 -04:00
Zbigniew Jędrzejewski-Szmek acc114f21c Actually add the patches 2017-06-27 16:30:12 -04:00
Zbigniew Jędrzejewski-Szmek 054ce3eced Fix build and backport one more patch which restores efficiency 2017-06-27 14:23:48 -04:00
Zbigniew Jędrzejewski-Szmek 4bbfd1a314 Fix an out-of-bounds write in systemd-resolved 2017-06-27 13:43:24 -04:00
Zbigniew Jędrzejewski-Szmek d743bb5bcc Revert "Build with meson"
This reverts commits 3fb4a15096
and 0e8350ca14.

Either building with meson or other upstream changes was causing
issues with booting, and I didn't have time to debug this properly.
2017-06-27 13:42:28 -04:00
Zbigniew Jędrzejewski-Szmek 0e8350ca14 Upload new sources 2017-06-16 12:08:17 -04:00
Zbigniew Jędrzejewski-Szmek 3fb4a15096 Build with meson 2017-06-16 11:54:00 -04:00
Zbigniew Jędrzejewski-Szmek 1d06cbf3d4 Also update hwdb_parse.py
This is needed because an additional property was added and the
tests fail otherwise. I think adding of the property is OK, it's
fully backwards compatible.

Also use %if 0 syntax to make it easy to copy&paste the commands.
2017-06-15 11:25:17 -04:00
Zbigniew Jędrzejewski-Szmek f4a67616bd Backport a bunch of fixes 2017-06-15 10:26:56 -04:00
Zbigniew Jędrzejewski-Szmek ee53796748 Pull in xzcat and lz4cat, used in test-compress
lz4 and lz4-libs is split in F26+. Not sure about xz, but let's pull
it in for safety.
2017-06-07 13:16:38 -04:00
Pat Riehecky c0f6af7fcc Use ID from /etc/os-release as ntpvendor 2017-04-18 16:43:25 -04:00
Zbigniew Jędrzejewski-Szmek 3e3b80766f Drop soft-static uid for systemd-journal-gateway
It has been removed from the uidgid list in setup, we should assign
a dynamic uid.
2017-03-27 11:03:08 -04:00
Michal Sekletar e47c648430 Add lz4 to build dependencies
This commit fixes build failure due to failed "make check".

Our test-compress uses lz4cat. Binary is included in lz4 package that
used to contain both library and binaries. Since lz4-libs split-off we
need to explicitly pull-in lz4.

See: http://pkgs.fedoraproject.org/cgit/rpms/lz4.git/commit/?id=34760ea9354a972f946af0282e2c145c660a823c
2017-03-16 09:47:07 +01:00
Michal Sekletar f5f0737829 Backport bugfixes from upstream
Most notably this commit fixes #1419501 that caused mock traceback when
running with --new-chroot.

Resolves: #1419501
2017-03-16 09:16:18 +01:00
Zbigniew Jędrzejewski-Szmek 2809df176d Fix installation conflict with polkit
Error: Transaction check error:
  file /usr/share/polkit-1/rules.d from install of systemd-233-1.fc27.x86_64 conflicts with file from package polkit-0.113-7.fc26.x86_64
2017-03-02 13:37:46 -05:00
Zbigniew Jędrzejewski-Szmek bb41272694 Update to v233 2017-03-02 11:30:49 -05:00
Zbigniew Jędrzejewski-Szmek 4877912f6e Add %ghost %dir entries for .wants dirs of our targets
What is included:
- .wants directories
- for our own targets listed in systemd.special(7)

This is not supposed to cover all possible .wants and .requires and .d
dirs for all units, or even targets, or even just our targets, but only
the reasonably common ones that we provide.
2017-02-16 13:38:46 -05:00
Zbigniew Jędrzejewski-Szmek 645d1b9eb7 Update description
At least the part about snapshotting was obsolete. Let's use
the text from https://www.freedesktop.org/wiki/Software/systemd/
with some slight modifications.
2017-02-16 13:10:10 -05:00
Zbigniew Jędrzejewski-Szmek 7d23031443 Remove gnutls.pc workaround 2017-02-15 09:46:38 -05:00
Zbigniew Jędrzejewski-Szmek a88eae1c54 gnu-efi is not available on all arches 2017-02-14 18:59:10 -05:00
Zbigniew Jędrzejewski-Szmek 40fcd871d4 Patch for test-ipcrm
It is part of unsafe-tests. It got enabled and turned out to be failing
in the koji environment.
2017-02-14 18:44:48 -05:00
Zbigniew Jędrzejewski-Szmek 6353553a57 Just nuke the gnutls private deps
It still fails in koji, and I'd have to download each package from
koji by hand to find out what is the issue (or wait until tomorrow for
a compose). Let's just nuke the whole thing, all deps should be installed.
2017-02-14 17:31:23 -05:00
Zbigniew Jędrzejewski-Szmek cfadacd273 Add explicit --enable switches for all optional deps
Also turn on "unsafe" tests.
2017-02-14 17:17:52 -05:00
Zbigniew Jędrzejewski-Szmek d4f0a28c8c Add work-around for misdetection of gnutls and µhttpd 2017-02-14 17:05:48 -05:00
Zbigniew Jędrzejewski-Szmek 0f34996575 Ignore the hwdb parser test
Previous commits backported some newer properties, but hwdb/parse_hwdb.py
was not updated. Just ignore it for now.
2017-02-14 15:40:19 -05:00
Jan Synacek 78d35a9ba2 machinectl fails when virtual machine is running (#1419501)
Resolves: #1419501
2017-02-14 11:59:00 +01:00
Zbigniew Jędrzejewski-Szmek f020f8b986 Overwrite LC_CTYPE
Build failed with the following:

Traceback (most recent call last):
  File "./hwdb/parse_hwdb.py", line 195, in <module>
    groups = parse(fname)
  File "./hwdb/parse_hwdb.py", line 136, in parse
    parsed = grammar.parseFile(fname)
  File "/usr/lib/python3.6/site-packages/pyparsing.py", line 2142, in parseFile
    file_contents = f.read()
  File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 15765: ordinal not in range(128)

In mock, LC_CTYPE is unset, so python3 defaults to ascii, uselessly.

I think "ID_VENDOR_FROM_DATABASE=VENGIT Korlátolt Felelősségű Társaság"
is the issue here.
2017-02-13 13:18:08 -05:00
Fedora Release Engineering 6c1e2a67b2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild 2017-02-11 14:24:20 +00:00
Zbigniew Jędrzejewski-Szmek 5d6eedd538 Moar patches 2017-01-31 12:11:17 -05:00
Zbigniew Jędrzejewski-Szmek b6b3541a52 Also include gperf compat patch 2017-01-29 18:26:01 -05:00
Zbigniew Jędrzejewski-Szmek 405c2cd182 Update hwdb to current git
The header on the patch is fake. git am does not deal well with just
diff output, mumbling the following:

  Applying: seccomp: rework seccomp code, to improve compat with some archs
  Applying:
  fatal: empty ident name (for <>) not allowed

We should really move away from mucking around with text patches.
2017-01-29 17:42:53 -05:00
Zbigniew Jędrzejewski-Szmek 6396212453 Compile with --enable-tpm 2017-01-29 17:39:09 -05:00
Zbigniew Jędrzejewski-Szmek 03e93e27d9 A number of backported patches, incl. seccomp fix 2017-01-29 17:38:52 -05:00
Adam Williamson 4c60d7b5ae Backport fix for boot failure in initrd-switch-root (#1414904) 2017-01-19 15:37:04 -08:00
Zbigniew Jędrzejewski-Szmek 74dc679828 Add fake dependency on systemd-pam to systemd-devel 2017-01-18 10:11:37 -05:00
Zbigniew Jędrzejewski-Szmek 25bd358ef1 Make sure we have our compressions libs ready
In case some library is not detected properly in the future, fail
the /configure step. We should probably do that for most deps, but
I'm too lazy atm.
2017-01-16 23:15:39 -05:00
Jan Synacek eaf2f302c0 Fix buildsystem to check for lz4 correctly (#1404406) 2017-01-16 23:12:23 -05:00
Zbigniew Jędrzejewski-Szmek ca3c77beb2 Revert b69d36e571
This was already fixed in e134e692b6.
2017-01-11 20:19:41 -05:00
Zbigniew Jędrzejewski-Szmek b810fade77 Use shorter syntax for shell redirections 2017-01-11 17:51:30 -05:00
Zbigniew Jędrzejewski-Szmek e4286e550e Also require sed and grep for libs %post
https://bugzilla.redhat.com/show_bug.cgi?id=1392236#c12
2017-01-11 17:38:12 -05:00
Zbigniew Jędrzejewski-Szmek 9286eca9c8 Remove stderr redirection from preset/disable calls in scriplets
We don't expect those calls to fail (they should work fine both
with systemd running and without). But if they fail, most likely
some unit is missing or misspelt, which we want to catch.
2017-01-11 14:33:24 -05:00
Zbigniew Jędrzejewski-Szmek 734f625c22 Drop console-shell.service from preset invocation
Missing unit would case the whole systemctl preset call to fail,
breaking getty@.service instantiation.

Reported by adamw.
2017-01-11 14:30:44 -05:00
Zbigniew Jędrzejewski-Szmek 324bf560f7 Bump dbus dependency version just in case
https://github.com/systemd/systemd/commit/0298f55bb0.
2017-01-11 13:30:19 -05:00
Zbigniew Jędrzejewski-Szmek b69d36e571 Add patch to restore Fedora-specific systemd-user PAM config 2017-01-11 12:16:22 -05:00
Kevin Fenzi 04206f627a Fix scriptlets to never fail in libs post. 2017-01-07 11:43:47 -07:00
Kevin Fenzi 1eb707d840 Add patch from Michal Schmidt to avoid process substitution. (#1392236) 2017-01-06 10:57:27 -07:00
Zbigniew Jędrzejewski-Szmek 1ec648fc4c Rebuild
Building with 232-2 in the buildroot did not work, because rpm cannot
unpack 232-2 properly. 232-has been untagged, so maybe things will
work now.
2016-11-07 12:30:04 -05:00
Zbigniew Jędrzejewski-Szmek c91b73ea39 Make /etc/dbus-1/system.d directory non-%ghost
koschei builds are failing on systemd.rpm:

DEBUG util.py:421:  error: unpacking of archive failed on file
                 /etc/dbus-1/system.d/org.freedesktop.hostname1.conf;581cb002: cpio: open
DEBUG util.py:421:  error: systemd-232-2.fc26.x86_64: install failed
2016-11-04 13:04:17 -04:00
Zbigniew Jędrzejewski-Szmek 348151a546 Fix ownership of directories we create
Previously unowned:
systemd-229-16.fc24.x86_64
|-- /etc/dbus-1/system.d/org.freedesktop.hostname1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.locale1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.login1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.network1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.resolve1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.systemd1.conf
|-- /etc/dbus-1/system.d/org.freedesktop.timedate1.conf
|-- /usr/share/factory/etc/nsswitch.conf
|-- /usr/share/factory/etc/pam.d/other
'-- /usr/share/factory/etc/pam.d/system-auth
systemd-container-229-16.fc24.x86_64
|-- /etc/dbus-1/system.d/org.freedesktop.import1.conf
'-- /etc/dbus-1/system.d/org.freedesktop.machine1.conf
2016-11-04 09:58:31 -04:00
Zbigniew Jędrzejewski-Szmek e134e692b6 Fix systemd-user PAM config and two packaging issues 2016-11-04 09:46:25 -04:00
Zbigniew Jędrzejewski-Szmek d81bdc27d3 Fix kernel-install 2016-11-04 09:12:11 -04:00
Zbigniew Jędrzejewski-Szmek 523b6ce46a Run testsuite in parallel 2016-11-03 22:11:56 -04:00
Zbigniew Jędrzejewski-Szmek 62b1bf52df Move systemd-nspawn man pages to the right subpackage 2016-11-03 22:11:56 -04:00
Zbigniew Jędrzejewski-Szmek da15385b06 Update sed-foo to enable nss-systemd and add UNAVAIL fallback for resolve
Only fall back to "dns" if nss-resolve is not installed (for the
architecture of the calling program). Once it is, we never want to
fall back to "dns" as that breaks enforcing DNSSEC verification and
also pointlessly retries NXDOMAIN failures.

C.f. https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=5e00954
2016-11-03 22:11:56 -04:00
Zbigniew Jędrzejewski-Szmek 12da227455 Replace grubby patch with a short-circuiting install.d "plugin" 2016-11-03 22:11:56 -04:00
Zbigniew Jędrzejewski-Szmek e42bd854c0 Create systemd-coredump user in %pre 2016-11-03 21:16:45 -04:00
Zbigniew Jędrzejewski-Szmek a6473965d9 Add %{_isa} to Provides on arch-full packages 2016-11-03 21:16:45 -04:00
Zbigniew Jędrzejewski-Szmek 1478fab950 Update to v232 2016-11-03 21:16:45 -04:00
Jan Synacek 14572d7192 SPC - Cannot restart host operating from container (#1384523)
Resolves: #1384523
2016-10-18 14:14:59 +02:00
Zbigniew Jędrzejewski-Szmek 7ae71c8772 Move nss-myhostname provides to systemd-libs
Also drop the removal of nss modules in %postun. If the module cannot be
loaded, it is simply ignored. It seems better to simply leave it there,
then play around with nsswitch.conf, which is always risky.
2016-10-11 13:03:07 -04:00
Zbigniew Jędrzejewski-Szmek 4e1286dd8b Do not recreate /var/log/journal on upgrades 2016-10-09 10:25:34 -04:00
Zbigniew Jędrzejewski-Szmek 65fed72862 Prevent systemd-udev-trigger.service from restarting
systemd-udev package should be updated in lockstep, so we rely on the
daemon-reexec in systemd.rpm's %post to get the drop in loaded.
2016-10-07 07:55:56 -04:00
Zbigniew Jędrzejewski-Szmek 51f362c39a Use install --target-directory 2016-10-07 07:55:33 -04:00
Zbigniew Jędrzejewski-Szmek 64282b85b2 Fix systemctl set-default 2016-10-07 07:55:30 -04:00
Zbigniew Jędrzejewski-Szmek 839ccebd9b Apply fix for systemd-udev upgrade causing Xorg crash 2016-10-04 16:48:13 -04:00
Zbigniew Jędrzejewski-Szmek a2242c1ded Apply patches properly 2016-10-03 12:12:41 -04:00
Zbigniew Jędrzejewski-Szmek 3a5d9b71f4 Better fix for the notify message issue 2016-09-29 17:04:15 -04:00
Zbigniew Jędrzejewski-Szmek 20fa848003 Fix for the empty notify message fuckup 2016-09-29 05:34:51 -04:00
Zbigniew Jędrzejewski-Szmek 8f85f19830 Revert "Add self-obsoletes on versions < 231"
This reverts commit 3250f00573.

This is not needed anymore, since we went the Recommends:systemd-bootchart
route.
2016-09-29 05:18:54 -04:00
Zbigniew Jędrzejewski-Szmek ef73cc0d30 Recommend systemd-bootchart
It was split out, but it's a tiny package so it's easiest to pull it
in on all "standard" installations.
2016-09-26 15:16:25 -04:00
Zbigniew Jędrzejewski-Szmek 3250f00573 Add self-obsoletes on versions < 231
https://bugzilla.redhat.com/show_bug.cgi?id=1377733#c7
2016-09-22 08:11:33 -04:00
Zbigniew Jędrzejewski-Szmek 696e2f22d4 Fixes for preset-all, daemon-reexec, and other bugs 2016-08-25 16:13:45 -04:00
Michal Sekletar 2666b4f578 Use static uid/gid for systemd-{resolve,network}
Clearly we have static uid/gid allocated so let's actually use them.

egrep 'systemd-resolve|network' /usr/share/doc/setup/uidgid
systemd-network 192     192     /               /sbin/nologin   systemd
systemd-resolve 193     193     /               /sbin/nologin   systemd
2016-08-04 15:14:41 +02:00
Michal Sekletar 126aa118e1 Don't create systemd-bus-proxy user and group
We no longer ship bus-proxyd hence user and group are not needed
anymore.
2016-08-04 14:18:42 +02:00
Zbigniew Jędrzejewski-Szmek edb4e05013 Avoid % in comments
https://bugzilla.redhat.com/show_bug.cgi?id=1347865
2016-08-04 01:05:08 -04:00
Adam Williamson c418e76b87 build with preset-all reversion 2016-08-03 11:35:49 -07:00
Adam Williamson 287353c355 Revert "Run preset-all on initial installation"
This reverts commit 46083abe1a.
preset-all really does not work right, disabling all sorts of
stuff it should not disable. This caused RHBZ #1363858 (no tty
on vt1) and probably broke other things too.
2016-08-03 11:32:13 -07:00
Zbigniew Jędrzejewski-Szmek 140d00ebaa Fix botched %_isa dependency 2016-07-26 21:33:39 -04:00
Zbigniew Jędrzejewski-Szmek 46083abe1a Run preset-all on initial installation
https://bugzilla.redhat.com/show_bug.cgi?id=1118740
2016-07-26 20:13:34 -04:00
Zbigniew Jędrzejewski-Szmek 6153dd9122 Version 231 2016-07-26 15:12:35 -04:00
Zbigniew Jędrzejewski-Szmek 1ed18e5e9d Remove a bunch of old cruft 2016-07-26 14:24:30 -04:00
Zbigniew Jędrzejewski-Szmek ee7e6a6d57 Add missing man files to -container
Patch from mihkulemin@gmail.com.
2016-06-30 09:04:42 -04:00
Zbigniew Jędrzejewski-Szmek 49a32c19f1 Disable KillUserProcesses for now
https://fedorahosted.org/fesco/ticket/1580
2016-06-08 01:11:08 -04:00
Zbigniew Jędrzejewski-Szmek abad21f221 Update to git snapshot 2016-06-08 01:10:04 -04:00
Zbigniew Jędrzejewski-Szmek b3d8d37d58 Remove systemd-compat-libs on upgrade 2016-05-21 23:56:03 -04:00
Zbigniew Jędrzejewski-Szmek 8f6ec2ee91 Version 230 2016-05-21 20:15:34 -04:00
Zbigniew Jędrzejewski-Szmek 8efe61bc18 Remove duplicated entries in -container %files 2016-04-26 07:58:16 -04:00
Zbigniew Jędrzejewski-Szmek b7ec953f25 Move udev-related commands to udev's %post
This removed the operation of stopping udevd in %pre, and starting it
in %post. I think this shouldn't be necessary anymore.
2016-04-22 15:52:47 -04:00
Zbigniew Jędrzejewski-Szmek 994aacdaa6 Include license file in systemd-libs
It can be installed without the main package, so it should carry the file
too.
2016-04-18 12:54:30 -04:00
Zbigniew Jędrzejewski-Szmek 28e2d47eef Split out systemd-pam subpackage
This allows minimal installations without systemd but with systemd-libs installed
to drop the dependency on pam.
2016-04-18 11:51:52 -04:00
Zbigniew Jędrzejewski-Szmek 8b4408b5c9 Use %include to include filetrigger script from file
This makes it easier to update them from the upstream version.
2016-04-18 11:51:16 -04:00
Harald Hoyer f7a77f9cb0 move more binaries and services from the main package to subpackages 2016-04-18 17:39:04 +02:00
Harald Hoyer 7f4276c417 move more binaries and services from the main package to subpackages 2016-04-18 16:58:13 +02:00
Harald Hoyer cf1399ec4a move device dependant stuff to the udev sub package 2016-04-18 11:11:24 +02:00
Zbigniew Jędrzejewski-Szmek b54bf1386b Own linger dir 2016-04-10 11:21:43 -04:00
Zbigniew Jędrzejewski-Szmek 37de5dfe28 Add myhostname to /etc/nsswitch.conf 2016-03-22 10:45:58 -04:00
Harald Hoyer 253663e57d kernel-install: fixed patch format 2016-03-21 11:56:11 +01:00
Harald Hoyer afdf3eeb86 systemd-229-8
- fixed kernel-install for copying files for grubby
Resolves: rhbz#1299019
2016-03-21 11:45:52 +01:00
Harald Hoyer 70cb855cd7 kernel-install-grubby.patch: correctly copy files with "-T"
"cp -T" ensures a directory is not installed as a directory in the
target directory
2016-03-21 11:42:31 +01:00
Harald Hoyer f9a2211aaa Revert "Revert "kernel-install-grubby.patch: only copy files to /boot on "add"""
This reverts commit 4ee6493f72.
2016-03-21 11:25:03 +01:00
Zbigniew Jędrzejewski-Szmek b9a1e35039 Backport a few more patches 2016-03-17 09:26:12 -04:00
Zbigniew Jędrzejewski-Szmek c7c4361581 Move tmpfiles-setup-dev to systemd-udev subpackage
This removes the dependency on kmod from the main package
(kmod-libs is still required).
2016-03-17 08:52:09 -04:00
Zbigniew Jędrzejewski-Szmek 43a7716012 Also protect systemd-udev from removal 2016-03-15 15:34:52 -04:00
Zbigniew Jędrzejewski-Szmek 0a19dfe97e Move vconsole-setup to systemd-udev subpackage 2016-03-15 15:34:17 -04:00
Zbigniew Jędrzejewski-Szmek bed2768dc7 Patch for failing compression test case 2016-03-11 18:24:49 -05:00
Zbigniew Jędrzejewski-Szmek 6428127a18 Add patch for #1313085 2016-03-11 17:49:05 -05:00
Zbigniew Jędrzejewski-Szmek 7aba950aa4 Output test-suite.log on test failures 2016-03-04 13:24:11 -05:00
Zbigniew Jędrzejewski-Szmek 2b682337e7 Backport a bunch of patches 2016-03-04 13:06:46 -05:00
Zbigniew Jędrzejewski-Szmek c16b573717 Split out system-udev subpackage 2016-03-04 13:06:46 -05:00
Zbigniew Jędrzejewski-Szmek 34bfceffe6 Split out systemd-container subpackage 2016-03-04 12:52:57 -05:00
Zbigniew Jędrzejewski-Szmek 8ad6641ff2 Remove obsolete python bits from spec file 2016-03-04 12:07:48 -05:00
Peter Robinson 1a10d33b63 bump Release 2016-03-01 11:56:58 +00:00
Peter Robinson 624d2b7fea Power64 and s390(x) now have libseccomp support, aarch64 has gnu-efi 2016-03-01 11:13:00 +00:00
Jan Synacek 92af61aefe Fix build failures on ppc64 (#1310800)
Resolves: #1310800
2016-02-23 10:10:16 +01:00
Dennis Gilmore 18259f3b8c revert: fixed kernel-install for copying files for grubby
Resolves: rhbz#1299019
- this causes the dtb files to not get installed at all and the fdtdir
- line in extlinux.conf to not get updated correctly
2016-02-16 16:33:04 -06:00
Dennis Gilmore 4ee6493f72 Revert "kernel-install-grubby.patch: only copy files to /boot on "add""
The fix is worse than the bug it tries to fix

This reverts commit 908de082ce.
2016-02-16 16:29:38 -06:00
Michal Sekletar 5a1e61f28b New upstream release 2016-02-11 20:11:09 +01:00
Harald Hoyer 0a417f082a systemd-228-10.gite35a787
- fixed kernel-install for copying files for grubby
Resolves: rhbz#1299019
2016-02-11 10:59:48 +01:00
Harald Hoyer 908de082ce kernel-install-grubby.patch: only copy files to /boot on "add"
Also make sure directories are copied to the same place and not in the
already existing directory.

https://bugzilla.redhat.com/show_bug.cgi?id=129901
2016-02-11 10:55:30 +01:00
Jan Synacek 340bf090f9 remove spurious slashes (#1303344) 2016-02-11 09:37:05 +01:00
Zbigniew Jędrzejewski-Szmek 1dc1e2f91f Remove duplicate from %files 2016-02-10 15:11:53 -05:00
Zbigniew Jędrzejewski-Szmek ebd481af7f Add patch to fix {net,linux}/if.h conflict 2016-02-10 15:05:03 -05:00
Fedora Release Engineering 4df4d1391d - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-05 01:12:51 +00:00
Peter Robinson e53f79084e Rebuild for binutils on aarch64 fix 2016-01-27 08:38:20 +00:00
Dan Horák f08e792a66 - apply the conflict with fedora-release only in Fedora 2016-01-08 10:48:55 +01:00
Jan Synacek 2ec3b0659d Fix rawhide build failures on ppc64 (#1286249) 2015-12-10 13:47:25 +01:00
Zbigniew Jędrzejewski-Szmek 25282cb229 Require tree for tests 2015-12-01 23:53:29 -05:00
Zbigniew Jędrzejewski-Szmek d8151dbe1d Create /etc/systemd/network 2015-11-29 01:12:44 -05:00
Zbigniew Jędrzejewski-Szmek 38d93ea79f Do not install nss modules by default 2015-11-26 11:01:20 -05:00
Zbigniew Jędrzejewski-Szmek 1279f70ebd Update to git snapshot 2015-11-23 22:41:11 -05:00
Zbigniew Jędrzejewski-Szmek 80f2df5146 Convert file trigger scripts to lua
At least the %filetriggerpostun script can be invoked hundreds of
times during an upgrade, so it makes sense to optimize it a bit.

assert(exec(...)) is used because of https://bugzilla.redhat.com/show_bug.cgi?id=1094072.
2015-11-22 19:59:39 -05:00
Zbigniew Jędrzejewski-Szmek dc105f307e Improve filetriggers to run in all required situations 2015-11-22 19:53:05 -05:00
Zbigniew Jędrzejewski-Szmek 56be258e41 Add BR:lz4 2015-11-19 08:46:22 -05:00
Zbigniew Jędrzejewski-Szmek fc651191db Enable rpm file triggers for daemon-reload
We have to do this now because the corresponding change to rpm macros
was merged into systemd-228.
2015-11-19 08:25:57 -05:00
Zbigniew Jędrzejewski-Szmek 5767bd4538 Fix version number in obsoleted package name 2015-11-18 20:22:43 -05:00
Kay Sievers 32b81ffc99 New upstream release 2015-11-18 11:10:43 +01:00
Zbigniew Jędrzejewski-Szmek 38ce1c6b7e Revert last four commits
Pushed by mistake too early :(
2015-11-14 19:38:10 -05:00
Zbigniew Jędrzejewski-Szmek 7a0ef9c797 Use file trigger to call systemctl daemon-reload 2015-11-14 19:32:46 -05:00
Zbigniew Jędrzejewski-Szmek 895657f1cb Move more files to -udev 2015-11-13 20:52:25 -05:00
Zbigniew Jędrzejewski-Szmek fb4fe7a672 Split out system-udev subpackage 2015-11-13 20:52:24 -05:00
Zbigniew Jędrzejewski-Szmek 30dafa4290 Split out systemd-container subpackage 2015-11-13 20:52:06 -05:00
Zbigniew Jędrzejewski-Szmek 49f71b6ae3 Do not assume fstab is present 2015-11-13 20:51:46 -05:00
Zbigniew Jędrzejewski-Szmek a884a616c9 Ignore the access mode on /var/log/journal 2015-11-12 00:03:27 -05:00
Zbigniew Jędrzejewski-Szmek a67535cbef Remove obsolete %post script 2015-11-12 00:03:27 -05:00
Zbigniew Jędrzejewski-Szmek b321c5a2de Rename journal-gateway subpackage to journal-remote
We have outgrown the old name...
2015-11-12 00:03:27 -05:00
Zbigniew Jędrzejewski-Szmek 76c0b72634 Remove obsoletes for old systemd version 2015-11-11 23:50:31 -05:00
Zbigniew Jędrzejewski-Szmek aec27b1382 Remove sysvinit from description
Sysvinit is long gone, no need to mention it.
2015-11-11 23:50:31 -05:00
Peter Robinson 2532db13a7 Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5 2015-11-11 12:07:32 +00:00
Lukas Nykryn 684a3bc691 Rebuild for libmicrohttpd soname bump 2015-11-10 17:14:29 +01:00
Robert Kuska 984ca0bc57 Rebuilt for Python3.5 rebuild 2015-11-06 12:59:00 +01:00
Kalev Lember 13362c9950 Fix up the patch to apply 2015-11-04 19:20:13 +01:00
Zbigniew Jędrzejewski-Szmek 35c1f69c22 Fix syntax in kernel install 2015-11-04 11:24:13 -05:00
Michal Schmidt 339d9a453b Rebuild for libmicrohttpd soname bump 2015-11-03 13:12:12 +01:00
Harald Hoyer f6039fadea kernel-install: fixed hmac filename
hmac is .vmlinuz-<version>.hmac so needs a special treatment
2015-10-08 16:26:38 +02:00
Harald Hoyer d4f2656784 kernel-install: restorecon the files copied to /boot 2015-10-08 16:13:16 +02:00
Kay Sievers 456eac18c7 New upstream release 2015-10-07 17:13:28 +02:00
Jan Synacek 5cdbe47c57 user systemd-journal-upload should be in systemd-journal group (#1262743) 2015-09-18 12:51:56 +02:00
Kay Sievers 7f82478f26 Fix sources 2015-09-18 01:36:56 +02:00
Kay Sievers 4463a3b894 Add selinux to system-user PAM config 2015-09-18 01:20:51 +02:00
Kay Sievers 41553e0ec2 New upstream release 2015-09-08 16:46:01 +02:00
Kay Sievers 6c1029f225 New upstream release 2015-08-27 17:06:22 +02:00
Kay Sievers b3ddfbd31c update tarball 2015-07-31 19:04:35 +02:00
Kay Sievers a5c858d8e5 New upstream release 2015-07-31 18:50:25 +02:00
Kay Sievers 5bd45994d7 update to git snapshot 2015-07-30 00:06:38 +02:00
Harald Hoyer 60a0b61d40 systemd.spec: it's "Recommends" not "Wants" 2015-07-29 19:31:53 +02:00
Harald Hoyer 68323a2a5a systemd.spec: turn diffutils into a soft requirement
diffutils is only needed for systemd-delta
2015-07-29 16:51:57 +02:00
Harald Hoyer 5c1c8ba5ff systemd.spec: require util-linux
we want /bin/mount
2015-07-29 16:50:23 +02:00
Kay Sievers 741490beeb New upstream release 2015-07-29 13:14:57 +02:00
Zbigniew Jędrzejewski-Szmek 35ec3ad770 python3-devel is required to expand macros 2015-07-25 14:30:54 -04:00
Zbigniew Jędrzejewski-Szmek 5b850f53b9 Fix sources 2015-07-25 13:54:20 -04:00
Zbigniew Jędrzejewski-Szmek 952794e6c0 Remove python subpackages and build just once 2015-07-25 00:14:03 -04:00
Zbigniew Jędrzejewski-Szmek a97e1246d5 Remove hidden files which are now part of the tarball
There were some fixes upstream for this, so it might not be necessary
starting with the next release.
2015-07-25 00:12:23 -04:00
Zbigniew Jędrzejewski-Szmek 3dfe820830 Use github tarballs
tar.xz is 800kB smaller than tar.gz, but not having to create the tarball
manually is much more convenient.
2015-07-25 00:11:30 -04:00
Kay Sievers a5e55f9d9f update tarball 2015-07-07 22:13:03 +02:00
Kay Sievers f7ff95060d New upstream release 2015-07-07 17:40:34 +02:00
Zbigniew Jędrzejewski-Szmek 036292004a Correct version in changelog 2015-07-06 15:00:20 -04:00
Zbigniew Jędrzejewski-Szmek 5984675661 Restore translation check and fix bug link
If the check fails, then systemd.i686 and systemd.x86_64 is most
likely non-coinstallable, which is problematic for users because it
breaks upgrades. So keep the check to catch botched builds until we
find underlying reason.
2015-07-06 14:59:36 -04:00
Kay Sievers 516775d649 update to git snapshot 2015-07-06 18:07:38 +02:00
Zbigniew Jędrzejewski-Szmek 52a9194e13 Bump release 2015-07-05 23:02:34 -04:00
Zbigniew Jędrzejewski-Szmek 527912bf78 Correct version in changelog 2015-07-05 22:52:35 -04:00
Zbigniew Jędrzejewski-Szmek 90aeeef683 Add example file with yama config 2015-07-05 22:52:35 -04:00
Kay Sievers 9a11c6baf7 temporary fix to work around broken kernel headers 2015-07-05 18:54:43 +02:00
Kay Sievers 569c6fda50 add missing journal-nocow.conf tmpfiles 2015-07-05 17:32:26 +02:00
Kay Sievers 790f46d643 update to git snapshot 2015-07-05 17:06:37 +02:00
Kay Sievers e074d0f41a always use "git archive" tarballs 2015-07-05 16:47:32 +02:00
Kay Sievers ee6fc81588 build systemd-boot EFI tools 2015-06-22 22:24:47 +02:00
Lennart Poettering e40887b16d New upstream release
- Undoes botched translation check, should be reinstated later?
2015-06-19 13:16:10 +02:00
Dennis Gilmore e3594d6614 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild 2015-06-19 02:25:02 +00:00
Zbigniew Jędrzejewski-Szmek acdc555f22 Clarify -devel description 2015-06-17 14:49:52 -04:00
Peter Robinson be68e452de The gold linker is now fixed on aarch64 2015-06-11 09:53:16 +01:00
Zbigniew Jędrzejewski-Szmek 436654a8a5 Patches for selinux issue and other problems 2015-06-10 15:08:55 -04:00
Zbigniew Jędrzejewski-Szmek e2168b5f24 Remove gudev 2015-06-09 12:22:05 -04:00
Harald Hoyer 6cfa04faa1 fix udev block device watch 2015-06-09 14:46:39 +02:00
Harald Hoyer 4dc6b4953d add support for network disk encryption 2015-06-09 11:29:38 +02:00
Peter Robinson 01fba4b815 Disable gold on aarch64 until it's fixed (tracked in rhbz #1225156) 2015-06-07 19:29:28 +01:00
Zbigniew Jędrzejewski-Szmek 7a75a5fbec Fix changelog and put hwdb.d in rpm 2015-06-01 21:00:21 -04:00
Zbigniew Jędrzejewski-Szmek 551967d7d9 Check for botched translations 2015-05-30 18:18:12 -04:00
Zbigniew Jędrzejewski-Szmek 9e71abc2c9 systemd-devel should require systemd-libs 2015-05-30 18:11:00 -04:00
Richard W.M. Jones d9b91fa93b Add patch to fix udev --daemon not cleaning child processes
(upstream commit 86c3bece38bcf5).
2015-05-28 09:02:50 +01:00
Richard W.M. Jones 78ba63c3c7 Add patch to fix udev --daemon crash (upstream commit 040e689654ef08). 2015-05-27 13:57:29 +01:00
Lennart Poettering 90957559ef really the new sources 2015-05-21 23:40:16 +02:00
Lennart Poettering 0a658c0c61 newer tarball 2015-05-21 23:36:08 +02:00
Lennart Poettering 836567c7a3 New upstream release
- Drop /etc/mtab hack, as that's apparently fixed in mock now (#1116158)
- Remove ghosting for %{_sysconfdir}/systemd/system/runlevel*.target, these targets are not configurable anymore in systemd upstream
- Drop work-around for #1002806, since this is solved upstream now
2015-05-21 22:39:30 +02:00
Dennis Gilmore 911deca421 fix up the conflicts version for fedora-release 2015-05-20 13:14:50 -05:00
Zbigniew Jędrzejewski-Szmek 05c90300b1 Fix compilation 2015-05-20 11:17:36 -04:00
Zbigniew Jędrzejewski-Szmek 5d3e2085f5 Bump release 2015-05-20 01:37:19 -04:00
Zbigniew Jędrzejewski-Szmek a48f80c6e3 More patches 2015-05-20 01:34:58 -04:00
Zbigniew Jędrzejewski-Szmek 0a8e7e6c19 Remove presets 2015-05-20 00:34:19 -04:00
Zbigniew Jędrzejewski-Szmek 812fb10583 Suppress warning from %post script when dir does not exist 2015-05-20 00:24:27 -04:00
Zbigniew Jędrzejewski-Szmek 75a820ceb0 Fix vconsole.conf sed script (#1218252) 2015-05-05 13:51:19 -04:00
Zbigniew Jędrzejewski-Szmek ef7b485f69 Patches for outstanding annoyances 2015-04-29 10:05:09 -04:00
Zbigniew Jędrzejewski-Szmek 0ab588521d Tighten requirements between subpackages
Use %{?_isa} everywhere: automatically generated requirements do not
specify the exact version. In principle it was possible to satisfy
automatically added requirements with an older systemd, and our manual
R:%{name}=%{version}-%{release} with a systemd package from a
different architecture. So tighten the requirements to make sure all
systemd subpackages are always upgraded in lock-step.

systemd-devel needs to require systemd-compat-libs explicitly. Otherwise
we get dangling symlinks.
2015-04-08 11:27:05 -04:00
Zbigniew Jędrzejewski-Szmek 77e6ed9659 More patches for outstanding bugs 2015-03-23 00:52:38 -04:00
Zbigniew Jędrzejewski-Szmek ffc19a0568 Create /var/lib/systemd/journal-upload 2015-03-23 00:52:37 -04:00
Zbigniew Jędrzejewski-Szmek c4099ef515 Move more stuff to systemd-journal-gatewayd subpackage 2015-03-22 23:36:54 -04:00
Zbigniew Jędrzejewski-Szmek c9f04dae19 Introduce helper variables for commonly used dirs
No change intended.
2015-03-22 22:52:11 -04:00
Zbigniew Jędrzejewski-Szmek 41d7c09d1b Reconfigure old Finnish keymaps in post 2015-03-14 12:08:23 -04:00
Zbigniew Jędrzejewski-Szmek 399a2a87d9 Backport a bunch of patches 2015-03-14 12:08:23 -04:00
Jan Synacek b4d5d4640a Buttons on Lenovo X6* tablets broken (#1198939) 2015-03-10 14:17:28 +01:00
Zbigniew Jędrzejewski-Szmek fa31ee886b Restore test verbosity 2015-03-03 19:21:12 -05:00
Zbigniew Jędrzejewski-Szmek 9c0d1d5a07 Remove s390 workaround 2015-03-03 19:21:12 -05:00
Zbigniew Jędrzejewski-Szmek b081c530a5 Remove duplicate ACLs in %post
This fixes a problem added during development, so it should be enough
to carry the scriplet for some time and remove it in all branches before
F22 goes stable.
2015-03-03 19:21:12 -05:00
Zbigniew Jędrzejewski-Szmek e4a83a82af Bugfixes 2015-03-03 19:21:12 -05:00
Michal Schmidt ade6190d36 arm: reenable lto. gcc-5.0.0-0.16 fixed the crash (#1193212) 2015-02-25 10:01:30 +01:00
Colin Walters b1d608a2b3 Revert patch that breaks Atomic/OSTree (#1195761)
Conflicts:
	systemd.spec
2015-02-24 17:46:22 -05:00
Michal Schmidt 5427ee063b Undo the resolv.conf workaround, Aim for a proper fix in Rawhide.
Do not merge this into F22 until other components are fixed (#1116651).

[See me reverting my reverts like a real weenie!]
2015-02-20 17:31:24 +01:00
Michal Schmidt 0cb630f4ff Revive fedora-disable-resolv.conf-symlink.patch to unbreak composes 2015-02-20 14:22:02 +01:00
Michal Schmidt 6e198e4088 arm: disabling gold did not help; disable lto instead (#1193212) 2015-02-18 17:00:58 +01:00
Michal Schmidt 68864dcf85 Merge branch 'master' into f22
Sew diverged branches.
2015-02-18 08:46:39 +01:00
Peter Jones 2c67f7fe1b Update 90-default.present for dbxtool.
Signed-off-by: Peter Jones <pjones@redhat.com>
2015-02-17 13:38:33 -05:00
Peter Jones df692bb9f2 Add dbxtool to 90-default.present.
As per
https://fedoraproject.org/wiki/Changes/UEFISecureBootBlacklistUpdates ,
this service should be started by default.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-02-17 13:36:47 -05:00
Peter Jones 5decfd300f Add dbxtool to 90-default.present.
As per
https://fedoraproject.org/wiki/Changes/UEFISecureBootBlacklistUpdates ,
this service should be started by default.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-02-17 13:36:37 -05:00
Lennart Poettering 78bc69f934 disable gold on arm 2015-02-16 22:55:06 +01:00
Lennart Poettering f93ca2d2c3 new tarball 2015-02-16 22:07:17 +01:00
Lennart Poettering 258b2a4ba8 add missing deps to spec file 2015-02-16 21:54:03 +01:00
Lennart Poettering 1a99f77d64 new release 2015-02-16 20:22:05 +01:00
Lennart Poettering 064fee0cbb New upstream release 2015-02-16 19:24:46 +01:00
Peter Robinson b4bdea39fb aarch64 now has seccomp support 2015-02-16 15:26:55 +00:00
Michal Schmidt c3cf2ae4ec Don't overwrite systemd.macros with unrelated Source file. 2015-02-05 14:24:17 +01:00
Jan Synacek 55323ee7ea Add touchpad hwdb (#1189319) 2015-02-05 09:17:17 +01:00
Zbigniew Jędrzejewski-Szmek f2ebf1a65b Disable rpcbind in presets 2015-01-31 11:50:30 -05:00
Zbigniew Jędrzejewski-Szmek 92e27a50e4 Enable timedatex in presets 2015-01-31 11:48:08 -05:00
Zbigniew Jędrzejewski-Szmek 547d1d8bad Fixup very old fstabs (#1009023) 2015-01-28 15:48:37 -05:00
Zbigniew Jędrzejewski-Szmek 6cf221b459 Fix permissions of /var/log/journal 2015-01-20 00:39:37 -05:00
Zbigniew Jędrzejewski-Szmek c90404b648 Cleanup up spec file a bit 2015-01-19 23:45:50 -05:00
Zbigniew Jędrzejewski-Szmek 5724974576 Turn on verification of keymaps in loginctl 2015-01-16 00:27:43 -05:00
Jan Synacek f524b4a4be RFE: journal: automatically rotate the file if it is unlinked (#1171719) 2015-01-07 14:00:52 +01:00
Zbigniew Jędrzejewski-Szmek b53cf7b99c Add firewalld port descriptions 2015-01-05 22:46:35 -05:00
Jan Synacek 5606d835af systemd-nspawn doesn't work on s390/s390x (#1175394) 2014-12-18 15:36:07 +01:00
Jan Synacek 378cf2ba6f fix version in the comment 2014-12-18 10:15:42 +01:00
Lennart Poettering dfe64b9c42 remove obsolete readahead file on upgrade 2014-12-11 18:56:02 +01:00
Lennart Poettering 9254d88a74 add missing libmount dependency 2014-12-11 00:01:54 +01:00
Lennart Poettering 239db0d9eb new upstream release 2014-12-10 23:50:50 +01:00
Zbigniew Jędrzejewski-Szmek ea19761321 systemd-217-4 2014-11-06 21:58:39 -05:00
Zbigniew Jędrzejewski-Szmek 0440dc0ca2 Bump kmod requirement for #1147248
(cherry picked from commit 74c288b6b9)
2014-11-06 21:58:39 -05:00
Zbigniew Jędrzejewski-Szmek 90edccda2e Change libgudev1 to only require systemd-libs 2014-11-06 20:48:38 -05:00
Michal Schmidt ba201ce670 Fix hanging journal flush (#1159641) 2014-11-05 00:31:09 +01:00
Michal Schmidt 32324f829f Fix ordering cycles involving systemd-journal-flush.service and remote-fs.target (#1159117) 2014-10-31 22:07:17 +01:00
Lennart Poettering c6e31c698a fixed upstream tarball 2014-10-28 19:07:51 +01:00
Lennart Poettering cc4dc44dee new upstream release 2014-10-28 18:32:02 +01:00
621 changed files with 2718 additions and 71890 deletions

2
.gitignore vendored
View File

@ -1,6 +1,8 @@
*~
/systemd-*/
/.build-*.log
/x86_64/
/systemd-*src.rpm
/systemd-*.tar.xz
/systemd-*.tar.gz
/*.rpm

View File

@ -1,52 +0,0 @@
From fdbdf6ec29bda40763d7d3e7bb2a63e2f5d60c4c Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Tue, 19 Aug 2014 20:53:29 +0200
Subject: [PATCH] systemctl: fail in the case that no unit files were found
Previously systemctl died with message
-bash-4.2# systemctl --root /rawhi list-unit-files
(src/systemctl/systemctl.c:868) Out of memory.
in the case that no unit files were found in the --root
or the directory did not exist.
So lets return ENOENT in the case that --root does not exist
and empty list in the case that there are no unit files.
---
src/shared/install.c | 6 ++++++
src/systemctl/systemctl.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/src/shared/install.c b/src/shared/install.c
index 0fe1371129..03c7a9da2e 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2044,6 +2044,12 @@ int unit_file_get_list(
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
+ if (root_dir) {
+ r = access(root_dir, F_OK);
+ if (r < 0)
+ return -errno;
+ }
+
r = lookup_paths_init_from_scope(&paths, scope, root_dir);
if (r < 0)
return r;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 36db652316..072f615ad5 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1350,6 +1350,10 @@ static int list_unit_files(sd_bus *bus, char **args) {
}
n_units = hashmap_size(h);
+
+ if (n_units == 0)
+ return 0;
+
units = new(UnitFileList, n_units);
if (!units) {
unit_file_list_free(h);

View File

@ -0,0 +1,70 @@
From 2e9d763e7cbeb33954bbe3f96fd94de2cd62edf7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 12 Nov 2020 14:28:24 +0100
Subject: [PATCH] test-path-util: do not fail if the fd_is_mount_point check
fails
This test fails on i686 and ppc64le in koji:
/* test_path */
Assertion 'fd_is_mount_point(fd, "/", 0) > 0' failed at src/test/test-path-util.c:85, function test_path(). Aborting.
I guess some permission error is the most likely.
---
src/test/test-path-util.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index f4f8d0550b..be428334f3 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -40,8 +40,6 @@ static void test_path_simplify(const char *in, const char *out, const char *out_
}
static void test_path(void) {
- _cleanup_close_ int fd = -1;
-
log_info("/* %s */", __func__);
test_path_compare("/goo", "/goo", 0);
@@ -80,10 +78,6 @@ static void test_path(void) {
assert_se(streq(basename("/aa///file..."), "file..."));
assert_se(streq(basename("file.../"), ""));
- fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
- assert_se(fd >= 0);
- assert_se(fd_is_mount_point(fd, "/", 0) > 0);
-
test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc", "aaa/bbb/ccc");
test_path_simplify("//aaa/.////ccc", "/aaa/./ccc", "/aaa/ccc");
test_path_simplify("///", "/", "/");
@@ -120,6 +114,22 @@ static void test_path(void) {
assert_se(!path_equal_ptr(NULL, "/a"));
}
+static void test_path_is_mountpoint(void) {
+ _cleanup_close_ int fd = -1;
+ int r;
+
+ log_info("/* %s */", __func__);
+
+ fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
+ assert_se(fd >= 0);
+
+ r = fd_is_mount_point(fd, "/", 0);
+ if (r < 0)
+ log_warning_errno(r, "Failed to check if / is a mount point, ignoring: %m");
+ else
+ assert_se(r == 1);
+}
+
static void test_path_equal_root(void) {
/* Nail down the details of how path_equal("/", ...) works. */
@@ -714,6 +724,7 @@ int main(int argc, char **argv) {
test_print_paths();
test_path();
+ test_path_is_mountpoint();
test_path_equal_root();
test_find_executable_full();
test_find_executable(argv[0]);

View File

@ -0,0 +1,33 @@
From e8bca4ba55f855260eda684a16e8feb5f20b1deb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 12 Nov 2020 15:06:12 +0100
Subject: [PATCH] test-path-util: ignore test failure
---
src/test/test-path-util.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index be428334f3..207c659b8b 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -120,14 +120,17 @@ static void test_path_is_mountpoint(void) {
log_info("/* %s */", __func__);
+ (void) system("uname -a");
+ (void) system("mountpoint /");
+
fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
assert_se(fd >= 0);
r = fd_is_mount_point(fd, "/", 0);
if (r < 0)
log_warning_errno(r, "Failed to check if / is a mount point, ignoring: %m");
- else
- assert_se(r == 1);
+ else if (r == 0)
+ log_warning("/ is not a mountpoint?");
}
static void test_path_equal_root(void) {

View File

@ -1,26 +0,0 @@
From 413f6df864083130a380b2f7adbb5aa970139fe7 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 20 Aug 2014 11:25:23 +0200
Subject: [PATCH] build: remove repeated KMOD section
---
src/core/build.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/core/build.h b/src/core/build.h
index d380382aba..a7f12a33e4 100644
--- a/src/core/build.h
+++ b/src/core/build.h
@@ -123,12 +123,6 @@
#define _KMOD_FEATURE_ "-KMOD"
#endif
-#ifdef HAVE_KMOD
-#define _KMOD_FEATURE_ "+KMOD"
-#else
-#define _KMOD_FEATURE_ "-KMOD"
-#endif
-
#ifdef HAVE_LIBIDN
#define _IDN_FEATURE_ "+IDN"
#else

View File

@ -1,120 +0,0 @@
From 5dd6d0f8ff1681fff9369e0aa2532979954dbfde Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 20 Aug 2014 13:49:39 +0200
Subject: [PATCH] machine-id-setup: don't try to read UUID from VM/container
manager if we operate on a root directory that's not /
This should make sure no UUID from the host systemd-machine-id-setup is
running on leaks onto a disk image that is provisioned with the tool.
---
src/core/machine-id-setup.c | 79 +++++++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 38 deletions(-)
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 712f60cb11..efb074fcbd 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -64,15 +64,16 @@ static int generate(char id[34], const char *root) {
int fd, r;
unsigned char *p;
sd_id128_t buf;
- char *q;
+ char *q;
ssize_t k;
- const char *vm_id;
- _cleanup_free_ char *dbus_machine_id = NULL;
+ const char *vm_id, *dbus_machine_id;
assert(id);
- if (asprintf(&dbus_machine_id, "%s/var/lib/dbus/machine-id", root) < 0)
- return log_oom();
+ if (isempty(root))
+ dbus_machine_id = "/var/lib/dbus/machine-id";
+ else
+ dbus_machine_id = strappenda(root, "/var/lib/dbus/machine-id");
/* First, try reading the D-Bus machine id, unless it is a symlink */
fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
@@ -93,46 +94,48 @@ static int generate(char id[34], const char *root) {
}
}
- /* If that didn't work, see if we are running in a container,
- * and a machine ID was passed in via $container_uuid the way
- * libvirt/LXC does it */
- r = detect_container(NULL);
- if (r > 0) {
- _cleanup_free_ char *e = NULL;
-
- r = getenv_for_pid(1, "container_uuid", &e);
+ if (isempty(root)) {
+ /* If that didn't work, see if we are running in a container,
+ * and a machine ID was passed in via $container_uuid the way
+ * libvirt/LXC does it */
+ r = detect_container(NULL);
if (r > 0) {
- if (strlen(e) >= 36) {
- r = shorten_uuid(id, e);
- if (r >= 0) {
- log_info("Initializing machine ID from container UUID.");
- return 0;
- }
- }
- }
-
- } else {
- /* If we are not running in a container, see if we are
- * running in qemu/kvm and a machine ID was passed in
- * via -uuid on the qemu/kvm command line */
+ _cleanup_free_ char *e = NULL;
- r = detect_vm(&vm_id);
- if (r > 0 && streq(vm_id, "kvm")) {
- char uuid[37];
-
- fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
- if (fd >= 0) {
- k = loop_read(fd, uuid, 36, false);
- safe_close(fd);
-
- if (k >= 36) {
- r = shorten_uuid(id, uuid);
+ r = getenv_for_pid(1, "container_uuid", &e);
+ if (r > 0) {
+ if (strlen(e) >= 36) {
+ r = shorten_uuid(id, e);
if (r >= 0) {
- log_info("Initializing machine ID from KVM UUID.");
+ log_info("Initializing machine ID from container UUID.");
return 0;
}
}
}
+
+ } else {
+ /* If we are not running in a container, see if we are
+ * running in qemu/kvm and a machine ID was passed in
+ * via -uuid on the qemu/kvm command line */
+
+ r = detect_vm(&vm_id);
+ if (r > 0 && streq(vm_id, "kvm")) {
+ char uuid[37];
+
+ fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
+ if (fd >= 0) {
+ k = loop_read(fd, uuid, 36, false);
+ safe_close(fd);
+
+ if (k >= 36) {
+ r = shorten_uuid(id, uuid);
+ if (r >= 0) {
+ log_info("Initializing machine ID from KVM UUID.");
+ return 0;
+ }
+ }
+ }
+ }
}
}

View File

@ -1,36 +0,0 @@
From 03664a62914782dbd8f069bbcf8a0c8ca1df7010 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Wed, 20 Aug 2014 14:34:23 +0200
Subject: [PATCH] resolved-dns-rr: fix typo
a->rrsig.type_covered != a->rrsig.type_covered" is always false
regardless of the values of its operands because those operands are identical.
---
src/resolve/resolved-dns-rr.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index c792deda47..c5f7cb931e 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -425,13 +425,13 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
case DNS_TYPE_RRSIG:
/* do the fast comparisons first */
- if (a->rrsig.type_covered != a->rrsig.type_covered ||
- a->rrsig.algorithm != a->rrsig.algorithm ||
- a->rrsig.labels != a->rrsig.labels ||
- a->rrsig.original_ttl != a->rrsig.original_ttl ||
- a->rrsig.expiration != a->rrsig.expiration ||
- a->rrsig.inception != a->rrsig.inception ||
- a->rrsig.key_tag != a->rrsig.key_tag ||
+ if (a->rrsig.type_covered != b->rrsig.type_covered ||
+ a->rrsig.algorithm != b->rrsig.algorithm ||
+ a->rrsig.labels != b->rrsig.labels ||
+ a->rrsig.original_ttl != b->rrsig.original_ttl ||
+ a->rrsig.expiration != b->rrsig.expiration ||
+ a->rrsig.inception != b->rrsig.inception ||
+ a->rrsig.key_tag != b->rrsig.key_tag ||
a->rrsig.signature_size != b->rrsig.signature_size ||
memcmp(a->rrsig.signature, b->rrsig.signature, a->rrsig.signature_size) != 0)
return false;

View File

@ -1,25 +0,0 @@
From be754d5443e5fe44ead733ad509b127409cdb0f0 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 20 Aug 2014 14:47:35 +0200
Subject: [PATCH] resolved: fix which return codes we check
Discovered by Lukas Nykryn
---
src/resolve/resolved-dns-domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/resolve/resolved-dns-domain.c b/src/resolve/resolved-dns-domain.c
index 6152047ecb..8ed1ecf0a4 100644
--- a/src/resolve/resolved-dns-domain.c
+++ b/src/resolve/resolved-dns-domain.c
@@ -434,8 +434,8 @@ int dns_name_endswith(const char *name, const char *suffix) {
saved_n = n;
q = dns_label_unescape(&s, ls, sizeof(ls));
- if (r < 0)
- return r;
+ if (q < 0)
+ return q;
w = dns_label_undo_idna(ls, q, ls, sizeof(ls));
if (w < 0)
return w;

View File

@ -1,21 +0,0 @@
From 7a855149eaf6dbd336d9defab5b4a9c70b75d5e6 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Wed, 20 Aug 2014 14:51:27 +0200
Subject: [PATCH] journal-remote: remove unreachable code
---
src/journal-remote/journal-remote.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index aa659d1bd4..7f422bfb37 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -579,7 +579,6 @@ static int request_handler(
log_error("MHD_get_connection_info failed: cannot get remote fd");
return mhd_respond(connection, MHD_HTTP_INTERNAL_SERVER_ERROR,
"Cannot check remote address");
- return code;
}
fd = ci->connect_fd;

View File

@ -1,27 +0,0 @@
From 081e009bef5a09c986bfabdf46e96810afaed1c3 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Wed, 20 Aug 2014 15:02:09 +0200
Subject: [PATCH] util: return after freeing all members of array
---
src/shared/util.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index 85a570a2a4..9d254e0464 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -7113,10 +7113,10 @@ int unquote_many_words(const char **p, ...) {
if (r < 0) {
int j;
- for (j = 0; j < c; j++) {
+ for (j = 0; j < c; j++)
free(l[j]);
- return r;
- }
+
+ return r;
}
if (r == 0)

View File

@ -1,22 +0,0 @@
From e1ad6e245dcf63faa8f183063eb97678f4f9ac94 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Wed, 20 Aug 2014 15:13:06 +0200
Subject: [PATCH] journal-upload: make sure that 'r' is initialized
---
src/journal-remote/journal-upload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 7a7aee8170..bdeeff6778 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -324,7 +324,7 @@ static int dispatch_fd_input(sd_event_source *event,
}
static int open_file_for_upload(Uploader *u, const char *filename) {
- int fd, r;
+ int fd, r = 0;
if (streq(filename, "-"))
fd = STDIN_FILENO;

View File

@ -1,26 +0,0 @@
From a9feff3d774eaa1cc1b59189e8f344c01e69f888 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 20 Aug 2014 15:56:14 +0200
Subject: [PATCH] resolved: write resolv.conf search - switch arguments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Found by Lukáš Nykrýn.
---
src/resolve/resolved-manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 04ee204074..56baf8730d 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -699,7 +699,7 @@ static void write_resolv_conf_server(DnsServer *s, FILE *f, unsigned *count) {
}
static void write_resolv_conf_search(const char *domain, FILE *f,
- unsigned *length, unsigned *count) {
+ unsigned *count, unsigned *length) {
assert(domain);
assert(f);
assert(length);

View File

@ -1,56 +0,0 @@
From 9b364545435d2b65fcf73519b3064bb7c28093b7 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Fri, 15 Aug 2014 21:04:07 +0200
Subject: [PATCH] sd-event: add API to access epoll_fd
This is a prerequisite for integrating sd-event into an external
event loop.
---
src/libsystemd/libsystemd.sym.m4 | 1 +
src/libsystemd/sd-event/sd-event.c | 8 ++++++++
src/systemd/sd-event.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index 415d89afbe..3fc9983f98 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -374,6 +374,7 @@ global:
sd_event_loop;
sd_event_exit;
sd_event_now;
+ sd_event_get_fd;
sd_event_get_state;
sd_event_get_tid;
sd_event_get_exit_code;
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 7917ab934a..e062997a80 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2361,6 +2361,14 @@ finish:
return r;
}
+_public_ int sd_event_get_fd(sd_event *e) {
+
+ assert_return(e, -EINVAL);
+ assert_return(!event_pid_changed(e), -ECHILD);
+
+ return e->epoll_fd;
+}
+
_public_ int sd_event_get_state(sd_event *e) {
assert_return(e, -EINVAL);
assert_return(!event_pid_changed(e), -ECHILD);
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index 5d9b3be6c7..d96852a763 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -90,6 +90,7 @@ int sd_event_exit(sd_event *e, int code);
int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec);
+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);

View File

@ -1,143 +0,0 @@
From 730836403aee5f5bb998e6e3622ea7068fce0699 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 19 Aug 2014 11:27:34 +0200
Subject: [PATCH] journalctl: add "-t --identifier=STRING" option
This turns journalctl to the counterpart of systemd-cat.
Messages sent with
systemd-cat --identifier foo --prioritiy debug
can now be shown with
journalctl --identifier foo --prioritiy debug
"--identifier" is not merged with "--unit" to make a clear
distinction between syslog and systemd units.
syslog identifiers can be chosen freely by anyone.
---
man/journalctl.xml | 14 ++++++++++++++
src/journal/journalctl.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/man/journalctl.xml b/man/journalctl.xml
index e10918a9c6..d4e031619a 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -498,6 +498,20 @@
</varlistentry>
<varlistentry>
+ <term><option>-t</option></term>
+ <term><option>--identifier=<replaceable>SYSLOG_IDENTIFIER</replaceable>|<replaceable>PATTERN</replaceable></option></term>
+
+ <listitem><para>Show messages for the
+ specified syslog identifier
+ <replaceable>SYSLOG_IDENTIFIER</replaceable>, or
+ for any of the messages with a <literal>SYSLOG_IDENTIFIER</literal>
+ matched by <replaceable>PATTERN</replaceable>.</para>
+
+ <para>This parameter can be specified
+ multiple times.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-u</option></term>
<term><option>--unit=<replaceable>UNIT</replaceable>|<replaceable>PATTERN</replaceable></option></term>
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 5c4a71d618..f3680d1ce2 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -89,6 +89,7 @@ static bool arg_force = false;
#endif
static usec_t arg_since, arg_until;
static bool arg_since_set = false, arg_until_set = false;
+static char **arg_syslog_identifier = NULL;
static char **arg_system_units = NULL;
static char **arg_user_units = NULL;
static const char *arg_field = NULL;
@@ -180,6 +181,7 @@ static void help(void) {
" -k --dmesg Show kernel message log from the current boot\n"
" -u --unit=UNIT Show data only from the specified unit\n"
" --user-unit=UNIT Show data only from the specified user session unit\n"
+ " -t --identifier=STRING Show only messages with the specified syslog identifier\n"
" -p --priority=RANGE Show only messages within the specified priority range\n"
" -e --pager-end Immediately jump to end of the journal in the pager\n"
" -f --follow Follow the journal\n"
@@ -276,6 +278,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "file", required_argument, NULL, ARG_FILE },
{ "root", required_argument, NULL, ARG_ROOT },
{ "header", no_argument, NULL, ARG_HEADER },
+ { "identifier", required_argument, NULL, 't' },
{ "priority", required_argument, NULL, 'p' },
{ "setup-keys", no_argument, NULL, ARG_SETUP_KEYS },
{ "interval", required_argument, NULL, ARG_INTERVAL },
@@ -304,7 +307,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:c:u:F:xrM:", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:c:t:u:F:xrM:", options, NULL)) >= 0)
switch (c) {
@@ -590,6 +593,12 @@ static int parse_argv(int argc, char *argv[]) {
arg_until_set = true;
break;
+ case 't':
+ r = strv_extend(&arg_syslog_identifier, optarg);
+ if (r < 0)
+ return log_oom();
+ break;
+
case 'u':
r = strv_extend(&arg_system_units, optarg);
if (r < 0)
@@ -1212,6 +1221,32 @@ static int add_priorities(sd_journal *j) {
return 0;
}
+
+static int add_syslog_identifier(sd_journal *j) {
+ int r;
+ char **i;
+
+ assert(j);
+
+ STRV_FOREACH(i, arg_syslog_identifier) {
+ char *u;
+
+ u = strappenda("SYSLOG_IDENTIFIER=", *i);
+ r = sd_journal_add_match(j, u, 0);
+ if (r < 0)
+ return r;
+ r = sd_journal_add_disjunction(j);
+ if (r < 0)
+ return r;
+ }
+
+ r = sd_journal_add_conjunction(j);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
static int setup_keys(void) {
#ifdef HAVE_GCRYPT
size_t mpk_size, seed_size, state_size, i;
@@ -1705,6 +1740,12 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
+ r = add_syslog_identifier(j);
+ if (r < 0) {
+ log_error("Failed to add filter for syslog identifiers: %s", strerror(-r));
+ return EXIT_FAILURE;
+ }
+
r = add_priorities(j);
if (r < 0) {
log_error("Failed to add filter for priorities: %s", strerror(-r));

View File

@ -1,24 +0,0 @@
From 3fdbc8205885f117b7dea289b44217310663e731 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:10:37 +0200
Subject: [PATCH] CODING_STYLE: document that we don't break lines at 80ch
---
CODING_STYLE | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/CODING_STYLE b/CODING_STYLE
index ca3b5183f9..a3fc26c1e1 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -1,6 +1,9 @@
-
- 8ch indent, no tabs
+- Don't break code lines too eagerly. We do *not* force line breaks at
+ 80ch, all of today's screens should be much larger than that. But
+ then again, don't overdo it, ~140ch should be enough really.
+
- Variables and functions *must* be static, unless they have a
prototype, and are supposed to be exported.

View File

@ -1,48 +0,0 @@
From 11adc1aef7a1a6e9ba3fda8eb34eb5fadedc0385 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:10:59 +0200
Subject: [PATCH] util: change return value of startswith() to non-const
This way we can use it on non-const strings, and don't end up with a
const'ified result.
This is similar to libc's strstr() which also takes a const string but
returns a non-const one.
---
src/shared/util.h | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/shared/util.h b/src/shared/util.h
index 87ad317319..8cd47b8294 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -158,15 +158,23 @@ static inline bool isempty(const char *p) {
return !p || !p[0];
}
-static inline const char *startswith(const char *s, const char *prefix) {
- if (strncmp(s, prefix, strlen(prefix)) == 0)
- return s + strlen(prefix);
+static inline char *startswith(const char *s, const char *prefix) {
+ size_t l;
+
+ l = strlen(prefix);
+ if (strncmp(s, prefix, l) == 0)
+ return (char*) s + l;
+
return NULL;
}
-static inline const char *startswith_no_case(const char *s, const char *prefix) {
- if (strncasecmp(s, prefix, strlen(prefix)) == 0)
- return s + strlen(prefix);
+static inline char *startswith_no_case(const char *s, const char *prefix) {
+ size_t l;
+
+ l = strlen(prefix);
+ if (strncasecmp(s, prefix, l) == 0)
+ return (char*) s + l;
+
return NULL;
}

View File

@ -1,55 +0,0 @@
From a9f85faf43ae2289e19ba9105c36496aefe66072 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:13:15 +0200
Subject: [PATCH] util: simplify close_nointr() a bit
---
src/shared/util.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index 9d254e0464..a54e879953 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -175,25 +175,24 @@ char* first_word(const char *s, const char *word) {
}
int close_nointr(int fd) {
- int r;
-
assert(fd >= 0);
- r = close(fd);
- if (r >= 0)
- return r;
- else if (errno == EINTR)
- /*
- * Just ignore EINTR; a retry loop is the wrong
- * thing to do on Linux.
- *
- * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
- * https://bugzilla.gnome.org/show_bug.cgi?id=682819
- * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
- * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
- */
+
+ if (close(fd) >= 0)
return 0;
- else
- return -errno;
+
+ /*
+ * Just ignore EINTR; a retry loop is the wrong thing to do on
+ * Linux.
+ *
+ * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
+ * https://bugzilla.gnome.org/show_bug.cgi?id=682819
+ * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
+ * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
+ */
+ if (errno == EINTR)
+ return 0;
+
+ return -errno;
}
int safe_close(int fd) {

View File

@ -1,42 +0,0 @@
From 5ed1227238724959f020169f5332086439709b55 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:13:43 +0200
Subject: [PATCH] util: make asynchronous_close() really work like an
asynchronous version of safe_close()
Save/restore errno, like we do in safe_close(). And don't fork a thread
if the parameter is already negative.
---
src/shared/async.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/shared/async.c b/src/shared/async.c
index 3876deda70..115901e637 100644
--- a/src/shared/async.c
+++ b/src/shared/async.c
@@ -73,7 +73,7 @@ int asynchronous_sync(void) {
}
static void *close_thread(void *p) {
- safe_close(PTR_TO_INT(p));
+ assert_se(close_nointr(PTR_TO_INT(p)) != -EBADF);
return NULL;
}
@@ -86,9 +86,13 @@ int asynchronous_close(int fd) {
* but it doesn't, so we work around it, and hide this as a
* far away as we can. */
- r = asynchronous_job(close_thread, INT_TO_PTR(fd));
- if (r < 0)
- safe_close(fd);
+ 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;
}

View File

@ -1,127 +0,0 @@
From 4c94096027f21d4ed0efe991534a926d39d52369 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:15:49 +0200
Subject: [PATCH] core: unify how we generate the prefix string when dumping
unit state
---
src/core/execute.c | 19 ++++++-------------
src/core/service.c | 6 ++----
src/core/socket.c | 1 +
src/core/unit.c | 7 ++-----
4 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/src/core/execute.c b/src/core/execute.c
index d8452a666c..2544a2470c 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2398,12 +2398,11 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
assert(s);
assert(f);
- if (!prefix)
- prefix = "";
-
if (s->pid <= 0)
return;
+ prefix = strempty(prefix);
+
fprintf(f,
"%sPID: "PID_FMT"\n",
prefix, s->pid);
@@ -2463,21 +2462,16 @@ char *exec_command_line(char **argv) {
}
void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
- _cleanup_free_ char *p2 = NULL;
- const char *prefix2;
-
_cleanup_free_ char *cmd = NULL;
+ const char *prefix2;
assert(c);
assert(f);
- if (!prefix)
- prefix = "";
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
+ prefix = strempty(prefix);
+ prefix2 = strappenda(prefix, "\t");
cmd = exec_command_line(c->argv);
-
fprintf(f,
"%sCommand Line: %s\n",
prefix, cmd ? cmd : strerror(ENOMEM));
@@ -2488,8 +2482,7 @@ void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
assert(f);
- if (!prefix)
- prefix = "";
+ prefix = strempty(prefix);
LIST_FOREACH(command, c, c)
exec_command_dump(c, f, prefix);
diff --git a/src/core/service.c b/src/core/service.c
index 6a4665a1ae..887b1c8514 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -463,16 +463,14 @@ static int service_load(Unit *u) {
}
static void service_dump(Unit *u, FILE *f, const char *prefix) {
-
ServiceExecCommand c;
Service *s = SERVICE(u);
const char *prefix2;
- _cleanup_free_ char *p2 = NULL;
assert(s);
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
+ prefix = strempty(prefix);
+ prefix2 = strappenda(prefix, "\t");
fprintf(f,
"%sService State: %s\n"
diff --git a/src/core/socket.c b/src/core/socket.c
index 1189f451d2..7ca8edbda8 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -471,6 +471,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
assert(s);
assert(f);
+ prefix = strempty(prefix);
prefix2 = strappenda(prefix, "\t");
fprintf(f,
diff --git a/src/core/unit.c b/src/core/unit.c
index 08e74b4160..56102b360d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -791,7 +791,6 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
char *t, **j;
UnitDependency d;
Iterator i;
- _cleanup_free_ char *p2 = NULL;
const char *prefix2;
char
timestamp1[FORMAT_TIMESTAMP_MAX],
@@ -806,10 +805,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
assert(u);
assert(u->type >= 0);
- if (!prefix)
- prefix = "";
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
+ prefix = strempty(prefix);
+ prefix2 = strappenda(prefix, "\t");
fprintf(f,
"%s-> Unit %s:\n"

View File

@ -1,24 +0,0 @@
From abb4c1cc0161cc6b371ee7ea2550df17a3bfc21e Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:17:02 +0200
Subject: [PATCH] service: asynchronous_close() already checks for negative
parameters, no need to duplicate that
---
src/core/service.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index 887b1c8514..008e81437d 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -180,9 +180,6 @@ static int service_set_main_pid(Service *s, pid_t pid) {
static void service_close_socket_fd(Service *s) {
assert(s);
- if (s->socket_fd < 0)
- return;
-
s->socket_fd = asynchronous_close(s->socket_fd);
}

View File

@ -1,526 +0,0 @@
From 8bb2d17d2b89e87b2e9d8f6c147a757f4670b0fc Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:19:25 +0200
Subject: [PATCH] service: remove some pointless linebreaks, to make things
more readable
---
src/core/service.c | 200 +++++++++++++++++------------------------------------
1 file changed, 65 insertions(+), 135 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index 008e81437d..f10582d89e 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -135,8 +135,7 @@ static void service_unwatch_pid_file(Service *s) {
if (!s->pid_file_pathspec)
return;
- log_debug_unit(UNIT(s)->id, "Stopping watch for %s's PID file %s",
- UNIT(s)->id, s->pid_file_pathspec->path);
+ log_debug_unit(UNIT(s)->id, "Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
path_spec_unwatch(s->pid_file_pathspec);
path_spec_done(s->pid_file_pathspec);
free(s->pid_file_pathspec);
@@ -166,10 +165,7 @@ static int service_set_main_pid(Service *s, pid_t pid) {
s->main_pid_known = true;
if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
- log_warning_unit(UNIT(s)->id,
- "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.",
- UNIT(s)->id, pid);
-
+ log_warning_unit(UNIT(s)->id, "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.", UNIT(s)->id, pid);
s->main_pid_alien = true;
} else
s->main_pid_alien = false;
@@ -362,14 +358,12 @@ static int service_add_default_dependencies(Service *s) {
* majority of services. */
/* First, pull in base system */
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
- SPECIAL_BASIC_TARGET, NULL, true);
+ r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_BASIC_TARGET, NULL, true);
if (r < 0)
return r;
/* Second, activate normal shutdown */
- r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS,
- SPECIAL_SHUTDOWN_TARGET, NULL, true);
+ r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
return r;
}
@@ -392,8 +386,8 @@ static void service_fix_output(Service *s) {
}
static int service_load(Unit *u) {
- int r;
Service *s = SERVICE(u);
+ int r;
assert(s);
@@ -556,25 +550,20 @@ static int service_load_pid_file(Service *s, bool may_warn) {
r = read_one_line_file(s->pid_file, &k);
if (r < 0) {
if (may_warn)
- log_info_unit(UNIT(s)->id,
- "PID file %s not readable (yet?) after %s.",
- s->pid_file, service_state_to_string(s->state));
+ log_info_unit(UNIT(s)->id, "PID file %s not readable (yet?) after %s.", s->pid_file, service_state_to_string(s->state));
return r;
}
r = parse_pid(k, &pid);
if (r < 0) {
if (may_warn)
- log_info_unit(UNIT(s)->id,
- "Failed to read PID from file %s: %s",
- s->pid_file, strerror(-r));
+ log_info_unit(UNIT(s)->id, "Failed to read PID from file %s: %s", s->pid_file, strerror(-r));
return r;
}
if (!pid_is_alive(pid)) {
if (may_warn)
log_info_unit(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file);
-
return -ESRCH;
}
@@ -582,14 +571,12 @@ static int service_load_pid_file(Service *s, bool may_warn) {
if (pid == s->main_pid)
return 0;
- log_debug_unit(UNIT(s)->id,
- "Main PID changing: "PID_FMT" -> "PID_FMT,
- s->main_pid, pid);
+ log_debug_unit(UNIT(s)->id, "Main PID changing: "PID_FMT" -> "PID_FMT, s->main_pid, pid);
+
service_unwatch_main_pid(s);
s->main_pid_known = false;
} else
- log_debug_unit(UNIT(s)->id,
- "Main PID loaded: "PID_FMT, pid);
+ log_debug_unit(UNIT(s)->id, "Main PID loaded: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
@@ -598,9 +585,7 @@ static int service_load_pid_file(Service *s, bool may_warn) {
r = unit_watch_pid(UNIT(s), pid);
if (r < 0) {
/* FIXME: we need to do something here */
- log_warning_unit(UNIT(s)->id,
- "Failed to watch PID "PID_FMT" from service %s",
- pid, UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
return r;
}
@@ -627,19 +612,19 @@ static int service_search_main_pid(Service *s) {
if (pid <= 0)
return -ENOENT;
- log_debug_unit(UNIT(s)->id,
- "Main PID guessed: "PID_FMT, pid);
+ log_debug_unit(UNIT(s)->id, "Main PID guessed: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
return r;
r = unit_watch_pid(UNIT(s), pid);
- if (r < 0)
+ if (r < 0) {
/* FIXME: we need to do something here */
- log_warning_unit(UNIT(s)->id,
- "Failed to watch PID "PID_FMT" from service %s",
- pid, UNIT(s)->id);
- return r;
+ log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
+ return r;
+ }
+
+ return 0;
}
static void service_set_state(Service *s, ServiceState state) {
@@ -1096,9 +1081,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run install restart timer: %s",
- UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false);
}
@@ -1136,9 +1119,7 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run 'stop-post' task: %s",
- UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1183,8 +1164,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
service_enter_stop_post(s, SERVICE_FAILURE_RESOURCES);
@@ -1227,8 +1207,7 @@ static void service_enter_stop(Service *s, ServiceResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1282,8 +1261,7 @@ static void service_enter_start_post(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
}
@@ -1375,8 +1353,7 @@ static void service_enter_start(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1489,9 +1466,7 @@ static void service_enter_reload(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run 'reload' task: %s",
- UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r));
s->reload_result = SERVICE_FAILURE_RESOURCES;
service_enter_running(s, SERVICE_SUCCESS);
}
@@ -1525,9 +1500,7 @@ static void service_run_next_control(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run next control task: %s",
- UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run next control task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SERVICE_START_PRE)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
@@ -1572,8 +1545,7 @@ static void service_run_next_main(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
+ log_warning_unit(UNIT(s)->id, "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
}
@@ -1588,41 +1560,35 @@ static int service_execute_action(Service *s, FailureAction action, const char *
case SERVICE_FAILURE_ACTION_NONE:
if (log_action_none)
- log_warning_unit(UNIT(s)->id,
- "%s %s, refusing to start.", UNIT(s)->id, reason);
+ log_warning_unit(UNIT(s)->id, "%s %s, refusing to start.", UNIT(s)->id, reason);
break;
case SERVICE_FAILURE_ACTION_REBOOT: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
- log_warning_unit(UNIT(s)->id,
- "%s %s, rebooting.", UNIT(s)->id, reason);
+ log_warning_unit(UNIT(s)->id, "%s %s, rebooting.", UNIT(s)->id, reason);
- r = manager_add_job_by_name(UNIT(s)->manager, JOB_START,
- SPECIAL_REBOOT_TARGET, JOB_REPLACE,
- true, &error, NULL);
+ r = manager_add_job_by_name(UNIT(s)->manager, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
if (r < 0)
- log_error_unit(UNIT(s)->id,
- "Failed to reboot: %s.", bus_error_message(&error, r));
+ log_error_unit(UNIT(s)->id, "Failed to reboot: %s.", bus_error_message(&error, r));
break;
}
case SERVICE_FAILURE_ACTION_REBOOT_FORCE:
- log_warning_unit(UNIT(s)->id,
- "%s %s, forcibly rebooting.", UNIT(s)->id, reason);
+ log_warning_unit(UNIT(s)->id, "%s %s, forcibly rebooting.", UNIT(s)->id, reason);
UNIT(s)->manager->exit_code = MANAGER_REBOOT;
break;
case SERVICE_FAILURE_ACTION_REBOOT_IMMEDIATE:
- log_warning_unit(UNIT(s)->id,
- "%s %s, rebooting immediately.", UNIT(s)->id, reason);
+ log_warning_unit(UNIT(s)->id, "%s %s, rebooting immediately.", UNIT(s)->id, reason);
+
sync();
+
if (s->reboot_arg) {
log_info("Rebooting with argument '%s'.", s->reboot_arg);
- syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
- LINUX_REBOOT_CMD_RESTART2, s->reboot_arg);
+ syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, s->reboot_arg);
}
log_info("Rebooting.");
@@ -1630,8 +1596,7 @@ static int service_execute_action(Service *s, FailureAction action, const char *
break;
default:
- log_error_unit(UNIT(s)->id,
- "failure action=%i", action);
+ log_error_unit(UNIT(s)->id, "failure action=%i", action);
assert_not_reached("Unknown FailureAction.");
}
@@ -1990,7 +1955,7 @@ _pure_ static bool service_check_snapshot(Unit *u) {
assert(s);
- return (s->socket_fd < 0);
+ return s->socket_fd < 0;
}
static int service_retry_pid_file(Service *s) {
@@ -2012,24 +1977,19 @@ static int service_retry_pid_file(Service *s) {
static int service_watch_pid_file(Service *s) {
int r;
- log_debug_unit(UNIT(s)->id,
- "Setting watch for %s's PID file %s",
- UNIT(s)->id, s->pid_file_pathspec->path);
+ log_debug_unit(UNIT(s)->id, "Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
+
r = path_spec_watch(s->pid_file_pathspec, service_dispatch_io);
if (r < 0)
goto fail;
/* the pidfile might have appeared just before we set the watch */
- log_debug_unit(UNIT(s)->id,
- "Trying to read %s's PID file %s in case it changed",
- UNIT(s)->id, s->pid_file_pathspec->path);
+ log_debug_unit(UNIT(s)->id, "Trying to read %s's PID file %s in case it changed", UNIT(s)->id, s->pid_file_pathspec->path);
service_retry_pid_file(s);
return 0;
fail:
- log_error_unit(UNIT(s)->id,
- "Failed to set a watch for %s's PID file %s: %s",
- UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
+ log_error_unit(UNIT(s)->id, "Failed to set a watch for %s's PID file %s: %s", UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
service_unwatch_pid_file(s);
return r;
}
@@ -2116,8 +2076,8 @@ static void service_notify_cgroup_empty_event(Unit *u) {
/* If we were hoping for the daemon to write its PID file,
* we can give up now. */
if (s->pid_file_pathspec) {
- log_warning_unit(u->id,
- "%s never wrote its PID file. Failing.", UNIT(s)->id);
+ log_warning_unit(u->id, "%s never wrote its PID file. Failing.", UNIT(s)->id);
+
service_unwatch_pid_file(s);
if (s->state == SERVICE_START)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
@@ -2223,9 +2183,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug_unit(u->id,
- "%s running next main command for state %s",
- u->id, service_state_to_string(s->state));
+ log_debug_unit(u->id, "%s running next main command for state %s", u->id, service_state_to_string(s->state));
service_run_next_main(s);
} else {
@@ -2285,8 +2243,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_pid = 0;
if (s->control_command) {
- exec_status_exit(&s->control_command->exec_status,
- &s->exec_context, pid, code, status);
+ exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);
if (s->control_command->ignore)
f = SERVICE_SUCCESS;
@@ -2311,9 +2268,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug_unit(u->id,
- "%s running next control command for state %s",
- u->id, service_state_to_string(s->state));
+ log_debug_unit(u->id, "%s running next control command for state %s", u->id, service_state_to_string(s->state));
service_run_next_control(s);
} else {
@@ -2323,9 +2278,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_command = NULL;
s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID;
- log_debug_unit(u->id,
- "%s got final SIGCHLD for state %s",
- u->id, service_state_to_string(s->state));
+ log_debug_unit(u->id, "%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state));
switch (s->state) {
@@ -2453,40 +2406,32 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
case SERVICE_START_PRE:
case SERVICE_START:
- log_warning_unit(UNIT(s)->id,
- "%s %s operation timed out. Terminating.",
- UNIT(s)->id,
- s->state == SERVICE_START ? "start" : "start-pre");
+ log_warning_unit(UNIT(s)->id, "%s %s operation timed out. Terminating.", UNIT(s)->id, s->state == SERVICE_START ? "start" : "start-pre");
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_START_POST:
- log_warning_unit(UNIT(s)->id,
- "%s start-post operation timed out. Stopping.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s start-post operation timed out. Stopping.", UNIT(s)->id);
service_enter_stop(s, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_RELOAD:
- log_warning_unit(UNIT(s)->id,
- "%s reload operation timed out. Stopping.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s reload operation timed out. Stopping.", UNIT(s)->id);
s->reload_result = SERVICE_FAILURE_TIMEOUT;
service_enter_running(s, SERVICE_SUCCESS);
break;
case SERVICE_STOP:
- log_warning_unit(UNIT(s)->id,
- "%s stopping timed out. Terminating.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id);
service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_STOP_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id,
- "%s stop-sigterm timed out. Killing.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Killing.", UNIT(s)->id);
service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id,
- "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id);
service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT);
}
@@ -2497,34 +2442,28 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
* Must be something we cannot kill, so let's just be
* weirded out and continue */
- log_warning_unit(UNIT(s)->id,
- "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_STOP_POST:
- log_warning_unit(UNIT(s)->id,
- "%s stop-post timed out. Terminating.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stop-post timed out. Terminating.", UNIT(s)->id);
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_FINAL_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id,
- "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id);
service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id,
- "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.",
- UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.", UNIT(s)->id);
service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, false);
}
break;
case SERVICE_FINAL_SIGKILL:
- log_warning_unit(UNIT(s)->id,
- "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id);
+ log_warning_unit(UNIT(s)->id, "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id);
service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, true);
break;
@@ -2551,10 +2490,9 @@ static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void
assert(s);
assert(source == s->watchdog_event_source);
- log_error_unit(UNIT(s)->id,
- "%s watchdog timeout (limit %s)!",
- UNIT(s)->id,
+ log_error_unit(UNIT(s)->id, "%s watchdog timeout (limit %s)!", UNIT(s)->id,
format_timespan(t, sizeof(t), s->watchdog_usec, 1));
+
service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_WATCHDOG);
return 0;
@@ -2571,9 +2509,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
u->id, pid, tags && *tags ? tags[0] : "(empty)");
if (s->notify_access == NOTIFY_NONE) {
- log_warning_unit(u->id,
- "%s: Got notification message from PID "PID_FMT", but reception is disabled.",
- u->id, pid);
+ log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid);
return;
}
@@ -2693,17 +2629,11 @@ static void service_bus_name_owner_change(
assert(old_owner || new_owner);
if (old_owner && new_owner)
- log_debug_unit(u->id,
- "%s's D-Bus name %s changed owner from %s to %s",
- u->id, name, old_owner, new_owner);
+ log_debug_unit(u->id, "%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner);
else if (old_owner)
- log_debug_unit(u->id,
- "%s's D-Bus name %s no longer registered by %s",
- u->id, name, old_owner);
+ log_debug_unit(u->id, "%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner);
else
- log_debug_unit(u->id,
- "%s's D-Bus name %s now registered by %s",
- u->id, name, new_owner);
+ log_debug_unit(u->id, "%s's D-Bus name %s now registered by %s", u->id, name, new_owner);
s->bus_name_good = !!new_owner;

View File

@ -1,30 +0,0 @@
From f49650cee2c5256dc0491432e1f12a4ae19be6c5 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:20:17 +0200
Subject: [PATCH] service: don't invoke functions at the same time as declaring
variables
---
src/core/service.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index f10582d89e..fc952e848f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -694,9 +694,13 @@ static void service_set_state(Service *s, ServiceState state) {
/* For remain_after_exit services, let's see if we can "release" the
* hold on the console, since unit_notify() only does that in case of
* change of state */
- if (state == SERVICE_EXITED && s->remain_after_exit &&
+ if (state == SERVICE_EXITED &&
+ s->remain_after_exit &&
UNIT(s)->manager->n_on_console > 0) {
- ExecContext *ec = unit_get_exec_context(UNIT(s));
+
+ ExecContext *ec;
+
+ ec = unit_get_exec_context(UNIT(s));
if (ec && exec_context_may_touch_console(ec)) {
Manager *m = UNIT(s)->manager;

View File

@ -1,139 +0,0 @@
From 28849dbadb7cd127f7f89e8892ec94c6a05070da Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:22:34 +0200
Subject: [PATCH] service,strv: introduce strv_find_startswith() and make use
of it
Unlike strv_find_prefix() the new call will return a pointer to the
suffix of the item we found, instead of the whole item. This is more
closer inline with what startswith() does, and allows us to simplify a
couple of invocations.
---
src/core/service.c | 44 +++++++++++++++++++++-----------------------
src/shared/strv.c | 17 +++++++++++++++++
src/shared/strv.h | 1 +
3 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index fc952e848f..262a40cc8b 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2526,12 +2526,13 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
}
/* Interpret MAINPID= */
- e = strv_find_prefix(tags, "MAINPID=");
+ e = strv_find_startswith(tags, "MAINPID=");
if (e && IN_SET(s->state, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD)) {
- if (parse_pid(e + 8, &pid) < 0)
+ if (parse_pid(e, &pid) < 0)
log_warning_unit(u->id, "Failed to parse MAINPID= field in notification message: %s", e);
else {
- log_debug_unit(u->id, "%s: got %s", u->id, e);
+ log_debug_unit(u->id, "%s: got MAINPID=%s", u->id, e);
+
service_set_main_pid(s, pid);
unit_watch_pid(UNIT(s), pid);
notify_dbus = true;
@@ -2546,44 +2547,41 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
}
/* Interpret STATUS= */
- e = strv_find_prefix(tags, "STATUS=");
+ e = strv_find_startswith(tags, "STATUS=");
if (e) {
- char *t;
+ _cleanup_free_ char *t = NULL;
- if (e[7]) {
- if (!utf8_is_valid(e+7)) {
+ if (!isempty(e)) {
+ if (!utf8_is_valid(e))
log_warning_unit(u->id, "Status message in notification is not UTF-8 clean.");
- return;
- }
+ else {
+ log_debug_unit(u->id, "%s: got STATUS=%s", u->id, e);
- log_debug_unit(u->id, "%s: got %s", u->id, e);
-
- t = strdup(e+7);
- if (!t) {
- log_oom();
- return;
+ t = strdup(e);
+ if (!t)
+ log_oom();
}
-
- } else
- t = NULL;
+ }
if (!streq_ptr(s->status_text, t)) {
+
free(s->status_text);
s->status_text = t;
+ t = NULL;
+
notify_dbus = true;
- } else
- free(t);
+ }
}
/* Interpret ERRNO= */
- e = strv_find_prefix(tags, "ERRNO=");
+ e = strv_find_startswith(tags, "ERRNO=");
if (e) {
int status_errno;
- if (safe_atoi(e + 6, &status_errno) < 0 || status_errno < 0)
+ if (safe_atoi(e, &status_errno) < 0 || status_errno < 0)
log_warning_unit(u->id, "Failed to parse ERRNO= field in notification message: %s", e);
else {
- log_debug_unit(u->id, "%s: got %s", u->id, e);
+ log_debug_unit(u->id, "%s: got ERRNO=%s", u->id, e);
if (s->status_errno != status_errno) {
s->status_errno = status_errno;
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 6448f3170f..0df978d23b 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -52,6 +52,23 @@ char *strv_find_prefix(char **l, const char *name) {
return NULL;
}
+char *strv_find_startswith(char **l, const char *name) {
+ char **i, *e;
+
+ assert(name);
+
+ /* Like strv_find_prefix, but actually returns only the
+ * suffix, not the whole item */
+
+ STRV_FOREACH(i, l) {
+ e = startswith(*i, name);
+ if (e)
+ return e;
+ }
+
+ return NULL;
+}
+
void strv_free(char **l) {
char **k;
diff --git a/src/shared/strv.h b/src/shared/strv.h
index ee55c148aa..9c9633c515 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -28,6 +28,7 @@
char *strv_find(char **l, const char *name) _pure_;
char *strv_find_prefix(char **l, const char *name) _pure_;
+char *strv_find_startswith(char **l, const char *name) _pure_;
void strv_free(char **l);
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);

View File

@ -1,30 +0,0 @@
From 55836941ff642d42403921fa9d5fd2f8376ae722 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:51:44 +0200
Subject: [PATCH] manager: reuse sockaddr_union instead of redefining our own
version of it
---
src/core/manager.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index 445461b6b9..e488aba5f8 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -527,13 +527,10 @@ static int manager_setup_notify(Manager *m) {
if (m->notify_fd < 0) {
_cleanup_close_ int fd = -1;
- union {
- struct sockaddr sa;
- struct sockaddr_un un;
- } sa = {
+ union sockaddr_union sa = {
.sa.sa_family = AF_UNIX,
};
- int one = 1;
+ static const int one = 1;
/* First free all secondary fields */
free(m->notify_socket);

View File

@ -1,99 +0,0 @@
From 70af4d17dafe81acc96f71f4ec06fbea7386bc38 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 16:52:41 +0200
Subject: [PATCH] manager: don#t dispatch sd_notify() messages and SIGCHLD
multiple times to the same units
---
src/core/manager.c | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index e488aba5f8..c91ece116f 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -562,7 +562,7 @@ static int manager_setup_notify(Manager *m) {
strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
if (r < 0) {
- log_error("bind(@%s) failed: %m", sa.un.sun_path+1);
+ log_error("bind(%s) failed: %m", sa.un.sun_path);
return -errno;
}
@@ -1398,7 +1398,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
.msg_controllen = sizeof(control),
};
struct ucred *ucred;
- Unit *u;
+ Unit *u1, *u2, *u3;
n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT);
if (n <= 0) {
@@ -1424,21 +1424,23 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
assert((size_t) n < sizeof(buf));
buf[n] = 0;
- u = manager_get_unit_by_pid(m, ucred->pid);
- if (u) {
- manager_invoke_notify_message(m, u, ucred->pid, buf, n);
+ /* Notify every unit that might be interested, but try
+ * to avoid notifying the same one multiple times. */
+ u1 = manager_get_unit_by_pid(m, ucred->pid);
+ if (u1) {
+ manager_invoke_notify_message(m, u1, ucred->pid, buf, n);
found = true;
}
- u = hashmap_get(m->watch_pids1, LONG_TO_PTR(ucred->pid));
- if (u) {
- manager_invoke_notify_message(m, u, ucred->pid, buf, n);
+ u2 = hashmap_get(m->watch_pids1, LONG_TO_PTR(ucred->pid));
+ if (u2 && u2 != u1) {
+ manager_invoke_notify_message(m, u2, ucred->pid, buf, n);
found = true;
}
- u = hashmap_get(m->watch_pids2, LONG_TO_PTR(ucred->pid));
- if (u) {
- manager_invoke_notify_message(m, u, ucred->pid, buf, n);
+ u3 = hashmap_get(m->watch_pids2, LONG_TO_PTR(ucred->pid));
+ if (u3 && u3 != u2 && u3 != u1) {
+ manager_invoke_notify_message(m, u3, ucred->pid, buf, n);
found = true;
}
@@ -1485,7 +1487,7 @@ static int manager_dispatch_sigchld(Manager *m) {
if (si.si_code == CLD_EXITED || si.si_code == CLD_KILLED || si.si_code == CLD_DUMPED) {
_cleanup_free_ char *name = NULL;
- Unit *u;
+ Unit *u1, *u2, *u3;
get_process_comm(si.si_pid, &name);
@@ -1499,15 +1501,15 @@ static int manager_dispatch_sigchld(Manager *m) {
/* And now figure out the unit this belongs
* to, it might be multiple... */
- u = manager_get_unit_by_pid(m, si.si_pid);
- if (u)
- invoke_sigchld_event(m, u, &si);
- u = hashmap_get(m->watch_pids1, LONG_TO_PTR(si.si_pid));
- if (u)
- invoke_sigchld_event(m, u, &si);
- u = hashmap_get(m->watch_pids2, LONG_TO_PTR(si.si_pid));
- if (u)
- invoke_sigchld_event(m, u, &si);
+ u1 = manager_get_unit_by_pid(m, si.si_pid);
+ if (u1)
+ invoke_sigchld_event(m, u1, &si);
+ u2 = hashmap_get(m->watch_pids1, LONG_TO_PTR(si.si_pid));
+ if (u2 && u2 != u1)
+ invoke_sigchld_event(m, u2, &si);
+ u3 = hashmap_get(m->watch_pids2, LONG_TO_PTR(si.si_pid));
+ if (u3 && u3 != u2 && u3 != u1)
+ invoke_sigchld_event(m, u3, &si);
}
/* And now, we actually reap the zombie. */

View File

@ -1,471 +0,0 @@
From 308d72dc1e2106f94ae637e2ea510e8d466d2af1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:03:15 +0200
Subject: [PATCH] core: allow informing systemd about service status changes
with RELOADING=1 and STOPPING=1 sd_notify() messages
---
man/sd_notify.xml | 93 ++++++++++++++++++++++++++++---------------
src/core/service.c | 105 +++++++++++++++++++++++++++++++++++++++++++------
src/core/service.h | 13 ++++++
src/test/test-daemon.c | 22 +++++++++--
4 files changed, 185 insertions(+), 48 deletions(-)
diff --git a/man/sd_notify.xml b/man/sd_notify.xml
index 6bf8230763..fbb882dfd2 100644
--- a/man/sd_notify.xml
+++ b/man/sd_notify.xml
@@ -46,7 +46,7 @@
<refnamediv>
<refname>sd_notify</refname>
<refname>sd_notifyf</refname>
- <refpurpose>Notify service manager about start-up completion and other daemon status changes</refpurpose>
+ <refpurpose>Notify service manager about start-up completion and other service status changes</refpurpose>
</refnamediv>
<refsynopsisdiv>
@@ -70,12 +70,12 @@
<refsect1>
<title>Description</title>
- <para><function>sd_notify()</function> shall be called
- by a daemon to notify the init system about status
- changes. It can be used to send arbitrary information,
- encoded in an environment-block-like string. Most
- importantly it can be used for start-up completion
- notification.</para>
+ <para><function>sd_notify()</function> may be called
+ by a service to notify the service manager about
+ state changes. It can be used to send arbitrary
+ information, encoded in an environment-block-like
+ string. Most importantly it can be used for start-up
+ completion notification.</para>
<para>If the <parameter>unset_environment</parameter>
parameter is non-zero, <function>sd_notify()</function>
@@ -99,58 +99,87 @@
<varlistentry>
<term>READY=1</term>
- <listitem><para>Tells the init system
- that daemon startup is finished. This
- is only used by systemd if the service
- definition file has Type=notify
- set. The passed argument is a boolean
- "1" or "0". Since there is little
+ <listitem><para>Tells the service
+ manager that service startup is
+ finished. This is only used by systemd
+ if the service definition file has
+ Type=notify set. Since there is little
value in signaling non-readiness, the
- only value daemons should send is
- "READY=1".</para></listitem>
+ only value services should send is
+ <literal>READY=1</literal>
+ (i.e. <literal>READY=0</literal> is
+ not defined).</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>RELOADING=1</term>
+
+ <listitem><para>Tells the service manager
+ that the service is reloading its
+ configuration. This is useful to allow
+ the service manager to track the service's
+ internal state, and present it to the
+ user. Note that a service that sends
+ this notification must also send a
+ <literal>READY=1</literal>
+ notification when it completed
+ reloading its
+ configuration.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>STOPPING=1</term>
+
+ <listitem><para>Tells the service manager
+ that the service is beginning its
+ shutdown. This is useful to allow the
+ service manager to track the service's
+ internal state, and present it to the
+ user.</para></listitem>
</varlistentry>
<varlistentry>
<term>STATUS=...</term>
<listitem><para>Passes a single-line
- status string back to the init system
- that describes the daemon state. This
+ UTF-8 status string back to the service manager
+ that describes the service state. This
is free-form and can be used for
various purposes: general state
feedback, fsck-like programs could
pass completion percentages and
failing programs could pass a human
readable error message. Example:
- "STATUS=Completed 66% of file system
- check..."</para></listitem>
+ <literal>STATUS=Completed 66% of file
+ system
+ check...</literal></para></listitem>
</varlistentry>
<varlistentry>
<term>ERRNO=...</term>
- <listitem><para>If a daemon fails, the
+ <listitem><para>If a service fails, the
errno-style error code, formatted as
- string. Example: "ERRNO=2" for
+ string. Example: <literal>ERRNO=2</literal> for
ENOENT.</para></listitem>
</varlistentry>
<varlistentry>
<term>BUSERROR=...</term>
- <listitem><para>If a daemon fails, the
+ <listitem><para>If a service fails, the
D-Bus error-style error code. Example:
- "BUSERROR=org.freedesktop.DBus.Error.TimedOut"</para></listitem>
+ <literal>BUSERROR=org.freedesktop.DBus.Error.TimedOut</literal></para></listitem>
</varlistentry>
<varlistentry>
<term>MAINPID=...</term>
<listitem><para>The main pid of the
- daemon, in case the init system did
+ service, in case the service manager did
not fork off the process
itself. Example:
- "MAINPID=4711"</para></listitem>
+ <literal>MAINPID=4711</literal></para></listitem>
</varlistentry>
<varlistentry>
@@ -183,7 +212,7 @@
clashes.</para>
<para>Note that systemd will accept status data sent
- from a daemon only if the
+ from a service only if the
<varname>NotifyAccess=</varname> option is correctly
set in the service definition file. See
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
@@ -222,7 +251,7 @@
<varname>$NOTIFY_SOCKET</varname> is <literal>@</literal>, the string is
understood as Linux abstract namespace socket. The
datagram is accompanied by the process credentials of
- the sending daemon, using SCM_CREDENTIALS.</para>
+ the sending service, using SCM_CREDENTIALS.</para>
</refsect1>
<refsect1>
@@ -232,7 +261,7 @@
<varlistentry>
<term><varname>$NOTIFY_SOCKET</varname></term>
- <listitem><para>Set by the init system
+ <listitem><para>Set by the service manager
for supervised processes for status
and start-up completion
notification. This environment variable
@@ -249,9 +278,9 @@
<example>
<title>Start-up Notification</title>
- <para>When a daemon finished starting up, it
+ <para>When a service finished starting up, it
might issue the following call to notify
- the init system:</para>
+ the service manager:</para>
<programlisting>sd_notify(0, "READY=1");</programlisting>
</example>
@@ -259,7 +288,7 @@
<example>
<title>Extended Start-up Notification</title>
- <para>A daemon could send the following after
+ <para>A service could send the following after
completing initialization:</para>
<programlisting>sd_notifyf(0, "READY=1\n"
@@ -271,7 +300,7 @@
<example>
<title>Error Cause Notification</title>
- <para>A daemon could send the following shortly before exiting, on failure</para>
+ <para>A service could send the following shortly before exiting, on failure</para>
<programlisting>sd_notifyf(0, "STATUS=Failed to start up: %s\n"
"ERRNO=%i",
diff --git a/src/core/service.c b/src/core/service.c
index 262a40cc8b..3221938793 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -92,6 +92,7 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void *userdata);
static void service_enter_signal(Service *s, ServiceState state, ServiceResult f);
+static void service_enter_reload_by_notify(Service *s);
static void service_init(Unit *u) {
Service *s = SERVICE(u);
@@ -473,7 +474,8 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
"%sGuessMainPID: %s\n"
"%sType: %s\n"
"%sRestart: %s\n"
- "%sNotifyAccess: %s\n",
+ "%sNotifyAccess: %s\n"
+ "%sNotifyState: %s\n",
prefix, service_state_to_string(s->state),
prefix, service_result_to_string(s->result),
prefix, service_result_to_string(s->reload_result),
@@ -483,7 +485,8 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
prefix, yes_no(s->guess_main_pid),
prefix, service_type_to_string(s->type),
prefix, service_restart_to_string(s->restart),
- prefix, notify_access_to_string(s->notify_access));
+ prefix, notify_access_to_string(s->notify_access),
+ prefix, notify_state_to_string(s->notify_state));
if (s->control_pid > 0)
fprintf(f,
@@ -1176,6 +1179,17 @@ fail:
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, true);
}
+static void service_enter_stop_by_notify(Service *s) {
+ assert(s);
+
+ unit_watch_all_pids(UNIT(s));
+
+ if (s->timeout_stop_usec > 0)
+ service_arm_timer(s, s->timeout_stop_usec);
+
+ service_set_state(s, SERVICE_STOP);
+}
+
static void service_enter_stop(Service *s, ServiceResult f) {
int r;
@@ -1226,9 +1240,18 @@ static void service_enter_running(Service *s, ServiceResult f) {
cgroup_ok = cgroup_good(s);
if ((main_pid_ok > 0 || (main_pid_ok < 0 && cgroup_ok != 0)) &&
- (s->bus_name_good || s->type != SERVICE_DBUS))
- service_set_state(s, SERVICE_RUNNING);
- else if (s->remain_after_exit)
+ (s->bus_name_good || s->type != SERVICE_DBUS)) {
+
+ /* If there are any queued up sd_notify()
+ * notifications, process them now */
+ if (s->notify_state == NOTIFY_RELOADING)
+ service_enter_reload_by_notify(s);
+ else if (s->notify_state == NOTIFY_STOPPING)
+ service_enter_stop_by_notify(s);
+ else
+ service_set_state(s, SERVICE_RUNNING);
+
+ } else if (s->remain_after_exit)
service_set_state(s, SERVICE_EXITED);
else
service_enter_stop(s, SERVICE_SUCCESS);
@@ -1433,12 +1456,19 @@ static void service_enter_restart(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
- "%s failed to schedule restart job: %s",
- UNIT(s)->id, bus_error_message(&error, -r));
+ log_warning_unit(UNIT(s)->id, "%s failed to schedule restart job: %s", UNIT(s)->id, bus_error_message(&error, -r));
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false);
}
+static void service_enter_reload_by_notify(Service *s) {
+ assert(s);
+
+ if (s->timeout_start_usec > 0)
+ service_arm_timer(s, s->timeout_start_usec);
+
+ service_set_state(s, SERVICE_RELOAD);
+}
+
static void service_enter_reload(Service *s) {
int r;
@@ -1667,6 +1697,8 @@ static int service_start(Unit *u) {
s->status_text = NULL;
s->status_errno = 0;
+ s->notify_state = NOTIFY_UNKNOWN;
+
service_enter_start_pre(s);
return 0;
}
@@ -2504,13 +2536,15 @@ static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void
static void service_notify_message(Unit *u, pid_t pid, char **tags) {
Service *s = SERVICE(u);
- const char *e;
+ _cleanup_free_ char *cc = NULL;
bool notify_dbus = false;
+ const char *e;
assert(u);
- log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s...)",
- u->id, pid, tags && *tags ? tags[0] : "(empty)");
+ cc = strv_join(tags, ", ");
+ log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s)",
+ u->id, pid, isempty(cc) ? "n/a" : cc);
if (s->notify_access == NOTIFY_NONE) {
log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid);
@@ -2539,10 +2573,46 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
}
}
+ /* Interpret RELOADING= */
+ if (strv_find(tags, "RELOADING=1")) {
+
+ log_debug_unit(u->id, "%s: got RELOADING=1", u->id);
+ s->notify_state = NOTIFY_RELOADING;
+
+ if (s->state == SERVICE_RUNNING)
+ service_enter_reload_by_notify(s);
+
+ notify_dbus = true;
+ }
+
/* Interpret READY= */
- if (s->type == SERVICE_NOTIFY && s->state == SERVICE_START && strv_find(tags, "READY=1")) {
+ if (strv_find(tags, "READY=1")) {
+
log_debug_unit(u->id, "%s: got READY=1", u->id);
- service_enter_start_post(s);
+ s->notify_state = NOTIFY_READY;
+
+ /* Type=notify services inform us about completed
+ * initialization with READY=1 */
+ if (s->type == SERVICE_NOTIFY && s->state == SERVICE_START)
+ service_enter_start_post(s);
+
+ /* Sending READY=1 while we are reloading informs us
+ * that the reloading is complete */
+ if (s->state == SERVICE_RELOAD && s->control_pid == 0)
+ service_enter_running(s, SERVICE_SUCCESS);
+
+ notify_dbus = true;
+ }
+
+ /* Interpret STOPPING= */
+ if (strv_find(tags, "STOPPING=1")) {
+
+ log_debug_unit(u->id, "%s: got STOPPING=1", u->id);
+ s->notify_state = NOTIFY_STOPPING;
+
+ if (s->state == SERVICE_RUNNING)
+ service_enter_stop_by_notify(s);
+
notify_dbus = true;
}
@@ -2798,6 +2868,15 @@ static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
+static const char* const notify_state_table[_NOTIFY_STATE_MAX] = {
+ [NOTIFY_UNKNOWN] = "unknown",
+ [NOTIFY_READY] = "ready",
+ [NOTIFY_RELOADING] = "reloading",
+ [NOTIFY_STOPPING] = "stopping",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(notify_state, NotifyState);
+
static const char* const service_result_table[_SERVICE_RESULT_MAX] = {
[SERVICE_SUCCESS] = "success",
[SERVICE_FAILURE_RESOURCES] = "resources",
diff --git a/src/core/service.h b/src/core/service.h
index 686cf4b0bd..0227321d99 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -91,6 +91,15 @@ typedef enum NotifyAccess {
_NOTIFY_ACCESS_INVALID = -1
} NotifyAccess;
+typedef enum NotifyState {
+ NOTIFY_UNKNOWN,
+ NOTIFY_READY,
+ NOTIFY_RELOADING,
+ NOTIFY_STOPPING,
+ _NOTIFY_STATE_MAX,
+ _NOTIFY_STATE_INVALID = -1
+} NotifyState;
+
typedef enum ServiceResult {
SERVICE_SUCCESS,
SERVICE_FAILURE_RESOURCES,
@@ -196,6 +205,7 @@ struct Service {
PathSpec *pid_file_pathspec;
NotifyAccess notify_access;
+ NotifyState notify_state;
};
extern const UnitVTable service_vtable;
@@ -219,6 +229,9 @@ ServiceExecCommand service_exec_command_from_string(const char *s) _pure_;
const char* notify_access_to_string(NotifyAccess i) _const_;
NotifyAccess notify_access_from_string(const char *s) _pure_;
+const char* notify_state_to_string(NotifyState i) _const_;
+NotifyState notify_state_from_string(const char *s) _pure_;
+
const char* service_result_to_string(ServiceResult i) _const_;
ServiceResult service_result_from_string(const char *s) _pure_;
diff --git a/src/test/test-daemon.c b/src/test/test-daemon.c
index bcc049b325..7e0ac754d1 100644
--- a/src/test/test-daemon.c
+++ b/src/test/test-daemon.c
@@ -25,13 +25,29 @@
int main(int argc, char*argv[]) {
- sd_notify(0, "STATUS=Starting up");
+ sd_notify(0,
+ "STATUS=Starting up");
+ sleep(5);
+
+ sd_notify(0,
+ "STATUS=Running\n"
+ "READY=1");
+ sleep(5);
+
+ sd_notify(0,
+ "STATUS=Reloading\n"
+ "RELOADING=1");
sleep(5);
+
sd_notify(0,
"STATUS=Running\n"
"READY=1");
- sleep(10);
- sd_notify(0, "STATUS=Quitting");
+ sleep(5);
+
+ sd_notify(0,
+ "STATUS=Quitting\n"
+ "STOPPING=1");
+ sleep(5);
return 0;
}

View File

@ -1,236 +0,0 @@
From af4ec4309e8f82aad87a8d574785c12f8763d5f8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:19:28 +0200
Subject: [PATCH] notify: send STOPPING=1 from our daemons
---
src/bus-proxyd/bus-proxyd.c | 6 +++++-
src/core/manager.c | 3 ++-
src/initctl/initctl.c | 1 +
src/journal-remote/journal-remote.c | 6 ++++--
src/journal-remote/journal-upload.c | 5 ++++-
src/journal/journald.c | 4 +++-
src/login/logind.c | 1 +
src/machine/machined.c | 1 +
src/network/networkd.c | 1 +
src/nspawn/nspawn.c | 8 +++++++-
src/resolve/resolved.c | 4 +++-
src/shutdownd/shutdownd.c | 1 +
src/timesync/timesyncd.c | 8 ++++++--
13 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index d8d989b9b0..d35d7f63b2 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -239,7 +239,7 @@ static int rename_service(sd_bus *a, sd_bus *b) {
pid, p,
uid, name,
a->unique_name);
- ;
+
return 0;
}
@@ -1474,6 +1474,10 @@ int main(int argc, char *argv[]) {
}
finish:
+ sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down.");
+
policy_free(&policy);
strv_free(arg_configuration);
free(arg_address);
diff --git a/src/core/manager.c b/src/core/manager.c
index c91ece116f..7401817844 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2551,7 +2551,8 @@ void manager_check_finished(Manager *m) {
bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec);
sd_notifyf(false,
- "READY=1\nSTATUS=Startup finished in %s.",
+ "READY=1\n"
+ "STATUS=Startup finished in %s.",
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC));
}
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index 0954e58afd..f1c2b8dfb4 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -431,6 +431,7 @@ int main(int argc, char *argv[]) {
fail:
sd_notify(false,
+ "STOPPING=1\n"
"STATUS=Shutting down...");
server_done(&server);
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 7f422bfb37..1cc86aeaf3 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -1530,10 +1530,12 @@ int main(int argc, char **argv) {
}
}
- server_destroy(&s);
+ sd_notifyf(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down after writing %" PRIu64 " entries...", s.event_count);
log_info("Finishing after writing %" PRIu64 " entries", s.event_count);
- sd_notify(false, "STATUS=Shutting down...");
+ server_destroy(&s);
free(arg_key);
free(arg_cert);
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index bdeeff6778..40c380aa9e 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -818,7 +818,10 @@ int main(int argc, char **argv) {
}
cleanup:
- sd_notify(false, "STATUS=Shutting down...");
+ sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down...");
+
destroy_uploader(&u);
finish:
diff --git a/src/journal/journald.c b/src/journal/journald.c
index b1a0e25d0c..de40827d6a 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -116,7 +116,9 @@ int main(int argc, char *argv[]) {
server_driver_message(&server, SD_MESSAGE_JOURNAL_STOP, "Journal stopped");
finish:
- sd_notify(false, "STATUS=Shutting down...");
+ sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down...");
server_done(&server);
diff --git a/src/login/logind.c b/src/login/logind.c
index 006c56ae51..52e1c43a47 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1226,6 +1226,7 @@ int main(int argc, char *argv[]) {
finish:
sd_notify(false,
+ "STOPPING=1\n"
"STATUS=Shutting down...");
if (m)
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 6160320127..f9d180d24a 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -350,6 +350,7 @@ int main(int argc, char *argv[]) {
finish:
sd_notify(false,
+ "STOPPING=1\n"
"STATUS=Shutting down...");
if (m)
diff --git a/src/network/networkd.c b/src/network/networkd.c
index 665f4c4709..fdb80368d4 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -125,6 +125,7 @@ int main(int argc, char *argv[]) {
out:
sd_notify(false,
+ "STOPPING=1\n"
"STATUS=Shutting down...");
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index d01da45930..2c718557ee 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3071,7 +3071,9 @@ int main(int argc, char *argv[]) {
goto finish;
}
- sd_notify(0, "READY=1");
+ sd_notify(false,
+ "READY=1\n"
+ "STATUS=Container running.");
assert_se(sigemptyset(&mask) == 0);
assert_se(sigemptyset(&mask_chld) == 0);
@@ -3504,6 +3506,10 @@ int main(int argc, char *argv[]) {
}
finish:
+ sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Terminating...");
+
loop_remove(loop_nr, &image_fd);
if (pid > 0)
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index 8235558585..88c3bcc591 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -100,7 +100,9 @@ int main(int argc, char *argv[]) {
sd_event_get_exit_code(m->event, &r);
finish:
- sd_notify(false, "STATUS=Shutting down...");
+ sd_notify(false,
+ "STOPPIN=1\n"
+ "STATUS=Shutting down...");
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index 92907497ed..99aa4b32b3 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -456,6 +456,7 @@ finish:
}
sd_notify(false,
+ "STOPPING=\n"
"STATUS=Exiting...");
return r;
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index 351bfd0236..ee3bc99ae0 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -132,7 +132,9 @@ int main(int argc, char *argv[]) {
log_warning("Failed to parse configuration file: %s", strerror(-r));
log_debug("systemd-timesyncd running as pid %lu", (unsigned long) getpid());
- sd_notify(false, "READY=1");
+ sd_notify(false,
+ "READY=1\n"
+ "STATUS=Daemon is running");
if (network_is_online()) {
r = manager_connect(m);
@@ -153,7 +155,9 @@ int main(int argc, char *argv[]) {
sd_event_get_exit_code(m->event, &r);
finish:
- sd_notify(false, "STATUS=Shutting down...");
+ sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down...");
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}

View File

@ -1,34 +0,0 @@
From 55cdcbacf70f05a40a155af24f6d2da6b478cba6 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:20:00 +0200
Subject: [PATCH] update TODO
---
TODO | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/TODO b/TODO
index cbd8384b4a..868518ab75 100644
--- a/TODO
+++ b/TODO
@@ -38,9 +38,6 @@ Features:
for "systemctl suspend" to finish to know when the suspending is
complete.
-* sd_notify("SHUTDOWN=1") to fix a dbus activation race.
- http://lists.freedesktop.org/archives/systemd-devel/2014-July/020983.html
-
* merge ~/.local/share and ~/.local/lib into one similar /usr/lib and /usr/share....
* make "systemctl suspend" block until we are back from suspend
@@ -603,9 +600,7 @@ Features:
* make sure systemd-ask-password-wall does not shutdown systemd-ask-password-console too early
-* support sd_notify() style notification when reload begins (RELOADING=1), reload is finished (READY=1), and add ReloadSignal= then to use in combination
-
-* support sd_notify() style notification when shutting down, to make auto-exit bus services work (STOPPING=1)
+* add ReloadSignal= for configuring a reload signal to use
* verify that the AF_UNIX sockets of a service in the fs still exist
when we start a service in order to avoid confusion when a user

View File

@ -1,49 +0,0 @@
From 430e21c2f7e77d600257ead56419f511e48e854a Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:20:19 +0200
Subject: [PATCH] bus: when terminating our bus-actviated services that
exit-on-idle send STOPPING=1 via sd_notify()
This should fix a race where a service thatis idle drops its name, and
is immediately requested by another client, which causes dbus-daemon to
ask systemd to activate it again, but since systemd still assumes it is
running it won't do anything.
---
src/libsystemd/sd-bus/bus-util.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 475ed34a53..c97bf7d99d 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -22,6 +22,8 @@
#include <sys/socket.h>
#include <sys/capability.h>
+#include "systemd/sd-daemon.h"
+
#include "util.h"
#include "strv.h"
#include "macro.h"
@@ -128,11 +130,17 @@ int bus_event_loop_with_idle(
if (r == -EBUSY)
continue;
+ /* Fallback for dbus1 connections: we
+ * unregister the name and wait for the
+ * response to come through for it */
if (r == -ENOTSUP) {
- /* Fallback for dbus1 connections: we
- * unregister the name and wait for
- * the response to come through for
- * it */
+
+ /* Inform the service manager that we
+ * are going down, so that it will
+ * queue all further start requests,
+ * instead of assuming we are already
+ * running. */
+ sd_notify(false, "STOPPING=1");
r = bus_async_unregister_and_exit(e, bus, name);
if (r < 0)

View File

@ -1,25 +0,0 @@
From f461c8073dee9cd10bfae5ae3586e785ec8a5d07 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:35:19 +0200
Subject: [PATCH] execute: explain in a comment, why close_all_fds() is invoked
the second time differently
---
src/core/execute.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/core/execute.c b/src/core/execute.c
index 2544a2470c..b5b22472d5 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1635,7 +1635,9 @@ int exec_spawn(ExecCommand *command,
}
/* We repeat the fd closing here, to make sure that
- * nothing is leaked from the PAM modules */
+ * nothing is leaked from the PAM modules. Note that
+ * we are more aggressive this time since socket_fd
+ * and the netns fds we don#t need anymore. */
err = close_all_fds(fds, n_fds);
if (err >= 0)
err = shift_fds(fds, n_fds);

View File

@ -1,106 +0,0 @@
From 21b2ce39d4038cd6176394836fdcfb7fba63f424 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 18:01:22 +0200
Subject: [PATCH] service: use the right timeout for stop processes we fork
---
src/core/service.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index 3221938793..7d6ea73e05 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -862,7 +862,7 @@ fail:
static int service_spawn(
Service *s,
ExecCommand *c,
- bool timeout,
+ usec_t timeout,
bool pass_fds,
bool apply_permissions,
bool apply_chroot,
@@ -907,8 +907,8 @@ static int service_spawn(
}
}
- if (timeout && s->timeout_start_usec > 0) {
- r = service_arm_timer(s, s->timeout_start_usec);
+ if (timeout > 0) {
+ r = service_arm_timer(s, timeout);
if (r < 0)
goto fail;
} else
@@ -1108,7 +1108,7 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
r = service_spawn(s,
s->control_command,
- true,
+ s->timeout_stop_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1207,7 +1207,7 @@ static void service_enter_stop(Service *s, ServiceResult f) {
r = service_spawn(s,
s->control_command,
- true,
+ s->timeout_stop_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1270,7 +1270,7 @@ static void service_enter_start_post(Service *s) {
r = service_spawn(s,
s->control_command,
- true,
+ s->timeout_start_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1334,8 +1334,7 @@ static void service_enter_start(Service *s) {
r = service_spawn(s,
c,
- s->type == SERVICE_FORKING || s->type == SERVICE_DBUS ||
- s->type == SERVICE_NOTIFY || s->type == SERVICE_ONESHOT,
+ IN_SET(s->type, SERVICE_FORKING, SERVICE_DBUS, SERVICE_NOTIFY, SERVICE_ONESHOT) ? s->timeout_start_usec : 0,
true,
true,
true,
@@ -1401,7 +1400,7 @@ static void service_enter_start_pre(Service *s) {
r = service_spawn(s,
s->control_command,
- true,
+ s->timeout_start_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1482,7 +1481,7 @@ static void service_enter_reload(Service *s) {
r = service_spawn(s,
s->control_command,
- true,
+ s->timeout_start_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1519,7 +1518,7 @@ static void service_run_next_control(Service *s) {
r = service_spawn(s,
s->control_command,
- true,
+ IN_SET(s->state, SERVICE_START_PRE, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD) ? s->timeout_start_usec : s->timeout_stop_usec,
false,
!s->permissions_start_only,
!s->root_directory_start_only,
@@ -1563,7 +1562,7 @@ static void service_run_next_main(Service *s) {
r = service_spawn(s,
s->main_command,
- true,
+ s->timeout_start_usec,
true,
true,
true,

View File

@ -1,22 +0,0 @@
From 1954ea346dc28226c0fffde848d49a297165b0a9 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 18:01:47 +0200
Subject: [PATCH] update TODO
---
TODO | 2 --
1 file changed, 2 deletions(-)
diff --git a/TODO b/TODO
index 868518ab75..16b61d045c 100644
--- a/TODO
+++ b/TODO
@@ -40,8 +40,6 @@ Features:
* merge ~/.local/share and ~/.local/lib into one similar /usr/lib and /usr/share....
-* make "systemctl suspend" block until we are back from suspend
-
* remove readahead in 217
* journald: allows specification of UID range for splitting up journal files

View File

@ -1,166 +0,0 @@
From 96fb8242cc1ef6b0e28f6c86a4f57950095dd7f1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 18:50:42 +0200
Subject: [PATCH] service: allow services of Type=oneshot that specify no
ExecStart= commands
This is useful for services that simply want to run something on
shutdown, but not at bootup. They should only set ExecStop= but leave
ExecStart= unset.
---
man/systemd.service.xml | 44 +++++++++++++++++++++++++++-----------------
src/core/service.c | 39 +++++++++++++++++++++++++++++----------
2 files changed, 56 insertions(+), 27 deletions(-)
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 5c4bd6569f..e584a1f006 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -139,9 +139,10 @@
<para>If set to
<option>simple</option> (the default
- value if neither
+ if neither
<varname>Type=</varname> nor
- <varname>BusName=</varname> are
+ <varname>BusName=</varname>, but
+ <varname>ExecStart=</varname> are
specified), it is expected that the
process configured with
<varname>ExecStart=</varname> is the
@@ -177,13 +178,17 @@
exits.</para>
<para>Behavior of
- <option>oneshot</option> is similar
- to <option>simple</option>; however,
- it is expected that the process has to
+ <option>oneshot</option> is similar to
+ <option>simple</option>; however, it
+ is expected that the process has to
exit before systemd starts follow-up
units. <varname>RemainAfterExit=</varname>
is particularly useful for this type
- of service.</para>
+ of service. This is the implied
+ default if neither
+ <varname>Type=</varname> or
+ <varname>ExecStart=</varname> are
+ specified.</para>
<para>Behavior of
<option>dbus</option> is similar to
@@ -313,22 +318,27 @@
<para>When <varname>Type</varname> is
not <option>oneshot</option>, only one
- command may be given. When
+ command may and must be given. When
<varname>Type=oneshot</varname> is
- used, more than one command may be
- specified. Multiple command lines may
- be concatenated in a single directive
- by separating them with semicolons
- (these semicolons must be passed as
- separate words). Alternatively, this
- directive may be specified more than
- once with the same effect.
- Lone semicolons may be escaped as
+ used, none or more than one command
+ may be specified. Multiple command
+ lines may be concatenated in a single
+ directive by separating them with
+ semicolons (these semicolons must be
+ passed as separate
+ words). Alternatively, this directive
+ may be specified more than once with
+ the same effect. Lone semicolons may
+ be escaped as
<literal>\;</literal>. If the empty
string is assigned to this option, the
list of commands to start is reset,
prior assignments of this option will
- have no effect.</para>
+ have no effect. If no
+ <varname>ExecStart=</varname> is
+ specified, then the service must have
+ <varname>RemainAfterExit=yes</varname>
+ set.</para>
<para>Each command line is split on
whitespace, with the first item being
diff --git a/src/core/service.c b/src/core/service.c
index 7d6ea73e05..1b864c4c8c 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -313,14 +313,23 @@ static int service_verify(Service *s) {
if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
- if (!s->exec_command[SERVICE_EXEC_START]) {
- log_error_unit(UNIT(s)->id, "%s lacks ExecStart setting. Refusing.", UNIT(s)->id);
+ if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]) {
+ log_error_unit(UNIT(s)->id, "%s lacks both ExecStart= and ExecStop= setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
- if (s->type != SERVICE_ONESHOT &&
- s->exec_command[SERVICE_EXEC_START]->command_next) {
- log_error_unit(UNIT(s)->id, "%s has more than one ExecStart setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) {
+ log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ return -EINVAL;
+ }
+
+ if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START]) {
+ log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.", UNIT(s)->id);
+ return -EINVAL;
+ }
+
+ if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) {
+ log_error_unit(UNIT(s)->id, "%s has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -410,8 +419,15 @@ static int service_load(Unit *u) {
if (r < 0)
return r;
- if (s->type == _SERVICE_TYPE_INVALID)
- s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE;
+ if (s->type == _SERVICE_TYPE_INVALID) {
+ /* Figure out a type automatically */
+ if (s->bus_name)
+ s->type = SERVICE_DBUS;
+ else if (s->exec_command[SERVICE_EXEC_START])
+ s->type = SERVICE_SIMPLE;
+ else
+ s->type = SERVICE_ONESHOT;
+ }
/* Oneshot services have disabled start timeout by default */
if (s->type == SERVICE_ONESHOT && !s->start_timeout_defined)
@@ -1309,9 +1325,6 @@ static void service_enter_start(Service *s) {
assert(s);
- assert(s->exec_command[SERVICE_EXEC_START]);
- assert(!s->exec_command[SERVICE_EXEC_START]->command_next || s->type == SERVICE_ONESHOT);
-
service_unwatch_control_pid(s);
service_unwatch_main_pid(s);
@@ -1332,6 +1345,12 @@ static void service_enter_start(Service *s) {
c = s->main_command = s->exec_command[SERVICE_EXEC_START];
}
+ if (!c) {
+ assert(s->type == SERVICE_ONESHOT);
+ service_enter_start_post(s);
+ return;
+ }
+
r = service_spawn(s,
c,
IN_SET(s->type, SERVICE_FORKING, SERVICE_DBUS, SERVICE_NOTIFY, SERVICE_ONESHOT) ? s->timeout_start_usec : 0,

View File

@ -1,126 +0,0 @@
From 59ccf93d97f0a37522e5f4fbf5cc0288dbedf495 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 19:08:30 +0200
Subject: [PATCH] install: simplify usage of _cleanup_ macros
---
src/shared/install.c | 27 +++++++++++++--------------
src/shared/path-lookup.h | 4 ++--
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index 03c7a9da2e..4b09a69456 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -45,8 +45,6 @@ typedef struct {
Hashmap *have_installed;
} InstallContext;
-#define _cleanup_install_context_done_ _cleanup_(install_context_done)
-
static int in_search_path(const char *path, char **search) {
_cleanup_free_ char *parent = NULL;
int r;
@@ -1161,7 +1159,7 @@ static int unit_file_can_install(
const char *name,
bool allow_symlink) {
- _cleanup_install_context_done_ InstallContext c = {};
+ _cleanup_(install_context_done) InstallContext c = {};
InstallInfo *i;
int r;
@@ -1498,7 +1496,7 @@ int unit_file_enable(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_install_context_done_ InstallContext c = {};
+ _cleanup_(install_context_done) InstallContext c = {};
char **i;
_cleanup_free_ char *config_path = NULL;
int r;
@@ -1537,7 +1535,7 @@ int unit_file_disable(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_install_context_done_ InstallContext c = {};
+ _cleanup_(install_context_done) InstallContext c = {};
char **i;
_cleanup_free_ char *config_path = NULL;
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
@@ -1597,7 +1595,7 @@ int unit_file_set_default(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_install_context_done_ InstallContext c = {};
+ _cleanup_(install_context_done) InstallContext c = {};
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
@@ -1859,7 +1857,7 @@ int unit_file_preset(
UnitFileChange **changes,
unsigned *n_changes) {
- _cleanup_install_context_done_ InstallContext plus = {}, minus = {};
+ _cleanup_(install_context_done) InstallContext plus = {}, minus = {};
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
@@ -1927,7 +1925,7 @@ int unit_file_preset_all(
UnitFileChange **changes,
unsigned *n_changes) {
- _cleanup_install_context_done_ InstallContext plus = {}, minus = {};
+ _cleanup_(install_context_done) InstallContext plus = {}, minus = {};
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
@@ -2019,14 +2017,15 @@ int unit_file_preset_all(
return r;
}
-static void unitfilelist_free(UnitFileList **f) {
- if (!*f)
+static void unit_file_list_free_one(UnitFileList *f) {
+ if (!f)
return;
- free((*f)->path);
- free(*f);
+ free(f->path);
+ free(f);
}
-#define _cleanup_unitfilelist_free_ _cleanup_(unitfilelist_free)
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(UnitFileList*, unit_file_list_free_one);
int unit_file_get_list(
UnitFileScope scope,
@@ -2071,7 +2070,7 @@ int unit_file_get_list(
}
for (;;) {
- _cleanup_unitfilelist_free_ UnitFileList *f = NULL;
+ _cleanup_(unit_file_list_free_onep) UnitFileList *f = NULL;
struct dirent *de;
errno = 0;
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 2fe8173f44..4bbd47ec39 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -38,8 +38,6 @@ typedef enum SystemdRunningAs {
_SYSTEMD_RUNNING_AS_INVALID = -1
} SystemdRunningAs;
-#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
-
int user_config_home(char **config_home);
int lookup_paths_init(LookupPaths *p,
@@ -50,3 +48,5 @@ int lookup_paths_init(LookupPaths *p,
const char *generator_early,
const char *generator_late);
void lookup_paths_free(LookupPaths *p);
+
+#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)

View File

@ -1,46 +0,0 @@
From 4fe1be9ce2e0cca6354a4167f0a1a7e1f943c91c Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 19:10:26 +0200
Subject: [PATCH] systemctl: in list-unit-files, always show legend, even if we
know about no unit files
---
src/systemctl/systemctl.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 072f615ad5..d9b8bee28d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1351,11 +1351,8 @@ static int list_unit_files(sd_bus *bus, char **args) {
n_units = hashmap_size(h);
- if (n_units == 0)
- return 0;
-
units = new(UnitFileList, n_units);
- if (!units) {
+ if (!units && n_units > 0) {
unit_file_list_free(h);
return log_oom();
}
@@ -1411,14 +1408,13 @@ static int list_unit_files(sd_bus *bus, char **args) {
return bus_log_parse_error(r);
}
- if (c > 0) {
- qsort(units, c, sizeof(UnitFileList), compare_unit_file_list);
- output_unit_file_list(units, c);
- }
+ qsort_safe(units, c, sizeof(UnitFileList), compare_unit_file_list);
+ output_unit_file_list(units, c);
- if (avoid_bus())
+ if (avoid_bus()) {
for (unit = units; unit < units + c; unit++)
free(unit->path);
+ }
return 0;
}

View File

@ -1,24 +0,0 @@
From 337ce7442a0602116c6253ebf202bd34f675f627 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 19:12:43 +0200
Subject: [PATCH] update TODO
---
TODO | 4 ----
1 file changed, 4 deletions(-)
diff --git a/TODO b/TODO
index 16b61d045c..3073f3a5a2 100644
--- a/TODO
+++ b/TODO
@@ -521,10 +521,6 @@ Features:
* properly handle loop back mounts via fstab, especially regards to fsck/passno
-* allow services with no ExecStart= but with an ExecStop=
-
-* dracut-shutdown needs to be ordered before unmounting /boot
-
* initialize the hostname from the fs label of /, if /etc/hostname does not exist?
* rename "userspace" to "core-os"

View File

@ -1,59 +0,0 @@
From 0975b63fb31263e535a2d26ed41e66e23f468bc5 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 12:44:17 +0200
Subject: [PATCH] dbus1-generator: properly free the FILE*
Also, rework the code to make use of fflush_and_check().
Issue discovered by Simon Danner.
---
src/dbus1-generator/dbus1-generator.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index e1ffc5515f..3c4522b589 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -40,6 +40,7 @@ static int create_dbus_files(
_cleanup_free_ char *b = NULL, *s = NULL, *lnk = NULL;
_cleanup_fclose_ FILE *f = NULL;
+ int r;
assert(path);
assert(name);
@@ -100,12 +101,15 @@ static int create_dbus_files(
}
}
- fflush(f);
- if (ferror(f)) {
- log_error("Failed to write %s: %m", a);
- return -errno;
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error("Failed to write %s: %s", a, strerror(-r));
+ return r;
}
+ fclose(f);
+ f = NULL;
+
service = s;
}
@@ -134,10 +138,10 @@ static int create_dbus_files(
name,
service);
- fflush(f);
- if (ferror(f)) {
- log_error("Failed to write %s: %m", b);
- return -errno;
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error("Failed to write %s: %s", b, strerror(-r));
+ return r;
}
lnk = strjoin(arg_dest_late, "/" SPECIAL_BUSNAMES_TARGET ".wants/", name, ".busname", NULL);

View File

@ -1,75 +0,0 @@
From 40a1eebde6be7ac3f1885147fc24e06ad1da260c Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 22 Aug 2014 13:55:57 +0200
Subject: [PATCH] shared: add MAXSIZE() and use it in resolved
The MAXSIZE() macro takes two types and returns the size of the larger
one. It is much simpler to use than MAX(sizeof(A), sizeof(B)) and also
avoids any compiler-extensions, unlike CONST_MAX() and MAX() (which are
needed to avoid evaluating arguments more than once). This was suggested
by Daniele Nicolodi <daniele@grinta.net>.
Also make resolved use this macro instead of CONST_MAX(). This enhances
readability quite a bit.
---
src/resolve/resolved-dns-stream.c | 2 +-
src/resolve/resolved-manager.c | 2 +-
src/shared/macro.h | 3 +++
src/test/test-util.c | 4 ++++
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
index 8b3a3ced4b..8aad5e4df1 100644
--- a/src/resolve/resolved-dns-stream.c
+++ b/src/resolve/resolved-dns-stream.c
@@ -64,7 +64,7 @@ static int dns_stream_complete(DnsStream *s, int error) {
static int dns_stream_identify(DnsStream *s) {
union {
struct cmsghdr header; /* For alignment */
- uint8_t buffer[CMSG_SPACE(CONST_MAX(sizeof(struct in_pktinfo), sizeof(struct in6_pktinfo)))
+ uint8_t buffer[CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
+ EXTRA_CMSG_SPACE /* kernel appears to require extra space */];
} control;
struct msghdr mh = {};
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 56baf8730d..659b1dacc8 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -841,7 +841,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
union {
struct cmsghdr header; /* For alignment */
- uint8_t buffer[CMSG_SPACE(CONST_MAX(sizeof(struct in_pktinfo), sizeof(struct in6_pktinfo)))
+ uint8_t buffer[CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
+ CMSG_SPACE(int) /* ttl/hoplimit */
+ EXTRA_CMSG_SPACE /* kernel appears to require extra buffer space */];
} control;
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 179b24c983..43fa3e556f 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -149,6 +149,9 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
((_A) > (_B)) ? (_A) : (_B), \
(void)0))
+/* takes two types and returns the size of the larger one */
+#define MAXSIZE(A, B) (sizeof(union _packed_ { typeof(A) a; typeof(B) b; }))
+
#define MAX3(x,y,z) \
__extension__ ({ \
const typeof(x) _c = MAX(x,y); \
diff --git a/src/test/test-util.c b/src/test/test-util.c
index ac1afce86b..34d5f2ed7d 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -90,6 +90,10 @@ static void test_max(void) {
assert_se(val1.a == 100);
assert_se(MAX(++d, 0) == 1);
assert_se(d == 1);
+
+ assert_cc(MAXSIZE(char[3], uint16_t) == 3);
+ assert_cc(MAXSIZE(char[3], uint32_t) == 4);
+ assert_cc(MAXSIZE(char, long) == sizeof(long));
}
static void test_first_word(void) {

View File

@ -1,25 +0,0 @@
From a7d611f280b3eadafd6b411b659a321b4d6e63f4 Mon Sep 17 00:00:00 2001
From: Daniel Mack <zonque@gmail.com>
Date: Fri, 22 Aug 2014 15:39:36 +0200
Subject: [PATCH] missing.h: add fake __NR_memfd_create for MIPS
We don't have the correct __NR_memfd_create syscall number yet, so set it to
0xffffffff for now to prevent compile time errors.
---
src/shared/missing.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 3ff1a21720..3051cb5640 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -167,6 +167,9 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
# define __NR_fanotify_mark 5296
# endif
# endif
+# ifndef __NR_memfd_create
+# define __NR_memfd_create 0xffffffff /* FIXME */
+# endif
#else
# ifndef __NR_fanotify_init
# define __NR_fanotify_init 338

View File

@ -1,23 +0,0 @@
From 2de1851fe3611c59abf77127c6b5bc1b91eb7cba Mon Sep 17 00:00:00 2001
From: Daniel Mack <zonque@gmail.com>
Date: Fri, 22 Aug 2014 16:10:02 +0200
Subject: [PATCH] missing.h: add a cpp warning for __NR_memfd_create on MIPS
---
src/shared/missing.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 3051cb5640..a9dd274274 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -168,7 +168,8 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
# endif
# endif
# ifndef __NR_memfd_create
-# define __NR_memfd_create 0xffffffff /* FIXME */
+# warning "__NR_memfd_create not yet defined for MIPS"
+# define __NR_memfd_create 0xffffffff
# endif
#else
# ifndef __NR_fanotify_init

View File

@ -1,704 +0,0 @@
From 2928b0a863091f8f291fddb168988711afd389ef Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 16:36:38 +0200
Subject: [PATCH] core: add support for a configurable system-wide start-up
timeout
When this system-wide start-up timeout is hit we execute one of the
failure actions already implemented for services that fail.
This should not only be useful on embedded devices, but also on laptops
which have the power-button reachable when the lid is closed. This
devices, when in a backpack might get powered on by accident due to the
easily reachable power button. We want to make sure that the system
turns itself off if it starts up due this after a while.
When the system manages to fully start-up logind will suspend the
machine by default if the lid is closed. However, in some cases we don't
even get as far as logind, and the boot hangs much earlier, for example
because we ask for a LUKS password that nobody ever enters.
Yeah, this is a real-life problem on my Yoga 13, which has one of those
easily accessible power buttons, even if the device is closed.
---
Makefile.am | 4 +-
man/systemd-system.conf.xml | 27 ++++++++++++-
man/systemd.service.xml | 23 +++++------
src/core/failure-action.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
src/core/failure-action.h | 40 +++++++++++++++++++
src/core/main.c | 13 +++++++
src/core/manager.c | 43 +++++++++++++++++++--
src/core/manager.h | 10 +++++
src/core/service.c | 77 ++++---------------------------------
src/core/service.h | 16 +-------
src/core/system.conf | 3 ++
src/shared/util.c | 21 ++++++++++
src/shared/util.h | 2 +
src/test/test-tables.c | 2 +-
14 files changed, 273 insertions(+), 102 deletions(-)
create mode 100644 src/core/failure-action.c
create mode 100644 src/core/failure-action.h
diff --git a/Makefile.am b/Makefile.am
index 4028112a62..cbf98bdac3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1112,7 +1112,9 @@ libsystemd_core_la_SOURCES = \
src/core/audit-fd.c \
src/core/audit-fd.h \
src/core/show-status.c \
- src/core/show-status.h
+ src/core/show-status.h \
+ src/core/failure-action.c \
+ src/core/failure-action.h
if HAVE_KMOD
libsystemd_core_la_SOURCES += \
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 6105c5131c..48690024f4 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -254,7 +254,6 @@
signal.</para></listitem>
</varlistentry>
-
<varlistentry>
<term><varname>TimerSlackNSec=</varname></term>
@@ -281,6 +280,32 @@
</varlistentry>
<varlistentry>
+ <term><varname>StartTimeoutSec=</varname></term>
+ <term><varname>StartTimeoutAction=</varname></term>
+ <term><varname>StartTimeoutRebootArgument=</varname></term>
+
+ <listitem><para>Configures an over-all
+ system start-up timeout and controls
+ what to do when the timeout is
+ reached. <varname>StartTimeoutSec=</varname>
+ specifies the timeout, and defaults to
+ <literal>15min</literal>. <varname>StartTimeoutAction=</varname>
+ configures the action to take when the
+ system did not finish boot-up within
+ the specified time. It takes the same
+ values as the per-service
+ <varname>StartLimitAction=</varname>
+ setting, see
+ <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ for details. Defaults to
+ <option>reboot-force</option>. <varname>StartTimeoutRebootArgument=</varname>
+ configures an optional reboot string
+ to pass to the
+ <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+ system call.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>DefaultTimerAccuracySec=</varname></term>
<listitem><para>Sets the default
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index e584a1f006..20d2a0d755 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -1155,29 +1155,30 @@ ExecStart=/bin/echo $ONE $TWO ${TWO}</programlisting>
</varlistentry>
<varlistentry>
+ <term><varname>FailureAction=</varname></term>
+ <listitem><para>Configure the action
+ to take when the service enters a failed
+ state. Takes the same values as
+ <varname>StartLimitAction=</varname>
+ and executes the same actions.
+ Defaults to <option>none</option>.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>RebootArgument=</varname></term>
<listitem><para>Configure the optional
argument for the
<citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
system call if
<varname>StartLimitAction=</varname>
+ or <varname>FailureAction=</varname>
is a reboot action. This works just
like the optional argument to
<command>systemctl reboot</command>
command.</para></listitem>
</varlistentry>
- <varlistentry>
- <term><varname>FailureAction=</varname></term>
- <listitem><para>Configure the action
- to take when the service enters a failed
- state. Takes the same values as
- <varname>StartLimitAction=</varname>
- and executes the same actions.
- Defaults to <option>none</option>.
- </para></listitem>
- </varlistentry>
-
</variablelist>
<para>Check
diff --git a/src/core/failure-action.c b/src/core/failure-action.c
new file mode 100644
index 0000000000..ca807b68da
--- /dev/null
+++ b/src/core/failure-action.c
@@ -0,0 +1,94 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Lennart Poettering
+ Copyright 2012 Michael Olbrich
+
+ 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/reboot.h>
+#include <linux/reboot.h>
+#include <sys/syscall.h>
+
+#include "bus-util.h"
+#include "bus-error.h"
+#include "special.h"
+#include "failure-action.h"
+
+int failure_action(
+ Manager *m,
+ FailureAction action,
+ const char *reboot_arg) {
+
+ int r;
+
+ assert(m);
+ assert(action >= 0);
+ assert(action < _FAILURE_ACTION_MAX);
+
+ switch (action) {
+
+ case FAILURE_ACTION_NONE:
+ break;
+
+ case FAILURE_ACTION_REBOOT: {
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+
+ log_warning("Rebooting as result of failure.");
+
+ update_reboot_param_file(reboot_arg);
+ r = manager_add_job_by_name(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
+ if (r < 0)
+ log_error("Failed to reboot: %s.", bus_error_message(&error, r));
+
+ break;
+ }
+
+ case FAILURE_ACTION_REBOOT_FORCE:
+ log_warning("Forcibly rebooting as result of failure.");
+ update_reboot_param_file(reboot_arg);
+ m->exit_code = MANAGER_REBOOT;
+ break;
+
+ case FAILURE_ACTION_REBOOT_IMMEDIATE:
+ log_warning("Rebooting immediately as result of failure.");
+
+ sync();
+
+ if (reboot_arg) {
+ log_info("Rebooting with argument '%s'.", reboot_arg);
+ syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, reboot_arg);
+ }
+
+ log_info("Rebooting.");
+ reboot(RB_AUTOBOOT);
+ break;
+
+ default:
+ assert_not_reached("Unknown failure action");
+ }
+
+ return -ECANCELED;
+}
+
+static const char* const failure_action_table[_FAILURE_ACTION_MAX] = {
+ [FAILURE_ACTION_NONE] = "none",
+ [FAILURE_ACTION_REBOOT] = "reboot",
+ [FAILURE_ACTION_REBOOT_FORCE] = "reboot-force",
+ [FAILURE_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate"
+};
+DEFINE_STRING_TABLE_LOOKUP(failure_action, FailureAction);
diff --git a/src/core/failure-action.h b/src/core/failure-action.h
new file mode 100644
index 0000000000..5353192f31
--- /dev/null
+++ b/src/core/failure-action.h
@@ -0,0 +1,40 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Lennart Poettering
+ Copyright 2012 Michael Olbrich
+
+ 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/>.
+***/
+
+typedef enum FailureAction {
+ FAILURE_ACTION_NONE,
+ FAILURE_ACTION_REBOOT,
+ FAILURE_ACTION_REBOOT_FORCE,
+ FAILURE_ACTION_REBOOT_IMMEDIATE,
+ _FAILURE_ACTION_MAX,
+ _FAILURE_ACTION_INVALID = -1
+} FailureAction;
+
+#include "macro.h"
+#include "manager.h"
+
+int failure_action(Manager *m, FailureAction action, const char *reboot_arg);
+
+const char* failure_action_to_string(FailureAction i) _const_;
+FailureAction failure_action_from_string(const char *s) _pure_;
diff --git a/src/core/main.c b/src/core/main.c
index 792b316c61..ed690162bf 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -116,6 +116,9 @@ static FILE* arg_serialization = NULL;
static bool arg_default_cpu_accounting = false;
static bool arg_default_blockio_accounting = false;
static bool arg_default_memory_accounting = false;
+static usec_t arg_start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
+static FailureAction arg_start_timeout_action = FAILURE_ACTION_REBOOT_FORCE;
+static char *arg_start_timeout_reboot_arg = NULL;
static void nop_handler(int sig) {}
@@ -669,6 +672,9 @@ static int parse_config_file(void) {
{ "Manager", "DefaultCPUAccounting", config_parse_bool, 0, &arg_default_cpu_accounting },
{ "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting },
{ "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting },
+ { "Manager", "StartTimeoutSec", config_parse_sec, 0, &arg_start_timeout_usec },
+ { "Manager", "StartTimeoutAction", config_parse_failure_action, 0, &arg_start_timeout_action },
+ { "Manager", "StartTimeoutRebootArgument",config_parse_string, 0, &arg_start_timeout_reboot_arg },
{}
};
@@ -1628,6 +1634,10 @@ int main(int argc, char *argv[]) {
m->default_memory_accounting = arg_default_memory_accounting;
m->runtime_watchdog = arg_runtime_watchdog;
m->shutdown_watchdog = arg_shutdown_watchdog;
+ m->start_timeout_usec = arg_start_timeout_usec;
+ m->start_timeout_action = arg_start_timeout_action;
+ free_and_strdup(&m->start_timeout_reboot_arg, arg_start_timeout_reboot_arg);
+
m->userspace_timestamp = userspace_timestamp;
m->kernel_timestamp = kernel_timestamp;
m->initrd_timestamp = initrd_timestamp;
@@ -1816,6 +1826,9 @@ finish:
set_free(arg_syscall_archs);
arg_syscall_archs = NULL;
+ free(arg_start_timeout_reboot_arg);
+ arg_start_timeout_reboot_arg = NULL;
+
label_finish();
if (reexecute) {
diff --git a/src/core/manager.c b/src/core/manager.c
index 7401817844..1bb0c9025f 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -435,6 +435,8 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
m->running_as = running_as;
m->exit_code = _MANAGER_EXIT_CODE_INVALID;
m->default_timer_accuracy_usec = USEC_PER_MINUTE;
+ m->start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
+ m->start_timeout_action = FAILURE_ACTION_REBOOT_FORCE;
m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1;
@@ -823,6 +825,9 @@ void manager_free(Manager *m) {
manager_close_idle_pipe(m);
+ sd_event_source_unref(m->start_timeout_event_source);
+ free(m->start_timeout_reboot_arg);
+
udev_unref(m->udev);
sd_event_unref(m->event);
@@ -970,6 +975,20 @@ static int manager_distribute_fds(Manager *m, FDSet *fds) {
return 0;
}
+static int on_start_timeout(sd_event_source *s, usec_t usec, void *userdata) {
+ Manager *m = userdata;
+
+ assert(s);
+ assert(m);
+
+ m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
+
+ log_error("Startup timed out.");
+
+ failure_action(m, m->start_timeout_action, m->start_timeout_reboot_arg);
+ return 0;
+}
+
int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
int r, q;
@@ -1042,6 +1061,22 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
m->send_reloading_done = true;
}
+ /* Possibly set up a start timeout */
+ if (!dual_timestamp_is_set(&m->finish_timestamp)) {
+ m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
+
+ if (m->start_timeout_usec) {
+ r = sd_event_add_time(
+ m->event,
+ &m->start_timeout_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + m->start_timeout_usec, 0,
+ on_start_timeout, m);
+ if (r < 0)
+ log_error("Failed to add start timeout event: %s", strerror(-r));
+ }
+ }
+
return r;
}
@@ -2462,10 +2497,8 @@ void manager_check_finished(Manager *m) {
if (hashmap_size(m->jobs) > 0) {
- if (m->jobs_in_progress_event_source) {
- sd_event_source_set_time(m->jobs_in_progress_event_source,
- now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC);
- }
+ if (m->jobs_in_progress_event_source)
+ sd_event_source_set_time(m->jobs_in_progress_event_source, now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC);
return;
}
@@ -2487,6 +2520,8 @@ void manager_check_finished(Manager *m) {
dual_timestamp_get(&m->finish_timestamp);
+ m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
+
if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) {
/* Note that m->kernel_usec.monotonic is always at 0,
diff --git a/src/core/manager.h b/src/core/manager.h
index 7cb76f7f00..7d26c3adea 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -33,6 +33,8 @@
/* Enforce upper limit how many names we allow */
#define MANAGER_MAX_NAMES 131072 /* 128K */
+#define DEFAULT_MANAGER_START_TIMEOUT_USEC (15*USEC_PER_MINUTE)
+
typedef struct Manager Manager;
typedef enum ManagerState {
@@ -69,6 +71,7 @@ typedef enum ManagerExitCode {
#include "unit-name.h"
#include "exit-status.h"
#include "show-status.h"
+#include "failure-action.h"
struct Manager {
/* Note that the set of units we know of is allowed to be
@@ -152,6 +155,7 @@ struct Manager {
dual_timestamp initrd_timestamp;
dual_timestamp userspace_timestamp;
dual_timestamp finish_timestamp;
+
dual_timestamp security_start_timestamp;
dual_timestamp security_finish_timestamp;
dual_timestamp generators_start_timestamp;
@@ -279,6 +283,12 @@ struct Manager {
/* Used for processing polkit authorization responses */
Hashmap *polkit_registry;
+
+ /* System wide startup timeouts */
+ usec_t start_timeout_usec;
+ sd_event_source *start_timeout_event_source;
+ FailureAction start_timeout_action;
+ char *start_timeout_reboot_arg;
};
int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m);
diff --git a/src/core/service.c b/src/core/service.c
index 1b864c4c8c..223e4b3a41 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -23,9 +23,6 @@
#include <signal.h>
#include <dirent.h>
#include <unistd.h>
-#include <sys/reboot.h>
-#include <linux/reboot.h>
-#include <sys/syscall.h>
#include "async.h"
#include "manager.h"
@@ -1052,8 +1049,6 @@ static int cgroup_good(Service *s) {
return !r;
}
-static int service_execute_action(Service *s, FailureAction action, const char *reason, bool log_action_none);
-
static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) {
int r;
assert(s);
@@ -1063,8 +1058,10 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD);
- if (s->result != SERVICE_SUCCESS)
- service_execute_action(s, s->failure_action, "failed", false);
+ if (s->result != SERVICE_SUCCESS) {
+ log_warning_unit(UNIT(s)->id, "%s failed.", UNIT(s)->id);
+ failure_action(UNIT(s)->manager, s->failure_action, s->reboot_arg);
+ }
if (allow_restart &&
!s->forbid_restart &&
@@ -1601,67 +1598,15 @@ fail:
service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
}
-static int service_execute_action(Service *s, FailureAction action, const char *reason, bool log_action_none) {
- assert(s);
-
- if (action == SERVICE_FAILURE_ACTION_REBOOT ||
- action == SERVICE_FAILURE_ACTION_REBOOT_FORCE)
- update_reboot_param_file(s->reboot_arg);
-
- switch (action) {
-
- case SERVICE_FAILURE_ACTION_NONE:
- if (log_action_none)
- log_warning_unit(UNIT(s)->id, "%s %s, refusing to start.", UNIT(s)->id, reason);
- break;
-
- case SERVICE_FAILURE_ACTION_REBOOT: {
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- int r;
-
- log_warning_unit(UNIT(s)->id, "%s %s, rebooting.", UNIT(s)->id, reason);
-
- r = manager_add_job_by_name(UNIT(s)->manager, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
- if (r < 0)
- log_error_unit(UNIT(s)->id, "Failed to reboot: %s.", bus_error_message(&error, r));
-
- break;
- }
-
- case SERVICE_FAILURE_ACTION_REBOOT_FORCE:
- log_warning_unit(UNIT(s)->id, "%s %s, forcibly rebooting.", UNIT(s)->id, reason);
- UNIT(s)->manager->exit_code = MANAGER_REBOOT;
- break;
-
- case SERVICE_FAILURE_ACTION_REBOOT_IMMEDIATE:
- log_warning_unit(UNIT(s)->id, "%s %s, rebooting immediately.", UNIT(s)->id, reason);
-
- sync();
-
- if (s->reboot_arg) {
- log_info("Rebooting with argument '%s'.", s->reboot_arg);
- syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, s->reboot_arg);
- }
-
- log_info("Rebooting.");
- reboot(RB_AUTOBOOT);
- break;
-
- default:
- log_error_unit(UNIT(s)->id, "failure action=%i", action);
- assert_not_reached("Unknown FailureAction.");
- }
-
- return -ECANCELED;
-}
-
static int service_start_limit_test(Service *s) {
assert(s);
if (ratelimit_test(&s->start_limit))
return 0;
- return service_execute_action(s, s->start_limit_action, "start request repeated too quickly", true);
+ log_warning_unit(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id);
+
+ return failure_action(UNIT(s)->manager, s->start_limit_action, s->reboot_arg);
}
static int service_start(Unit *u) {
@@ -2908,14 +2853,6 @@ static const char* const service_result_table[_SERVICE_RESULT_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(service_result, ServiceResult);
-static const char* const failure_action_table[_SERVICE_FAILURE_ACTION_MAX] = {
- [SERVICE_FAILURE_ACTION_NONE] = "none",
- [SERVICE_FAILURE_ACTION_REBOOT] = "reboot",
- [SERVICE_FAILURE_ACTION_REBOOT_FORCE] = "reboot-force",
- [SERVICE_FAILURE_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate"
-};
-DEFINE_STRING_TABLE_LOOKUP(failure_action, FailureAction);
-
const UnitVTable service_vtable = {
.object_size = sizeof(Service),
.exec_context_offset = offsetof(Service, exec_context),
diff --git a/src/core/service.h b/src/core/service.h
index 0227321d99..5bcfd14339 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -28,6 +28,7 @@ typedef struct Service Service;
#include "ratelimit.h"
#include "kill.h"
#include "exit-status.h"
+#include "failure-action.h"
typedef enum ServiceState {
SERVICE_DEAD,
@@ -113,15 +114,6 @@ typedef enum ServiceResult {
_SERVICE_RESULT_INVALID = -1
} ServiceResult;
-typedef enum FailureAction {
- SERVICE_FAILURE_ACTION_NONE,
- SERVICE_FAILURE_ACTION_REBOOT,
- SERVICE_FAILURE_ACTION_REBOOT_FORCE,
- SERVICE_FAILURE_ACTION_REBOOT_IMMEDIATE,
- _SERVICE_FAILURE_ACTION_MAX,
- _SERVICE_FAILURE_ACTION_INVALID = -1
-} FailureAction;
-
struct Service {
Unit meta;
@@ -193,10 +185,9 @@ struct Service {
char *status_text;
int status_errno;
- FailureAction failure_action;
-
RateLimit start_limit;
FailureAction start_limit_action;
+ FailureAction failure_action;
char *reboot_arg;
UnitRef accept_socket;
@@ -234,6 +225,3 @@ NotifyState notify_state_from_string(const char *s) _pure_;
const char* service_result_to_string(ServiceResult i) _const_;
ServiceResult service_result_from_string(const char *s) _pure_;
-
-const char* failure_action_to_string(FailureAction i) _const_;
-FailureAction failure_action_from_string(const char *s) _pure_;
diff --git a/src/core/system.conf b/src/core/system.conf
index 65a35a0689..45448de328 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -23,6 +23,9 @@
#CapabilityBoundingSet=
#SystemCallArchitectures=
#TimerSlackNSec=
+#StartTimeoutSec=15min
+#StartTimeoutAction=reboot-force
+#StartTimeoutRebootArgument=
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=journal
#DefaultStandardError=inherit
diff --git a/src/shared/util.c b/src/shared/util.c
index a54e879953..fc6f668726 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -7137,3 +7137,24 @@ int unquote_many_words(const char **p, ...) {
return c;
}
+
+int free_and_strdup(char **p, const char *s) {
+ char *t;
+
+ assert(p);
+
+ /* Replaces a string pointer with an strdup()ed new string,
+ * possibly freeing the old one. */
+
+ if (s) {
+ t = strdup(s);
+ if (!t)
+ return -ENOMEM;
+ } else
+ t = NULL;
+
+ free(*p);
+ *p = t;
+
+ return 0;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 8cd47b8294..cd947dbbef 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -978,3 +978,5 @@ int is_symlink(const char *path);
int unquote_first_word(const char **p, char **ret);
int unquote_many_words(const char **p, ...) _sentinel_;
+
+int free_and_strdup(char **p, const char *s);
diff --git a/src/test/test-tables.c b/src/test/test-tables.c
index 88e7d10c60..58fe4433b7 100644
--- a/src/test/test-tables.c
+++ b/src/test/test-tables.c
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
test_table(device_state, DEVICE_STATE);
test_table(exec_input, EXEC_INPUT);
test_table(exec_output, EXEC_OUTPUT);
- test_table(failure_action, SERVICE_FAILURE_ACTION);
+ test_table(failure_action, FAILURE_ACTION);
test_table(job_mode, JOB_MODE);
test_table(job_result, JOB_RESULT);
test_table(job_state, JOB_STATE);

View File

@ -1,85 +0,0 @@
From e12919e8be5c80efe09a57f642bbd2411b313ced Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 16:41:00 +0200
Subject: [PATCH] core: print 'startup finished' messages even if we log to
console
---
src/core/manager.c | 55 ++++++++++++++++++++++++++----------------------------
1 file changed, 26 insertions(+), 29 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index 1bb0c9025f..7508fefaef 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2539,44 +2539,41 @@ void manager_check_finished(Manager *m) {
kernel_usec = m->initrd_timestamp.monotonic - m->kernel_timestamp.monotonic;
initrd_usec = m->userspace_timestamp.monotonic - m->initrd_timestamp.monotonic;
- if (!log_on_console())
- log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
- "KERNEL_USEC="USEC_FMT, kernel_usec,
- "INITRD_USEC="USEC_FMT, initrd_usec,
- "USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
- format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
- format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
- format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
- format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
- NULL);
+ log_struct(LOG_INFO,
+ MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ "KERNEL_USEC="USEC_FMT, kernel_usec,
+ "INITRD_USEC="USEC_FMT, initrd_usec,
+ "USERSPACE_USEC="USEC_FMT, userspace_usec,
+ "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
+ format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
+ format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
+ format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
+ format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
+ NULL);
} else {
kernel_usec = m->userspace_timestamp.monotonic - m->kernel_timestamp.monotonic;
initrd_usec = 0;
- if (!log_on_console())
- log_struct(LOG_INFO,
- MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
- "KERNEL_USEC="USEC_FMT, kernel_usec,
- "USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
- format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
- format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
- format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
- NULL);
- }
- } else {
- firmware_usec = loader_usec = initrd_usec = kernel_usec = 0;
- total_usec = userspace_usec = m->finish_timestamp.monotonic - m->userspace_timestamp.monotonic;
-
- if (!log_on_console())
log_struct(LOG_INFO,
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ "KERNEL_USEC="USEC_FMT, kernel_usec,
"USERSPACE_USEC="USEC_FMT, userspace_usec,
- "MESSAGE=Startup finished in %s.",
+ "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
+ format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
+ format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
NULL);
+ }
+ } else {
+ firmware_usec = loader_usec = initrd_usec = kernel_usec = 0;
+ total_usec = userspace_usec = m->finish_timestamp.monotonic - m->userspace_timestamp.monotonic;
+
+ log_struct(LOG_INFO,
+ MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
+ "USERSPACE_USEC="USEC_FMT, userspace_usec,
+ "MESSAGE=Startup finished in %s.",
+ format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
+ NULL);
}
SET_FOREACH(u, m->startup_units, i)

View File

@ -1,22 +0,0 @@
From c4147df156835513c43260a14fc9f7af177f737f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 16:58:25 +0200
Subject: [PATCH] resolved: fix typo in log message
---
src/resolve/resolved-manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 659b1dacc8..f97989754d 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -449,7 +449,7 @@ static int manager_llmnr_start(Manager *m) {
return 0;
eaddrinuse:
- log_warning("There appears to be another LLMNR respondering running. Turning off LLMNR support.");
+ log_warning("There appears to be another LLMNR responder running. Turning off LLMNR support.");
m->llmnr_support = SUPPORT_NO;
manager_llmnr_stop(m);

View File

@ -1,219 +0,0 @@
From f07756bfe25c64119704c93a634162d6c88b5c89 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 16:59:46 +0200
Subject: [PATCH] core: introduce "poweroff" as new failure action types
Also, change the default action on a system start-up timeout to powering off.
---
man/systemd-system.conf.xml | 2 +-
man/systemd.service.xml | 31 +++++++++++++++++++-----------
src/core/failure-action.c | 46 +++++++++++++++++++++++++++++++++++++++++----
src/core/failure-action.h | 3 +++
src/core/main.c | 2 +-
src/core/manager.c | 2 +-
src/core/shutdown.c | 3 +--
src/core/system.conf | 2 +-
8 files changed, 70 insertions(+), 21 deletions(-)
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 48690024f4..1fad1dba80 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -298,7 +298,7 @@
setting, see
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for details. Defaults to
- <option>reboot-force</option>. <varname>StartTimeoutRebootArgument=</varname>
+ <option>poweroff-force</option>. <varname>StartTimeoutRebootArgument=</varname>
configures an optional reboot string
to pass to the
<citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 20d2a0d755..8b17f857ce 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -1131,26 +1131,35 @@ ExecStart=/bin/echo $ONE $TWO ${TWO}</programlisting>
hit. Takes one of
<option>none</option>,
<option>reboot</option>,
- <option>reboot-force</option>, or
- <option>reboot-immediate</option>. If
- <option>none</option> is set,
- hitting the rate limit will trigger no
- action besides that the start will not
- be permitted. <option>reboot</option>
+ <option>reboot-force</option>,
+ <option>reboot-immediate</option>,
+ <option>poweroff</option>,
+ <option>poweroff-force</option> or
+ <option>poweroff-immediate</option>. If
+ <option>none</option> is set, hitting
+ the rate limit will trigger no action
+ besides that the start will not be
+ permitted. <option>reboot</option>
causes a reboot following the normal
shutdown procedure (i.e. equivalent to
<command>systemctl reboot</command>).
- <option>reboot-force</option> causes
- a forced reboot which will terminate
- all processes forcibly but should
- cause no dirty file systems on reboot
+ <option>reboot-force</option> causes a
+ forced reboot which will terminate all
+ processes forcibly but should cause no
+ dirty file systems on reboot
(i.e. equivalent to <command>systemctl
reboot -f</command>) and
<option>reboot-immediate</option>
causes immediate execution of the
<citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
system call, which might result in
- data loss. Defaults to
+ data loss. Similar,
+ <option>poweroff</option>,
+ <option>poweroff-force</option>,
+ <option>poweroff-immediate</option>
+ have the effect of powering down the
+ system with similar
+ semantics. Defaults to
<option>none</option>.</para></listitem>
</varlistentry>
diff --git a/src/core/failure-action.c b/src/core/failure-action.c
index ca807b68da..941747429f 100644
--- a/src/core/failure-action.c
+++ b/src/core/failure-action.c
@@ -40,10 +40,19 @@ int failure_action(
assert(action >= 0);
assert(action < _FAILURE_ACTION_MAX);
- switch (action) {
+ if (action == FAILURE_ACTION_NONE)
+ return -ECANCELED;
- case FAILURE_ACTION_NONE:
- break;
+ if (m->running_as == SYSTEMD_USER) {
+ /* Downgrade all options to simply exiting if we run
+ * in user mode */
+
+ log_warning("Exiting as result of failure.");
+ m->exit_code = MANAGER_EXIT;
+ return -ECANCELED;
+ }
+
+ switch (action) {
case FAILURE_ACTION_REBOOT: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -78,6 +87,32 @@ int failure_action(
reboot(RB_AUTOBOOT);
break;
+ case FAILURE_ACTION_POWEROFF: {
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+
+ log_warning("Powering off as result of failure.");
+
+ r = manager_add_job_by_name(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE, true, &error, NULL);
+ if (r < 0)
+ log_error("Failed to poweroff: %s.", bus_error_message(&error, r));
+
+ break;
+ }
+
+ case FAILURE_ACTION_POWEROFF_FORCE:
+ log_warning("Forcibly powering off as result of failure.");
+ m->exit_code = MANAGER_POWEROFF;
+ break;
+
+ case FAILURE_ACTION_POWEROFF_IMMEDIATE:
+ log_warning("Powering off immediately as result of failure.");
+
+ sync();
+
+ log_info("Powering off.");
+ reboot(RB_POWER_OFF);
+ break;
+
default:
assert_not_reached("Unknown failure action");
}
@@ -89,6 +124,9 @@ static const char* const failure_action_table[_FAILURE_ACTION_MAX] = {
[FAILURE_ACTION_NONE] = "none",
[FAILURE_ACTION_REBOOT] = "reboot",
[FAILURE_ACTION_REBOOT_FORCE] = "reboot-force",
- [FAILURE_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate"
+ [FAILURE_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate",
+ [FAILURE_ACTION_POWEROFF] = "poweroff",
+ [FAILURE_ACTION_POWEROFF_FORCE] = "poweroff-force",
+ [FAILURE_ACTION_POWEROFF_IMMEDIATE] = "poweroff-immediate"
};
DEFINE_STRING_TABLE_LOOKUP(failure_action, FailureAction);
diff --git a/src/core/failure-action.h b/src/core/failure-action.h
index 5353192f31..1af4dd987b 100644
--- a/src/core/failure-action.h
+++ b/src/core/failure-action.h
@@ -27,6 +27,9 @@ typedef enum FailureAction {
FAILURE_ACTION_REBOOT,
FAILURE_ACTION_REBOOT_FORCE,
FAILURE_ACTION_REBOOT_IMMEDIATE,
+ FAILURE_ACTION_POWEROFF,
+ FAILURE_ACTION_POWEROFF_FORCE,
+ FAILURE_ACTION_POWEROFF_IMMEDIATE,
_FAILURE_ACTION_MAX,
_FAILURE_ACTION_INVALID = -1
} FailureAction;
diff --git a/src/core/main.c b/src/core/main.c
index ed690162bf..bd148b1b33 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -117,7 +117,7 @@ static bool arg_default_cpu_accounting = false;
static bool arg_default_blockio_accounting = false;
static bool arg_default_memory_accounting = false;
static usec_t arg_start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
-static FailureAction arg_start_timeout_action = FAILURE_ACTION_REBOOT_FORCE;
+static FailureAction arg_start_timeout_action = FAILURE_ACTION_POWEROFF_FORCE;
static char *arg_start_timeout_reboot_arg = NULL;
static void nop_handler(int sig) {}
diff --git a/src/core/manager.c b/src/core/manager.c
index 7508fefaef..7639aeef19 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -436,7 +436,7 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
m->exit_code = _MANAGER_EXIT_CODE_INVALID;
m->default_timer_accuracy_usec = USEC_PER_MINUTE;
m->start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
- m->start_timeout_action = FAILURE_ACTION_REBOOT_FORCE;
+ m->start_timeout_action = FAILURE_ACTION_POWEROFF_FORCE;
m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1;
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 1abc140e7d..0e2ea5754f 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -435,8 +435,7 @@ int main(int argc, char *argv[]) {
if (read_one_line_file(REBOOT_PARAM_FILE, &param) >= 0) {
log_info("Rebooting with argument '%s'.", param);
- syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
- LINUX_REBOOT_CMD_RESTART2, param);
+ syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, param);
}
}
diff --git a/src/core/system.conf b/src/core/system.conf
index 45448de328..5a723bb20e 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -24,7 +24,7 @@
#SystemCallArchitectures=
#TimerSlackNSec=
#StartTimeoutSec=15min
-#StartTimeoutAction=reboot-force
+#StartTimeoutAction=poweroff-force
#StartTimeoutRebootArgument=
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=journal

View File

@ -1,88 +0,0 @@
From d81afec1c9bf4b73e3df8996d65ecae95d19b6db Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 18:07:18 +0200
Subject: [PATCH] core: split up "starting" manager state into "initializing"
and "starting"
We'll stay in "initializing" until basic.target has reached, at which
point we will enter "starting".
This is preparation so that we can change the startip timeout to only
apply to the first phase of startup, not the full procedure.
---
src/core/cgroup.c | 4 ++--
src/core/manager.c | 11 +++++++++--
src/core/manager.h | 1 +
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 9248cb523b..6c6e4f5e7b 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -300,7 +300,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
char buf[MAX(DECIMAL_STR_MAX(unsigned long), DECIMAL_STR_MAX(usec_t)) + 1];
sprintf(buf, "%lu\n",
- state == MANAGER_STARTING && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
+ IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
c->cpu_shares != (unsigned long) -1 ? c->cpu_shares : 1024);
r = cg_set_attribute("cpu", path, "cpu.shares", buf);
if (r < 0)
@@ -328,7 +328,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
CGroupBlockIODeviceBandwidth *b;
if (!is_root) {
- sprintf(buf, "%lu\n", state == MANAGER_STARTING && c->startup_blockio_weight != (unsigned long) -1 ? c->startup_blockio_weight :
+ sprintf(buf, "%lu\n", IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_blockio_weight != (unsigned long) -1 ? c->startup_blockio_weight :
c->blockio_weight != (unsigned long) -1 ? c->blockio_weight : 1000);
r = cg_set_attribute("blkio", path, "blkio.weight", buf);
if (r < 0)
diff --git a/src/core/manager.c b/src/core/manager.c
index 7639aeef19..9abdf475cf 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2837,7 +2837,7 @@ static bool manager_get_show_status(Manager *m) {
if (m->no_console_output)
return false;
- if (!IN_SET(manager_state(m), MANAGER_STARTING, MANAGER_STOPPING))
+ if (!IN_SET(manager_state(m), MANAGER_INITIALIZING, MANAGER_STARTING, MANAGER_STOPPING))
return false;
if (m->show_status > 0)
@@ -2928,8 +2928,14 @@ ManagerState manager_state(Manager *m) {
assert(m);
/* Did we ever finish booting? If not then we are still starting up */
- if (!dual_timestamp_is_set(&m->finish_timestamp))
+ if (!dual_timestamp_is_set(&m->finish_timestamp)) {
+
+ u = manager_get_unit(m, SPECIAL_BASIC_TARGET);
+ if (!u || !UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u)))
+ return MANAGER_INITIALIZING;
+
return MANAGER_STARTING;
+ }
/* Is the special shutdown target queued? If so, we are in shutdown state */
u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET);
@@ -2955,6 +2961,7 @@ ManagerState manager_state(Manager *m) {
}
static const char *const manager_state_table[_MANAGER_STATE_MAX] = {
+ [MANAGER_INITIALIZING] = "initializing",
[MANAGER_STARTING] = "starting",
[MANAGER_RUNNING] = "running",
[MANAGER_DEGRADED] = "degraded",
diff --git a/src/core/manager.h b/src/core/manager.h
index 7d26c3adea..8e3c146b42 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -38,6 +38,7 @@
typedef struct Manager Manager;
typedef enum ManagerState {
+ MANAGER_INITIALIZING,
MANAGER_STARTING,
MANAGER_RUNNING,
MANAGER_DEGRADED,

View File

@ -1,32 +0,0 @@
From d74f9e8e8a3dcddb043ef193e4bb14f58efa095f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 22 Aug 2014 18:10:22 +0200
Subject: [PATCH] update TODO
---
TODO | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/TODO b/TODO
index 3073f3a5a2..0fcd3a0b8e 100644
--- a/TODO
+++ b/TODO
@@ -24,6 +24,9 @@ External:
Features:
+* apply start timeout during the "initializing" manager state only,
+ instead of both "initializing" and "starting".
+
* journald: make use of uid-range.h to managed uid ranges to split
journals in.
@@ -138,8 +141,6 @@ Features:
* For timer units: add some mechanisms so that timer units that trigger immediately on boot do not have the services
they run added to the initial transaction and thus confuse Type=idle.
-* Add timeout to early-boot, and shut down the system if it is hit. Solves the laptop-in-bag problem and is useful for embedded cases
-
* Run most system services with cgroupfs read-only and procfs with a more secure mode (doesn't work, since the hidepid= option is per-pid-namespace, not per-mount)
* sd-event: generate a failure of a default event loop is executed out-of-thread

View File

@ -1,27 +0,0 @@
From 41a451cc2901a5deb985aea4cc8de204a22e5612 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Mon, 25 Aug 2014 15:29:50 +0200
Subject: [PATCH] systemctl: fix broken list-unit-files with --root
This patch modifies unit_file_get_list which will now return
hashmap of structures where f->path is *without* root_dir prefix.
This change should be ok, because current code either does not use
root_dir at all or calls basename() on the f->path.
---
src/shared/install.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index 4b09a69456..a07d1dd315 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2099,7 +2099,7 @@ int unit_file_get_list(
if (!f)
return -ENOMEM;
- f->path = path_make_absolute(de->d_name, units_dir);
+ f->path = path_make_absolute(de->d_name, *i);
if (!f->path)
return -ENOMEM;

View File

@ -1,244 +0,0 @@
From c45a5a74465a39280b855f9d720b2ab4779a47fa Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Fri, 15 Aug 2014 18:49:29 +0200
Subject: [PATCH] sd-event: split run into prepare/wait/dispatch
This will allow sd-event to be integrated into an external event loop, which
in turn will allow (say) glib-based applications to use our various libraries,
without manually integrating each of them (bus, rtnl, dhcp, ...).
The external event-loop should integrate sd-event int he following way:
Every iteration must start with a call to sd_event_prepare(), which will
return 0 if no event sources are ready to be processed, a positive value if
they are and a negative value on error. sd_event_prepare() may only be called
following sd_event_dispatch(); a call to sd_event_wait() indicating that no
sources are ready to be dispatched; or a failed call to sd_event_dispatch() or
sd_event_wait().
A successful call to sd_event_prepare() indicating that no event sources are
ready to be dispatched must be followed by a call to sd_event_wait(),
which will return 0 if it timed out without event sources being ready to
be processed, a negative value on error and a positive value otherwise.
sd_event_wait() may only be called following a successful call to
sd_event_prepare() indicating that no event sources are ready to be dispatched.
If sd_event_wait() indicates that some events sources are ready to be
dispatched, it must be followed by a call to sd_event_dispatch(). This
is the only time sd_event_dispatch() may be called.
---
src/libsystemd/sd-event/sd-event.c | 122 +++++++++++++++++++++++++++++--------
src/systemd/sd-event.h | 5 ++
2 files changed, 102 insertions(+), 25 deletions(-)
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index e062997a80..a71962c24c 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2210,12 +2210,8 @@ static int process_watchdog(sd_event *e) {
return arm_watchdog(e);
}
-_public_ int sd_event_run(sd_event *e, uint64_t timeout) {
- struct epoll_event *ev_queue;
- unsigned ev_queue_max;
- sd_event_source *p;
- int r, i, m;
- bool timedout;
+_public_ int sd_event_prepare(sd_event *e) {
+ int r;
assert_return(e, -EINVAL);
assert_return(!event_pid_changed(e), -ECHILD);
@@ -2223,38 +2219,60 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
assert_return(e->state == SD_EVENT_PASSIVE, -EBUSY);
if (e->exit_requested)
- return dispatch_exit(e);
+ goto pending;
- sd_event_ref(e);
e->iteration++;
- e->state = SD_EVENT_RUNNING;
r = event_prepare(e);
if (r < 0)
- goto finish;
+ return r;
r = event_arm_timer(e, &e->realtime);
if (r < 0)
- goto finish;
+ return r;
r = event_arm_timer(e, &e->boottime);
if (r < 0)
- goto finish;
+ return r;
r = event_arm_timer(e, &e->monotonic);
if (r < 0)
- goto finish;
+ return r;
r = event_arm_timer(e, &e->realtime_alarm);
if (r < 0)
- goto finish;
+ return r;
r = event_arm_timer(e, &e->boottime_alarm);
if (r < 0)
- goto finish;
+ return r;
if (event_next_pending(e) || e->need_process_child)
- timeout = 0;
+ goto pending;
+
+ e->state = SD_EVENT_PREPARED;
+
+ return 0;
+
+pending:
+ e->state = SD_EVENT_PREPARED;
+ return sd_event_wait(e, 0);
+}
+
+_public_ int sd_event_wait(sd_event *e, uint64_t timeout) {
+ struct epoll_event *ev_queue;
+ unsigned ev_queue_max;
+ int r, m, i;
+
+ assert_return(e, -EINVAL);
+ assert_return(!event_pid_changed(e), -ECHILD);
+ assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
+ assert_return(e->state == SD_EVENT_PREPARED, -EBUSY);
+
+ if (e->exit_requested) {
+ e->state = SD_EVENT_PENDING;
+ return 1;
+ }
ev_queue_max = CLAMP(e->n_sources, 1U, EPOLL_QUEUE_MAX);
ev_queue = newa(struct epoll_event, ev_queue_max);
@@ -2262,12 +2280,16 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
m = epoll_wait(e->epoll_fd, ev_queue, ev_queue_max,
timeout == (uint64_t) -1 ? -1 : (int) ((timeout + USEC_PER_MSEC - 1) / USEC_PER_MSEC));
if (m < 0) {
- r = errno == EAGAIN || errno == EINTR ? 1 : -errno;
+ if (errno == EINTR) {
+ e->state = SD_EVENT_PENDING;
+ return 1;
+ }
+
+ r = -errno;
+
goto finish;
}
- timedout = m == 0;
-
dual_timestamp_get(&e->timestamp);
e->timestamp_boottime = now(CLOCK_BOOTTIME);
@@ -2324,21 +2346,71 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
goto finish;
}
- p = event_next_pending(e);
- if (!p) {
- r = !timedout;
- goto finish;
+ if (event_next_pending(e)) {
+ e->state = SD_EVENT_PENDING;
+
+ return 1;
}
- r = source_dispatch(p);
+ r = 0;
finish:
e->state = SD_EVENT_PASSIVE;
- sd_event_unref(e);
return r;
}
+_public_ int sd_event_dispatch(sd_event *e) {
+ sd_event_source *p;
+ int r;
+
+ assert_return(e, -EINVAL);
+ assert_return(!event_pid_changed(e), -ECHILD);
+ assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
+ assert_return(e->state == SD_EVENT_PENDING, -EBUSY);
+
+ if (e->exit_requested)
+ return dispatch_exit(e);
+
+ p = event_next_pending(e);
+ if (p) {
+ sd_event_ref(e);
+
+ e->state = SD_EVENT_RUNNING;
+ r = source_dispatch(p);
+ e->state = SD_EVENT_PASSIVE;
+
+ sd_event_unref(e);
+
+ return r;
+ }
+
+ e->state = SD_EVENT_PASSIVE;
+
+ return 1;
+}
+
+_public_ int sd_event_run(sd_event *e, uint64_t timeout) {
+ int r;
+
+ assert_return(e, -EINVAL);
+ assert_return(!event_pid_changed(e), -ECHILD);
+ assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
+ assert_return(e->state == SD_EVENT_PASSIVE, -EBUSY);
+
+ r = sd_event_prepare(e);
+ if (r > 0)
+ return sd_event_dispatch(e);
+ else if (r < 0)
+ return r;
+
+ r = sd_event_wait(e, timeout);
+ if (r > 0)
+ return sd_event_dispatch(e);
+ else
+ return r;
+}
+
_public_ int sd_event_loop(sd_event *e) {
int r;
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index d96852a763..8e013b33f6 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -52,6 +52,8 @@ enum {
enum {
SD_EVENT_PASSIVE,
+ SD_EVENT_PREPARED,
+ SD_EVENT_PENDING,
SD_EVENT_RUNNING,
SD_EVENT_EXITING,
SD_EVENT_FINISHED
@@ -84,6 +86,9 @@ int sd_event_add_defer(sd_event *e, sd_event_source **s, sd_event_handler_t call
int sd_event_add_post(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
int sd_event_add_exit(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
+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);
int sd_event_exit(sd_event *e, int code);

View File

@ -1,27 +0,0 @@
From 6d148a842ebb04a9a9bc2853e167a9d8eddf8cd8 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Tue, 26 Aug 2014 00:22:06 +0200
Subject: [PATCH] sd-event: sd_event_prepare - stay in PREPARED if
sd_event_wait() indicates that no sources are pending
---
src/libsystemd/sd-event/sd-event.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index a71962c24c..32777e386b 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2256,7 +2256,11 @@ _public_ int sd_event_prepare(sd_event *e) {
pending:
e->state = SD_EVENT_PREPARED;
- return sd_event_wait(e, 0);
+ r = sd_event_wait(e, 0);
+ if (r == 0)
+ e->state = SD_EVENT_PREPARED;
+
+ return r;
}
_public_ int sd_event_wait(sd_event *e, uint64_t timeout) {

View File

@ -1,30 +0,0 @@
From 42aeb14a4a0fa7d43da96a8ed0fb0e180a2dd5c8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 03:59:05 +0200
Subject: [PATCH] update TODO
---
TODO | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/TODO b/TODO
index 0fcd3a0b8e..471d3b29bc 100644
--- a/TODO
+++ b/TODO
@@ -24,8 +24,15 @@ External:
Features:
+* remove multi-seat-x now
+
+* refcounting in sd-resolve is borked
+
+* exponential backoff in timesyncd and resolved when we cannot reach a server
+
* apply start timeout during the "initializing" manager state only,
- instead of both "initializing" and "starting".
+ instead of both "initializing" and "starting". maybe rename the
+ timeout to "initialization-timeout" then or so?
* journald: make use of uid-range.h to managed uid ranges to split
journals in.

View File

@ -1,26 +0,0 @@
From 4fc13f521ab44eb55c599b07c18860c1aeca35a7 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 04:03:24 +0200
Subject: [PATCH] Revert "systemctl: fix broken list-unit-files with --root"
This reverts commit 41a451cc2901a5deb985aea4cc8de204a22e5612.
This breaks checks for masking of units file, since we invoke
null_or_empty_path() on the resulting path.
---
src/shared/install.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index a07d1dd315..4b09a69456 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2099,7 +2099,7 @@ int unit_file_get_list(
if (!f)
return -ENOMEM;
- f->path = path_make_absolute(de->d_name, *i);
+ f->path = path_make_absolute(de->d_name, units_dir);
if (!f->path)
return -ENOMEM;

View File

@ -1,60 +0,0 @@
From 77cf759ea05bea476cdcb8d0dcd04c4e6fb3b2ff Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Tue, 26 Aug 2014 18:27:36 +0200
Subject: [PATCH] udev: hwdb - do not look at "usb_device" parents
Based on a patch from Simon McVittie <simon.mcvittie@collabora.co.uk>.
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758050
---
src/udev/udev-builtin-hwdb.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c
index cac97e756b..695a31a12f 100644
--- a/src/udev/udev-builtin-hwdb.c
+++ b/src/udev/udev-builtin-hwdb.c
@@ -88,9 +88,10 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
const char *filter, bool test) {
struct udev_device *d;
char s[16];
- int n = 0;
+ bool last = false;
+ int r = 0;
- for (d = srcdev; d; d = udev_device_get_parent(d)) {
+ for (d = srcdev; d && !last; d = udev_device_get_parent(d)) {
const char *dsubsys;
const char *modalias = NULL;
@@ -104,19 +105,24 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
modalias = udev_device_get_property_value(d, "MODALIAS");
- /* the usb_device does not have a modalias, compose one */
- if (!modalias && streq(dsubsys, "usb"))
- modalias = modalias_usb(d, s, sizeof(s));
+ if (streq(dsubsys, "usb") && streq_ptr(udev_device_get_devtype(d), "usb_device")) {
+ /* if the usb_device does not have a modalias, compose one */
+ if (!modalias)
+ modalias = modalias_usb(d, s, sizeof(s));
+
+ /* avoid looking at any parent device, they are usually just a USB hub */
+ last = true;
+ }
if (!modalias)
continue;
- n = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test);
- if (n > 0)
+ r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test);
+ if (r > 0)
break;
}
- return n;
+ return r;
}
static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool test) {

View File

@ -1,24 +0,0 @@
From 8dac15b6e9792c2b0f503ddf78ac499817904a6f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 20:23:49 +0200
Subject: [PATCH] update TODO
---
TODO | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/TODO b/TODO
index 471d3b29bc..09f82d3c37 100644
--- a/TODO
+++ b/TODO
@@ -24,6 +24,10 @@ External:
Features:
+* dbus: add new message hdr field for allowing interactive auth, write spec for it. update dbus spec to mandate that unknown flags *must* be ignored...
+
+* maybe introduce AssertXYZ= similar to ConditionXYZ= that causes a unit to fail (instead of skipping it) if some condition is not true...
+
* remove multi-seat-x now
* refcounting in sd-resolve is borked

View File

@ -1,33 +0,0 @@
From daa05349dfefb12638c96e034c11be613bdc39b7 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@43-1.org>
Date: Tue, 26 Aug 2014 00:19:54 +0200
Subject: [PATCH] NEWS: Fix typos.
---
NEWS | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 7dad765a33..2fca2cdc93 100644
--- a/NEWS
+++ b/NEWS
@@ -42,8 +42,8 @@ CHANGES WITH 216:
* systemd-resolved now includes a caching DNS stub resolver
and a complete LLMNR name resolution implementation. A new
- NSS module "nss-resolve" has been added which make be used
- of glibc's own "nss-dns" to resolve hostnames via
+ NSS module "nss-resolve" has been added which can be used
+ instead of glibc's own "nss-dns" to resolve hostnames via
systemd-resolved. Hostnames, addresses and arbitrary RRs may
be resolved via systemd-resolved D-Bus APIs. In contrast to
the glibc internal resolver systemd-resolved is aware of
@@ -606,7 +606,7 @@ CHANGES WITH 214:
* Access modes specified in tmpfiles snippets may now be
prefixed with "~", which indicates that they shall be masked
- by whether the existing file or directly is currently
+ by whether the existing file or directory is currently
writable, readable or executable at all. Also, if specified,
the sgid/suid/sticky bits will be masked for all
non-directories.

View File

@ -1,22 +0,0 @@
From 7965435e588c8d2fb824c5fd4b8c2739bc30acdf Mon Sep 17 00:00:00 2001
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Thu, 21 Aug 2014 12:38:08 +0200
Subject: [PATCH] missing: add BPF_XOR
BPF_XOR was introduced in kernel 3.7
---
src/shared/missing.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/shared/missing.h b/src/shared/missing.h
index a9dd274274..c80ed2ad99 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -593,3 +593,7 @@ static inline int setns(int fd, int nstype) {
#ifndef NET_NAME_RENAMED
# define NET_NAME_RENAMED 4
#endif
+
+#ifndef BPF_XOR
+# define BPF_XOR 0xa0
+#endif

View File

@ -1,23 +0,0 @@
From 32dfe42c66085c55916e5306a9a07d42d3958b6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <stlman@poczta.fm>
Date: Tue, 26 Aug 2014 12:28:28 +0200
Subject: [PATCH] networkd-wait-online: add missing short option 'i' to
optstring
---
src/network/networkd-wait-online.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c
index 6c2fdd1b2c..714343656b 100644
--- a/src/network/networkd-wait-online.c
+++ b/src/network/networkd-wait-online.c
@@ -59,7 +59,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "+hq", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "+hiq", options, NULL)) >= 0)
switch (c) {

View File

@ -1,33 +0,0 @@
From 52754725e185f1331f821d85ed2ef78fb92af1fe Mon Sep 17 00:00:00 2001
From: Filipe Brandenburger <filbranden@google.com>
Date: Mon, 25 Aug 2014 22:05:02 -0700
Subject: [PATCH] test-compress: make sure asserts with side effects use
assert_se()
Otherwise the test fails when built with CPPFLAGS='-DNDEBUG' which disables
assertions.
Tested:
- make check TESTS='test-compress' CPPFLAGS='-DNDEBUG'
---
src/journal/test-compress.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index f5f5f8df39..026d630ac2 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -145,11 +145,11 @@ static void test_compress_stream(int compression,
assert_se((dst = mkostemp_safe(pattern, O_RDWR|O_CLOEXEC)) >= 0);
- assert(compress(src, dst, -1) == 0);
+ assert_se(compress(src, dst, -1) == 0);
if (cat) {
assert_se(asprintf(&cmd, "%s %s | diff %s -", cat, pattern, srcfile) > 0);
- assert(system(cmd) == 0);
+ assert_se(system(cmd) == 0);
}
log_debug("/* test decompression */");

View File

@ -1,78 +0,0 @@
From 8d95631ea6c039a60bb7ac456f687a8fdf0c4381 Mon Sep 17 00:00:00 2001
From: Filipe Brandenburger <filbranden@google.com>
Date: Mon, 25 Aug 2014 22:05:03 -0700
Subject: [PATCH] test-path-util: use assert_se in all assertions
Otherwise they get optimized out when CPPFLAGS='-DNDEBUG' is used, and that
causes the tests to fail.
Tested:
- make check TESTS='test-path-util' CPPFLAGS='-DNDEBUG'
---
src/test/test-path-util.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index c8dcd85397..01afb3e6fe 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -79,35 +79,35 @@ static void test_path(void) {
char p2[] = "//aaa/.////ccc";
char p3[] = "/./";
- assert(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
- assert(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
- assert(path_equal(path_kill_slashes(p3), "/./"));
+ assert_se(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
+ assert_se(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
+ assert_se(path_equal(path_kill_slashes(p3), "/./"));
}
}
static void test_find_binary(const char *self) {
char *p;
- assert(find_binary("/bin/sh", &p) == 0);
+ assert_se(find_binary("/bin/sh", &p) == 0);
puts(p);
- assert(streq(p, "/bin/sh"));
+ assert_se(streq(p, "/bin/sh"));
free(p);
- assert(find_binary(self, &p) == 0);
+ assert_se(find_binary(self, &p) == 0);
puts(p);
- assert(endswith(p, "/test-path-util"));
- assert(path_is_absolute(p));
+ assert_se(endswith(p, "/test-path-util"));
+ assert_se(path_is_absolute(p));
free(p);
- assert(find_binary("sh", &p) == 0);
+ assert_se(find_binary("sh", &p) == 0);
puts(p);
- assert(endswith(p, "/sh"));
- assert(path_is_absolute(p));
+ assert_se(endswith(p, "/sh"));
+ assert_se(path_is_absolute(p));
free(p);
- assert(find_binary("xxxx-xxxx", &p) == -ENOENT);
+ assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
- assert(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
+ assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
}
static void test_prefixes(void) {
@@ -156,8 +156,8 @@ static void test_prefixes(void) {
b = false;
PATH_FOREACH_PREFIX_MORE(s, "") {
- assert(!b);
- assert(streq(s, ""));
+ assert_se(!b);
+ assert_se(streq(s, ""));
b = true;
}
}

View File

@ -1,27 +0,0 @@
From 684fc8927e0f83496d4384ac434e265f7cd7a87b Mon Sep 17 00:00:00 2001
From: Filipe Brandenburger <filbranden@google.com>
Date: Mon, 25 Aug 2014 22:05:04 -0700
Subject: [PATCH] test-util: use assert_se() for call to safe_mkdir with side
effect
Otherwise it gets optimized out when CPPFLAGS='-DNDEBUG' is used.
Tested:
- make check TESTS='test-util' CPPFLAGS='-DNDEBUG'
---
src/test/test-util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 34d5f2ed7d..4d9b28f9c8 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -863,7 +863,7 @@ static void test_readlink_and_make_absolute(void) {
char name_alias[] = "/tmp/test-readlink_and_make_absolute-alias";
char *r = NULL;
- assert(mkdir_safe(tempdir, 0755, getuid(), getgid()) >= 0);
+ assert_se(mkdir_safe(tempdir, 0755, getuid(), getgid()) >= 0);
assert_se(touch(name) >= 0);
assert_se(symlink(name, name_alias) >= 0);

View File

@ -1,65 +0,0 @@
From bb19cb17076bbec942ad08f94d41ba36b28a5a13 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 20:35:31 +0200
Subject: [PATCH] sd-bus: remove unused call bus_kernel_create_monitor()
Noticed by Djalal Harouni
---
src/libsystemd/sd-bus/bus-kernel.c | 31 -------------------------------
src/libsystemd/sd-bus/bus-kernel.h | 1 -
2 files changed, 32 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 3ca271c704..03c4165095 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1535,37 +1535,6 @@ int bus_kernel_create_domain(const char *name, char **s) {
return fd;
}
-int bus_kernel_create_monitor(const char *bus) {
- struct kdbus_cmd_hello *hello;
- int fd;
-
- assert(bus);
-
- fd = bus_kernel_open_bus_fd(bus, NULL);
- if (fd < 0)
- return fd;
-
- hello = alloca0(sizeof(struct kdbus_cmd_hello));
- hello->size = sizeof(struct kdbus_cmd_hello);
- hello->conn_flags = KDBUS_HELLO_ACTIVATOR;
- hello->pool_size = KDBUS_POOL_SIZE;
-
- if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) {
- safe_close(fd);
- return -errno;
- }
-
- /* The higher 32bit of both flags fields are considered
- * 'incompatible flags'. Refuse them all for now. */
- if (hello->bus_flags > 0xFFFFFFFFULL ||
- hello->conn_flags > 0xFFFFFFFFULL) {
- safe_close(fd);
- return -ENOTSUP;
- }
-
- return fd;
-}
-
int bus_kernel_try_close(sd_bus *bus) {
assert(bus);
assert(bus->is_kernel);
diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h
index 87f98c58bf..448dd3a797 100644
--- a/src/libsystemd/sd-bus/bus-kernel.h
+++ b/src/libsystemd/sd-bus/bus-kernel.h
@@ -70,7 +70,6 @@ int bus_kernel_make_starter(int fd, const char *name, bool activating, bool acce
int bus_kernel_create_bus(const char *name, bool world, char **s);
int bus_kernel_create_domain(const char *name, char **s);
-int bus_kernel_create_monitor(const char *bus);
int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated);
void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, size_t allocated);

View File

@ -1,25 +0,0 @@
From 498cfc230af8f83675be2e92057956f1792969e4 Mon Sep 17 00:00:00 2001
From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Date: Sat, 23 Aug 2014 21:11:44 +0200
Subject: [PATCH] systemctl: Correct error message printed when
bus_process_wait fails
Actually use the variable containing the return code of bus_process_wait when
printing the error message as a result of it failing.
---
src/systemctl/systemctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d9b8bee28d..65348193b7 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2382,7 +2382,7 @@ static int wait_for_jobs(sd_bus *bus, Set *s) {
while (!set_isempty(s)) {
q = bus_process_wait(bus);
if (q < 0) {
- log_error("Failed to wait for response: %s", strerror(-r));
+ log_error("Failed to wait for response: %s", strerror(-q));
return q;
}

View File

@ -1,36 +0,0 @@
From f2322f0b64107b2eee1fadb6c59857381277a9f8 Mon Sep 17 00:00:00 2001
From: Hristo Venev <mustrumr97@gmail.com>
Date: Tue, 26 Aug 2014 20:40:35 +0200
Subject: [PATCH] sd-bus: don't include internal header memfd.h in public
header sd-bus.h
https://bugs.freedesktop.org/show_bug.cgi?id=83097
---
src/libsystemd/sd-bus/bus-message.c | 1 +
src/systemd/sd-bus.h | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index c058b06f41..d00455a112 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -28,6 +28,7 @@
#include "strv.h"
#include "time-util.h"
#include "cgroup-util.h"
+#include "memfd.h"
#include "sd-bus.h"
#include "bus-message.h"
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 1e23a93a60..036ab556c1 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -28,7 +28,6 @@
#include "sd-id128.h"
#include "sd-event.h"
-#include "memfd.h"
#include "_sd-common.h"
_SD_BEGIN_DECLARATIONS;

View File

@ -1,47 +0,0 @@
From 24a5d6b04e17d447cf122f02a8a2dedd843cce45 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 21:03:20 +0200
Subject: [PATCH] util: make sure reset_all_signal_handlers() continues with
all other signal handlers when one sigaction() fails
After all, we usually don't check for failures here, and it is better to
do as much as we can...
---
src/shared/util.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index fc6f668726..4af2d3ceba 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -937,7 +937,7 @@ int readlink_and_canonicalize(const char *p, char **r) {
}
int reset_all_signal_handlers(void) {
- int sig;
+ int sig, r = 0;
for (sig = 1; sig < _NSIG; sig++) {
struct sigaction sa = {
@@ -945,17 +945,18 @@ int reset_all_signal_handlers(void) {
.sa_flags = SA_RESTART,
};
+ /* These two cannot be caught... */
if (sig == SIGKILL || sig == SIGSTOP)
continue;
/* On Linux the first two RT signals are reserved by
* glibc, and sigaction() will return EINVAL for them. */
if ((sigaction(sig, &sa, NULL) < 0))
- if (errno != EINVAL)
- return -errno;
+ if (errno != EINVAL && r == 0)
+ r = -errno;
}
- return 0;
+ return r;
}
char *strstrip(char *s) {

View File

@ -1,66 +0,0 @@
From 1dedb74a2e1d840b531b76b01a76979f3b57456b Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 21:04:21 +0200
Subject: [PATCH] util: reset signals when we fork off agents
If we invoke agents, we should make sure we actually can kill them
again. I mean, it's probably not our job to cleanup the signals if our
tools are invoked in weird contexts, but at least we should make sure,
that the subprocesses we invoke and intend to control work as intended.
Also see:
http://lists.freedesktop.org/archives/systemd-devel/2014-August/022460.html
---
src/shared/util.c | 18 ++++++++++++++++++
src/shared/util.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/src/shared/util.c b/src/shared/util.c
index 4af2d3ceba..98c07163da 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -959,6 +959,18 @@ int reset_all_signal_handlers(void) {
return r;
}
+int reset_signal_mask(void) {
+ sigset_t ss;
+
+ if (sigemptyset(&ss) < 0)
+ return -errno;
+
+ if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0)
+ return -errno;
+
+ return 0;
+}
+
char *strstrip(char *s) {
char *e;
@@ -5131,6 +5143,12 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
/* Don't leak fds to the agent */
close_all_fds(except, n_except);
+ /* Make sure we actually can kill the agent, if we need to, in
+ * case somebody invoked us from a shell script that trapped
+ * SIGTERM or so... */
+ reset_all_signal_handlers();
+ reset_signal_mask();
+
stdout_is_tty = isatty(STDOUT_FILENO);
stderr_is_tty = isatty(STDERR_FILENO);
diff --git a/src/shared/util.h b/src/shared/util.h
index cd947dbbef..ea87c96956 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -274,6 +274,7 @@ int readlink_and_make_absolute(const char *p, char **r);
int readlink_and_canonicalize(const char *p, char **r);
int reset_all_signal_handlers(void);
+int reset_signal_mask(void);
char *strstrip(char *s);
char *delete_chars(char *s, const char *bad);

View File

@ -1,101 +0,0 @@
From 1b6d7fa742e303611dff8d7ebfa86ee5fb8b7dc7 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 21:11:35 +0200
Subject: [PATCH] util: make use of newly added reset_signal_mask() call
wherever appropriate
---
src/core/execute.c | 6 ++----
src/core/main.c | 7 ++-----
src/nspawn/nspawn.c | 4 +---
src/shared/util.c | 5 +----
4 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/src/core/execute.c b/src/core/execute.c
index b5b22472d5..066efd6fdf 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1301,7 +1301,6 @@ int exec_spawn(ExecCommand *command,
int dont_close[n_fds + 3];
uid_t uid = (uid_t) -1;
gid_t gid = (gid_t) -1;
- sigset_t ss;
int i, err;
/* child */
@@ -1319,9 +1318,8 @@ int exec_spawn(ExecCommand *command,
if (context->ignore_sigpipe)
ignore_signals(SIGPIPE, -1);
- assert_se(sigemptyset(&ss) == 0);
- if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
- err = -errno;
+ err = reset_signal_mask();
+ if (err < 0) {
r = EXIT_SIGNAL_MASK;
goto fail_child;
}
diff --git a/src/core/main.c b/src/core/main.c
index bd148b1b33..95ab40fffc 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1834,7 +1834,6 @@ finish:
if (reexecute) {
const char **args;
unsigned i, args_size;
- sigset_t ss;
/* Close and disarm the watchdog, so that the new
* instance can reinitialize it, but doesn't get
@@ -1918,12 +1917,10 @@ finish:
args[i++] = NULL;
assert(i <= args_size);
- /* reenable any blocked signals, especially important
+ /* Reenable any blocked signals, especially important
* if we switch from initial ramdisk to init=... */
reset_all_signal_handlers();
-
- assert_se(sigemptyset(&ss) == 0);
- assert_se(sigprocmask(SIG_SETMASK, &ss, NULL) == 0);
+ reset_signal_mask();
if (switch_root_init) {
args[0] = switch_root_init;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 2c718557ee..56d9cc68c6 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3156,9 +3156,7 @@ int main(int argc, char *argv[]) {
kmsg_socket_pair[0] = safe_close(kmsg_socket_pair[0]);
reset_all_signal_handlers();
-
- assert_se(sigemptyset(&mask) == 0);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ reset_signal_mask();
k = open_terminal(console, O_RDWR);
if (k != STDIN_FILENO) {
diff --git a/src/shared/util.c b/src/shared/util.c
index 98c07163da..fdcf5719fa 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3890,16 +3890,13 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
_cleanup_hashmap_free_free_ Hashmap *pids = NULL;
_cleanup_closedir_ DIR *_d = NULL;
struct dirent *de;
- sigset_t ss;
/* We fork this all off from a child process so that
* we can somewhat cleanly make use of SIGALRM to set
* a time limit */
reset_all_signal_handlers();
-
- assert_se(sigemptyset(&ss) == 0);
- assert_se(sigprocmask(SIG_SETMASK, &ss, NULL) == 0);
+ reset_signal_mask();
assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);

View File

@ -1,22 +0,0 @@
From 36202fd2bc252616966166c98ccb0e0e5ece1fc9 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Aug 2014 21:47:46 +0200
Subject: [PATCH] sd-journal: never log anything by default from a library
---
src/journal/sd-journal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index b9ec90230d..80ff8fef57 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2557,7 +2557,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
/* Let's do the type check by hand, since we used 0 context above. */
if (o->object.type != OBJECT_DATA) {
- log_error("%s:offset " OFSfmt ": object has type %d, expected %d",
+ log_debug("%s:offset " OFSfmt ": object has type %d, expected %d",
j->unique_file->path, j->unique_offset,
o->object.type, OBJECT_DATA);
return -EBADMSG;

View File

@ -1,244 +0,0 @@
From 3c56cab44150ad47323970cfadfb0257c6305a74 Mon Sep 17 00:00:00 2001
From: Ben Wolsieffer <benwolsieffer@gmail.com>
Date: Tue, 26 Aug 2014 22:08:02 +0200
Subject: [PATCH] logind: add HandleLidSwitchDocked= option to logind.conf +
documentation
https://bugs.freedesktop.org/show_bug.cgi?id=82485
---
man/logind.conf.xml | 16 +++++++++++-----
src/login/logind-action.c | 18 ------------------
src/login/logind-button.c | 18 ++++++++++++++++--
src/login/logind-core.c | 22 ++++++++++++++++++++++
src/login/logind-dbus.c | 1 +
src/login/logind-gperf.gperf | 1 +
src/login/logind.c | 7 +++++--
src/login/logind.conf | 1 +
src/login/logind.h | 2 ++
9 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/man/logind.conf.xml b/man/logind.conf.xml
index f037da259b..8ba95230be 100644
--- a/man/logind.conf.xml
+++ b/man/logind.conf.xml
@@ -224,6 +224,7 @@
<term><varname>HandleSuspendKey=</varname></term>
<term><varname>HandleHibernateKey=</varname></term>
<term><varname>HandleLidSwitch=</varname></term>
+ <term><varname>HandleLidSwitchDocked=</varname></term>
<listitem><para>Controls whether
logind shall handle the system power
@@ -255,13 +256,18 @@
and
<varname>HandleLidSwitch=</varname>
default to <literal>suspend</literal>.
+ <varname>HandleLidSwitchDocked=</varname>
+ defaults to <literal>ignore</literal>.
<varname>HandleHibernateKey=</varname>
defaults to
- <literal>hibernate</literal>. Note
- that the lid switch is ignored if the
- system is inserted in a docking
- station, or if more than one display
- is connected.</para></listitem>
+ <literal>hibernate</literal>. If the
+ system is inserted in a docking station,
+ or if more than one display is connected,
+ the action specified by
+ <varname>HandleLidSwitchDocked=</varname>
+ occurs; otherwise the
+ <varname>HandleLidSwitch=</varname>
+ action occurs.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index 36ee4418b8..0844df20a9 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -71,24 +71,6 @@ int manager_handle_action(
}
if (inhibit_key == INHIBIT_HANDLE_LID_SWITCH) {
- int n;
-
- /* If we are docked don't react to lid closing */
- if (manager_is_docked(m)) {
- log_debug("Ignoring lid switch request, system is docked.");
- return 0;
- }
-
- /* If we have more than one display connected,
- * don't react to lid closing. */
- n = manager_count_displays(m);
- if (n < 0)
- log_warning("Display counting failed: %s", strerror(-n));
- else if (n > 1) {
- log_debug("Ignoring lid switch request, %i displays connected.", n);
- return 0;
- }
-
/* If the last system suspend or startup is too close,
* let's not suspend for now, to give USB docking
* stations some time to settle so that we can
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 2561d13c67..57e619efe6 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -97,13 +97,27 @@ int button_set_seat(Button *b, const char *sn) {
return 0;
}
+static void button_lid_switch_handle_action(Manager *manager, bool is_edge) {
+ HandleAction handle_action;
+
+ assert(manager);
+
+ /* If we are docked, handle the lid switch differently */
+ if (manager_is_docked_or_multiple_displays(manager))
+ handle_action = manager->handle_lid_switch_docked;
+ else
+ handle_action = manager->handle_lid_switch;
+
+ manager_handle_action(manager, INHIBIT_HANDLE_LID_SWITCH, handle_action, manager->lid_switch_ignore_inhibited, is_edge);
+}
+
static int button_recheck(sd_event_source *e, void *userdata) {
Button *b = userdata;
assert(b);
assert(b->lid_closed);
- manager_handle_action(b->manager, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, false);
+ button_lid_switch_handle_action(b->manager, false);
return 1;
}
@@ -186,7 +200,7 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
NULL);
b->lid_closed = true;
- manager_handle_action(b->manager, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true);
+ button_lid_switch_handle_action(b->manager, true);
button_install_check_event_source(b);
} else if (ev.code == SW_DOCK) {
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 053d2ed63e..ed7ea5da31 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -537,3 +537,25 @@ int manager_count_displays(Manager *m) {
return n;
}
+
+bool manager_is_docked_or_multiple_displays(Manager *m) {
+ int n;
+
+ /* If we are docked don't react to lid closing */
+ if (manager_is_docked(m)) {
+ log_debug("System is docked.");
+ return true;
+ }
+
+ /* If we have more than one display connected,
+ * assume that we are docked. */
+ n = manager_count_displays(m);
+ if (n < 0)
+ log_warning("Display counting failed: %s", strerror(-n));
+ else if (n > 1) {
+ log_debug("Multiple (%i) displays connected.", n);
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index acef5119b1..0b2b7b5afe 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1919,6 +1919,7 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("HandleSuspendKey", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleHibernateKey", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("HandleLidSwitch", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("HandleLidSwitchDocked", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_docked), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("IdleAction", "s", property_get_handle_action, offsetof(Manager, idle_action), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("IdleActionUSec", "t", NULL, offsetof(Manager, idle_action_usec), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("PreparingForShutdown", "b", property_get_preparing, 0, 0),
diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf
index 006f7286c5..62460673b9 100644
--- a/src/login/logind-gperf.gperf
+++ b/src/login/logind-gperf.gperf
@@ -24,6 +24,7 @@ Login.HandlePowerKey, config_parse_handle_action, 0, offsetof(Manag
Login.HandleSuspendKey, config_parse_handle_action, 0, offsetof(Manager, handle_suspend_key)
Login.HandleHibernateKey, config_parse_handle_action, 0, offsetof(Manager, handle_hibernate_key)
Login.HandleLidSwitch, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch)
+Login.HandleLidSwitchDocked, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_docked)
Login.PowerKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, power_key_ignore_inhibited)
Login.SuspendKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, suspend_key_ignore_inhibited)
Login.HibernateKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, hibernate_key_ignore_inhibited)
diff --git a/src/login/logind.c b/src/login/logind.c
index 52e1c43a47..1f94a97bd0 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -55,6 +55,7 @@ Manager *manager_new(void) {
m->handle_suspend_key = HANDLE_SUSPEND;
m->handle_hibernate_key = HANDLE_HIBERNATE;
m->handle_lid_switch = HANDLE_SUSPEND;
+ m->handle_lid_switch_docked = HANDLE_IGNORE;
m->lid_switch_ignore_inhibited = true;
m->idle_action_usec = 30 * USEC_PER_MINUTE;
@@ -232,7 +233,8 @@ static int manager_enumerate_buttons(Manager *m) {
if (m->handle_power_key == HANDLE_IGNORE &&
m->handle_suspend_key == HANDLE_IGNORE &&
m->handle_hibernate_key == HANDLE_IGNORE &&
- m->handle_lid_switch == HANDLE_IGNORE)
+ m->handle_lid_switch == HANDLE_IGNORE &&
+ m->handle_lid_switch_docked == HANDLE_IGNORE)
return 0;
e = udev_enumerate_new(m->udev);
@@ -875,7 +877,8 @@ static int manager_connect_udev(Manager *m) {
if (m->handle_power_key != HANDLE_IGNORE ||
m->handle_suspend_key != HANDLE_IGNORE ||
m->handle_hibernate_key != HANDLE_IGNORE ||
- m->handle_lid_switch != HANDLE_IGNORE) {
+ m->handle_lid_switch != HANDLE_IGNORE ||
+ m->handle_lid_switch_docked != HANDLE_IGNORE) {
m->udev_button_monitor = udev_monitor_new_from_netlink(m->udev, "udev");
if (!m->udev_button_monitor)
diff --git a/src/login/logind.conf b/src/login/logind.conf
index 79f96ec05b..4608a2c0e2 100644
--- a/src/login/logind.conf
+++ b/src/login/logind.conf
@@ -18,6 +18,7 @@
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
+#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
diff --git a/src/login/logind.h b/src/login/logind.h
index 31353eff02..2f76572580 100644
--- a/src/login/logind.h
+++ b/src/login/logind.h
@@ -114,6 +114,7 @@ struct Manager {
HandleAction handle_suspend_key;
HandleAction handle_hibernate_key;
HandleAction handle_lid_switch;
+ HandleAction handle_lid_switch_docked;
bool power_key_ignore_inhibited;
bool suspend_key_ignore_inhibited;
@@ -159,6 +160,7 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session);
bool manager_is_docked(Manager *m);
int manager_count_displays(Manager *m);
+bool manager_is_docked_or_multiple_displays(Manager *m);
extern const sd_bus_vtable manager_vtable[];

View File

@ -1,25 +0,0 @@
From 66f311206e908a5b6f21e66fad73e1e5ea3e31d6 Mon Sep 17 00:00:00 2001
From: Ivan Shapovalov <intelfx100@gmail.com>
Date: Wed, 27 Aug 2014 00:17:43 +0400
Subject: [PATCH] units: order systemd-fsck@.service after local-fs-pre.target.
With this change, it becomes possible to order a unit to activate before any
modifications to the file systems. This is especially useful for supporting
resume from hibernation.
---
units/systemd-fsck@.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/units/systemd-fsck@.service.in b/units/systemd-fsck@.service.in
index c12efa8e76..d2cda6a466 100644
--- a/units/systemd-fsck@.service.in
+++ b/units/systemd-fsck@.service.in
@@ -10,7 +10,7 @@ Description=File System Check on %f
Documentation=man:systemd-fsck@.service(8)
DefaultDependencies=no
BindsTo=%i.device
-After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device systemd-fsck-root.service
+After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device systemd-fsck-root.service local-fs-pre.target
Before=shutdown.target
[Service]

View File

@ -1,353 +0,0 @@
From 42483a747489ff46aed3588b78bf4b9480dbeaf7 Mon Sep 17 00:00:00 2001
From: Ivan Shapovalov <intelfx100@gmail.com>
Date: Wed, 27 Aug 2014 00:17:44 +0400
Subject: [PATCH] hibernate-resume: add a tool to write a device node's
major:minor to /sys/power/resume.
This can be used to initiate a resume from hibernation by path to a swap
device containing the hibernation image.
The respective templated unit is also added. It is instantiated using
path to the desired resume device.
---
.gitignore | 1 +
Makefile-man.am | 7 +++
Makefile.am | 17 +++++--
man/systemd-hibernate-resume@.service.xml | 81 ++++++++++++++++++++++++++++++
src/hibernate-resume/Makefile | 1 +
src/hibernate-resume/hibernate-resume.c | 81 ++++++++++++++++++++++++++++++
units/.gitignore | 1 +
units/systemd-hibernate-resume@.service.in | 20 ++++++++
8 files changed, 206 insertions(+), 3 deletions(-)
create mode 100644 man/systemd-hibernate-resume@.service.xml
create mode 120000 src/hibernate-resume/Makefile
create mode 100644 src/hibernate-resume/hibernate-resume.c
create mode 100644 units/systemd-hibernate-resume@.service.in
diff --git a/.gitignore b/.gitignore
index 8189da71f0..0b5608ccf9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -75,6 +75,7 @@
/systemd-getty-generator
/systemd-gnome-ask-password-agent
/systemd-gpt-auto-generator
+/systemd-hibernate-resume
/systemd-hostnamed
/systemd-inhibit
/systemd-initctl
diff --git a/Makefile-man.am b/Makefile-man.am
index 562ecba435..09a10383a9 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -70,6 +70,7 @@ MANPAGES += \
man/systemd-getty-generator.8 \
man/systemd-gpt-auto-generator.8 \
man/systemd-halt.service.8 \
+ man/systemd-hibernate-resume@.service.8 \
man/systemd-inhibit.1 \
man/systemd-initctl.service.8 \
man/systemd-journald.service.8 \
@@ -199,6 +200,7 @@ MANPAGES_ALIAS += \
man/systemd-firstboot.service.1 \
man/systemd-fsck-root.service.8 \
man/systemd-fsck.8 \
+ man/systemd-hibernate-resume.8 \
man/systemd-hibernate.service.8 \
man/systemd-hybrid-sleep.service.8 \
man/systemd-initctl.8 \
@@ -305,6 +307,7 @@ man/systemd-ask-password-wall.service.8: man/systemd-ask-password-console.servic
man/systemd-firstboot.service.1: man/systemd-firstboot.1
man/systemd-fsck-root.service.8: man/systemd-fsck@.service.8
man/systemd-fsck.8: man/systemd-fsck@.service.8
+man/systemd-hibernate-resume.8: man/systemd-hibernate-resume@.service.8
man/systemd-hibernate.service.8: man/systemd-suspend.service.8
man/systemd-hybrid-sleep.service.8: man/systemd-suspend.service.8
man/systemd-initctl.8: man/systemd-initctl.service.8
@@ -567,6 +570,9 @@ man/systemd-fsck-root.service.html: man/systemd-fsck@.service.html
man/systemd-fsck.html: man/systemd-fsck@.service.html
$(html-alias)
+man/systemd-hibernate-resume.html: man/systemd-hibernate-resume@.service.html
+ $(html-alias)
+
man/systemd-hibernate.service.html: man/systemd-suspend.service.html
$(html-alias)
@@ -1619,6 +1625,7 @@ EXTRA_DIST += \
man/systemd-getty-generator.xml \
man/systemd-gpt-auto-generator.xml \
man/systemd-halt.service.xml \
+ man/systemd-hibernate-resume@.service.xml \
man/systemd-hostnamed.service.xml \
man/systemd-inhibit.xml \
man/systemd-initctl.service.xml \
diff --git a/Makefile.am b/Makefile.am
index cbf98bdac3..a487caa7bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -378,7 +378,8 @@ rootlibexec_PROGRAMS = \
systemd-sleep \
systemd-bus-proxyd \
systemd-socket-proxyd \
- systemd-update-done
+ systemd-update-done \
+ systemd-hibernate-resume
systemgenerator_PROGRAMS = \
systemd-getty-generator \
@@ -528,7 +529,8 @@ nodist_systemunit_DATA = \
units/initrd-udevadm-cleanup-db.service \
units/initrd-switch-root.service \
units/systemd-nspawn@.service \
- units/systemd-update-done.service
+ units/systemd-update-done.service \
+ units/systemd-hibernate-resume@.service
dist_userunit_DATA = \
units/user/basic.target \
@@ -575,7 +577,8 @@ EXTRA_DIST += \
units/initrd-udevadm-cleanup-db.service.in \
units/initrd-switch-root.service.in \
units/systemd-nspawn@.service.in \
- units/systemd-update-done.service.in
+ units/systemd-update-done.service.in \
+ units/systemd-hibernate-resume@.service.in
CLEANFILES += \
units/console-shell.service.m4 \
@@ -2103,6 +2106,14 @@ systemd_delta_LDADD = \
libsystemd-shared.la
# ------------------------------------------------------------------------------
+systemd_hibernate_resume_SOURCES = \
+ src/hibernate-resume/hibernate-resume.c
+
+systemd_hibernate_resume_LDADD = \
+ libsystemd-internal.la \
+ libsystemd-shared.la
+
+# ------------------------------------------------------------------------------
systemd_getty_generator_SOURCES = \
src/getty-generator/getty-generator.c
diff --git a/man/systemd-hibernate-resume@.service.xml b/man/systemd-hibernate-resume@.service.xml
new file mode 100644
index 0000000000..9b188b0d96
--- /dev/null
+++ b/man/systemd-hibernate-resume@.service.xml
@@ -0,0 +1,81 @@
+<?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 2014 Ivan Shapovalov
+
+ 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="systemd-hibernate-resume@.service">
+
+ <refentryinfo>
+ <title>systemd-hibernate-resume@.service</title>
+ <productname>systemd</productname>
+
+ <authorgroup>
+ <author>
+ <contrib>Developer</contrib>
+ <firstname>Ivan</firstname>
+ <surname>Shapovalov</surname>
+ <email>intelfx100@gmail.com</email>
+ </author>
+ </authorgroup>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>systemd-hibernate-resume@.service</refentrytitle>
+ <manvolnum>8</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>systemd-hibernate-resume@.service</refname>
+ <refname>systemd-hibernate-resume</refname>
+ <refpurpose>Resume from hibernation</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <para><filename>systemd-hibernate-resume@.service</filename></para>
+ <para><filename>/usr/lib/systemd/systemd-hibernate-resume</filename></para>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para><filename>systemd-hibernate-resume@.service</filename> is a
+ service that initiates hibernation resume from a device
+ containing the resume image. It is instantiated for each
+ device that is configured for resuming from.</para>
+
+ <para><filename>systemd-hibernate-resume</filename> only supports
+ the in-kernel hibernation implementation, known as swsusp.
+ Internally, it works by writing the major:minor of specified
+ device node to <filename>/sys/power/resume</filename>.</para>
+
+ <para>Failing to initiate a resume is not an error condition.
+ It may mean that there was no resume image (e. g. if the
+ system has been simply powered off and not hibernated). In
+ such case, the boot is ordinarily continued.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+ <para>
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd-hibernate-resume-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ </para>
+ </refsect1>
+
+</refentry>
diff --git a/src/hibernate-resume/Makefile b/src/hibernate-resume/Makefile
new file mode 120000
index 0000000000..d0b0e8e008
--- /dev/null
+++ b/src/hibernate-resume/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c
new file mode 100644
index 0000000000..8f68f81f9e
--- /dev/null
+++ b/src/hibernate-resume/hibernate-resume.c
@@ -0,0 +1,81 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Ivan Shapovalov
+
+ 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 <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "log.h"
+#include "util.h"
+#include "fileio.h"
+
+int main(int argc, char *argv[]) {
+ struct stat st;
+ const char *device;
+ _cleanup_free_ char *major_minor = NULL;
+ int r;
+
+ if (argc != 2) {
+ log_error("This program expects one argument.");
+ return EXIT_FAILURE;
+ }
+
+ log_set_target(LOG_TARGET_AUTO);
+ log_parse_environment();
+ log_open();
+
+ umask(0022);
+
+ device = argv[1];
+
+ if (stat(device, &st) < 0) {
+ log_error("Failed to stat '%s': %m", device);
+ return EXIT_FAILURE;
+ }
+
+ if (!S_ISBLK(st.st_mode)) {
+ log_error("Resume device '%s' is not a block device.", device);
+ return EXIT_FAILURE;
+ }
+
+ if (asprintf(&major_minor, "%d:%d", major(st.st_rdev), minor(st.st_rdev)) < 0) {
+ log_oom();
+ return EXIT_FAILURE;
+ }
+
+ r = write_string_file("/sys/power/resume", major_minor);
+ if (r < 0) {
+ log_error("Failed to write '%s' to /sys/power/resume: %s", major_minor, strerror(-r));
+ return EXIT_FAILURE;
+ }
+
+ /*
+ * The write above shall not return.
+ *
+ * However, failed resume is a normal condition (may mean that there is
+ * no hibernation image).
+ */
+
+ log_info("Could not resume from '%s' (%s).", device, major_minor);
+ return EXIT_SUCCESS;
+}
diff --git a/units/.gitignore b/units/.gitignore
index d9b60ac0fc..c60f357416 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -54,6 +54,7 @@
/systemd-reboot.service
/systemd-remount-fs.service
/systemd-resolved.service
+/systemd-hibernate-resume@.service
/systemd-rfkill@.service
/systemd-shutdownd.service
/systemd-suspend.service
diff --git a/units/systemd-hibernate-resume@.service.in b/units/systemd-hibernate-resume@.service.in
new file mode 100644
index 0000000000..6db584dc4d
--- /dev/null
+++ b/units/systemd-hibernate-resume@.service.in
@@ -0,0 +1,20 @@
+# 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.
+
+[Unit]
+Description=Resume from hibernation using device %f
+Documentation=man:systemd-hibernate-resume@.service(8)
+DefaultDependencies=no
+BindsTo=%i.device
+Wants=local-fs-pre.target
+After=%i.device
+Before=local-fs-pre.target systemd-remount-fs.service systemd-fsck-root.service
+ConditionPathExists=/etc/initrd-release
+
+[Service]
+Type=oneshot
+ExecStart=@rootlibexecdir@/systemd-hibernate-resume %f

View File

@ -1,330 +0,0 @@
From d2c68822c47e37b582820f45b496b2e7d1f9e642 Mon Sep 17 00:00:00 2001
From: Ivan Shapovalov <intelfx100@gmail.com>
Date: Wed, 27 Aug 2014 00:17:45 +0400
Subject: [PATCH] hibernate-resume-generator: add a generator for instantiating
the resume unit.
hibernate-resume-generator understands resume= kernel command line parameter
and instantiates the systemd-resume@.service accordingly if it is passed.
This enables resume from hibernation using device specified on the kernel
command line, and it may be specified either as "/dev/disk/by-foo/bar"
or "FOO=bar", not only "/dev/sdXY" which is understood by the in-kernel
implementation.
So now resume= is brought on par with root= in terms of possible ways to
specify a device.
---
.gitignore | 1 +
Makefile-man.am | 2 +
Makefile.am | 11 +++-
man/kernel-command-line.xml | 14 ++++-
man/systemd-hibernate-resume-generator.xml | 93 +++++++++++++++++++++++++++++
src/resume-generator/Makefile | 1 +
src/resume-generator/resume-generator.c | 95 ++++++++++++++++++++++++++++++
7 files changed, 215 insertions(+), 2 deletions(-)
create mode 100644 man/systemd-hibernate-resume-generator.xml
create mode 120000 src/resume-generator/Makefile
create mode 100644 src/resume-generator/resume-generator.c
diff --git a/.gitignore b/.gitignore
index 0b5608ccf9..8aed0b9ba6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,7 @@
/systemd-gnome-ask-password-agent
/systemd-gpt-auto-generator
/systemd-hibernate-resume
+/systemd-hibernate-resume-generator
/systemd-hostnamed
/systemd-inhibit
/systemd-initctl
diff --git a/Makefile-man.am b/Makefile-man.am
index 09a10383a9..5c27937152 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -70,6 +70,7 @@ MANPAGES += \
man/systemd-getty-generator.8 \
man/systemd-gpt-auto-generator.8 \
man/systemd-halt.service.8 \
+ man/systemd-hibernate-resume-generator.8 \
man/systemd-hibernate-resume@.service.8 \
man/systemd-inhibit.1 \
man/systemd-initctl.service.8 \
@@ -1625,6 +1626,7 @@ EXTRA_DIST += \
man/systemd-getty-generator.xml \
man/systemd-gpt-auto-generator.xml \
man/systemd-halt.service.xml \
+ man/systemd-hibernate-resume-generator.xml \
man/systemd-hibernate-resume@.service.xml \
man/systemd-hostnamed.service.xml \
man/systemd-inhibit.xml \
diff --git a/Makefile.am b/Makefile.am
index a487caa7bc..cbdf551fa8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -385,7 +385,8 @@ systemgenerator_PROGRAMS = \
systemd-getty-generator \
systemd-fstab-generator \
systemd-system-update-generator \
- systemd-debug-generator
+ systemd-debug-generator \
+ systemd-hibernate-resume-generator
dist_bashcompletion_DATA = \
shell-completion/bash/busctl \
@@ -2146,6 +2147,14 @@ systemd_system_update_generator_LDADD = \
libsystemd-label.la \
libsystemd-shared.la
+# ------------------------------------------------------------------------------
+systemd_hibernate_resume_generator_SOURCES = \
+ src/resume-generator/resume-generator.c
+
+systemd_hibernate_resume_generator_LDADD = \
+ libsystemd-label.la \
+ libsystemd-shared.la
+
if ENABLE_EFI
# ------------------------------------------------------------------------------
systemgenerator_PROGRAMS += \
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index 36428aaa94..d872e6d5b9 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -351,6 +351,17 @@
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>resume=</varname></term>
+
+ <listitem>
+ <para>Enables resume from hibernation
+ using the specified device.
+ All <citerefentry><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>-like
+ pathes are supported. For details, see
+ <citerefentry><refentrytitle>systemd-hibernate-resume-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
@@ -373,7 +384,8 @@
<citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-modules-load.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-backlight@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd-rfkill@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>systemd-rfkill@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd-hibernate-resume-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/systemd-hibernate-resume-generator.xml b/man/systemd-hibernate-resume-generator.xml
new file mode 100644
index 0000000000..1a4b99ced4
--- /dev/null
+++ b/man/systemd-hibernate-resume-generator.xml
@@ -0,0 +1,93 @@
+<?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 2014 Ivan Shapovalov
+
+ 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="systemd-hibernate-resume-generator">
+
+ <refentryinfo>
+ <title>systemd-hibernate-resume-generator</title>
+ <productname>systemd</productname>
+
+ <authorgroup>
+ <author>
+ <contrib>Developer</contrib>
+ <firstname>Ivan</firstname>
+ <surname>Shapovalov</surname>
+ <email>intelfx100@gmail.com</email>
+ </author>
+ </authorgroup>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>systemd-hibernate-resume-generator</refentrytitle>
+ <manvolnum>8</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>systemd-hibernate-resume-generator</refname>
+ <refpurpose>Unit generator for resume= kernel parameter</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <para><filename>/usr/lib/systemd/system-generators/systemd-hibernate-resume-generator</filename></para>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para><filename>systemd-hibernate-resume-generator</filename> is
+ a generator that instantiates
+ <citerefentry><refentrytitle>systemd-hibernate-resume@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ unit according to the value of <option>resume=</option>
+ parameter specified on the kernel command line.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>Kernel Command Line</title>
+
+ <para><filename>systemd-hibernate-resume-generator</filename> understands
+ the following kernel command line parameters:</para>
+
+ <variablelist class='kernel-commandline-options'>
+
+ <varlistentry>
+ <term><varname>resume=</varname></term>
+
+ <listitem><para>Takes a path to the resume
+ device. Both persistent block device pathes like
+ <filename>/dev/disk/by-foo/bar</filename> and
+ <citerefentry><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>-style
+ specifiers like <literal>FOO=bar</literal>
+ are supported.</para></listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+ <para>
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd-hibernate-resume@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+ </para>
+ </refsect1>
+
+</refentry>
diff --git a/src/resume-generator/Makefile b/src/resume-generator/Makefile
new file mode 120000
index 0000000000..d0b0e8e008
--- /dev/null
+++ b/src/resume-generator/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/src/resume-generator/resume-generator.c b/src/resume-generator/resume-generator.c
new file mode 100644
index 0000000000..f40721662e
--- /dev/null
+++ b/src/resume-generator/resume-generator.c
@@ -0,0 +1,95 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2014 Ivan Shapovalov
+
+ 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 "log.h"
+#include "util.h"
+#include "special.h"
+#include "mkdir.h"
+#include "unit-name.h"
+
+static const char *arg_dest = "/tmp";
+static char *arg_resume_dev = NULL;
+
+static int parse_proc_cmdline_item(const char *key, const char *value) {
+ if (streq(key, "resume") && value) {
+ free(arg_resume_dev);
+ arg_resume_dev = fstab_node_to_udev_node(value);
+ if (!arg_resume_dev)
+ return log_oom();
+ }
+
+ return 0;
+}
+
+static int process_resume(void) {
+ _cleanup_free_ char *name = NULL, *lnk = NULL;
+
+ name = unit_name_from_path_instance("systemd-hibernate-resume", arg_resume_dev, ".service");
+ if (!name)
+ return log_oom();
+
+ lnk = strjoin(arg_dest, "/" SPECIAL_SYSINIT_TARGET ".wants/", name, NULL);
+ if (!lnk)
+ return log_oom();
+
+ mkdir_parents_label(lnk, 0755);
+ if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0) {
+ log_error("Failed to create symlink %s: %m", lnk);
+ return -errno;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ int r = 0;
+
+ if (argc > 1 && argc != 4) {
+ log_error("This program takes three or no arguments.");
+ return EXIT_FAILURE;
+ }
+
+ if (argc > 1)
+ arg_dest = argv[1];
+
+ log_set_target(LOG_TARGET_SAFE);
+ log_parse_environment();
+ log_open();
+
+ umask(0022);
+
+ /* Don't even consider resuming outside of initramfs. */
+ if (!in_initrd())
+ return EXIT_SUCCESS;
+
+ if (parse_proc_cmdline(parse_proc_cmdline_item) < 0)
+ return EXIT_FAILURE;
+
+ if (arg_resume_dev != NULL)
+ r = process_resume();
+
+ free(arg_resume_dev);
+
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}

View File

@ -1,35 +0,0 @@
From 36f5ace2db7fc43796107b2da9874e4c4bbc623e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 26 Aug 2014 21:14:11 -0400
Subject: [PATCH] man: reword sd-hibernate-resume description and add link
"each device" was suggesting that this service might be instantiated
multiple times. "hibernation resume" was too jargon-y.
---
man/systemd-hibernate-resume@.service.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/man/systemd-hibernate-resume@.service.xml b/man/systemd-hibernate-resume@.service.xml
index 9b188b0d96..30bfd88101 100644
--- a/man/systemd-hibernate-resume@.service.xml
+++ b/man/systemd-hibernate-resume@.service.xml
@@ -54,13 +54,14 @@
<refsect1>
<title>Description</title>
- <para><filename>systemd-hibernate-resume@.service</filename> is a
- service that initiates hibernation resume from a device
- containing the resume image. It is instantiated for each
- device that is configured for resuming from.</para>
+ <para><filename>systemd-hibernate-resume@.service</filename>
+ initiates the resume from hibernation. It is
+ instantiated with the device to resume from as the
+ template argument.</para>
<para><filename>systemd-hibernate-resume</filename> only supports
- the in-kernel hibernation implementation, known as swsusp.
+ the in-kernel hibernation implementation, known as
+ <ulink url="https://www.kernel.org/doc/Documentation/power/swsusp.txt">swsusp</ulink>.
Internally, it works by writing the major:minor of specified
device node to <filename>/sys/power/resume</filename>.</para>

View File

@ -1,39 +0,0 @@
From bf2e0ece853b888eb37055849975ddeab3f5f051 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <arvidjaar@gmail.com>
Date: Sun, 24 Aug 2014 11:11:33 +0400
Subject: [PATCH] Document "...|..." udev match syntax
---
man/udev.xml | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/man/udev.xml b/man/udev.xml
index db729378c5..2948b9ce2b 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -272,8 +272,8 @@
</varlistentry>
</variablelist>
- <para>Most of the fields support shell glob pattern matching. The following
- pattern characters are supported:</para>
+ <para>Most of the fields support shell glob pattern matching and
+ alternate patterns. The following special characters are supported:</para>
<variablelist>
<varlistentry>
<term><literal>*</literal></term>
@@ -300,6 +300,14 @@
any characters not enclosed are matched.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>|</literal></term>
+ <listitem>
+ <para>Separates alternative patterns. For example, the pattern string
+ <literal>abc|x*</literal> would match either <literal>abc</literal>
+ or <literal>x*</literal>.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
<para>The following keys can get values assigned:</para>

View File

@ -1,63 +0,0 @@
From 1977376274fc81f13e4220d224237e7cc71f0c63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Dr=C4=85g?= <piotrdrag@gmail.com>
Date: Sun, 24 Aug 2014 18:18:35 +0200
Subject: [PATCH] po: update Polish translation
https://bugs.freedesktop.org/show_bug.cgi?id=83015
---
po/pl.po | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/po/pl.po b/po/pl.po
index 6a95d2fd74..0407fe0861 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -1,13 +1,13 @@
# translation of pl.po to Polish
-# Piotr Drąg <piotrdrag@gmail.com>, 2011, 2013.
+# Piotr Drąg <piotrdrag@gmail.com>, 2011, 2013, 2014.
# Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: systemd\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-01-12 19:29+0100\n"
-"PO-Revision-Date: 2013-01-12 19:30+0100\n"
+"POT-Creation-Date: 2014-08-24 18:10+0200\n"
+"PO-Revision-Date: 2014-08-24 18:15+0200\n"
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
"Language-Team: Polish <trans-pl@lists.fedoraproject.org>\n"
"Language: pl\n"
@@ -389,3 +389,31 @@ msgid "Authentication is required to access the system and service manager."
msgstr ""
"Wymagane jest uwierzytelnienie, aby uzyskać dostęp do menedżera systemu i "
"usług."
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:5
+msgid "Manage system services or units"
+msgstr "Zarządzanie usługami lub jednostkami systemu"
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:6
+msgid "Authentication is required to manage system services or units."
+msgstr ""
+"Wymagane jest uwierzytelnienie, aby zarządzać usługami lub jednostkami "
+"systemu."
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:7
+msgid "Manage system service or unit files"
+msgstr "Zarządzanie plikami usług lub jednostek systemu"
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:8
+msgid "Authentication is required to manage system service or unit files."
+msgstr ""
+"Wymagane jest uwierzytelnienie, aby zarządzać plikami usług lub jednostek "
+"systemu."
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:9
+msgid "Reload the systemd state"
+msgstr "Ponowne wczytanie stanu systemd"
+
+#: ../src/core/org.freedesktop.systemd1.policy.in.in.h:10
+msgid "Authentication is required to reload the systemd state."
+msgstr "Wymagane jest uwierzytelnienie, aby ponownie wczytać stan systemd."

View File

@ -1,26 +0,0 @@
From e512e8a255ef29d5a8eb605f8849202ea3d3e4cb Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Wed, 27 Aug 2014 08:41:10 +0200
Subject: [PATCH] keymap: Adjust for more Samsung 900X4 series
Reportedly also applies to NP900X4B, so relax the match to apply to all models
of this series.
https://launchpad.net/bugs/902332
---
hwdb/60-keyboard.hwdb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hwdb/60-keyboard.hwdb b/hwdb/60-keyboard.hwdb
index ef0ebc5187..0ffcb83277 100644
--- a/hwdb/60-keyboard.hwdb
+++ b/hwdb/60-keyboard.hwdb
@@ -939,7 +939,7 @@ keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*550P*:pvr*
# Series 7 / 9
keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*700Z*:pvr*
keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*700G*:pvr*
-keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*900X[34][CDEFG]*:pvr*
+keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*900X[34]*:pvr*
keyboard:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*940X3G*:pvr*
KEYBOARD_KEY_ce=!prog1 # Fn+F1 launch settings
KEYBOARD_KEY_a0=!mute # Fn+F6 mute

View File

@ -1,34 +0,0 @@
From 81fc054dc7c365545bca86d78bf36a12658cedb3 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Tue, 26 Aug 2014 13:33:08 +0200
Subject: [PATCH] systemctl: fix broken list-unit-files with --root
---
src/shared/install.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index 4b09a69456..3ef995a928 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2072,6 +2072,7 @@ int unit_file_get_list(
for (;;) {
_cleanup_(unit_file_list_free_onep) UnitFileList *f = NULL;
struct dirent *de;
+ _cleanup_free_ char *path = NULL;
errno = 0;
de = readdir(d);
@@ -2121,7 +2122,11 @@ int unit_file_get_list(
goto found;
}
- r = unit_file_can_install(&paths, root_dir, f->path, true);
+ path = path_make_absolute(de->d_name, *i);
+ if (!path)
+ return -ENOMEM;
+
+ r = unit_file_can_install(&paths, root_dir, path, true);
if (r == -EINVAL || /* Invalid setting? */
r == -EBADMSG || /* Invalid format? */
r == -ENOENT /* Included file not found? */)

View File

@ -1,114 +0,0 @@
From aeb50ff0bd4bbbca74c4695072232348351d512d Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 27 Aug 2014 17:45:41 +0200
Subject: [PATCH] tmpfiles: make resolv.conf entry conditional on resolved
support
---
Makefile.am | 15 +++++++++++++--
TODO | 2 --
configure.ac | 1 +
tmpfiles.d/.gitignore | 1 +
tmpfiles.d/{etc.conf => etc.conf.m4} | 2 ++
5 files changed, 17 insertions(+), 4 deletions(-)
create mode 100644 tmpfiles.d/.gitignore
rename tmpfiles.d/{etc.conf => etc.conf.m4} (95%)
diff --git a/Makefile.am b/Makefile.am
index cbdf551fa8..70faed4acb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1940,14 +1940,16 @@ nodist_systemunit_DATA += \
units/systemd-tmpfiles-setup.service \
units/systemd-tmpfiles-clean.service
+nodist_tmpfiles_DATA = \
+ tmpfiles.d/etc.conf
+
dist_tmpfiles_DATA = \
tmpfiles.d/systemd.conf \
tmpfiles.d/systemd-nologin.conf \
tmpfiles.d/systemd-remote.conf \
tmpfiles.d/tmp.conf \
tmpfiles.d/x11.conf \
- tmpfiles.d/var.conf \
- tmpfiles.d/etc.conf
+ tmpfiles.d/var.conf
if HAVE_SYSV_COMPAT
dist_tmpfiles_DATA += \
@@ -1970,10 +1972,14 @@ INSTALL_DIRS += \
endif
EXTRA_DIST += \
+ tmpfiles.d/etc.conf.m4 \
units/systemd-tmpfiles-setup-dev.service.in \
units/systemd-tmpfiles-setup.service.in \
units/systemd-tmpfiles-clean.service.in
+CLEANFILES += \
+ tmpfiles.d/etc.conf
+
# ------------------------------------------------------------------------------
if ENABLE_SYSUSERS
systemd_sysusers_SOURCES = \
@@ -5708,6 +5714,11 @@ src/%: src/%.m4
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+tmpfiles.d/%: tmpfiles.d/%.m4
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+
+
units/%: units/%.m4
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
diff --git a/TODO b/TODO
index 09f82d3c37..372825e8bd 100644
--- a/TODO
+++ b/TODO
@@ -120,8 +120,6 @@ Features:
* Allow multiple ExecStart= for all Type= settings, so that we can cover rescue.service nicely
-* the resolv.conf tmpfiles line should be covered by ENABLE_NETWORKD...
-
* Add a new verb "systemctl top"
* logind: allow users to kill or lock their own sessions
diff --git a/configure.ac b/configure.ac
index 18b719856b..08a8a105f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1023,6 +1023,7 @@ have_resolved=no
AC_ARG_ENABLE(resolved, AS_HELP_STRING([--disable-resolved], [disable resolve daemon]))
if test "x$enable_resolved" != "xno"; then
have_resolved=yes
+ M4_DEFINES="$M4_DEFINES -DENABLE_RESOLVED"
fi
AM_CONDITIONAL(ENABLE_RESOLVED, [test "$have_resolved" = "yes"])
diff --git a/tmpfiles.d/.gitignore b/tmpfiles.d/.gitignore
new file mode 100644
index 0000000000..eb323154ff
--- /dev/null
+++ b/tmpfiles.d/.gitignore
@@ -0,0 +1 @@
+etc.conf
diff --git a/tmpfiles.d/etc.conf b/tmpfiles.d/etc.conf.m4
similarity index 95%
rename from tmpfiles.d/etc.conf
rename to tmpfiles.d/etc.conf.m4
index b23272cb27..f567c8d6ea 100644
--- a/tmpfiles.d/etc.conf
+++ b/tmpfiles.d/etc.conf.m4
@@ -10,6 +10,8 @@
L /etc/os-release - - - - ../usr/lib/os-release
L /etc/localtime - - - - ../usr/share/zoneinfo/UTC
L+ /etc/mtab - - - - ../proc/self/mounts
+m4_ifdef(`ENABLE_RESOLVED',
L /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf
+)
C /etc/nsswitch.conf - - - -
C /etc/pam.d - - - -

View File

@ -1,44 +0,0 @@
From 285e8c126b1607188249c42e74c172cb69cc99a6 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 27 Aug 2014 17:46:00 +0200
Subject: [PATCH] TODO
---
TODO | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/TODO b/TODO
index 372825e8bd..a00c13dab2 100644
--- a/TODO
+++ b/TODO
@@ -61,11 +61,6 @@ Features:
* systemd.show_status= should probably have a mode where only failed
units are shown.
-* sd-event:
- - make it possible to embedd our event loop into foreign event loops
- by passing out the epoll fd and providing three functions that fit
- into GSource nicely.
-
* networkd:
- add LLDP client side support
- ipv4ll with multiple interfaces doesn't work when both dhcp and
@@ -74,18 +69,10 @@ Features:
- dhcp and ipv4ll should probably be skipped for "lo" devices, even
if the user has a catchall .network file installed, that might
theoretically match it.
- - we probably should introduce a new operational state that
- indicates that we are trying to acquire some configuration for a
- link but haven't acquired any yet. Just to inform the admin that
- networkd cares about an interface, but is still in progress..
- the DHCP lease data (such as NTP/DNS) is still made available when
a carrier is lost on a link. It should be removed instantly.
- .network setting that allows overriding of the hostname to send to the dhcp server
http://lists.freedesktop.org/archives/systemd-devel/2014-July/021550.html
- - add per-network Domains= settings, with a special syntax Domains=*
- for routing all non-otherwise routed traffic to this link
- - add UseDomains= setting to [DHCP] to add dhcp supplied domains to
- per-interface Domains= list.
- expose in the API the following bits:
- option 15, domain name and/or option 119, search list
- option 12, host name and/or option 81, fqdn

View File

@ -1,41 +0,0 @@
From 418bcb0ce3b704ea26ee1b4a68706abca536f65a Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 22 Aug 2014 14:38:28 +0200
Subject: [PATCH] shared: drop UNIQUE()
The UNIQUE() macro works fine if used in un-stacked macros. However, once
you stack them like:
MAX(MIN(a, b),
CLAMP(MAX(c, d), e, f))
you will get warnings due to shadowing other variables. gcc uses the last
line of a macro expansion as value for __LINE__, therefore, we cannot even
avoid this by splitting the expressions across lines.
Remove the only user of UNIQUE() so we introduce a new helper in
follow-ups.
---
src/shared/macro.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 43fa3e556f..2807bc74e8 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -79,8 +79,6 @@
#define XCONCATENATE(x, y) x ## y
#define CONCATENATE(x, y) XCONCATENATE(x, y)
-#define UNIQUE(prefix) CONCATENATE(prefix, __LINE__)
-
/* Rounds up */
#define ALIGN4(l) (((l) + 3) & ~3)
@@ -219,7 +217,7 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
#else
#define assert_cc(expr) \
DISABLE_WARNING_DECLARATION_AFTER_STATEMENT; \
- struct UNIQUE(_assert_struct_) { \
+ struct CONCATENATE(_assert_struct_, __LINE__) { \
char x[(expr) ? 0 : -1]; \
}; \
REENABLE_WARNING

View File

@ -1,119 +0,0 @@
From fb835651aff79a1e7fc5795086c9b26e59a8e6ca Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 22 Aug 2014 14:41:37 +0200
Subject: [PATCH] shared: make container_of() use unique variable names
If you stack container_of() macros, you will get warnings due to shadowing
variables of the parent context. To avoid this, use unique names for
variables.
Two new helpers are added:
UNIQ: This evaluates to a truly unique value never returned by any
evaluation of this macro. It's a shortcut for __COUNTER__.
UNIQ_T: Takes two arguments and concatenates them. It is a shortcut for
CONCATENATE, but meant to defined typed local variables.
As you usually want to use variables that you just defined, you need to
reference the same unique value at least two times. However, UNIQ returns
a new value on each evaluation, therefore, you have to pass the unique
values into the macro like this:
#define my_macro(a, b) __max_macro(UNIQ, UNIQ, (a), (b))
#define __my_macro(uniqa, uniqb, a, b) ({
typeof(a) UNIQ_T(A, uniqa) = (a);
typeof(b) UNIQ_T(B, uniqb) = (b);
MY_UNSAFE_MACRO(UNIQ_T(A, uniqa), UNIQ_T(B, uniqb));
})
This way, MY_UNSAFE_MACRO() can safely evaluate it's arguments multiple
times as they are local variables. But you can also stack invocations to
the macro my_macro() without clashing names.
This is the same as if you did:
#define my_macro(a, b) __max_macro(__COUNTER__, __COUNTER__, (a), (b))
#define __my_macro(prefixa, prefixb, a, b) ({
typeof(a) CONCATENATE(A, prefixa) = (a);
typeof(b) CONCATENATE(B, prefixb) = (b);
MY_UNSAFE_MACRO(CONCATENATE(A, prefixa), CONCATENATE(B, prefixb));
})
...but in my opinion, the first macro is easier to write and read.
This patch starts by converting container_of() to use this new helper.
Other macros may follow (like MIN, MAX, CLAMP, ...).
---
src/shared/macro.h | 13 ++++++++-----
src/test/test-util.c | 19 +++++++++++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 2807bc74e8..e6734804bd 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -79,6 +79,9 @@
#define XCONCATENATE(x, y) x ## y
#define CONCATENATE(x, y) XCONCATENATE(x, y)
+#define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq))
+#define UNIQ __COUNTER__
+
/* Rounds up */
#define ALIGN4(l) (((l) + 3) & ~3)
@@ -122,13 +125,13 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
- *
*/
-#define container_of(ptr, type, member) \
+#define container_of(ptr, type, member) __container_of(UNIQ, (ptr), type, member)
+#define __container_of(uniq, ptr, type, member) \
__extension__ ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) ); \
- })
+ const typeof( ((type*)0)->member ) *UNIQ_T(A, uniq) = (ptr); \
+ (type*)( (char *)UNIQ_T(A, uniq) - offsetof(type,member) ); \
+ })
#undef MAX
#define MAX(a,b) \
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 4d9b28f9c8..795f3a1b3d 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -96,6 +96,24 @@ static void test_max(void) {
assert_cc(MAXSIZE(char, long) == sizeof(long));
}
+static void test_container_of(void) {
+ struct mytype {
+ uint8_t pad1[3];
+ uint64_t v1;
+ uint8_t pad2[2];
+ uint32_t v2;
+ } _packed_ myval = { };
+
+ assert_cc(sizeof(myval) == 17);
+ assert_se(container_of(&myval.v1, struct mytype, v1) == &myval);
+ assert_se(container_of(&myval.v2, struct mytype, v2) == &myval);
+ assert_se(container_of(&container_of(&myval.v2,
+ struct mytype,
+ v2)->v1,
+ struct mytype,
+ v1) == &myval);
+}
+
static void test_first_word(void) {
assert_se(first_word("Hello", ""));
assert_se(first_word("Hello", "Hello"));
@@ -1218,6 +1236,7 @@ int main(int argc, char *argv[]) {
test_streq_ptr();
test_align_power2();
test_max();
+ test_container_of();
test_first_word();
test_close_many();
test_parse_boolean();

View File

@ -1,33 +0,0 @@
From 60240797a4ce464ec7a0537ccbec4c83f599251c Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 22 Aug 2014 14:57:11 +0200
Subject: [PATCH] login: fix memory-leak on DropController()
Our bus-name watch helpers only remove a bus-name if it's not a
controller, anymore. If we call manager_drop_busname() before
unregistering the controller, the busname will not be dropped. Therefore,
first drop the controller, then drop the bus-name.
---
src/login/logind-session.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 136bbce78e..0c6e425603 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1061,11 +1061,13 @@ bool session_is_controller(Session *s, const char *sender) {
static void session_swap_controller(Session *s, char *name) {
SessionDevice *sd;
+ char *c;
if (s->controller) {
- manager_drop_busname(s->manager, s->controller);
- free(s->controller);
+ c = s->controller;
s->controller = NULL;
+ manager_drop_busname(s->manager, c);
+ free(c);
/* Drop all devices as they're now unused. Do that after the
* controller is released to avoid sending out useles

View File

@ -1,26 +0,0 @@
From 92e63a51052e9ba2fbe6e47a173b6264ae292a58 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Wed, 27 Aug 2014 18:02:17 +0200
Subject: [PATCH] udev: add missing new-line in udevadm error
fprintf() does not add new-lines automatically like log_*() does. Add the
missing \n specified so "udevadm" invoked without arguments adds a newline
to:
udevadm: missing or unknown command
---
src/udev/udevadm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c
index 2c11550467..df546dd823 100644
--- a/src/udev/udevadm.c
+++ b/src/udev/udevadm.c
@@ -134,7 +134,7 @@ int main(int argc, char *argv[]) {
goto out;
}
- fprintf(stderr, "%s: missing or unknown command", program_invocation_short_name);
+ fprintf(stderr, "%s: missing or unknown command\n", program_invocation_short_name);
rc = 2;
out:
label_finish();

View File

@ -1,37 +0,0 @@
From f1566e63da92cee5cbc0074df9cd9a8dc078a62e Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Wed, 27 Aug 2014 18:03:29 +0200
Subject: [PATCH] util: make lookup_uid() global
This is a useful helper, make it global. It will be required for
libsystemd-terminal, at minimum.
---
src/shared/util.c | 2 +-
src/shared/util.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index fdcf5719fa..9e4ff85ffb 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2604,7 +2604,7 @@ bool hostname_is_set(void) {
return !isempty(u.nodename) && !streq(u.nodename, "(none)");
}
-static char *lookup_uid(uid_t uid) {
+char *lookup_uid(uid_t uid) {
long bufsize;
char *name;
_cleanup_free_ char *buf = NULL;
diff --git a/src/shared/util.h b/src/shared/util.h
index ea87c96956..3401280d09 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -432,6 +432,7 @@ int sigprocmask_many(int how, ...);
bool hostname_is_set(void);
+char* lookup_uid(uid_t uid);
char* gethostname_malloc(void);
char* getlogname_malloc(void);
char* getusername_malloc(void);

View File

@ -1,172 +0,0 @@
From aae2b488d084cf2af9a552a55e1d9cc614f2a12a Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Sun, 24 Aug 2014 18:55:58 +0200
Subject: [PATCH] bus: split bus_map_all_properties into multiple helpers
The bus_map_all_properties() helper calls
org.freedesktop.DBus.Properties.GetAll() on a given target and parses the
result according to a given property-table. This simplifies dealing with
DBus.Properties significantly. However, the function is blocking and thus
not really useful in many situations.
This patch extracts the core of this function and adds two new helpers
which directly take dbus-messages as arguments. This way, you can issue
asynchronous requests and parse the result via these helpers:
bus_message_map_all_properties():
This is the same as bus_map_all_properties() but takes the result
message from a GetAll() request as argument. You can thus issue an
asynchronous GetAll() request and then use this helper once you got
the result.
bus_message_map_properties_changed():
This function takes a signal-message that was retrieved via a
PropertiesChanged signal and then parses it like if you retrieved
it via GetAll(). Furthermore, this function returns the number of
matched properties that got invalidated by the PropertiesChanged
signal, but didn't carry the new value. This way, the caller can
issue a new GetAll() request and then parse the result.
The old function bus_map_all_properties() is functionally unchanged, but
now uses bus_message_map_all_properties() internally.
---
src/libsystemd/sd-bus/bus-util.c | 93 +++++++++++++++++++++++++++++++---------
src/libsystemd/sd-bus/bus-util.h | 8 ++++
2 files changed, 80 insertions(+), 21 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index c97bf7d99d..aed3889b12 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -974,32 +974,17 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
return r;
}
-int bus_map_all_properties(sd_bus *bus,
- const char *destination,
- const char *path,
- const struct bus_properties_map *map,
- void *userdata) {
- _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+int bus_message_map_all_properties(sd_bus *bus,
+ sd_bus_message *m,
+ const struct bus_properties_map *map,
+ void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(bus);
- assert(destination);
- assert(path);
+ assert(m);
assert(map);
- r = sd_bus_call_method(
- bus,
- destination,
- path,
- "org.freedesktop.DBus.Properties",
- "GetAll",
- &error,
- &m,
- "s", "");
- if (r < 0)
- return r;
-
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{sv}");
if (r < 0)
return r;
@@ -1052,7 +1037,73 @@ int bus_map_all_properties(sd_bus *bus,
return r;
}
- return r;
+ return sd_bus_message_exit_container(m);
+}
+
+int bus_message_map_properties_changed(sd_bus *bus,
+ sd_bus_message *m,
+ const struct bus_properties_map *map,
+ void *userdata) {
+ const char *member;
+ int r, invalidated, i;
+
+ assert(bus);
+ assert(m);
+ assert(map);
+
+ /* skip interface, but allow callers to do that themselves */
+ sd_bus_message_skip(m, "s");
+
+ r = bus_message_map_all_properties(bus, m, map, userdata);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "s");
+ if (r < 0)
+ return r;
+
+ invalidated = 0;
+ while ((r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &member)) > 0)
+ for (i = 0; map[i].member; i++)
+ if (streq(map[i].member, member)) {
+ ++invalidated;
+ break;
+ }
+
+ r = sd_bus_message_exit_container(m);
+ if (r < 0)
+ return r;
+
+ return invalidated;
+}
+
+int bus_map_all_properties(sd_bus *bus,
+ const char *destination,
+ const char *path,
+ const struct bus_properties_map *map,
+ void *userdata) {
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ int r;
+
+ assert(bus);
+ assert(destination);
+ assert(path);
+ assert(map);
+
+ r = sd_bus_call_method(
+ bus,
+ destination,
+ path,
+ "org.freedesktop.DBus.Properties",
+ "GetAll",
+ &error,
+ &m,
+ "s", "");
+ if (r < 0)
+ return r;
+
+ return bus_message_map_all_properties(bus, m, map, userdata);
}
int bus_open_transport(BusTransport transport, const char *host, bool user, sd_bus **bus) {
diff --git a/src/libsystemd/sd-bus/bus-util.h b/src/libsystemd/sd-bus/bus-util.h
index faf1775809..696daa1f03 100644
--- a/src/libsystemd/sd-bus/bus-util.h
+++ b/src/libsystemd/sd-bus/bus-util.h
@@ -46,6 +46,14 @@ struct bus_properties_map {
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
+int bus_message_map_all_properties(sd_bus *bus,
+ sd_bus_message *m,
+ const struct bus_properties_map *map,
+ void *userdata);
+int bus_message_map_properties_changed(sd_bus *bus,
+ sd_bus_message *m,
+ const struct bus_properties_map *map,
+ void *userdata);
int bus_map_all_properties(sd_bus *bus,
const char *destination,
const char *path,

File diff suppressed because it is too large Load Diff

View File

@ -1,975 +0,0 @@
From e202fa31fb2d60084e7b2ab7976a81c138184d40 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Wed, 27 Aug 2014 18:17:27 +0200
Subject: [PATCH] terminal: add input interface
The idev-interface provides input drivers for all libsystemd-terminal
based applications. It is split into 4 main objects:
idev_context: The context object tracks global state of the input
interface. This will include data like system-keymaps,
xkb contexts and more.
idev_session: A session serves as controller for a set of devices.
Each session on an idev-context is independent of each
other. The session is also the main notification object.
All events raised via idev are reported through the
session interface. Apart of that, the session is a
pretty dumb object that just contains devices.
idev_element: Elements provide real hardware in the idev stack. For
each hardware device, one element is added. Elements
have no knowledge of higher-level device types, they
only provide raw input data to the upper levels. For
example, each evdev device is represented by a different
element in an idev session.
idev_device: Devices are objects that the application deals with. An
application is usually not interested in elements (and
those are hidden to applications), instead, they want
high-level input devices like keyboard, touchpads, mice
and more. Device are the high-level interface provided
by idev. Each device might be fed by a set of elements.
Elements drive the device. If elements are removed,
devices are destroyed. If elements are added, suitable
devices are created.
Applications should monitor the system for sessions and hardware devices.
For each session they want to operate on, they create an idev_session
object and add hardware to that object. The idev interface requires the
application to monitor the system (preferably via sysview_*, but not
required) for hardware devices. Whenever hardware is added to the idev
session, new devices *might* be created. The relationship between hardware
and high-level idev-devices is hidden in the idev-session and not exposed.
Internally, the idev elements and devices are virtual objects. Each real
hardware and device type inherits those virtual objects and provides real
elements and devices. Those types will be added in follow-up commits.
Data flow from hardware to the application is done via idev_*_feed()
functions. Data flow from applications to hardware is done via
idev_*_feedback() functions. Feedback is usually used for LEDs, FF and
similar operations.
---
Makefile.am | 3 +
src/libsystemd-terminal/idev-internal.h | 165 +++++++++
src/libsystemd-terminal/idev.c | 587 ++++++++++++++++++++++++++++++++
src/libsystemd-terminal/idev.h | 133 ++++++++
4 files changed, 888 insertions(+)
create mode 100644 src/libsystemd-terminal/idev-internal.h
create mode 100644 src/libsystemd-terminal/idev.c
create mode 100644 src/libsystemd-terminal/idev.h
diff --git a/Makefile.am b/Makefile.am
index 3a263f8c17..82f474e20e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2971,6 +2971,9 @@ libsystemd_terminal_la_CFLAGS = \
$(AM_CFLAGS)
libsystemd_terminal_la_SOURCES = \
+ src/libsystemd-terminal/idev.h \
+ src/libsystemd-terminal/idev-internal.h \
+ src/libsystemd-terminal/idev.c \
src/libsystemd-terminal/sysview.h \
src/libsystemd-terminal/sysview-internal.h \
src/libsystemd-terminal/sysview.c \
diff --git a/src/libsystemd-terminal/idev-internal.h b/src/libsystemd-terminal/idev-internal.h
new file mode 100644
index 0000000000..bffefbb9c1
--- /dev/null
+++ b/src/libsystemd-terminal/idev-internal.h
@@ -0,0 +1,165 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 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/>.
+***/
+
+#pragma once
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <systemd/sd-bus.h>
+#include <systemd/sd-event.h>
+#include "hashmap.h"
+#include "idev.h"
+#include "list.h"
+#include "util.h"
+
+typedef struct idev_link idev_link;
+typedef struct idev_device_vtable idev_device_vtable;
+typedef struct idev_element idev_element;
+typedef struct idev_element_vtable idev_element_vtable;
+
+/*
+ * Element Links
+ */
+
+struct idev_link {
+ /* element-to-device connection */
+ LIST_FIELDS(idev_link, links_by_element);
+ idev_element *element;
+
+ /* device-to-element connection */
+ LIST_FIELDS(idev_link, links_by_device);
+ idev_device *device;
+};
+
+/*
+ * Devices
+ */
+
+struct idev_device_vtable {
+ void (*free) (idev_device *d);
+ void (*attach) (idev_device *d, idev_link *l);
+ void (*detach) (idev_device *d, idev_link *l);
+ int (*feed) (idev_device *d, idev_data *data);
+};
+
+struct idev_device {
+ const idev_device_vtable *vtable;
+ idev_session *session;
+ char *name;
+
+ LIST_HEAD(idev_link, links);
+
+ bool public : 1;
+ bool enabled : 1;
+};
+
+#define IDEV_DEVICE_INIT(_vtable, _session) ((idev_device){ \
+ .vtable = (_vtable), \
+ .session = (_session), \
+ })
+
+idev_device *idev_find_device(idev_session *s, const char *name);
+
+int idev_device_add(idev_device *d, const char *name);
+idev_device *idev_device_free(idev_device *d);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(idev_device*, idev_device_free);
+
+int idev_device_feed(idev_device *d, idev_data *data);
+void idev_device_feedback(idev_device *d, idev_data *data);
+
+/*
+ * Elements
+ */
+
+struct idev_element_vtable {
+ void (*free) (idev_element *e);
+ void (*enable) (idev_element *e);
+ void (*disable) (idev_element *e);
+ void (*open) (idev_element *e);
+ void (*close) (idev_element *e);
+ void (*feedback) (idev_element *e, idev_data *data);
+};
+
+struct idev_element {
+ const idev_element_vtable *vtable;
+ idev_session *session;
+ unsigned long n_open;
+ char *name;
+
+ LIST_HEAD(idev_link, links);
+
+ bool enabled : 1;
+ bool readable : 1;
+ bool writable : 1;
+};
+
+#define IDEV_ELEMENT_INIT(_vtable, _session) ((idev_element){ \
+ .vtable = (_vtable), \
+ .session = (_session), \
+ })
+
+idev_element *idev_find_element(idev_session *s, const char *name);
+
+int idev_element_add(idev_element *e, const char *name);
+idev_element *idev_element_free(idev_element *e);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(idev_element*, idev_element_free);
+
+int idev_element_feed(idev_element *e, idev_data *data);
+void idev_element_feedback(idev_element *e, idev_data *data);
+
+/*
+ * Sessions
+ */
+
+struct idev_session {
+ idev_context *context;
+ char *name;
+ char *path;
+
+ Hashmap *element_map;
+ Hashmap *device_map;
+
+ idev_event_fn event_fn;
+ void *userdata;
+
+ bool custom : 1;
+ bool managed : 1;
+ bool enabled : 1;
+};
+
+idev_session *idev_find_session(idev_context *c, const char *name);
+int idev_session_raise_device_data(idev_session *s, idev_device *d, idev_data *data);
+
+/*
+ * Contexts
+ */
+
+struct idev_context {
+ unsigned long ref;
+ sd_event *event;
+ sd_bus *sysbus;
+
+ Hashmap *session_map;
+ Hashmap *data_map;
+};
diff --git a/src/libsystemd-terminal/idev.c b/src/libsystemd-terminal/idev.c
new file mode 100644
index 0000000000..5e3080797a
--- /dev/null
+++ b/src/libsystemd-terminal/idev.c
@@ -0,0 +1,587 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 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 <inttypes.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <systemd/sd-bus.h>
+#include <systemd/sd-event.h>
+#include <systemd/sd-login.h>
+#include "hashmap.h"
+#include "idev.h"
+#include "idev-internal.h"
+#include "login-shared.h"
+#include "macro.h"
+#include "set.h"
+#include "util.h"
+
+static void element_open(idev_element *e);
+static void element_close(idev_element *e);
+
+/*
+ * Devices
+ */
+
+idev_device *idev_find_device(idev_session *s, const char *name) {
+ assert_return(s, NULL);
+ assert_return(name, NULL);
+
+ return hashmap_get(s->device_map, name);
+}
+
+int idev_device_add(idev_device *d, const char *name) {
+ int r;
+
+ assert_return(d, -EINVAL);
+ assert_return(d->vtable, -EINVAL);
+ assert_return(d->session, -EINVAL);
+ assert_return(name, -EINVAL);
+
+ d->name = strdup(name);
+ if (!d->name)
+ return -ENOMEM;
+
+ r = hashmap_put(d->session->device_map, d->name, d);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+idev_device *idev_device_free(idev_device *d) {
+ idev_device tmp;
+
+ if (!d)
+ return NULL;
+
+ assert(!d->enabled);
+ assert(!d->public);
+ assert(!d->links);
+ assert(d->vtable);
+ assert(d->vtable->free);
+
+ if (d->name)
+ hashmap_remove_value(d->session->device_map, d->name, d);
+
+ tmp = *d;
+ d->vtable->free(d);
+
+ free(tmp.name);
+
+ return NULL;
+}
+
+int idev_device_feed(idev_device *d, idev_data *data) {
+ assert(d);
+ assert(data);
+ assert(data->type < IDEV_DATA_CNT);
+
+ if (d->vtable->feed)
+ return d->vtable->feed(d, data);
+ else
+ return 0;
+}
+
+void idev_device_feedback(idev_device *d, idev_data *data) {
+ idev_link *l;
+
+ assert(d);
+ assert(data);
+ assert(data->type < IDEV_DATA_CNT);
+
+ LIST_FOREACH(links_by_device, l, d->links)
+ idev_element_feedback(l->element, data);
+}
+
+static void device_attach(idev_device *d, idev_link *l) {
+ assert(d);
+ assert(l);
+
+ if (d->vtable->attach)
+ d->vtable->attach(d, l);
+
+ if (d->enabled)
+ element_open(l->element);
+}
+
+static void device_detach(idev_device *d, idev_link *l) {
+ assert(d);
+ assert(l);
+
+ if (d->enabled)
+ element_close(l->element);
+
+ if (d->vtable->detach)
+ d->vtable->detach(d, l);
+}
+
+void idev_device_enable(idev_device *d) {
+ idev_link *l;
+
+ assert(d);
+
+ if (!d->enabled) {
+ d->enabled = true;
+ LIST_FOREACH(links_by_device, l, d->links)
+ element_open(l->element);
+ }
+}
+
+void idev_device_disable(idev_device *d) {
+ idev_link *l;
+
+ assert(d);
+
+ if (d->enabled) {
+ d->enabled = false;
+ LIST_FOREACH(links_by_device, l, d->links)
+ element_close(l->element);
+ }
+}
+
+/*
+ * Elements
+ */
+
+idev_element *idev_find_element(idev_session *s, const char *name) {
+ assert_return(s, NULL);
+ assert_return(name, NULL);
+
+ return hashmap_get(s->element_map, name);
+}
+
+int idev_element_add(idev_element *e, const char *name) {
+ int r;
+
+ assert_return(e, -EINVAL);
+ assert_return(e->vtable, -EINVAL);
+ assert_return(e->session, -EINVAL);
+ assert_return(name, -EINVAL);
+
+ e->name = strdup(name);
+ if (!e->name)
+ return -ENOMEM;
+
+ r = hashmap_put(e->session->element_map, e->name, e);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+idev_element *idev_element_free(idev_element *e) {
+ idev_element tmp;
+
+ if (!e)
+ return NULL;
+
+ assert(!e->enabled);
+ assert(!e->links);
+ assert(e->n_open == 0);
+ assert(e->vtable);
+ assert(e->vtable->free);
+
+ if (e->name)
+ hashmap_remove_value(e->session->element_map, e->name, e);
+
+ tmp = *e;
+ e->vtable->free(e);
+
+ free(tmp.name);
+
+ return NULL;
+}
+
+int idev_element_feed(idev_element *e, idev_data *data) {
+ int r, error = 0;
+ idev_link *l;
+
+ assert(e);
+ assert(data);
+ assert(data->type < IDEV_DATA_CNT);
+
+ LIST_FOREACH(links_by_element, l, e->links) {
+ r = idev_device_feed(l->device, data);
+ if (r != 0)
+ error = r;
+ }
+
+ return error;
+}
+
+void idev_element_feedback(idev_element *e, idev_data *data) {
+ assert(e);
+ assert(data);
+ assert(data->type < IDEV_DATA_CNT);
+
+ if (e->vtable->feedback)
+ e->vtable->feedback(e, data);
+}
+
+static void element_open(idev_element *e) {
+ assert(e);
+
+ if (e->n_open++ == 0 && e->vtable->open)
+ e->vtable->open(e);
+}
+
+static void element_close(idev_element *e) {
+ assert(e);
+ assert(e->n_open > 0);
+
+ if (--e->n_open == 0 && e->vtable->close)
+ e->vtable->close(e);
+}
+
+static void element_enable(idev_element *e) {
+ assert(e);
+
+ if (!e->enabled) {
+ e->enabled = true;
+ if (e->vtable->enable)
+ e->vtable->enable(e);
+ }
+}
+
+static void element_disable(idev_element *e) {
+ assert(e);
+
+ if (e->enabled) {
+ e->enabled = false;
+ if (e->vtable->disable)
+ e->vtable->disable(e);
+ }
+}
+
+/*
+ * Sessions
+ */
+
+static int session_raise(idev_session *s, idev_event *ev) {
+ return s->event_fn(s, s->userdata, ev);
+}
+
+static int session_raise_device_add(idev_session *s, idev_device *d) {
+ idev_event event = {
+ .type = IDEV_EVENT_DEVICE_ADD,
+ .device_add = {
+ .device = d,
+ },
+ };
+
+ return session_raise(s, &event);
+}
+
+static int session_raise_device_remove(idev_session *s, idev_device *d) {
+ idev_event event = {
+ .type = IDEV_EVENT_DEVICE_REMOVE,
+ .device_remove = {
+ .device = d,
+ },
+ };
+
+ return session_raise(s, &event);
+}
+
+int idev_session_raise_device_data(idev_session *s, idev_device *d, idev_data *data) {
+ idev_event event = {
+ .type = IDEV_EVENT_DEVICE_DATA,
+ .device_data = {
+ .device = d,
+ .data = *data,
+ },
+ };
+
+ return session_raise(s, &event);
+}
+
+static int session_add_device(idev_session *s, idev_device *d) {
+ int r;
+
+ assert(s);
+ assert(d);
+
+ log_debug("idev: %s: add device '%s'", s->name, d->name);
+
+ d->public = true;
+ r = session_raise_device_add(s, d);
+ if (r != 0) {
+ d->public = false;
+ goto error;
+ }
+
+ return 0;
+
+error:
+ if (r < 0)
+ log_debug("idev: %s: error while adding device '%s': %s",
+ s->name, d->name, strerror(-r));
+ return r;
+}
+
+static int session_remove_device(idev_session *s, idev_device *d) {
+ int r, error = 0;
+
+ assert(s);
+ assert(d);
+
+ log_debug("idev: %s: remove device '%s'", s->name, d->name);
+
+ d->public = false;
+ r = session_raise_device_remove(s, d);
+ if (r != 0)
+ error = r;
+
+ idev_device_disable(d);
+
+ if (error < 0)
+ log_debug("idev: %s: error while removing device '%s': %s",
+ s->name, d->name, strerror(-error));
+ idev_device_free(d);
+ return error;
+}
+
+static int session_add_element(idev_session *s, idev_element *e) {
+ assert(s);
+ assert(e);
+
+ log_debug("idev: %s: add element '%s'", s->name, e->name);
+
+ if (s->enabled)
+ element_enable(e);
+
+ return 0;
+}
+
+static int session_remove_element(idev_session *s, idev_element *e) {
+ int r, error = 0;
+ idev_device *d;
+ idev_link *l;
+
+ assert(s);
+ assert(e);
+
+ log_debug("idev: %s: remove element '%s'", s->name, e->name);
+
+ while ((l = e->links)) {
+ d = l->device;
+ LIST_REMOVE(links_by_device, d->links, l);
+ LIST_REMOVE(links_by_element, e->links, l);
+ device_detach(d, l);
+
+ if (!d->links) {
+ r = session_remove_device(s, d);
+ if (r != 0)
+ error = r;
+ }
+
+ l->device = NULL;
+ l->element = NULL;
+ free(l);
+ }
+
+ element_disable(e);
+
+ if (error < 0)
+ log_debug("idev: %s: error while removing element '%s': %s",
+ s->name, e->name, strerror(-r));
+ idev_element_free(e);
+ return error;
+}
+
+idev_session *idev_find_session(idev_context *c, const char *name) {
+ assert_return(c, NULL);
+ assert_return(name, NULL);
+
+ return hashmap_get(c->session_map, name);
+}
+
+int idev_session_new(idev_session **out,
+ idev_context *c,
+ unsigned int flags,
+ const char *name,
+ idev_event_fn event_fn,
+ void *userdata) {
+ _cleanup_(idev_session_freep) idev_session *s = NULL;
+ int r;
+
+ assert_return(out, -EINVAL);
+ assert_return(c, -EINVAL);
+ assert_return(name, -EINVAL);
+ assert_return(event_fn, -EINVAL);
+ assert_return((flags & IDEV_SESSION_CUSTOM) == !session_id_valid(name), -EINVAL);
+ assert_return(!(flags & IDEV_SESSION_CUSTOM) || !(flags & IDEV_SESSION_MANAGED), -EINVAL);
+ assert_return(!(flags & IDEV_SESSION_MANAGED) || c->sysbus, -EINVAL);
+
+ s = new0(idev_session, 1);
+ if (!s)
+ return -ENOMEM;
+
+ s->context = idev_context_ref(c);
+ s->custom = flags & IDEV_SESSION_CUSTOM;
+ s->managed = flags & IDEV_SESSION_MANAGED;
+ s->event_fn = event_fn;
+ s->userdata = userdata;
+
+ s->name = strdup(name);
+ if (!s->name)
+ return -ENOMEM;
+
+ if (s->managed) {
+ r = sd_bus_path_encode("/org/freedesktop/login1/session", s->name, &s->path);
+ if (r < 0)
+ return r;
+ }
+
+ s->element_map = hashmap_new(string_hash_func, string_compare_func);
+ if (!s->element_map)
+ return -ENOMEM;
+
+ s->device_map = hashmap_new(string_hash_func, string_compare_func);
+ if (!s->device_map)
+ return -ENOMEM;
+
+ r = hashmap_put(c->session_map, s->name, s);
+ if (r < 0)
+ return r;
+
+ *out = s;
+ s = NULL;
+ return 0;
+}
+
+idev_session *idev_session_free(idev_session *s) {
+ idev_element *e;
+
+ if (!s)
+ return NULL;
+
+ while ((e = hashmap_first(s->element_map)))
+ session_remove_element(s, e);
+
+ assert(hashmap_size(s->device_map) == 0);
+
+ if (s->name)
+ hashmap_remove_value(s->context->session_map, s->name, s);
+
+ s->context = idev_context_unref(s->context);
+ hashmap_free(s->device_map);
+ hashmap_free(s->element_map);
+ free(s->path);
+ free(s->name);
+ free(s);
+
+ return NULL;
+}
+
+bool idev_session_is_enabled(idev_session *s) {
+ return s && s->enabled;
+}
+
+void idev_session_enable(idev_session *s) {
+ idev_element *e;
+ Iterator i;
+
+ assert(s);
+
+ if (!s->enabled) {
+ s->enabled = true;
+ HASHMAP_FOREACH(e, s->element_map, i)
+ element_enable(e);
+ }
+}
+
+void idev_session_disable(idev_session *s) {
+ idev_element *e;
+ Iterator i;
+
+ assert(s);
+
+ if (s->enabled) {
+ s->enabled = false;
+ HASHMAP_FOREACH(e, s->element_map, i)
+ element_disable(e);
+ }
+}
+
+/*
+ * Contexts
+ */
+
+int idev_context_new(idev_context **out, sd_event *event, sd_bus *sysbus) {
+ _cleanup_(idev_context_unrefp) idev_context *c = NULL;
+
+ assert_return(out, -EINVAL);
+ assert_return(event, -EINVAL);
+
+ c = new0(idev_context, 1);
+ if (!c)
+ return -ENOMEM;
+
+ c->ref = 1;
+ c->event = sd_event_ref(event);
+
+ if (sysbus)
+ c->sysbus = sd_bus_ref(sysbus);
+
+ c->session_map = hashmap_new(string_hash_func, string_compare_func);
+ if (!c->session_map)
+ return -ENOMEM;
+
+ c->data_map = hashmap_new(string_hash_func, string_compare_func);
+ if (!c->data_map)
+ return -ENOMEM;
+
+ *out = c;
+ c = NULL;
+ return 0;
+}
+
+static void context_cleanup(idev_context *c) {
+ assert(hashmap_size(c->data_map) == 0);
+ assert(hashmap_size(c->session_map) == 0);
+
+ hashmap_free(c->data_map);
+ hashmap_free(c->session_map);
+ c->sysbus = sd_bus_unref(c->sysbus);
+ c->event = sd_event_unref(c->event);
+ free(c);
+}
+
+idev_context *idev_context_ref(idev_context *c) {
+ assert_return(c, NULL);
+ assert_return(c->ref > 0, NULL);
+
+ ++c->ref;
+ return c;
+}
+
+idev_context *idev_context_unref(idev_context *c) {
+ if (!c)
+ return NULL;
+
+ assert_return(c->ref > 0, NULL);
+
+ if (--c->ref == 0)
+ context_cleanup(c);
+
+ return NULL;
+}
diff --git a/src/libsystemd-terminal/idev.h b/src/libsystemd-terminal/idev.h
new file mode 100644
index 0000000000..6f618f37af
--- /dev/null
+++ b/src/libsystemd-terminal/idev.h
@@ -0,0 +1,133 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 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/>.
+***/
+
+/*
+ * IDev
+ */
+
+#pragma once
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <systemd/sd-bus.h>
+#include <systemd/sd-event.h>
+#include "util.h"
+
+typedef struct idev_data idev_data;
+
+typedef struct idev_event idev_event;
+typedef struct idev_device idev_device;
+typedef struct idev_session idev_session;
+typedef struct idev_context idev_context;
+
+/*
+ * Types
+ */
+
+enum {
+ IDEV_ELEMENT_CNT
+};
+
+enum {
+ IDEV_DEVICE_CNT
+};
+
+/*
+ * Data Packets
+ */
+
+enum {
+ IDEV_DATA_RESYNC,
+ IDEV_DATA_CNT
+};
+
+struct idev_data {
+ unsigned int type;
+ bool resync : 1;
+};
+
+/*
+ * Events
+ */
+
+enum {
+ IDEV_EVENT_DEVICE_ADD,
+ IDEV_EVENT_DEVICE_REMOVE,
+ IDEV_EVENT_DEVICE_DATA,
+ IDEV_EVENT_CNT
+};
+
+struct idev_event {
+ unsigned int type;
+ union {
+ struct {
+ idev_device *device;
+ } device_add, device_remove;
+
+ struct {
+ idev_device *device;
+ idev_data data;
+ } device_data;
+ };
+};
+
+typedef int (*idev_event_fn) (idev_session *s, void *userdata, idev_event *ev);
+
+/*
+ * Devices
+ */
+
+void idev_device_enable(idev_device *d);
+void idev_device_disable(idev_device *d);
+
+/*
+ * Sessions
+ */
+
+enum {
+ IDEV_SESSION_CUSTOM = (1 << 0),
+ IDEV_SESSION_MANAGED = (1 << 1),
+};
+
+int idev_session_new(idev_session **out,
+ idev_context *c,
+ unsigned int flags,
+ const char *name,
+ idev_event_fn event_fn,
+ void *userdata);
+idev_session *idev_session_free(idev_session *s);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(idev_session*, idev_session_free);
+
+bool idev_session_is_enabled(idev_session *s);
+void idev_session_enable(idev_session *s);
+void idev_session_disable(idev_session *s);
+
+/*
+ * Contexts
+ */
+
+int idev_context_new(idev_context **out, sd_event *event, sd_bus *sysbus);
+idev_context *idev_context_ref(idev_context *c);
+idev_context *idev_context_unref(idev_context *c);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(idev_context*, idev_context_unref);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,566 +0,0 @@
From 8e9371905c743cf997b2e8fa7fe3238f81f741fe Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Wed, 27 Aug 2014 18:38:01 +0200
Subject: [PATCH] terminal: add systemd-evcat input debugging tool
Like systemd-subterm, this new systemd-evcat tool should only be used to
debug libsystemd-terminal. systemd-evcat attaches to the running session
and pushes all evdev devices attached to the current session into an
idev-session. All events of the created idev-devices are then printed to
stdout for input-event debugging.
---
.gitignore | 1 +
Makefile.am | 14 ++
src/libsystemd-terminal/evcat.c | 499 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 514 insertions(+)
create mode 100644 src/libsystemd-terminal/evcat.c
diff --git a/.gitignore b/.gitignore
index 8aed0b9ba6..f8650870a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,6 +69,7 @@
/systemd-detect-virt
/systemd-efi-boot-generator
/systemd-escape
+/systemd-evcat
/systemd-firstboot
/systemd-fsck
/systemd-fstab-generator
diff --git a/Makefile.am b/Makefile.am
index 35a4c44a9f..e091febc1f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2954,6 +2954,7 @@ noinst_LTLIBRARIES += \
libsystemd-terminal.la
noinst_PROGRAMS += \
+ systemd-evcat \
systemd-subterm
unifontdatadir=$(datadir)/unifont
@@ -2995,6 +2996,19 @@ libsystemd_terminal_la_LIBADD = \
libsystemd-shared.la \
$(TERMINAL_LIBS)
+systemd_evcat_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(TERMINAL_CFLAGS)
+
+systemd_evcat_SOURCES = \
+ src/libsystemd-terminal/evcat.c
+
+systemd_evcat_LDADD = \
+ libsystemd-terminal.la \
+ libsystemd-internal.la \
+ libsystemd-shared.la \
+ $(TERMINAL_LIBS)
+
systemd_subterm_SOURCES = \
src/libsystemd-terminal/subterm.c
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
new file mode 100644
index 0000000000..590a30d873
--- /dev/null
+++ b/src/libsystemd-terminal/evcat.c
@@ -0,0 +1,499 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 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/>.
+***/
+
+/*
+ * Event Catenation
+ * The evcat tool catenates input events of all requested devices and prints
+ * them to standard-output. It's only meant for debugging of input-related
+ * problems.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <getopt.h>
+#include <libevdev/libevdev.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <systemd/sd-bus.h>
+#include <systemd/sd-event.h>
+#include <systemd/sd-login.h>
+#include <termios.h>
+#include <unistd.h>
+#include <xkbcommon/xkbcommon.h>
+#include "build.h"
+#include "bus-util.h"
+#include "event-util.h"
+#include "idev.h"
+#include "macro.h"
+#include "sysview.h"
+#include "term-internal.h"
+#include "util.h"
+
+typedef struct Evcat Evcat;
+
+struct Evcat {
+ char *session;
+ char *seat;
+ sd_event *event;
+ sd_bus *bus;
+ sysview_context *sysview;
+ idev_context *idev;
+ idev_session *idev_session;
+
+ bool managed : 1;
+};
+
+static Evcat *evcat_free(Evcat *e) {
+ if (!e)
+ return NULL;
+
+ e->idev_session = idev_session_free(e->idev_session);
+ e->idev = idev_context_unref(e->idev);
+ e->sysview = sysview_context_free(e->sysview);
+ e->bus = sd_bus_unref(e->bus);
+ e->event = sd_event_unref(e->event);
+ free(e->seat);
+ free(e->session);
+ free(e);
+
+ tcflush(0, TCIOFLUSH);
+
+ return NULL;
+}
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(Evcat*, evcat_free);
+
+static bool is_managed(const char *session) {
+ unsigned int vtnr;
+ struct stat st;
+ long mode;
+ int r;
+
+ /* Using logind's Controller API is highly fragile if there is already
+ * a session controller running. If it is registered as controller
+ * itself, TakeControl will simply fail. But if its a legacy controller
+ * that does not use logind's controller API, we must never register
+ * our own controller. Otherwise, we really mess up the VT. Therefore,
+ * only run in managed mode if there's no-one else. */
+
+ if (geteuid() == 0)
+ return false;
+
+ if (!isatty(1))
+ return false;
+
+ if (!session)
+ return false;
+
+ r = sd_session_get_vt(session, &vtnr);
+ if (r < 0 || vtnr < 1 || vtnr > 63)
+ return false;
+
+ mode = 0;
+ r = ioctl(1, KDGETMODE, &mode);
+ if (r < 0 || mode != KD_TEXT)
+ return false;
+
+ r = fstat(1, &st);
+ if (r < 0 || minor(st.st_rdev) != vtnr)
+ return false;
+
+ return true;
+}
+
+static int evcat_new(Evcat **out) {
+ _cleanup_(evcat_freep) Evcat *e = NULL;
+ int r;
+
+ assert(out);
+
+ e = new0(Evcat, 1);
+ if (!e)
+ return log_oom();
+
+ r = sd_pid_get_session(getpid(), &e->session);
+ if (r < 0) {
+ log_error("Cannot retrieve logind session: %s", strerror(-r));
+ return r;
+ }
+
+ r = sd_session_get_seat(e->session, &e->seat);
+ if (r < 0) {
+ log_error("Cannot retrieve seat of logind session: %s", strerror(-r));
+ return r;
+ }
+
+ e->managed = is_managed(e->session);
+
+ r = sd_event_default(&e->event);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_open_system(&e->bus);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_attach_event(e->bus, e->event, SD_EVENT_PRIORITY_NORMAL);
+ if (r < 0)
+ return r;
+
+ r = sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
+ if (r < 0)
+ return r;
+
+ r = sd_event_add_signal(e->event, NULL, SIGTERM, NULL, NULL);
+ if (r < 0)
+ return r;
+
+ r = sd_event_add_signal(e->event, NULL, SIGINT, NULL, NULL);
+ if (r < 0)
+ return r;
+
+ r = sysview_context_new(&e->sysview,
+ SYSVIEW_CONTEXT_SCAN_LOGIND |
+ SYSVIEW_CONTEXT_SCAN_EVDEV,
+ e->event,
+ e->bus,
+ NULL);
+ if (r < 0)
+ return r;
+
+ r = idev_context_new(&e->idev, e->event, e->bus);
+ if (r < 0)
+ return r;
+
+ *out = e;
+ e = NULL;
+ return 0;
+}
+
+static void kdata_print(idev_data *data) {
+ idev_data_keyboard *k = &data->keyboard;
+ char buf[128];
+ uint32_t i, c;
+ int cwidth;
+
+ /* Key-press state: UP/DOWN/REPEAT */
+ printf(" %-6s", k->value == 0 ? "UP" :
+ k->value == 1 ? "DOWN" :
+ "REPEAT");
+
+ /* Keycode that triggered the event */
+ printf(" | %5u", (unsigned)k->keycode);
+
+ /* Well-known name of the keycode */
+ printf(" | %-20s", libevdev_event_code_get_name(EV_KEY, k->keycode) ? : "<unknown>");
+
+ /* Well-known modifiers */
+ printf(" | %-5s", (k->mods & IDEV_KBDMOD_SHIFT) ? "SHIFT" : "");
+ printf(" %-4s", (k->mods & IDEV_KBDMOD_CTRL) ? "CTRL" : "");
+ printf(" %-3s", (k->mods & IDEV_KBDMOD_ALT) ? "ALT" : "");
+ printf(" %-5s", (k->mods & IDEV_KBDMOD_LINUX) ? "LINUX" : "");
+ printf(" %-4s", (k->mods & IDEV_KBDMOD_CAPS) ? "CAPS" : "");
+
+ /* Resolved symbols */
+ printf(" |");
+ for (i = 0; i < k->n_syms; ++i) {
+ buf[0] = 0;
+ xkb_keysym_get_name(k->keysyms[i], buf, sizeof(buf));
+
+ if (is_locale_utf8()) {
+ c = k->codepoints[i];
+ if (c < 0x110000 && c > 0x20 && (c < 0x7f || c > 0x9f)) {
+ /* "%4lc" doesn't work well, so hard-code it */
+ cwidth = mk_wcwidth(c);
+ while (cwidth++ < 2)
+ printf(" ");
+
+ printf(" '%lc':", (wchar_t)c);
+ } else {
+ printf(" ");
+ }
+ }
+
+ printf(" XKB_KEY_%-30s", buf);
+ }
+
+ printf("\n");
+}
+
+static bool kdata_is_exit(idev_data *data) {
+ idev_data_keyboard *k = &data->keyboard;
+
+ if (k->value != 1)
+ return false;
+ if (k->n_syms != 1)
+ return false;
+
+ return k->codepoints[0] == 'q';
+}
+
+static int evcat_idev_fn(idev_session *session, void *userdata, idev_event *ev) {
+ Evcat *e = userdata;
+
+ switch (ev->type) {
+ case IDEV_EVENT_DEVICE_ADD:
+ idev_device_enable(ev->device_add.device);
+ break;
+ case IDEV_EVENT_DEVICE_REMOVE:
+ idev_device_disable(ev->device_remove.device);
+ break;
+ case IDEV_EVENT_DEVICE_DATA:
+ switch (ev->device_data.data.type) {
+ case IDEV_DATA_KEYBOARD:
+ if (kdata_is_exit(&ev->device_data.data))
+ sd_event_exit(e->event, 0);
+ else
+ kdata_print(&ev->device_data.data);
+
+ break;
+ }
+
+ break;
+ }
+
+ return 0;
+}
+
+static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *ev) {
+ unsigned int flags, type;
+ Evcat *e = userdata;
+ sysview_device *d;
+ const char *name;
+ int r;
+
+ switch (ev->type) {
+ case SYSVIEW_EVENT_SESSION_FILTER:
+ if (streq_ptr(e->session, ev->session_filter.id))
+ return 1;
+
+ break;
+ case SYSVIEW_EVENT_SESSION_ADD:
+ assert(!e->idev_session);
+
+ name = sysview_session_get_name(ev->session_add.session);
+ flags = 0;
+
+ if (e->managed)
+ flags |= IDEV_SESSION_MANAGED;
+
+ r = idev_session_new(&e->idev_session,
+ e->idev,
+ flags,
+ name,
+ evcat_idev_fn,
+ e);
+ if (r < 0) {
+ log_error("Cannot create idev session: %s", strerror(-r));
+ return r;
+ }
+
+ idev_session_enable(e->idev_session);
+
+ if (e->managed) {
+ r = sysview_session_take_control(ev->session_add.session);
+ if (r < 0) {
+ log_error("Cannot request session control: %s", strerror(-r));
+ return r;
+ }
+ }
+
+ break;
+ case SYSVIEW_EVENT_SESSION_REMOVE:
+ idev_session_disable(e->idev_session);
+ e->idev_session = idev_session_free(e->idev_session);
+ sd_event_exit(e->event, 0);
+ break;
+ case SYSVIEW_EVENT_SESSION_ATTACH:
+ d = ev->session_attach.device;
+ type = sysview_device_get_type(d);
+ if (type == SYSVIEW_DEVICE_EVDEV) {
+ r = idev_session_add_evdev(e->idev_session, sysview_device_get_ud(d));
+ if (r < 0) {
+ log_error("Cannot add evdev device to idev: %s", strerror(-r));
+ return r;
+ }
+ }
+
+ break;
+ case SYSVIEW_EVENT_SESSION_DETACH:
+ d = ev->session_detach.device;
+ type = sysview_device_get_type(d);
+ if (type == SYSVIEW_DEVICE_EVDEV) {
+ r = idev_session_remove_evdev(e->idev_session, sysview_device_get_ud(d));
+ if (r < 0) {
+ log_error("Cannot remove evdev device from idev: %s", strerror(-r));
+ return r;
+ }
+ }
+
+ break;
+ case SYSVIEW_EVENT_SESSION_CONTROL:
+ r = ev->session_control.error;
+ if (r < 0) {
+ log_error("Cannot acquire session control: %s", strerror(-r));
+ return r;
+ }
+
+ r = ioctl(1, KDSKBMODE, K_UNICODE);
+ if (r < 0) {
+ log_error("Cannot set K_UNICODE on stdout: %m");
+ return -errno;
+ }
+
+ r = ioctl(1, KDSETMODE, KD_TEXT);
+ if (r < 0) {
+ log_error("Cannot set KD_TEXT on stdout: %m");
+ return -errno;
+ }
+
+ printf("\n");
+
+ break;
+ }
+
+ return 0;
+}
+
+static int evcat_run(Evcat *e) {
+ struct termios in_attr, saved_attr;
+ int r;
+
+ assert(e);
+
+ if (!e->managed && geteuid() > 0)
+ log_warning("You run in unmanaged mode without being root. This is likely to produce no output..");
+
+ printf("evcat - Read and catenate events from selected input devices\n"
+ " Running on seat '%s' in user-session '%s'\n"
+ " Exit by pressing ^C or 'q'\n\n",
+ e->seat ? : "seat0", e->session ? : "<none>");
+
+ r = sysview_context_start(e->sysview, evcat_sysview_fn, e);
+ if (r < 0)
+ goto out;
+
+ r = tcgetattr(0, &in_attr);
+ if (r < 0) {
+ r = -errno;
+ goto out;
+ }
+
+ saved_attr = in_attr;
+ in_attr.c_lflag &= ~ECHO;
+
+ r = tcsetattr(0, TCSANOW, &in_attr);
+ if (r < 0) {
+ r = -errno;
+ goto out;
+ }
+
+ r = sd_event_loop(e->event);
+ tcsetattr(0, TCSANOW, &saved_attr);
+ printf("exiting..\n");
+
+out:
+ sysview_context_stop(e->sysview);
+ return r;
+}
+
+static int help(void) {
+ printf("%s [OPTIONS...]\n\n"
+ "Read and catenate events from selected input devices.\n\n"
+ " -h --help Show this help\n"
+ " --version Show package version\n"
+ , program_invocation_short_name);
+
+ return 0;
+}
+
+static int parse_argv(int argc, char *argv[]) {
+ enum {
+ ARG_VERSION = 0x100,
+ };
+ static const struct option options[] = {
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
+ {},
+ };
+ int c;
+
+ assert(argc >= 0);
+ assert(argv);
+
+ while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+ switch (c) {
+ case 'h':
+ help();
+ return 0;
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
+ return 0;
+
+ case '?':
+ return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
+ }
+
+ if (argc > optind) {
+ log_error("Too many arguments");
+ return -EINVAL;
+ }
+
+ return 1;
+}
+
+int main(int argc, char *argv[]) {
+ _cleanup_(evcat_freep) Evcat *e = NULL;
+ int r;
+
+ log_set_target(LOG_TARGET_AUTO);
+ log_parse_environment();
+ log_open();
+
+ setlocale(LC_ALL, "");
+ if (!is_locale_utf8())
+ log_warning("Locale is not set to UTF-8. Codepoints will not be printed!");
+
+ r = parse_argv(argc, argv);
+ if (r <= 0)
+ goto finish;
+
+ r = evcat_new(&e);
+ if (r < 0)
+ goto finish;
+
+ r = evcat_run(e);
+
+finish:
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}

View File

@ -1,93 +0,0 @@
From c609cb9898dc8dec5dcb0b1d111b3f6b6a5e09d4 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 27 Aug 2014 19:04:29 +0200
Subject: [PATCH] man: add sample glib/sd-event integration
This should be moved to man pages, but for now the C code is included directly.
Suggested by Zbyszek.
---
man/glib-event-glue.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 man/glib-event-glue.c
diff --git a/man/glib-event-glue.c b/man/glib-event-glue.c
new file mode 100644
index 0000000000..95aaea1e63
--- /dev/null
+++ b/man/glib-event-glue.c
@@ -0,0 +1,74 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ Copyright 2014 Tom Gundersen
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+***/
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "glib-event-glue.h"
+
+typedef struct SDEventSource {
+ GSource source;
+ GPollFD pollfd;
+ sd_event *event;
+} SDEventSource;
+
+static gboolean event_prepare(GSource *source, gint *timeout_) {
+ return sd_event_prepare(((SDEventSource *)source)->event) > 0;
+}
+
+static gboolean event_check(GSource *source) {
+ return sd_event_wait(((SDEventSource *)source)->event, 0) > 0;
+}
+
+static gboolean event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) {
+ return sd_event_dispatch(((SDEventSource *)source)->event) > 0;
+}
+
+static void event_finalize(GSource *source) {
+ sd_event_unref(((SDEventSource *)source)->event);
+}
+
+static GSourceFuncs event_funcs = {
+ .prepare = event_prepare,
+ .check = event_check,
+ .dispatch = event_dispatch,
+ .finalize = event_finalize,
+};
+
+GSource *g_sd_event_create_source(sd_event *event) {
+ SDEventSource *source;
+
+ source = (SDEventSource *)g_source_new(&event_funcs, sizeof(SDEventSource));
+
+ source->event = sd_event_ref(event);
+ source->pollfd.fd = sd_event_get_fd(event);
+ source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+
+ g_source_add_poll((GSource *)source, &source->pollfd);
+
+ return (GSource *)source;
+}

View File

@ -1,91 +0,0 @@
From 8a7c93d858c342744adf481565d8bb03b9713dcf Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 27 Aug 2014 21:42:20 +0200
Subject: [PATCH] util: fix minimal race where we might miss SIGTERMs when
forking off an agent
Before forking, block all signals, and unblock them afterwards. This way
the child will have them blocked, and we won't lose them.
---
src/shared/util.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index 9e4ff85ffb..cf9d487b82 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5102,9 +5102,9 @@ int fd_inc_rcvbuf(int fd, size_t n) {
}
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...) {
- pid_t parent_pid, agent_pid;
- int fd;
bool stdout_is_tty, stderr_is_tty;
+ pid_t parent_pid, agent_pid;
+ sigset_t ss, saved_ss;
unsigned n, i;
va_list ap;
char **l;
@@ -5112,16 +5112,25 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
assert(pid);
assert(path);
- parent_pid = getpid();
-
/* Spawns a temporary TTY agent, making sure it goes away when
* we go away */
+ parent_pid = getpid();
+
+ /* First we temporarily block all signals, so that the new
+ * child has them blocked initially. This way, we can be sure
+ * that SIGTERMs are not lost we might send to the agent. */
+ assert_se(sigfillset(&ss) >= 0);
+ assert_se(sigprocmask(SIG_SETMASK, &ss, &saved_ss) >= 0);
+
agent_pid = fork();
- if (agent_pid < 0)
+ if (agent_pid < 0) {
+ assert_se(sigprocmask(SIG_SETMASK, &saved_ss, NULL) >= 0);
return -errno;
+ }
if (agent_pid != 0) {
+ assert_se(sigprocmask(SIG_SETMASK, &saved_ss, NULL) >= 0);
*pid = agent_pid;
return 0;
}
@@ -5132,24 +5141,26 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
_exit(EXIT_FAILURE);
+ /* Make sure we actually can kill the agent, if we need to, in
+ * case somebody invoked us from a shell script that trapped
+ * SIGTERM or so... */
+ reset_all_signal_handlers();
+ reset_signal_mask();
+
/* Check whether our parent died before we were able
- * to set the death signal */
+ * to set the death signal and unblock the signals */
if (getppid() != parent_pid)
_exit(EXIT_SUCCESS);
/* Don't leak fds to the agent */
close_all_fds(except, n_except);
- /* Make sure we actually can kill the agent, if we need to, in
- * case somebody invoked us from a shell script that trapped
- * SIGTERM or so... */
- reset_all_signal_handlers();
- reset_signal_mask();
-
stdout_is_tty = isatty(STDOUT_FILENO);
stderr_is_tty = isatty(STDERR_FILENO);
if (!stdout_is_tty || !stderr_is_tty) {
+ int fd;
+
/* Detach from stdout/stderr. and reopen
* /dev/tty for them. This is important to
* ensure that when systemctl is started via

View File

@ -1,22 +0,0 @@
From eff3f4f9e92b56d9dfb90d5094e48cc743c776cc Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 27 Aug 2014 21:43:33 +0200
Subject: [PATCH] update TODO
---
TODO | 2 ++
1 file changed, 2 insertions(+)
diff --git a/TODO b/TODO
index a00c13dab2..bc81a70eb1 100644
--- a/TODO
+++ b/TODO
@@ -24,6 +24,8 @@ External:
Features:
+* nspawn --network-interface= doesn't work...
+
* dbus: add new message hdr field for allowing interactive auth, write spec for it. update dbus spec to mandate that unknown flags *must* be ignored...
* maybe introduce AssertXYZ= similar to ConditionXYZ= that causes a unit to fail (instead of skipping it) if some condition is not true...

View File

@ -1,21 +0,0 @@
From 00b333bb1039809a42ba4c7f25ba85f68766477d Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Wed, 27 Aug 2014 23:23:10 +0200
Subject: [PATCH] terminal: remove unused variable
---
src/libsystemd-terminal/idev-keyboard.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index 647aade932..7ab4db2cf7 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -312,7 +312,6 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus,
sd_bus_message *signal,
void *userdata,
sd_bus_error *ret_err) {
- _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
kbdctx *kc = userdata;
int r;

View File

@ -1,36 +0,0 @@
From 57cd09acf2c63a414aa2131c00a2b3f600eb0133 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 23 Aug 2014 22:35:03 -0400
Subject: [PATCH] sd-journal: properly convert object->size on big endian
mmap code crashes when attempting to map an object of zero size.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758392
https://bugs.freedesktop.org/show_bug.cgi?id=82894
---
src/journal/journal-file.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 3d416820b0..da2ef3b795 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -214,14 +214,15 @@ static unsigned type_to_context(int type) {
static inline int journal_file_object_keep(JournalFile *f, Object *o, uint64_t offset) {
unsigned context = type_to_context(o->object.type);
+ uint64_t s = le64toh(o->object.size);
return mmap_cache_get(f->mmap, f->fd, f->prot, context, true,
- offset, o->object.size, &f->last_stat, NULL);
+ offset, s, &f->last_stat, NULL);
}
static inline int journal_file_object_release(JournalFile *f, Object *o, uint64_t offset) {
unsigned context = type_to_context(o->object.type);
+ uint64_t s = le64toh(o->object.size);
- return mmap_cache_release(f->mmap, f->fd, f->prot, context,
- offset, o->object.size);
+ return mmap_cache_release(f->mmap, f->fd, f->prot, context, offset, s);
}

View File

@ -1,51 +0,0 @@
From 0f99f74a14ef193c1ebde687c5cc76e1d67b85ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 26 Aug 2014 23:54:31 -0400
Subject: [PATCH] sd-journal: verify that object start with the field name
If the journal is corrupted, we might return an object that does
not start with the expected field name and/or is shorter than it
should.
---
src/journal/journal-file.c | 1 -
src/journal/sd-journal.c | 15 +++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 986e94de39..7286e14ddb 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -425,7 +425,6 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec
if (!VALID64(offset))
return -EFAULT;
-
r = journal_file_move_to(f, type_to_context(type), false, offset, sizeof(ObjectHeader), &t);
if (r < 0)
return r;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 80ff8fef57..693707cb34 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2571,6 +2571,21 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
if (r < 0)
return r;
+ /* Check if we have at least the field name and "=". */
+ if (ol <= k) {
+ log_debug("%s:offset " OFSfmt ": object has size %zu, expected at least %zu",
+ j->unique_file->path, j->unique_offset,
+ ol, k + 1);
+ return -EBADMSG;
+ }
+
+ if (memcmp(odata, j->unique_field, k) || ((const char*) odata)[k] != '=') {
+ log_debug("%s:offset " OFSfmt ": object does not start with \"%s=\"",
+ j->unique_file->path, j->unique_offset,
+ j->unique_field);
+ return -EBADMSG;
+ }
+
/* OK, now let's see if we already returned this data
* object by checking if it exists in the earlier
* traversed files. */

View File

@ -1,26 +0,0 @@
From 371ad55d460559b4262e25d0f9b64dc37c3f7565 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 28 Aug 2014 11:01:31 +0200
Subject: [PATCH] terminal: sysview: don't return uninitialized error codes
In case 'scan_evdev' and 'scan_drm' are both false, we never set 'r' to
anyhting, thus return an uninitialized error code. Fix this by always
returning 0 as we catch negative codes earlier, anyway. Thanks to Thomas
H.P. Anderson for the report.
---
src/libsystemd-terminal/sysview.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
index d885cb4d4a..f5363dedf4 100644
--- a/src/libsystemd-terminal/sysview.c
+++ b/src/libsystemd-terminal/sysview.c
@@ -821,7 +821,7 @@ static int context_ud_prepare_monitor(sysview_context *c, struct udev_monitor *m
return r;
}
- return r;
+ return 0;
}
static int context_ud_prepare_scan(sysview_context *c, struct udev_enumerate *e) {

View File

@ -1,37 +0,0 @@
From 3125b3ef5db70d45882c7d6f617705802c5f939e Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Thu, 28 Aug 2014 12:15:51 +0200
Subject: [PATCH] nspawn: fix --network-interface
Use SETLINK when modifying an existing link.
---
TODO | 2 --
src/nspawn/nspawn.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/TODO b/TODO
index bc81a70eb1..a00c13dab2 100644
--- a/TODO
+++ b/TODO
@@ -24,8 +24,6 @@ External:
Features:
-* nspawn --network-interface= doesn't work...
-
* dbus: add new message hdr field for allowing interactive auth, write spec for it. update dbus spec to mandate that unknown flags *must* be ignored...
* maybe introduce AssertXYZ= similar to ConditionXYZ= that causes a unit to fail (instead of skipping it) if some condition is not true...
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 56d9cc68c6..5af89c9b32 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1886,7 +1886,7 @@ static int move_network_interfaces(pid_t pid) {
if (ifi < 0)
return ifi;
- r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, ifi);
+ r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, ifi);
if (r < 0) {
log_error("Failed to allocate netlink message: %s", strerror(-r));
return r;

View File

@ -1,23 +0,0 @@
From 200716a628b70fe723e7d4e09bb2ece10c10bdc0 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 28 Aug 2014 12:21:33 +0200
Subject: [PATCH] terminal: free xkb state on keyboard destruction
Fix leaking the xkb-state during keyboard destruction, leaking lots of xkb
references into the wild.
---
src/libsystemd-terminal/idev-keyboard.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index 7ab4db2cf7..03f54bb74f 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -550,6 +550,7 @@ int idev_keyboard_new(idev_device **out, idev_session *s, const char *name) {
static void keyboard_free(idev_device *d) {
idev_keyboard *k = keyboard_from_device(d);
+ xkb_state_unref(k->xkb_state);
free(k->repdata.keyboard.codepoints);
free(k->repdata.keyboard.keysyms);
free(k->evdata.keyboard.codepoints);

View File

@ -1,38 +0,0 @@
From fa9838ddd62ea31f8aea99757916a16d76b31cbc Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 28 Aug 2014 12:25:58 +0200
Subject: [PATCH] terminal: free sysview-device names on destruction
Don't leak the device-names during device destruction in sysview. Somehow,
the device-name is "const char*", so make it "char*" first to avoid
warnings when calling free() on it.
---
src/libsystemd-terminal/sysview-internal.h | 2 +-
src/libsystemd-terminal/sysview.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libsystemd-terminal/sysview-internal.h b/src/libsystemd-terminal/sysview-internal.h
index 5aee9f67d8..9299fabb82 100644
--- a/src/libsystemd-terminal/sysview-internal.h
+++ b/src/libsystemd-terminal/sysview-internal.h
@@ -39,7 +39,7 @@
struct sysview_device {
sysview_seat *seat;
- const char *name;
+ char *name;
unsigned int type;
union {
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
index f5363dedf4..bd345fa22e 100644
--- a/src/libsystemd-terminal/sysview.c
+++ b/src/libsystemd-terminal/sysview.c
@@ -98,6 +98,7 @@ sysview_device *sysview_device_free(sysview_device *device) {
break;
}
+ free(device->name);
free(device);
return NULL;

View File

@ -1,70 +0,0 @@
From d974ad0524942882f489914013d08ab16d147170 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 28 Aug 2014 12:42:03 +0200
Subject: [PATCH] bus: fix use-after-free in slot-release
We must not access slot->floating after we possible dropped the last
reference to it. Fix all callback-invocations to first check
slot->floating and possible disconnect the slot, then release the last
reference.
---
src/libsystemd/sd-bus/sd-bus.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index a204d67590..8caa404227 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -2107,7 +2107,7 @@ static int process_timeout(sd_bus *bus) {
r = c->callback(bus, m, slot->userdata, &error_buffer);
bus->current_userdata = NULL;
bus->current_handler = NULL;
- bus->current_slot = sd_bus_slot_unref(slot);
+ bus->current_slot = NULL;
bus->current_message = NULL;
if (slot->floating) {
@@ -2115,6 +2115,8 @@ static int process_timeout(sd_bus *bus) {
sd_bus_slot_unref(slot);
}
+ sd_bus_slot_unref(slot);
+
return bus_maybe_reply_error(m, r, &error_buffer);
}
@@ -2203,13 +2205,15 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
r = c->callback(bus, m, slot->userdata, &error_buffer);
bus->current_userdata = NULL;
bus->current_handler = NULL;
- bus->current_slot = sd_bus_slot_unref(slot);
+ bus->current_slot = NULL;
if (slot->floating) {
bus_slot_disconnect(slot);
sd_bus_slot_unref(slot);
}
+ sd_bus_slot_unref(slot);
+
return bus_maybe_reply_error(m, r, &error_buffer);
}
@@ -2529,7 +2533,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
r = c->callback(bus, m, slot->userdata, &error_buffer);
bus->current_userdata = NULL;
bus->current_handler = NULL;
- bus->current_slot = sd_bus_slot_unref(slot);
+ bus->current_slot = NULL;
bus->current_message = NULL;
if (slot->floating) {
@@ -2537,6 +2541,8 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
sd_bus_slot_unref(slot);
}
+ sd_bus_slot_unref(slot);
+
return bus_maybe_reply_error(m, r, &error_buffer);
}

View File

@ -1,131 +0,0 @@
From 667a0377fb25ddb0c3efbc43d186ffd4c097ce41 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 28 Aug 2014 14:45:38 +0200
Subject: [PATCH] macro: use unique variable names for math-macros
Similar to container_of(), we now use unique variable names for the bascic
math macros MAX, MIN, CLAMP, LESS_BY. Furthermore, unit tests are added to
verify they work as expected.
For a rationale, see:
commit fb835651aff79a1e7fc5795086c9b26e59a8e6ca
Author: David Herrmann <dh.herrmann@gmail.com>
Date: Fri Aug 22 14:41:37 2014 +0200
shared: make container_of() use unique variable names
---
src/shared/macro.h | 53 +++++++++++++++++++++++++++++-----------------------
src/test/test-util.c | 17 +++++++++++++++++
2 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/src/shared/macro.h b/src/shared/macro.h
index e6734804bd..9ee332c8df 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -134,12 +134,13 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
})
#undef MAX
-#define MAX(a,b) \
+#define MAX(a, b) __MAX(UNIQ, (a), UNIQ, (b))
+#define __MAX(aq, a, bq, b) \
__extension__ ({ \
- const typeof(a) _a = (a); \
- const typeof(b) _b = (b); \
- _a > _b ? _a : _b; \
- })
+ const typeof(a) UNIQ_T(A, aq) = (a); \
+ const typeof(b) UNIQ_T(B, bq) = (b); \
+ UNIQ_T(A,aq) > UNIQ_T(B,bq) ? UNIQ_T(A,aq) : UNIQ_T(B,bq); \
+ })
/* evaluates to (void) if _A or _B are not constant or of different types */
#define CONST_MAX(_A, _B) \
@@ -160,12 +161,13 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
})
#undef MIN
-#define MIN(a,b) \
+#define MIN(a, b) __MIN(UNIQ, (a), UNIQ, (b))
+#define __MIN(aq, a, bq, b) \
__extension__ ({ \
- const typeof(a) _a = (a); \
- const typeof(b) _b = (b); \
- _a < _b ? _a : _b; \
- })
+ const typeof(a) UNIQ_T(A, aq) = (a); \
+ const typeof(b) UNIQ_T(B, bq) = (b); \
+ UNIQ_T(A,aq) < UNIQ_T(B,bq) ? UNIQ_T(A,aq) : UNIQ_T(B,bq); \
+ })
#define MIN3(x,y,z) \
__extension__ ({ \
@@ -173,22 +175,27 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
MIN(_c, z); \
})
-#define LESS_BY(A,B) \
+#define LESS_BY(a, b) __LESS_BY(UNIQ, (a), UNIQ, (b))
+#define __LESS_BY(aq, a, bq, b) \
__extension__ ({ \
- const typeof(A) _A = (A); \
- const typeof(B) _B = (B); \
- _A > _B ? _A - _B : 0; \
- })
+ const typeof(a) UNIQ_T(A, aq) = (a); \
+ const typeof(b) UNIQ_T(B, bq) = (b); \
+ UNIQ_T(A,aq) > UNIQ_T(B,bq) ? UNIQ_T(A,aq) - UNIQ_T(B,bq) : 0; \
+ })
-#ifndef CLAMP
-#define CLAMP(x, low, high) \
+#undef CLAMP
+#define CLAMP(x, low, high) __CLAMP(UNIQ, (x), UNIQ, (low), UNIQ, (high))
+#define __CLAMP(xq, x, lowq, low, highq, high) \
__extension__ ({ \
- const typeof(x) _x = (x); \
- const typeof(low) _low = (low); \
- const typeof(high) _high = (high); \
- ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
- })
-#endif
+ const typeof(x) UNIQ_T(X,xq) = (x); \
+ const typeof(low) UNIQ_T(LOW,lowq) = (low); \
+ const typeof(high) UNIQ_T(HIGH,highq) = (high); \
+ UNIQ_T(X,xq) > UNIQ_T(HIGH,highq) ? \
+ UNIQ_T(HIGH,highq) : \
+ UNIQ_T(X,xq) < UNIQ_T(LOW,lowq) ? \
+ UNIQ_T(LOW,lowq) : \
+ UNIQ_T(X,xq); \
+ })
#define assert_se(expr) \
do { \
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 795f3a1b3d..72a8a6b130 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -94,6 +94,23 @@ static void test_max(void) {
assert_cc(MAXSIZE(char[3], uint16_t) == 3);
assert_cc(MAXSIZE(char[3], uint32_t) == 4);
assert_cc(MAXSIZE(char, long) == sizeof(long));
+
+ assert_se(MAX(-5, 5) == 5);
+ assert_se(MAX(5, 5) == 5);
+ assert_se(MAX(MAX(1, MAX(2, MAX(3, 4))), 5) == 5);
+ assert_se(MAX(MAX(1, MAX(2, MAX(3, 2))), 1) == 3);
+ assert_se(MAX(MIN(1, MIN(2, MIN(3, 4))), 5) == 5);
+ assert_se(MAX(MAX(1, MIN(2, MIN(3, 2))), 1) == 2);
+ assert_se(LESS_BY(8, 4) == 4);
+ assert_se(LESS_BY(8, 8) == 0);
+ assert_se(LESS_BY(4, 8) == 0);
+ assert_se(LESS_BY(16, LESS_BY(8, 4)) == 12);
+ assert_se(LESS_BY(4, LESS_BY(8, 4)) == 0);
+ assert_se(CLAMP(-5, 0, 1) == 0);
+ assert_se(CLAMP(5, 0, 1) == 1);
+ assert_se(CLAMP(5, -10, 1) == 1);
+ assert_se(CLAMP(5, -10, 10) == 5);
+ assert_se(CLAMP(CLAMP(0, -10, 10), CLAMP(-5, 10, 20), CLAMP(100, -5, 20)) == 10);
}
static void test_container_of(void) {

Some files were not shown because too many files have changed in this diff Show More