Commit graph

5854 commits

Author SHA1 Message Date
Kay Sievers f252ff1742 rename stdio-bridge to bus-proxyd 2013-11-29 22:12:59 +01:00
Lennart Poettering 219728b31b bus: synthesize NameLost/NameAcquired from kernel messages on top if NameOwnerChange 2013-11-29 22:03:55 +01:00
Lennart Poettering 51502af33d bus: fix callback index when dispatching kernel messages 2013-11-29 22:03:55 +01:00
Lennart Poettering 7d22c71732 bus: add the ability for backends to queue to input messages at the same time
We need this so that one incoming kernel message can result in two
high-level bus messages, for the case where we synthesize NameAcquired
and NameOwnerChanged in the same instance.
2013-11-29 22:03:55 +01:00
Daniel Mack 3519d4c895 libsystemd-bus: sd_bus_request_name: use kdbus_translate_request_name_flags() 2013-11-29 22:01:34 +01:00
Daniel Mack 98f17eda0f libsystemd-bus: rename sd_bus_kernel_translate_request_name_flags
... to keep the namespace clean.
2013-11-29 22:01:34 +01:00
Daniel Mack 6018903565 libsystemd-bus: add kdbus support for sd_bus_get_owner() 2013-11-29 22:01:34 +01:00
Daniel Mack 87b522ae19 libsystemd-bus: add sd_bus_translate_attach_flags()
Factor out code from sd_bus_negotiate_attach_creds() to a generic
translate function, so it can be used from other places.
2013-11-29 22:01:34 +01:00
Daniel Mack c931748d20 libsystemd-bus: factor out DBus bits out of sd_bus_get_owner()
Just a preparation for upcoming kdbus support.
2013-11-29 22:01:34 +01:00
Kay Sievers fa6ccbf423 bus: do not fail if "comm" information cannot be retrieved from /proc 2013-11-29 21:34:14 +01:00
Kay Sievers c6dfb87f1d bus: fix size calculation for match data 2013-11-29 21:03:54 +01:00
Lennart Poettering 34a2c9e841 bus: when synthesizing messages locally, fill in a sender 2013-11-29 20:14:11 +01:00
Lennart Poettering b5dda4d84a busctl: fix --help line breaks 2013-11-29 20:14:11 +01:00
Lennart Poettering 777d7a6123 kdbus: synthesize NameOwnerChange signals from kernel messages and support matches against NameOwnerChange 2013-11-29 20:14:11 +01:00
Lennart Poettering a9ed78b0ca kdbus: add base enums for items 2013-11-29 20:14:11 +01:00
Kay Sievers 197941a8d5 bus: do not fail if task information cannot be retrieved from /proc 2013-11-29 19:46:59 +01:00
Lukasz Skalski 9bb058a1e0 libsystemd-bus: clean up bus-control.c file 2013-11-29 19:08:51 +01:00
Kay Sievers 547708f59e bus: do not fail if cgroup information cannot be retrieved from /proc 2013-11-29 18:57:06 +01:00
Kay Sievers 8bd54e897c libsystemd-bus: catch up with latest kdbus changes 2013-11-29 18:37:39 +01:00
Daniel Mack ea1edeceb1 libsystemd-bus: follow kdbus renames
kdbus now has more generic names for the items it passes around. That
allows for usage from other contexts.
2013-11-29 18:10:36 +01:00
Daniel Mack c58dea190c libsystemd-bus: copy over kdbus provided 128-bit bus id
kdbus now copies the bus unique id back to userspace in the hello
ioctl(). Use these bytes to set the server id of the sd_bus.
2013-11-29 16:27:30 +01:00
Daniel Mack d21a7bb1a9 libsystemd-bus: catch up with latest kdbus changes
kdbus_cmd_hello now has a new uint64_t flags field for the requested
attachments. Follow that change in libsystemd-bus.
2013-11-29 15:36:40 +01:00
Daniel Mack 71008e18a0 systemd-stdio-bridge: make it socket-activatable and usable as kdbus bridge
Augment systemd-stdio-bridge a bit to make it a 1:1 bridge from legacy
DBus clients to kdbus. In particular,

 * allow setting the bus path of the upstream bus as command line
   argument
 * use sd_listen_fds() for systemd's socket activation
 * omit calling sd_bus_negotiate_fds() when upstream bus is kdbus
 * reply to bus send errors with proper dbus error messages
 * treat -ECONNRESET as expected end-of-connection condition
2013-11-29 14:06:50 +01:00
Daniel Mack ed99569df8 libsystemd-bus: sd_bus_request_name: fix return value for kdbus
kdbus returns -EALREADY if the requesting connection is already the
owner of a name, and -EEXIST if the name already exists and the
connection is not able to take it over.

Also, n->flags needs a translation as well to match the SD_BUS_* enum
values.
2013-11-29 14:06:50 +01:00
Daniel Mack 0253ddccbb libsystemd-bus: kernel: add sd_bus_kernel_translate_request_name_flags
Flags used to request a name from kdbus are not identical to what DBus
and sd_bus use internally. Introduce a simple function to do the
translation for us. It's factored out to a separate function so the
dbus-driver instance can make use of it as well.
2013-11-29 14:06:50 +01:00
Daniel Mack b6bd53c1ee libsystemd-bus: make sd_bus_list_names return all connections, including unique names 2013-11-29 14:06:50 +01:00
Daniel Mack b147398450 libsystemd-bus: add kdbus support for sd_bus_list_names()
kdbus will tell us the minimum buffer size it needs in case the default
8kb buffer doesn't suffice.
2013-11-29 14:06:49 +01:00
Daniel Mack 9eb34e8225 libsystemd-bus: bring definitions in sync with kdbus
In particular, KDBUS_ITEM_NEXT is now called KDBUS_PART_NEXT, and
KDBUS_ITEM_FOREACH was renamed to KDBUS_PART_FOREACH and takes one more
argument to make it more flexible.
2013-11-29 14:06:49 +01:00
Lennart Poettering 5461f53f18 bus: when turning a buffer into a sd_bus_message avoid creating zero-length parts 2013-11-29 13:34:55 +01:00
Kay Sievers 76037baee0 bus: creds - ignore EINVAL when acessing the (inactive) LSM /proc interface 2013-11-29 11:52:22 +01:00
Lukasz Skalski 27df44a2c6 bus: Add KDBUS_MSG_SRC_NAMES to bus_kernel_make_message() function 2013-11-29 11:43:28 +01:00
Lennart Poettering 7f4cec6995 busctl: drop bus driver name from list of services 2013-11-28 20:44:26 +01:00
Lennart Poettering a4297f08ed bus: merge sd_bus_get_owner() and sd_bus_get_owner_creds() into one call
Since the backing ioctl for this on kdbus is the same we retain
atomicity this way.
2013-11-28 20:44:26 +01:00
Zbigniew Jędrzejewski-Szmek df41aaf9a2 Remove some unused variables 2013-11-28 14:37:11 -05:00
Zbigniew Jędrzejewski-Szmek bdb628eec6 virt: split detect_vm into separate functions
It didn't build on arm. Let's simplify it a bit by
splitting x86 specific parts out, which should also make
things easier when arm virtualization support is added.
2013-11-28 14:37:11 -05:00
Marc-Antoine Perennou dda3e81486 core: fix SetUnitProperties 2013-11-28 20:33:54 +01:00
Tom Gundersen ff83aac364 Revert "link-config: match length for kernel commandline option"
This reverts commit da66338e17.

It is superseeded by 70f75a523b
2013-11-28 20:06:42 +01:00
Lennart Poettering 5b12334d35 bus: add new sd_bus_creds object to encapsulate process credentials
This way we can unify handling of credentials that are attached to
messages, or can be queried for bus name owners or connection peers.

This also adds the ability to extend incomplete credential information
with data from /proc,

Also, provide a convenience call that will automatically determine the
most appropriate credential object for an incoming message, by using the
the attached information if possible, the sending name information if
available and otherwise the peer's credentials.
2013-11-28 18:42:18 +01:00
Lennart Poettering 70f75a523b util: fix handling of trailing whitespace in split_quoted()
Inspired by a patch by Lukas Nykryn.
2013-11-28 18:42:18 +01:00
David Herrmann 486cd82c8f logind: remove unused session->closing field
This field is always false, drop it. If you want a reliable way to get
session state, call session_get_state(). Testing for any flags directly
doesn't work currently so don't pretend it would.
2013-11-28 17:41:44 +01:00
David Herrmann c506027af8 logind: require VTs on seat0 and forbid elsewhere
Sessions on seat0 must pass us a vtnr, otherwise, you shouldn't try
attaching it to seat0. For seats without VTs, we do the exact opposite: we
forbid VTs.

There can be odd situations if the session-files contain invalid
combinations. However, we try to keep sessions alive and restore state as
good as possible.
2013-11-28 17:41:38 +01:00
David Herrmann 92bd5ff3a0 logind: make VT numbers unsigned
Fix the whole code to use "unsigned int" for vtnr. 0 is an invalid vtnr so
we don't need negative numbers at all.

Note that most code already assumes it's unsigned so in case there's a
negative vtnr, our code may, under special circumstances, silently break.
So this patch makes sure all sources of vtnrs verify the validity. Also
note that the dbus api already uses unsigned ints.
2013-11-28 17:38:16 +01:00
Tom Gundersen 92fe133abf networkd: fix several Address entries in [Network] section 2013-11-28 17:17:04 +01:00
David Herrmann 2a16a986ce event: allow EPOLLET as event flag
EPOLLET enables edge-triggered mode (see epoll(7) for more). For most
use-cases, level-triggered is just fine, but for master-TTYs we need
edge-triggered to catch EPOLLHUP. master-TTYs signal EPOLLHUP if no client
is connected, but a client may connect some time later (same happens
during vhangup(2)).

However, epoll doesn't allow masking EPOLLHUP so it's signaled constantly.
To avoid this, edge-triggered mode is needed.
2013-11-28 15:16:49 +01:00
David Herrmann 90a18413f8 logind: mute/restore VT on behalf of session controllers
If a session process calls TakeControl(), we now put the VT into
KD_GRAPHICS+K_OFF mode. This way, the new session controller can solely
rely on the logind-dbus API to manage the session.

Once the controller exits or calls ReleaseControl(), we restore the VT. We
also restore it, if we lost a controller during crash/restart (but only if
there really *was* a controller previously).

Note that we also must put the VT into VT_PROCESS mode. We want VT_AUTO
semantics, but VT_AUTO+KD_GRAPHICS actually disables *all* VT switches
(who came up with that great idea?). Hence, we set VT_PROCESS for logind
but acknowledge *all* requests immediately.

If a compositor wants custom VT setups, they can still get this by *first*
calling TakeControl() and afterwards setting up the VT. logind doesn't
touch the VT during controller runtime, only during setup/teardown. This
is actually what weston already does.
2013-11-28 15:16:49 +01:00
David Herrmann 6d33772f9a logind: restore session-controller after crash
We now save the unique bus-name of a session-controller as CONTROLLER=%s
in the session files. This allows us to restore the controller after a
crash or restart.

Note that we test whether the name is still valid (dbus guarantees that
the name is unique as long as the machine is up and running). If it is,
we know that the controller still exists and can safely restore it. Our
dbus-name-tracking guarantees that we're notified once it exits.

Also note that session-devices are *not* restored. We have no way to know
which devices where used before the crash. We could store all these on
disk, too, or mark them via udev. However, this seems to be rather
cumbersome. Instead, we expect controllers to listen for NewSession
signals for their own session. This is sent on session_load() and they can
then re-request all devices.

The only race I could find is if logind crashes, then the session
controller tries calling ReleaseControl() (which will fail as logind is
down) but keeps the bus-connection valid for other independent requests.
If logind is restarted, it will restore the old controller and thus block
the session.
However, this seems unlikely for several reasons:
 - The ReleaseControl() call must occur exactly in the timespan where
   logind is dead.
 - A process which calls ReleaseControl() usually closes the
   bus-connection afterwards. Especially if ReleaseControl() fails, the
   process should notice that something is wrong and close the bus.
 - A process calling ReleaseControl() usually exits afterwards. There may
   be any cleanup pending, but other than that, usual compositors exit.
 - If a session-controller calls ReleaseControl(), a session is usually
   considered closing. There is no known use-case where we hand-over
   session-control in a single session. So we don't care whether the
   controller is locked afterwards.

So this seems negligible.
2013-11-28 15:16:49 +01:00
David Herrmann d1107170f9 logind: ignore failing close() on session-devices
Unfortunately, close() on a revoked/removed character-device fails with
ENODEV. I tried tracking this down in the kernel, but couldn't figure out
were exactly it comes from. However, can be easily reproduced with:
  fd = open("/dev/input/event0", O_RDWR);
  ioctl(fd, EVIOCREVOKE, 0);
  r = close(fd);
A second close on @fd would return EBADF so the close is actually valid.

We simply ignore close() errors for all session-devices as their access
may be revoked asynchronously, or the device might get unplugged.
We use close_nointr() in case anyone ever looks at the return value (or
anyone runs "grep 'close(' -r src/" to find broken close() calls).

Fixes:
  systemd-logind[31992]: Assertion 'close_nointr(fd) == 0' failed at src/shared/util.c:185, function close_nointr_nofail(). Aborting.
2013-11-28 15:16:49 +01:00
David Herrmann 5fd38859b3 bus: add bus_name_has_owner() helper
Small helper to run a synchronous "NameHasOwner" request on the
dbus-daemon.
2013-11-28 15:16:49 +01:00
David Herrmann 3fdb2494c1 login: revert lazy session-activation on non-VT seats
Existing applications like gdm already depend on new sessions to get
immediately activated on seats without VTs. Fixes a bug reported as:
  [systemd-devel] systemd 208:trouble with inactive user sessions at non-seat0 seats

This patch restores the original behavior. We either need to add a new
flag for session-creation or some other heuristic to avoid activating new
sessions in the future.
2013-11-28 10:52:18 +01:00
Kay Sievers dd971bd2ce bus: update kdbus.h and always subscribe to KDBUS_HELLO_ATTACH_NAMES 2013-11-28 02:26:03 +01:00