1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 11:55:44 +03:00
Commit Graph

16849 Commits

Author SHA1 Message Date
Tom Gundersen
f7f53e9e6e sd-event: allow naming event sources 2014-08-28 21:19:17 +02:00
Tom Gundersen
5968b1c304 sd-rtnl: log if kernel buffer is overrun as we currently can't handle that case 2014-08-28 21:19:16 +02:00
Lennart Poettering
ac528e3e3b hibernate-resume: refuse to run outside of an initrd 2014-08-28 20:26:14 +02:00
Lennart Poettering
202aea456d update TODO 2014-08-28 20:26:14 +02:00
Zbigniew Jędrzejewski-Szmek
ddb7f7fc07 networkctl: do not mix dns and ntp servers 2014-08-28 09:41:29 -04:00
David Herrmann
427c71629e bus: don't skip interfaces in bus_message_map_properties_changed()
Skipping interfaces randomly without the caller specifying it is nasty.
Avoid this and let the caller do that themselves.
2014-08-28 15:25:51 +02:00
David Herrmann
c168eb6785 locale: fix sending PropertiesChanged for x11 keymap changed
The sd_bus_emit_properties_changed() call for x11 keymap changes lacks
commas.. whoops. Fix it! Now localed emits PropertiesChanged signals
again.
2014-08-28 15:25:51 +02:00
Harald Hoyer
5a4bf02ff5 use the switch_root function in shutdown
removes code duplication

also move switch-root to shared
2014-08-28 15:25:15 +02:00
David Herrmann
667a0377fb 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 fb835651af
    Author: David Herrmann <dh.herrmann@gmail.com>
    Date:   Fri Aug 22 14:41:37 2014 +0200

        shared: make container_of() use unique variable names
2014-08-28 14:45:38 +02:00
David Herrmann
d974ad0524 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.
2014-08-28 12:45:51 +02:00
David Herrmann
fa9838ddd6 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.
2014-08-28 12:45:51 +02:00
David Herrmann
200716a628 terminal: free xkb state on keyboard destruction
Fix leaking the xkb-state during keyboard destruction, leaking lots of xkb
references into the wild.
2014-08-28 12:45:51 +02:00
Tom Gundersen
3125b3ef5d nspawn: fix --network-interface
Use SETLINK when modifying an existing link.
2014-08-28 12:16:07 +02:00
David Herrmann
371ad55d46 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.
2014-08-28 11:04:18 +02:00
Zbigniew Jędrzejewski-Szmek
0f99f74a14 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.
2014-08-27 21:05:28 -04:00
Zbigniew Jędrzejewski-Szmek
57cd09acf2 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
2014-08-27 21:05:28 -04:00
Thomas Hindoe Paaboel Andersen
00b333bb10 terminal: remove unused variable 2014-08-27 23:23:10 +02:00
Lennart Poettering
eff3f4f9e9 update TODO 2014-08-27 21:43:46 +02:00
Lennart Poettering
8a7c93d858 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.
2014-08-27 21:43:46 +02:00
Tom Gundersen
c609cb9898 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.
2014-08-27 19:04:29 +02:00
David Herrmann
8e9371905c 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.
2014-08-27 18:42:29 +02:00
David Herrmann
e06cc7b074 terminal: add xkb-based keyboard devices to idev
The idev-keyboard object provides keyboard devices to the idev interface.
It uses libxkbcommon to provide proper keymap support.

So far, the keyboard implementation is pretty straightforward with one
keyboard device per matching evdev element. We feed everything into the
system keymap and provide proper high-level keyboard events to the
application. Compose-features and IM need to be added later.
2014-08-27 18:42:28 +02:00
David Herrmann
c93e5a62ff terminal: add evdev elements to idev
The evdev-element provides linux evdev interfaces as idev-elements. This
way, all real input hardware devices on linux can be used with the idev
interface.

We use libevdev to interface with the kernel. It's a simple wrapper
library around the kernel evdev API that takes care to resync devices
after kernel-queue overflows, which is a rather non-trivial task.
Furthermore, it's a well tested interface used by all other major input
users (Xorg, weston, libinput, ...).
Last but not least, it provides nice keycode to keyname lookup tables (and
vice versa), which is really nice for debugging input problems.
2014-08-27 18:42:28 +02:00
David Herrmann
e202fa31fb 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.
2014-08-27 18:42:28 +02:00
David Herrmann
7ed3a638b2 terminal: add system view interface
We're going to need multiple binaries that provide session-services via
logind device management. To avoid re-writing the seat/session/device
scan/monitor interface for each of them, this commit adds a generic helper
to libsystemd-terminal:

The sysview interface scans and tracks seats, sessions and devices on a
system. It basically mirrors the state of logind on the application side.
Now, each session-service can listen for matching sessions and
attach to them. On each session, managed device access is provided. This
way, it is pretty simple to write session-services that attach to multiple
sessions (even split across seats).
2014-08-27 18:42:28 +02:00
David Herrmann
aae2b488d0 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.
2014-08-27 18:42:28 +02:00
David Herrmann
f1566e63da util: make lookup_uid() global
This is a useful helper, make it global. It will be required for
libsystemd-terminal, at minimum.
2014-08-27 18:42:28 +02:00
David Herrmann
92e63a5105 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
2014-08-27 18:42:28 +02:00
David Herrmann
60240797a4 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.
2014-08-27 18:42:28 +02:00
David Herrmann
fb835651af 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, ...).
2014-08-27 18:42:28 +02:00
David Herrmann
418bcb0ce3 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.
2014-08-27 18:42:28 +02:00
Tom Gundersen
285e8c126b TODO 2014-08-27 18:17:16 +02:00
Tom Gundersen
aeb50ff0bd tmpfiles: make resolv.conf entry conditional on resolved support 2014-08-27 18:17:16 +02:00
Lukas Nykryn
81fc054dc7 systemctl: fix broken list-unit-files with --root 2014-08-27 11:48:48 +02:00
Martin Pitt
e512e8a255 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
2014-08-27 08:41:10 +02:00
Piotr Drąg
1977376274 po: update Polish translation
https://bugs.freedesktop.org/show_bug.cgi?id=83015
2014-08-27 01:00:56 -04:00
Andrei Borzenkov
bf2e0ece85 Document "...|..." udev match syntax 2014-08-27 01:00:56 -04:00
Zbigniew Jędrzejewski-Szmek
36f5ace2db 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.
2014-08-26 21:14:11 -04:00
Ivan Shapovalov
d2c68822c4 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.
2014-08-26 22:19:56 +02:00
Ivan Shapovalov
42483a7474 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.
2014-08-26 22:19:54 +02:00
Ivan Shapovalov
66f311206e 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.
2014-08-26 22:19:50 +02:00
Ben Wolsieffer
3c56cab441 logind: add HandleLidSwitchDocked= option to logind.conf + documentation
https://bugs.freedesktop.org/show_bug.cgi?id=82485
2014-08-26 22:08:02 +02:00
Lennart Poettering
36202fd2bc sd-journal: never log anything by default from a library 2014-08-26 21:47:46 +02:00
Lennart Poettering
1b6d7fa742 util: make use of newly added reset_signal_mask() call wherever appropriate 2014-08-26 21:12:54 +02:00
Lennart Poettering
1dedb74a2e 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
2014-08-26 21:12:47 +02:00
Lennart Poettering
24a5d6b04e 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...
2014-08-26 21:03:23 +02:00
Hristo Venev
f2322f0b64 sd-bus: don't include internal header memfd.h in public header sd-bus.h
https://bugs.freedesktop.org/show_bug.cgi?id=83097
2014-08-26 20:40:35 +02:00
Sjoerd Simons
498cfc230a 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.
2014-08-26 20:37:05 +02:00
Lennart Poettering
bb19cb1707 sd-bus: remove unused call bus_kernel_create_monitor()
Noticed by Djalal Harouni
2014-08-26 20:35:44 +02:00
Filipe Brandenburger
684fc8927e 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'
2014-08-26 20:31:33 +02:00