1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 20:25:38 +03:00
Commit Graph

25985 Commits

Author SHA1 Message Date
Lennart Poettering
ff0c5ebd4a ipv4acd: make sure our event handler callbacks never check uninitialized "r" for errors 2016-05-26 15:34:42 +02:00
Lennart Poettering
e3f4eedba1 ipv4acd: normalize time types to usec_t
We try to stick to usec_t for encoding time information, do that here too. In
particular, get rid of "int" second specifications, since signed timespans are
a weird thing.
2016-05-26 15:34:42 +02:00
Lennart Poettering
d63458452d ipv4acd: in case the state engine is reused, reset n_conflict timer to 0 2016-05-26 15:34:42 +02:00
Lennart Poettering
d914f7a563 ipv4acd: no need to memcpy() where assignment suffices 2016-05-26 15:34:42 +02:00
Lennart Poettering
c9e458a419 ipv4acd: introduce new "started" state
This state is active immediately after the state engine was started, but before
the first timer hits.

This way multiple _start() invocations on the same object are always detected
correctly.
2016-05-26 15:34:42 +02:00
Lennart Poettering
d246e77a43 ipv4acd: rename ipv4acd_stop() → ipv4acd_reset()
This is much less confusing, since there's also sd_ipv4acd_stop(), which was
idfferent from ipv4acd_stop().

After renaming it, let's also use the funciton when destroying ipv4acd objects,
as the code is pretty much the same for that.
2016-05-26 15:34:42 +02:00
Lennart Poettering
4dbf7b3a93 ipv4acd: add "_event_source" suffix to event source objects
Otherwise the field "receive_message" is a bit too confusing, as it suggests it
actually stores a message object of some kind.
2016-05-26 15:34:42 +02:00
Lennart Poettering
784cdc2d0b ipv4acd: make the iteration and conflict fields unsigned
They are counters after all, and can never go below zero, hence don't pretend
with the chose type that they could.

Also, prefix their name with "n_", to indicate that they are counters.
2016-05-26 15:34:42 +02:00
Lennart Poettering
73e94c0dcb ipv4l-{acd,ll}: make sure ipv4 addresses are unsigned
And some other minor fixes.
2016-05-26 15:34:42 +02:00
Lennart Poettering
a48fc60a33 ipv4acd: library code should never log
Or actually, not at any level higher than debug.
2016-05-26 15:34:42 +02:00
Lennart Poettering
c116f52635 sd-ipv4{acl,ll}: don't make use of RefCnt objects
These objects are only useful when multiple threads are involved, as they
operate with atomic operations. Given that our libraries are explicitly not
thread-safe don't make use of RefCnt here, and make things a bit simpler.
2016-05-26 15:34:42 +02:00
Lennart Poettering
45aa74c72e sd-network: don't needlessly abbreviate "callback" as "cb" in struct members
It's OK to abbreviate this in the local scope, but otherwise, let's not be
needlessly terse.
2016-05-26 15:34:42 +02:00
Lennart Poettering
671eaa7405 dhcp: fix operator precedence issue with macro 2016-05-26 15:34:42 +02:00
Lennart Poettering
c1c9b211e3 sd-ndisc: make the _stop() call idempotent
It's a good idea to make stopcalls idempotent, so that they become nops if the
object is already stopped.
2016-05-26 15:34:42 +02:00
Lennart Poettering
a114066685 sd-network: fix up assertion chaos
assert_return() should only be used to validate user-facing parameters and
state, assert() should be used for checking our own internal state and
parameters.
2016-05-26 15:34:42 +02:00
Lennart Poettering
5c4c338adc sd-ndisc: rename sd_ndisc_init() to sd_ndisc_reset()
After all, it's actually used for resetting the state, not only for the initial
initialization.

While we are at it, also simplify the error path for
sd_ndisc_discovery_start().
2016-05-26 15:34:42 +02:00
Lennart Poettering
2f8e763376 sd-network: rename "index" field of the various clients to "ifindex"
A field "index" is not particularly precise and also might conflict with libc's
index() function definition. Also, pretty much everywhere else we call this
concept "ifindex", including in networkd, the primary user of these libraries.
Hence, let's fix this up and call this "ifindex" everywhere here too.
2016-05-26 15:34:42 +02:00
Lennart Poettering
9c2438b84e sd-ndisc: properly make various parameters unsigned 2016-05-26 15:34:42 +02:00
Lennart Poettering
16f0b479ca sd-dhcp: shorten NUL initialization a bit 2016-05-26 15:34:42 +02:00
Lennart Poettering
3d0b8a55f2 manager: remove spurious newline 2016-05-26 15:34:41 +02:00
Lennart Poettering
004845d18e sd-network: unify packet processing logic a bit
Let's always check for errno being EAGAIN/EINTR the same way, and always log if
we receive weirdly short packets.
2016-05-26 15:34:41 +02:00
Ansgar Burchardt
e81f253967 Typo: systemd-nspaw -> systemd-nspawn (#3354) 2016-05-26 10:44:35 +02:00
Lennart Poettering
bbed3b8efd Merge pull request #3247 from fbuihuu/ask-passowrd-on-all-consoles
ask-password: ask for passphrases not only on the first console
2016-05-24 12:14:21 +02:00
Zbigniew Jędrzejewski-Szmek
755700bbd4 Udevadm trivial cleanups (#3331)
* udevadm-info: use _cleanup_

* udevadm-info: propagate return value from export_devices()

* sd-device: add comment and remove unnecessary braces
2016-05-24 12:07:42 +02:00
Werner Fink
6af621248f ask-password: ask for passphrases not only on the first console of /dev/console
but also on all other consoles.  This does help on e.g. mainframes
where often a serial console together with other consoles are
used.  Even rack based servers attachted to both a serial console
as well as having a virtual console do sometimes miss a connected
monitor.

To be able to ask on all terminal devices of /dev/console the devices
are collected. If more than one device are found, then on each of the
terminals a inquiring task for passphrase is forked and do not return
to the caller.

Every task has its own session and its own controlling terminal.
If one of the tasks does handle a password, the remaining tasks
will be terminated.

Also let contradictory options on the command of
systemd-tty-ask-password-agent fail.

Spwan for each device of the system console /dev/console a own process.
Replace the system call wait() with with system call waitid().
Use SIGTERM instead of SIGHUP to get unresponsive childs down.

Port the collect_consoles() function forward to a pulbic and strv
based function "get_kernel_consoles()" in terminal-util.c and use this
in tty-ask-password-agent.c.
2016-05-24 11:57:27 +02:00
Zbigniew Jędrzejewski-Szmek
e77813ca9f Revert "rules: allow users to access frame buffer devices" (#3333)
This reverts commit 483d8bbb4c.

In [1] Michel Dänzer and Daniel Vetter wrote:
>> The scenario you describe isn't possible if the Wayland compositor
>> directly uses the KMS API of /dev/dri/card*, but it may be possible if
>> the Wayland compositor uses the fbdev API of /dev/fb* instead (e.g. if
>> weston uses its fbdev backend).
>
> Yeah, if both weston and your screen grabber uses native fbdev API you can
> now screenshot your desktop. And since fbdev has no concept of "current
> owner of the display hw" like the drm master, I think this is not fixable.
> At least not just in userspace. Also even with native KMS compositors
> fbdev still doesn't have the concept of ownership, which is why it doesn't
> bother clearing it's buffer before KMS takes over. I agree that this
> should be reverted or at least hidden better.

TBH, I think that privilege separation between processes running under the same
UID is tenuous. Even with drm, in common setups any user process can ptrace the
"current owner of the display" and call DROP_MASTER or do whatever. It *is*
possible to prevent that, e.g. by disabling ptrace using yama.ptrace_scope, or
selinux, and so on, but afaik this is not commonly done. E.g. all Fedora
systems pull in elfutils-default-yama-scope.rpm through dependencies which sets
yama.ptrace_scope=0. And even assuming that ptrace was disabled, it is trivial
to modify files on disk, communicate through dbus, etc; there is just to many
ways for a non-sandboxed process to interact maliciously with the display shell
to close them all off. To achieve real protection, some sort of sandboxing
must be implemented, and in that case there is no need to rely on access mode
on the device files, since much more stringent measures have to be implemented
anyway.

The situation is similar for framebuffer devices. It is common to add
framebuffer users to video group to allow them unlimited access to /dev/fb*.
Using uaccess would be better solution in that case. Also, since there is no
"current owner" limitation like in DRM, processes running under the same UID
should be able to access /proc/<pid-of-display-server>/fd/* and gain access to
the devices. Nevertheless, weston implements a suid wrapper to access the
devices and then drop privileges, and this patch would make this daemon
pointless. So if the weston developers feel that this change reduces security,
I prefer to revert it.

[1] https://lists.freedesktop.org/archives/wayland-devel/2016-May/029017.html
2016-05-24 11:32:30 +02:00
Tom Gundersen
bee26651fc sd-device: udev-db - handle properties with empty value (#3330)
The statemachine was unable to parse properties with empty values,
reported in [0].

When reaching the start of the KEY, we would unconditionally read
one more character before starting to look for the end-of-line.
Simply look for the end-of-line from the first character.

[0]: <https://bugzilla.redhat.com/show_bug.cgi?id=1338823>
2016-05-23 19:34:29 -04:00
Zbigniew Jędrzejewski-Szmek
21b587cfd9 man: explain what list-units does a bit better (#3324)
https://bugzilla.redhat.com/show_bug.cgi?id=1338584
2016-05-23 15:33:44 +02:00
Susant Sahani
15fec93be3 networkd: networkd: ndisc set SO_BINDTODEVICE on socket (#3294)
From the issue #2004 we are receiving packet even if this
packet is not intended for this interface.

This can be reproduced.

lp3s0: Updating address: 2001:db8:1:0:7e7a:91ff:fe6d:ffe2/64 (valid for 1d)
wlp3s0: Updating address: fe80::7e7a:91ff:fe6d:ffe2/64 (valid forever)
NDisc CLIENT: Received RA from non-link-local address ::. Ignoring.
NDisc CLIENT: Received RA on wrong interface: 2 != 6. Ignoring.
NDisc CLIENT: Received RA on wrong interface: 2 != 3. Ignoring.
enp0s25: Updating address: 2001:db8:1:0:2ad2:44ff:fe6a:ae07/64 (valid for 1d)
enp0s25: Updating address: fe80::2ad2:44ff:fe6a:ae07/64 (valid forever)
NDisc CLIENT: Sent Router Solicitation
NDisc CLIENT: Sent Router Solicitation
NDisc CLIENT: Sent Router Solicitation
NDisc CLIENT: Received RA on wrong interface: 3 != 2. Ignoring.
NDisc CLIENT: Received RA on wrong interface: 3 != 6. Ignoring.
NDisc CLIENT: Received RA from non-link-local address ::. Ignoring.
NDisc CLIENT: Received RA on wrong interface: 2 != 6. Ignoring.
NDisc CLIENT: Received RA on wrong interface: 2 != 3. Ignoring.
enp0s25: Updating address: 2001:db8:1:0:2ad2:44ff:fe6a:ae07/64 (valid for 1d)
enp0s25: Updating address: fe80::2ad2:44ff:fe6a:ae07/64 (valid forever)

Add SO_BINDTODEVICE to socket
fixes #2004
2016-05-23 11:13:57 +02:00
Dave Reisner
4f9020fa10 Mention initrd-root-device.target in NEWS (#3325) 2016-05-23 10:31:47 +02:00
Evgeny Vereshchagin
f134289ac5 resolved: don't stop handle messages after receiving a zero length UDP packet (#3323)
Fixes:

-bash-4.3# ss --udp -l -p
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
UNCONN     0      0          *:5355                     *:* users:(("systemd-resolve",pid=601,fd=12))
UNCONN     0      0         :::5355                    :::* users:(("systemd-resolve",pid=601,fd=14))

-bash-4.3# nping --udp -p 5355 --data-length 0 -c 1 localhost

-bash-4.3# journalctl -u systemd-resolved -b --no-hostname
...
May 21 14:59:22 systemd-resolved[601]: Event source llmnr-ipv4-udp (type io) returned error, disabling: Input/output error
...

-bash-4.3# nping --udp -p 5355 --data-length 1000 -c 1 localhost

-bash-4.3# ss --udp -l
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
UNCONN     2304   0          *:5355                     *:*
UNCONN     0      0         :::5355                    :::*
2016-05-23 10:19:14 +02:00
Tom Gundersen
ffd9877ca9 Merge pull request #3322 from poettering/random-ipv4acd-fixes
Random ipv4acd fixes
2016-05-23 00:16:28 +02:00
Lennart Poettering
e095f51dd1 ipv4acd/ipv4ll: stop using read() on SOCK_DGRAM sockets
This is a follow-up to cf447cb62d.

Let's generally follow the rule to not use read() on SOCK_DGRAM sockets, let's
always use recv() on that.

Also, don't abort IPV4ACD logic in case we read a short packet. Simply log and
ignore.
2016-05-22 14:26:36 +02:00
Lennart Poettering
e78f9587ab sd-ipv4acd: do not define ether_addr_is_nul() redundantly
we already have ether_addr_is_null() in ether-addr-util.h, let's use it here,
too.
2016-05-22 14:26:06 +02:00
Lennart Poettering
2d3e723657 sd-ipv4acd: drop HASH_KEY definition, as it is unused 2016-05-22 14:25:02 +02:00
Zbigniew Jędrzejewski-Szmek
b5a2179b10 nspawn: remove unreachable return statement (#3320) 2016-05-22 13:02:41 +02:00
Zbigniew Jędrzejewski-Szmek
3a74d4fc90 networkd-ndisc: do not return value from void function
Fixup for #3304.

Only warn, and not return, because that's what sd_dhcp6_client_start()
does right below the call to sd_dhcp6_client_set_local_address().
2016-05-21 18:31:29 -04:00
Zbigniew Jędrzejewski-Szmek
469978a824 build-sys: bump so version 2016-05-21 18:31:29 -04:00
Zbigniew Jędrzejewski-Szmek
46e40fab2b NEWS: final updates for v230 2016-05-21 18:31:29 -04:00
Zbigniew Jędrzejewski-Szmek
20fc581119 run: do not try to use reply after freeing it (#3318)
We'd call sd_bus_message_unref and then proceed to use
variables pointing into the reply buffer (fd and char*).
dup the fd and copy the string before destorying the reply.

This makes systemd-run run again for me.

https://bugzilla.redhat.com/show_bug.cgi?id=1337636
2016-05-21 18:30:33 -04:00
Lennart Poettering
0525107594 units: restore ConditionNeesUpdate=/etc in ldconfig.service (#3311)
In order to support stateless systems that support offline /usr updates
properly, let's restore the ConditionNeesUpdate=/etc line that makes sure we
are run when /usr is updated and this update needs to be propagated to the
/etc/ld.so.conf file stored in /etc.

This reverts part of #2859, which snuck this change in, but really shouldn't
have.
2016-05-21 17:09:18 -04:00
Tom Gundersen
cf447cb62d libsystemd-network: use recv(..., 0) instead of read(...) (#3317)
According to recv(2) these should be the same, but that is not true.
Passing a buffer of length 0 to read is defined to be a noop according
to read(2), but passing a buffer of length 0 to recv will discard the
pending pacet.

We can easily hit this as we allocate our buffer size depending on
the size of the incoming packet (using FIONREAD). As pointed out in
issue #3299 simply sending an empty UDP packet to the DHCP client
port will trigger a busy loop in networkd as we are polling on the
socket but never discarding the empty packet.

This reverts ad5ae47a0d but fixes the
same issue.
2016-05-22 00:00:32 +03:00
Evgeny Vereshchagin
3da48d7aa9 core: set all log fds to -1 when freezing (#3314)
Fixes:
-bash-4.3# echo core >/proc/sys/kernel/core_pattern
-bash-4.3# kill -ABRT 1
-bash-4.3# kill -ABRT 1
[   61.373922] systemd[1]: segfault at 7fff1d0a8f48 ip 00007fc9ca91b1c3 sp 00007fff1d0a8f50 error 6 in libc-2.23.so[7fc9ca8ce000+1c0000]
[   61.768017] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000008b
[   61.768017]
...

Recursive ABRT and segfault:
PID 1 - core
TID 1:
...
 #153905 0x00005575fc3f829d log_dispatch
 #153906 0x00005575fc3f8aa3 log_assert
 #153907 0x00005575fc3f8ae9 log_assert_failed
 #153908 0x00005575fc3e7eb1 safe_close
 #153909 0x00005575fc3f6d5e log_close_journal
 #153910 0x00005575fc3f829d log_dispatch
 #153911 0x00005575fc3f85a1 log_internalv
 #153912 0x00005575fc3f86a1 log_internal
 #153913 0x00005575fc31c4c1 crash
 #153914 0x00007fb26f2cf3d0 __restore_rt
 #153915 0x00007fb26f2ced00 pause
 #153916 0x00005575fc403944 freeze
 #153917 0x00005575fc31bf7b freeze_or_reboot
...
2016-05-21 12:40:34 -04:00
Tejun Heo
508c45daa4 core: put opening curly braces on the same line as function names (#3313)
Recently added cgroup helper functions break the style convention.  Fix them
up.
2016-05-20 23:46:42 +03:00
Lennart Poettering
7673628066 Revert "core/dbus: further simplify branch code" (#3307) 2016-05-20 23:36:22 +03:00
Tom Gundersen
e4de3d23bb Merge pull request #3304 from tomty89/master
[networkd] ndisc DHCPv6 triggering fixes
2016-05-20 19:00:08 +02:00
Tom Gundersen
e506f43666 Merge pull request #3276 from ssahani/issue-3264
networkd: Drop IPv6LL address when link is down.
2016-05-20 18:54:49 +02:00
Lennart Poettering
f9e26ecc48 Merge pull request #3290 from htejun/cgroup2-io-compat
Implement compat translation between IO* and BlockIO* settings
2016-05-20 18:53:11 +02:00
Tom Gundersen
51e0b25077 Merge pull request #3235 from dkg/hwaddr-cleanup
minor improvements for dealing with MAC Addresses
2016-05-20 17:27:58 +02:00
Jonathan Boulle
4e282d11b7 core/dbus: revert oversimplification (#3309)
free_and_strdup handles NULL but not empty strings.

See also:
https://github.com/systemd/systemd/pull/3283#issuecomment-220603145
https://github.com/systemd/systemd/pull/3307
2016-05-20 16:20:00 +02:00