Commit graph

31898 commits

Author SHA1 Message Date
Lennart Poettering 67ae4e8d59 core: move user lookup event priority to -11
This is internal stuff, us talking to ourselves and relatively
independent of everything else, let's put this at
highest priority hence.
2018-01-23 18:15:16 +01:00
Lennart Poettering 832316370b mount,swap: write event loop priority as "SD_EVENT_PRIORITY_NORMAL-x"
We do that in all other cases, let's do it here too. Since
SD_EVENT_PRIORITY_NORMAL evaluates to zero there's zero effective
difference, but it makes things easier to grok and grep for if we always
express relative priorities within PID 1 only.
2018-01-23 18:13:01 +01:00
Lennart Poettering 4259d20215 manager: add MANAGER_IS_RUNNING() for checking whether the manager is running
This macro is useful as the check is not obvious, and we better abstract
this away.
2018-01-23 16:43:56 +01:00
Lennart Poettering 4adf314b77 manager: split out send_ready and basic.target checking into functions of their own
Let's shorten manager_check_finished() a bit by splitting out checking
of basic.target and the two things we do when we reach it.

This should not change behaviour, except for one thing: we now check
basic.target's actual state for figuring out whether it is up, instead
of generically checking whether it has any job queued. This is arguably
more correct, and is what other code does too for similar purposes, for
example manager_state()
2018-01-23 16:39:12 +01:00
Lennart Poettering 8a44b0b849
Merge pull request #7834 from jkloetzke/disable-watchdog
core: add "disable watchdog " function
2018-01-23 15:58:17 +01:00
Lennart Poettering e69b29a8b9
Merge pull request #7940 from sourcejedi/mount
mount rationalization
2018-01-23 13:45:24 +01:00
Patrik Flykt 10a0f27bfd sd-dhcp6-client: Fix DHCPv6 client file descriptor handling
The DHCPv6 client will set its state to DHCP6_STATE_STOPPED if
an error occurs or when receiving an Information Reply DHCPv6
message. Once in DHCP6_STATE_STOPPED, the DHCPv6 client needs
to be restarted by calling sd_dhcp6_client_start().

As of pull request #7796 client_reset() no longer closes the
network socket, thus a call to sd_dhcp6_client_start() needs to
check whether the file descriptor already exists in order not to
create a new one. Likewise, a call to sd_dhcp6_client_unref()
must now close the network socket as client_reset() is not
closing it.

Reported by asavah and Yu Watanabe.
2018-01-23 13:42:12 +01:00
Alan Jenkins b6ba0c164d mount: don't consider activated until /sbin/mount returns
So far, we considered mount units activated as soon as the mount
appeared.  This avoided seeing a difference between mounts started by
systemd, and e.g. by running `mount` from a terminal.
(`umount` was not handled this way).

However in some cases, options passed to `mount` require additional
system calls after the mount is successfully created.  E.g. the
`private` mount option, or the `ro` option on bind mounts.
It seems best to wait for mount to finish doing that.  E.g. in
the `private` case, the current behaviour could theoretically cause
non-deterministic results, as child mounts inherit the
private/shared propagation setting from their parent.

This also avoids a special case in mount_reload().
2018-01-23 11:09:18 +00:00
Alan Jenkins 5701836121 mount: clarify that umount retries do not (anymore) allow multiple timeouts
It _looks_ as if, back when we used to retry unsuccessful calls to umount,
this would have inflated the effective timeout.  Multiplying it by
RETRY_UMOUNT_MAX.  Which is set to 32.

I'm surprised if it's true: I would have expected it to be noticed during
the work on NFS timeouts.  But I can't see what would have stopped it.

Clarify that I do not expect this to happen anymore.  I think each
individual umount call is allowed up to the full timeout, but if umount
ever exited with a signal status, we would stop retrying.

To be extra clear, make sure that we do not retry in the event that umount
perversely returned EXIT_SUCCESS after receiving SIGTERM.
2018-01-23 11:09:18 +00:00
Alan Jenkins 006aabbd05 mount: mountinfo event is supposed to always arrive before SIGCHLD
"Due to the io event priority logic we can be sure the new mountinfo is
loaded before we process the SIGCHLD for the mount command."

I think this is a reasonable expectation.  But if it works, then the
other comment must be false:

"Note that mount(8) returning and the kernel sending us a mount table
change event might happen out-of-order."

Therefore we can clean up the code for the latter.

If this is working as advertised, then we can make sure that mount units
fail if the mount we thought we were creating did not actually appear,
due to races or trickery (or because /sbin/mount did something unexpected
despite returning EXIT_SUCCESS).

Include a specific warning message for this failure.

If we give up when the mount point is still mounted after 32 successful
calls to /sbin/umount, that seems a fairly similar case.  So make that
message a LOG_WARN as well (not LOG_DEBUG). Also, this was recently changed to only
retry while umount is returning EXIT_SUCCESS; in that case in particular
there would be no other messages in the log to suggest what had happened.
2018-01-23 11:09:06 +00:00
Martin Pitt 2b0c59baa2 hwdb: map zoomin/out keys to up/down
Some keyboards come with a zoom see-saw or rocker which until now got
mapped to the Linux "zoomin/out" keys in hwdb. However, these keycodes
are not recognized by any major desktop. They now produce Up/Down key
events so that they can be used for scrolling.

The internet is full of instructions how to "unbreak" these keys, e. g.

  https://askubuntu.com/questions/471802/make-the-zoom-slider-of-microsoft-natural-ergonomic-keyboard-4000-and-7000-scrol
  https://unix.stackexchange.com/questions/322075/how-to-get-ms-natural-ergonomic-4000-slider-work-on-linux-mint

So let's make it official. But keep their physical meaning in comments
in case desktops start to do something useful with them at some point.

Thanks to Finn Christiansen for the original patch!

Replaces #6953
2018-01-23 10:30:49 +01:00
Maciej S. Szmigiero 0d2eef9bcb hwdb: Add Microsoft Sculpt Comfort Mouse data (#7946)
This adds measured Microsoft Sculpt Comfort (Bluetooth) Mouse data to hwdb.
2018-01-23 15:25:24 +10:00
ott 4cbfd62b46 resolve: Adjust and unify D-Bus call timeout (#7847)
DNS queries have a timeout of DNS_TRANSACTION_ATTEMPTS_MAX *
DNS_TIMEOUT_MAX_USEC = 120 s. Calls to the ResolveHostname method of
the org.freedesktop.resolve1.Manager interface have various call
timeouts that are smaller than 120 s. So it seems correct to adjust
the call timeout to the maximum query timeout and to unify the call
timeout among all callers.

A timeout of 120 s might seem large, in particular since BIND does seem
to have a query timeout of 10 s. However, it seems match the timeout
value of 120 s of Unbound. Moreover, the query and timeout handling of
resolve have problems and might be improved in the future, so this
change is at best an interim solution.
2018-01-23 09:53:31 +09:00
lbernstone 47628ee121 hwdb: Added sensor geometry for Jumper EZpad 6 Pro (#7955) 2018-01-23 09:51:11 +09:00
Yu Watanabe 77d0776c3b
loopback-setup: update log message (#7956)
This makes not log "Failed to ..." when each operation succeeds.

Fixes #7930.
2018-01-23 09:50:31 +09:00
Gianluca Boiano b391a8d895 hwdb: readded accelerometer orientation entry for AsusTek TP500LB (#7958) 2018-01-23 09:50:09 +09:00
Olivier Schwander 2b0ad7a08f hwdb: add Ideazon Zboard Merc and Ideazon Zboard Fang (#6954) 2018-01-22 21:41:11 +01:00
Jan Klötzke 21a6abdf0e bash-completion: systemd-analyze: add service-watchdogs verb 2018-01-22 21:39:57 +01:00
Lennart Poettering 4fef7818a3
Merge pull request #7719 from gdamjan/efistub-LoaderImageIdentifier
EFI stub: add LoaderImageIdentifier, LoaderFirmwareInfo, LoaderFirmwareType and StubInfo
2018-01-22 20:41:22 +01:00
Lennart Poettering 8dba4c60e2
Merge pull request #7952 from poettering/tmpfiles-tweaks
Some tmpfiles tweaks
2018-01-22 20:33:40 +01:00
Reverend Homer 98f6093687 systemctl: replace manual GetAll call with bus_map_all_properties() in unit_exists() 2018-01-22 20:33:15 +01:00
Jérémy Rosen bf70ff2cff fix reload propagation for device alias
udev-made .device aliases are not normal alias

They are full-fledged units which are linked to
the same sysfs path

we need to explicitely propagate reload to all
alias
2018-01-22 19:53:55 +01:00
Jan Klötzke 889d695d6c systemd-analyze: add service-watchdogs verb
New debug verb that enables or disables the service runtime watchdogs
and emergency actions during runtime. This is the systemd-analyze
version of the systemd.service_watchdogs command line option.
2018-01-22 18:10:12 +01:00
Jan Klötzke 2a12e32efa pid1: add option to disable service watchdogs
Add a "systemd.service_watchdogs=" option to the command line which
disables all service runtime watchdogs and emergency actions.
2018-01-22 18:10:03 +01:00
Armin Widegreen 4f5e172341 journal: Fix journal dumping for json, cat and export output
Incorporating the fix from d00f1d57 into other output formats of journalctl.

If journal files are corrupted, e.g. not cleanly closed, some journal
entries can not be read by output options other than 'short' (default).
If such entries has been identified, they will now just be skipped.
2018-01-22 18:08:52 +01:00
Jan Klötzke 43ce15ac30 bus-util: add bool property setter 2018-01-22 18:06:56 +01:00
Michal Koutný 204d140c4d core/timer: Prevent timer looping when unit cannot start
When a unit job finishes early (e.g. when fork(2) fails) triggered unit goes
through states
        stopped->failed (or failed->failed),
in case a ExecStart= command fails unit passes through
        stopped->starting->failed.

The former transition doesn't result in unit active/inactive timestamp being
updated and timer (OnUnitActiveSec= or OnUnitInactiveSec=) would use an expired
timestamp triggering immediately again (repeatedly).

This patch exploits timer's last trigger timestamp to ensure the timer isn't
triggered more frequently than OnUnitActiveSec=/OnUnitInactiveSec= period.

Steps to reproduce:

0) Create sample units:

cat >~/.config/systemd/user/looper.service <<EOD
[Service]
ExecStart=/usr/bin/sleep 2
EOD

cat >~/.config/systemd/user/looper.timer <<EOD
[Timer]
AccuracySec=5
OnUnitActiveSec=5
EOD

1) systemctl --user daemon-reload

2) systemctl --user start looper.timer
   # to have first activation timestamp/sentinel
   systemctl --user start looper.service

o  Observe the service is being regularly triggered.

3) systemctl set-property user@$UID.service TasksMax=2

o  Observe the tight looping as long as the looper.service cannot be started.

Ref: #5969
2018-01-22 17:13:00 +01:00
Susant Sahani 3e52ec4301 netword: tunnel remove unwanted space. 2018-01-22 15:50:07 +01:00
Reverend Homer 8ac8c411d7 remove canonicalize_file_name() mention from TODO
canonicalize_file_name() invocations were replaced by chase_symlinks() in
Decemeber 2016 with PR #4694, so we don't need this mention in the TODO anymore
2018-01-22 15:49:45 +01:00
Lennart Poettering 586a8e93a0 update TODO 2018-01-22 15:33:26 +01:00
Lennart Poettering 79c91cecc7 tmpfiles: use the DEBUG_LOGGING macro where applicable 2018-01-22 15:33:13 +01:00
Lennart Poettering 07982ed1ef tmpfiles: add missing OOM check 2018-01-22 15:32:57 +01:00
Lennart Poettering 201be4265f tmpfiles: avoid using wrong type for strlen() result
The result of strlen is size_t, hence let's not store it in an "int"
just to pass it on as as size_t right-away. In fact let's not store it
at all…
2018-01-22 15:31:50 +01:00
Lennart Poettering 920ce82852 tmpfiles: in dir_cleanup() take benefit that log_error_errno() returns the error code passed in 2018-01-22 15:31:24 +01:00
Lennart Poettering ecc1709c2c tmpfiles: fold five lines into two
log_full_errno() has all these nice benefits, let's make use of them to
shorten five lines into two.
2018-01-22 15:30:05 +01:00
Lennart Poettering 47925d7f32
Merge pull request #7943 from yuwata/fix-chase_symlinks
fs-util: use `_cleanup_close_` attribute
2018-01-22 12:42:24 +01:00
Frantisek Sumsal 1dc52f56f9 journald-native: Fix typo in MANDLOCK message 2018-01-22 12:27:09 +01:00
Susant Sahani fb5c821664 networkd: DHCPv6 client allow to configure Rapid Commit (#6930)
The DHCPv6 client can obtain configuration parameters from a
DHCPv6 server through a rapid two-message exchange solicit and reply).
When the rapid commit option is enabled by both the DHCPv6 client and
the DHCPv6 server, the two-message exchange is used, rather than the default
four-method exchange (solicit, advertise, request, and reply). The two-message
exchange provides faster client configuration and is beneficial in environments
in which networks are under a heavy load.

Closes #5845
2018-01-22 17:09:18 +09:00
Yu Watanabe db52db4afa fuzz: cast to void when return value is ignored 2018-01-22 09:58:29 +09:00
Yu Watanabe 0f3da640de fuzz: check return value
Closes CID #1385306 and #1385300.
2018-01-22 09:55:38 +09:00
Yu Watanabe 7444956723 fuzz: fix coding style 2018-01-22 09:54:30 +09:00
Zbigniew Jędrzejewski-Szmek d8eb10d61a core: delay logging the taint string until after basic.target is reached (#7935)
This happens to be almost the same moment as when we send READY=1 in the user
instance, but the logic is slightly different, since we log taint when
basic.target is reached in the system manager, but we send the notification
only in the user manager. So add a separate flag for this and propagate it
across reloads.

Fixes #7683.
2018-01-21 21:17:54 +09:00
Yu Watanabe 48eae2e480 test-resolve: check return value
Closes CID #1385310.
2018-01-21 19:38:33 +09:00
Yu Watanabe 1eeddba492 sd-dhcp6-client: do not refer uninitialized variable
Fixes CID #1385308.
2018-01-21 19:27:30 +09:00
Yu Watanabe b539437a05 fs-util: chase_symlinks(): prevent double free
Fixes CID #1385316.
2018-01-21 19:19:28 +09:00
Yu Watanabe 2b6d2dda6b fs-util: use _cleanup_close_ attribute
The commit f14f1806e3 introduced CHASE_SAFE
flag. When the flag is set, then `fd_parent` may not be properly closed.
This sets `_cleanup_close_` attribute to `fd_parent`.
Thus, now `fd_parent` is always closed properly.
2018-01-21 19:07:14 +09:00
Zbigniew Jędrzejewski-Szmek 91ec71c162 man: document that sd_j_stream_fd is signal safe (#7942)
Fixes #7912.
2018-01-21 18:51:55 +09:00
Alan Jenkins 25cd49647c mount: forbid mount on path with symlinks
It was forbidden to create mount units for a symlink.  But the reason is
that the mount unit needs to know the real path that will appear in
/proc/self/mountinfo.  The kernel dereferences *all* the symlinks in the
path at mount time (I checked this with `mount -c` running under `strace`).

This will have no effect on most systems.  As recommended by docs, most
systems use /etc/fstab, as opposed to native mount unit files.
fstab-generator dereferences symlinks for backwards compatibility.

A relatively minor issue regarding Time Of Check / Time Of Use also exists
here.  I can't see how to get rid of it entirely.  If we pass an absolute
path to mount, the racing process can replace it with a symlink.  If we
chdir() to the mount point and pass ".", the racing process can move the
directory.  The latter might potentially be nicer, except that it breaks
WorkingDirectory=.

I'm not saying the race is relevant to security - I just want to consider
how bad the effect is.  Currently, it can make the mount unit active (and
hence the job return success), despite there never being a matching entry
in /proc/self/mountinfo.  This wart will be removed in the next commit;
i.e. it will make the mount unit fail instead.
2018-01-20 22:06:34 +00:00
Yu Watanabe 08fde561ba
Merge pull request #7938 from keszybz/get-fd-unsafe
man: document signal unsafeness of sd_journal_get_fd
2018-01-20 13:20:33 +09:00
Zbigniew Jędrzejewski-Szmek 89f552c0e2 man: document signal unsafeness of journal functions
Fixes #7912.
2018-01-20 15:11:54 +11:00