Compare commits

...

9 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 1b87e27999
Merge pull request #15315 from DaanDeMeyer/deprecate-sd-bus-priority
sd-bus: Deprecate priority functions
2020-04-03 18:07:54 +02:00
Lennart Poettering c4b2371263 capability: don't skip ambient caps setup if we actually have something to set
Follow-up for 7ea4392f1e

Let's not hide errors needlessly aggressively.
2020-04-03 18:02:08 +02:00
Zbigniew Jędrzejewski-Szmek e30934c80f
Merge pull request #15310 from poettering/repart-no-enable
make systemd-repart static again, but condition it out if no config
2020-04-03 17:44:47 +02:00
Topi Miettinen 1887032f71 shared/dissect-image: log messages from cryptsetup
Before:
```
write(2, "Device /dev/loop1p1 is too small.\n", 34) = -1 ENOTCONN (Transport
endpoint is not connected)
```

After:
```
$ journalctl -b -e | grep 'too small'
Apr 02 16:53:30 loora systemd[343579]: Device /dev/loop1p1 is too small.
```
2020-04-03 17:44:20 +02:00
Giedrius Statkevičius aa5408e2e8 resolve: reload /etc/hosts on inode change
On certain distributions such as NixOS the mtime of `/etc/hosts` is
locked to a fixed value. In such cases, only checking the last mtime of
`/etc/hosts` is not enough - we also need to check if the st_ino/st_dev
match up. Thus, let's make sure make sure that systemd-resolved also
rereads `/etc/hosts` if the inode or the device containing `/etc/hosts` changes.

Test script:

```bash
hosts="/etc/hosts"
echo "127.0.0.1 testpr" > "hosts_new"
mv "hosts_new" "$hosts"
resolvectl query testpr || exit 1
mtime="$(stat -c %y "$hosts")"
echo "127.0.0.1 newhost" > "hosts_tmp"
touch -d "$mtime" "hosts_tmp"
install -p "hosts_tmp" "$hosts"
sleep 10
resolvectl query newhost || exit 1
rm -f "hosts_tmp"
```

Closes #14456.
2020-04-03 17:34:10 +02:00
Daan De Meyer 1e9a7c44a9 sd-bus: remove unused priority logic 2020-04-02 21:42:32 +02:00
Daan De Meyer 11a177d9de sd-bus: Deprecate priority functions 2020-04-02 21:36:59 +02:00
Lennart Poettering fdfe909123 units: run systemd-repart only if there's configuration for it 2020-04-02 17:07:48 +02:00
Lennart Poettering aade0c3b6e Revert "units: make systemd-repart.service installable"
This reverts commit 7e1ed1f3b2.

systemd-repart is not a user service that should be something people
enable/disable, instead it should just work if there's configuration for
it. It's like systemd-tmpfiles, systemd-sysusers, systemd-load-modules,
systemd-binfmt, systemd-systemd-sysctl which are NOPs if they have no
configuration, and thus don't hurt, but cannot be disabled since they
are too deep part of the OS.

This doesn't mean people couldn't disable the service if they really
want to, there's after all "systemctl mask" and build-time disabling,
but those are OS developer facing instead of admin facing, that's how it
should be.

Note that systemd-repart is in particular an initrd service, and so far
enable/disable state of those is not managed anyway via "systemctl
enable/disable" but more what dracut decides to package up and what not.
2020-04-02 17:04:59 +02:00
13 changed files with 41 additions and 53 deletions

View File

@ -291,9 +291,7 @@ manpages = [
'sd_bus_message_get_interface',
'sd_bus_message_get_member',
'sd_bus_message_get_path',
'sd_bus_message_get_priority',
'sd_bus_message_get_sender',
'sd_bus_message_set_priority',
'sd_bus_message_set_sender'],
''],
['sd_bus_message_set_expect_reply',

View File

@ -70,7 +70,6 @@
<citerefentry><refentrytitle>sd_bus_message_dump</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_cookie</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_signature</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@ -84,7 +83,6 @@
<citerefentry><refentrytitle>sd_bus_message_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_seal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_set_expect_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_skip</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -19,8 +19,6 @@
<refname>sd_bus_message_get_path</refname>
<refname>sd_bus_message_get_interface</refname>
<refname>sd_bus_message_get_member</refname>
<refname>sd_bus_message_set_priority</refname>
<refname>sd_bus_message_get_priority</refname>
<refname>sd_bus_message_set_sender</refname>
<refname>sd_bus_message_get_sender</refname>
@ -57,18 +55,6 @@
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_message_set_priority</function></funcdef>
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
<paramdef>int64_t <parameter>priority</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_message_get_priority</function></funcdef>
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
<paramdef>int64_t *<parameter>priority</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_message_set_sender</function></funcdef>
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
@ -100,10 +86,6 @@
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for more discussion of those values.</para>
<para><function>sd_bus_message_set_priority()</function> and
<function>sd_bus_message_get_priority()</function> modify and query a message's priority
respectively. sd-bus currently doesn't make use of a message's priority.</para>
<para><function>sd_bus_message_set_sender()</function> sets the sender service name for the specified bus message
object. The specified name must be a valid unique or well-known service name. This function is useful only for
messages to send on direct connections as for connections to bus brokers the broker will fill in the destination
@ -139,9 +121,8 @@
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>For <function>sd_bus_message_set_destination()</function>,
<function>sd_bus_message_set_sender()</function> and
<function>sd_bus_message_set_priority()</function>, the message is already sealed.</para>
<listitem><para>For <function>sd_bus_message_set_destination()</function> and
<function>sd_bus_message_set_sender()</function>, the message is already sealed.</para>
</listitem>
</varlistentry>

View File

@ -19,7 +19,6 @@ enable getty@.service
enable systemd-timesyncd.service
enable systemd-networkd.service
enable systemd-resolved.service
enable systemd-repart.service
enable systemd-homed.service
enable systemd-userdbd.socket

View File

@ -107,11 +107,13 @@ int capability_ambient_set_apply(uint64_t set, bool also_inherit) {
unsigned long i;
int r;
/* Add the capabilities to the ambient set (an possibly also the inheritable set) */
/* Check that we can use PR_CAP_AMBIENT or quit early. */
if (!ambient_capabilities_supported())
return 0;
/* Add the capabilities to the ambient set. */
return (set & all_capabilities()) == 0 ?
0 : -EOPNOTSUPP; /* if actually no ambient caps are to be set, be silent,
* otherwise fail recognizably */
if (also_inherit) {
caps = cap_get_proc();

View File

@ -1833,7 +1833,7 @@ static int dispatch_wqueue(sd_bus *bus) {
return ret;
}
static int bus_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
static int bus_read_message(sd_bus *bus) {
assert(bus);
return bus_socket_read_message(bus);
@ -1860,17 +1860,13 @@ static void rqueue_drop_one(sd_bus *bus, size_t i) {
bus->rqueue_size--;
}
static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **m) {
static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
int r, ret = 0;
assert(bus);
assert(m);
assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
/* Note that the priority logic is only available on kdbus,
* where the rqueue is unused. We check the rqueue here
* anyway, because it's simple... */
for (;;) {
if (bus->rqueue_size > 0) {
/* Dispatch a queued message */
@ -1880,7 +1876,7 @@ static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd
}
/* Try to read a new message */
r = bus_read_message(bus, hint_priority, priority);
r = bus_read_message(bus);
if (r < 0)
return r;
if (r == 0) {
@ -2237,7 +2233,7 @@ _public_ int sd_bus_call(
i++;
}
r = bus_read_message(bus, false, 0);
r = bus_read_message(bus);
if (r < 0) {
if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
@ -2776,7 +2772,7 @@ static int dispatch_track(sd_bus *bus) {
return 1;
}
static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
static int process_running(sd_bus *bus, sd_bus_message **ret) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
@ -2795,7 +2791,7 @@ static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd
if (r != 0)
goto null_message;
r = dispatch_rqueue(bus, hint_priority, priority, &m);
r = dispatch_rqueue(bus, &m);
if (r < 0)
return r;
if (!m)
@ -2981,7 +2977,7 @@ finish:
return r;
}
static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
int r;
/* Returns 0 when we didn't do anything. This should cause the
@ -3021,7 +3017,7 @@ static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
case BUS_RUNNING:
case BUS_HELLO:
r = process_running(bus, hint_priority, priority, ret);
r = process_running(bus, ret);
if (r >= 0)
return r;
@ -3048,11 +3044,11 @@ static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit
}
_public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
return bus_process_internal(bus, false, 0, ret);
return bus_process_internal(bus, ret);
}
_public_ int sd_bus_process_priority(sd_bus *bus, int64_t priority, sd_bus_message **ret) {
return bus_process_internal(bus, true, priority, ret);
return bus_process_internal(bus, ret);
}
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {

View File

@ -37,6 +37,8 @@ void etc_hosts_free(EtcHosts *hosts) {
void manager_etc_hosts_flush(Manager *m) {
etc_hosts_free(&m->etc_hosts);
m->etc_hosts_mtime = USEC_INFINITY;
m->etc_hosts_ino = 0;
m->etc_hosts_dev = 0;
}
static int parse_line(EtcHosts *hosts, unsigned nr, const char *line) {
@ -224,8 +226,9 @@ static int manager_etc_hosts_read(Manager *m) {
return 0;
}
/* Did the mtime change? If not, there's no point in re-reading the file. */
if (timespec_load(&st.st_mtim) == m->etc_hosts_mtime)
/* Did the mtime or ino/dev change? If not, there's no point in re-reading the file. */
if (timespec_load(&st.st_mtim) == m->etc_hosts_mtime &&
st.st_ino == m->etc_hosts_ino && st.st_dev == m->etc_hosts_dev)
return 0;
}
@ -249,6 +252,8 @@ static int manager_etc_hosts_read(Manager *m) {
return r;
m->etc_hosts_mtime = timespec_load(&st.st_mtim);
m->etc_hosts_ino = st.st_ino;
m->etc_hosts_dev = st.st_dev;
m->etc_hosts_last = ts;
return 1;

View File

@ -591,6 +591,8 @@ int manager_new(Manager **ret) {
.need_builtin_fallbacks = true,
.etc_hosts_last = USEC_INFINITY,
.etc_hosts_mtime = USEC_INFINITY,
.etc_hosts_ino = 0,
.etc_hosts_dev = 0,
.read_etc_hosts = true,
};

View File

@ -127,6 +127,8 @@ struct Manager {
/* Data from /etc/hosts */
EtcHosts etc_hosts;
usec_t etc_hosts_last, etc_hosts_mtime;
ino_t etc_hosts_ino;
dev_t etc_hosts_dev;
bool read_etc_hosts;
/* Local DNS stub on 127.0.0.53:53 */

View File

@ -1188,6 +1188,8 @@ static int decrypt_partition(
if (r < 0)
return log_debug_errno(r, "Failed to initialize dm-crypt: %m");
crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
r = crypt_load(cd, CRYPT_LUKS, NULL);
if (r < 0)
return log_debug_errno(r, "Failed to load LUKS metadata: %m");
@ -1246,6 +1248,8 @@ static int verity_partition(
if (r < 0)
return r;
crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
r = crypt_load(cd, CRYPT_VERITY, NULL);
if (r < 0)
return r;

View File

@ -204,7 +204,7 @@ int sd_bus_get_fd(sd_bus *bus);
int sd_bus_get_events(sd_bus *bus);
int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec);
int sd_bus_process(sd_bus *bus, sd_bus_message **r);
int sd_bus_process_priority(sd_bus *bus, int64_t max_priority, sd_bus_message **r);
int sd_bus_process_priority(sd_bus *bus, int64_t max_priority, sd_bus_message **r) _sd_deprecated_; /* deprecated */
int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
int sd_bus_flush(sd_bus *bus);
int sd_bus_enqueue_for_read(sd_bus *bus, sd_bus_message *m);
@ -272,7 +272,7 @@ int sd_bus_message_seal(sd_bus_message *m, uint64_t cookie, uint64_t timeout_use
int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type);
int sd_bus_message_get_cookie(sd_bus_message *m, uint64_t *cookie);
int sd_bus_message_get_reply_cookie(sd_bus_message *m, uint64_t *cookie);
int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority);
int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority) _sd_deprecated_; /* deprecated */
int sd_bus_message_get_expect_reply(sd_bus_message *m);
int sd_bus_message_get_auto_start(sd_bus_message *m);
@ -306,7 +306,7 @@ int sd_bus_message_set_allow_interactive_authorization(sd_bus_message *m, int b)
int sd_bus_message_set_destination(sd_bus_message *m, const char *destination);
int sd_bus_message_set_sender(sd_bus_message *m, const char *sender);
int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority);
int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority) _sd_deprecated_; /* deprecated */
int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
int sd_bus_message_appendv(sd_bus_message *m, const char *types, va_list ap);

View File

@ -226,7 +226,8 @@ in_units = [
'multi-user.target.wants/'],
['systemd-vconsole-setup.service', 'ENABLE_VCONSOLE'],
['systemd-volatile-root.service', ''],
['systemd-repart.service', 'ENABLE_REPART'],
['systemd-repart.service', 'ENABLE_REPART',
'sysinit.target.wants/ initrd-root-fs.target.wants/'],
['user-runtime-dir@.service', ''],
['user@.service', ''],
]

View File

@ -15,6 +15,10 @@ Conflicts=shutdown.target
After=sysroot.mount
Before=initrd-root-fs.target shutdown.target
ConditionVirtualization=!container
ConditionDirectoryNotEmpty=|/usr/lib/repart.d
ConditionDirectoryNotEmpty=|/usr/local/lib/repart.d
ConditionDirectoryNotEmpty=|/etc/repart.d
ConditionDirectoryNotEmpty=|/run/repart.d
[Service]
Type=oneshot
@ -23,7 +27,3 @@ ExecStart=@rootbindir@/systemd-repart --dry-run=no
# The tool returns 77 if there's no existing GPT partition table
SuccessExitStatus=77
[Install]
WantedBy=sysinit.target
WantedBy=initrd-root-fs.target