Commit graph

59 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 568981d2ac missing: add __NR_getrandom for a few more archs
Mips has getrandom() too, but there's just too many variants
for me too care. Either someone who cares does it, or they get
compile-time warnings with old kernel headers.
2014-11-22 12:04:53 -05:00
Vicente Olivert Riera e6c019026b Properly define the __NR_memfd_create macro for MIPS
This macro exists for MIPS since v3.17:
  https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=42944521af97a3b25516f15f3149aec3779656dc
2014-11-04 08:27:31 +01:00
Lennart Poettering 875c2e220e journald: if available pull audit messages from the kernel into journal logs 2014-11-03 21:51:28 +01:00
Lennart Poettering 45071fcaa0 memfd: always create our memfds with CLOEXEC set
We really shouldn't create fds ever that have the flag unset.
2014-10-30 16:23:34 +01:00
Lennart Poettering 97768fc574 util: don't block on getrandom() 2014-10-30 15:27:53 +01:00
Dave Reisner 74a550c5d8 missing.h: fix wrong __NR_getrandom syscall def
278 is vmsplice on x86_64. 318 is what we want:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/syscalls/syscall_64.tbl
2014-10-29 20:41:46 -04:00
Lennart Poettering 793062063a missing: no tabs please, we are british 2014-10-29 17:08:18 +01:00
Lennart Poettering b244d9f374 missing: simplify memfd ifdeffery 2014-10-29 17:07:47 +01:00
Lennart Poettering 539618a0dd util: make use of the new getrandom() syscall if it is available when needing entropy
Doesn't require an fd, and could be a bit faster, so let's make use of
it, if it is available.
2014-10-29 17:06:32 +01:00
Lennart Poettering a5f0359600 resolved: simplify detection of packets from the loopback device
We can simplify our code quite a bit if we explicitly check for the
ifindex being 1 on Linux as a loopback check. Apparently, this is
hardcoded on Linux on the kernel, and effectively exported to userspace
via rtnl and such, hence we should be able to rely on it.
2014-10-22 16:52:38 +02:00
Zbigniew Jędrzejewski-Szmek c7e4a7bece missing: remove fanotify
It was only used in readahead.
2014-10-17 08:55:42 -04:00
Zbigniew Jędrzejewski-Szmek 27c64db6df build-sys: use linux/memfd.h if available
linux/memfd.h was added linux 3.17, so it might not be widely
available for a while.

Also, check if memfd_create is defined, for the HAVE_LINUX_MEMFD_H
check to have a chance of succeeding.

Also, collapse all ifdefs for memfd-related stuff, because they
were all added together so there's no need to check separately.
2014-10-05 19:07:28 -04:00
Thomas Hindoe Paaboel Andersen cf4acf84c6 Remove repeated includes
In pty.c there was both an include of our pty.h and the system installed pty.h.
The latter contains only two functions openpty and forkpty. We use neither so
I assume it was a typo and removed it. We still compile and pass all tests.
2014-10-01 23:25:50 +02:00
Cristian Rodríguez 06b7f7bd7f missing: memfd_create takes unsigned int flags in final version 2014-09-16 21:46:14 +02:00
Tom Gundersen 04d180c8a8 missing: add IFF_MULTI_QUEUE
This was added in 3.8, but we should building with 3.7 headers.

Reported by Samuli Suominen <ssuominen@gentoo.org>.
2014-08-31 18:50:23 +02:00
Michael Olbrich 7965435e58 missing: add BPF_XOR
BPF_XOR was introduced in kernel 3.7
2014-08-26 20:27:17 +02:00
Daniel Mack 2de1851fe3 missing.h: add a cpp warning for __NR_memfd_create on MIPS 2014-08-22 16:10:02 +02:00
Daniel Mack a7d611f280 missing.h: add fake __NR_memfd_create for MIPS
We don't have the correct __NR_memfd_create syscall number yet, so set it to
0xffffffff for now to prevent compile time errors.
2014-08-22 15:41:18 +02:00
Daniel Mack 4632777024 memfd: fix memfd_create() syscall wrapper
Unlike earlier versions, the syscall only takes 2 arguments in its
final version, not 3.
2014-08-18 12:37:22 +02:00
Daniel Mack a6082d778e kdbus: switch over to generic memfd implementation (ABI+API break) 2014-08-17 21:47:00 +02:00
Tom Gundersen 04b67d4925 udev: link_setup - respect kernel name assign policy
Newer kernels export meta-information about the origin of an ifname. Respect this
from the ifname rename logic. We do not rename any interfaces that was originally
named by userspace, nor once which have already been renamed from userspace.

Moreover, we optionally do not (the default) rename interfaces which the kernel
claims to have named in a predictable way.
2014-08-08 13:30:15 +02:00
Zbigniew Jędrzejewski-Szmek 7bed7f0e3b Move BTRFS_IOC_DEVICES_READY to missing.h 2014-08-03 00:28:12 -04:00
Lennart Poettering 9198814968 missing: add missing bonding definitions 2014-08-01 18:55:56 +02:00
Lennart Poettering ec2c5e4398 resolved: implement LLMNR uniqueness verification 2014-07-31 17:47:19 +02:00
Lennart Poettering 623a4c97b9 resolve: add llmnr responder side for UDP and TCP
Name defending is still missing.
2014-07-29 20:57:58 +02:00
Jean-André Santoni 6589d0dba2 Add IFLA_VTI defines to missing.h 2014-07-21 21:04:44 -04:00
Zbigniew Jędrzejewski-Szmek 75616a1332 missing.h: add IFLA_MACVLAN_FLAGS
Now we are getting into kernel < 3.4 territory...

https://bugs.freedesktop.org/show_bug.cgi?id=80095
2014-07-16 16:44:50 -04:00
Zbigniew Jędrzejewski-Szmek 81577dc228 missing.h: add various network enums
We used to check if e.g. IFLA_BOND_MAX is defined and provide fallback
values in missing.h is it wasn't. But over time, various kernel
versions added IFLA_* defines, so checking for IFLA_BOND_MAX is not
enough if the kernel is new enough to have some of them but too old to
have all. In case we detect that the latest known enum value is
missing, #define most of them.

https://bugs.freedesktop.org/show_bug.cgi?id=80095
2014-06-20 22:05:43 -04:00
Tom Gundersen 66269b05cf rtnl: message - read group membership of incoming messages 2014-05-10 20:56:37 +02:00
Zbigniew Jędrzejewski-Szmek 0830ba6189 build-sys: add newly used if_link.h defines to missing.h
Reported-by: Arnaud Gaboury <arnaud.gaboury@gmail.com>
2014-04-05 13:18:36 -04:00
Lennart Poettering a853c45d9a missing: add more compat for old kernels and loop devices
https://bugs.freedesktop.org/show_bug.cgi?id=76335
2014-03-21 03:43:47 +01:00
Lennart Poettering 5f381b355a missing: define LO_FLAGS_PARTSCAN if it is missing
https://bugs.freedesktop.org/show_bug.cgi?id=76335
2014-03-19 01:10:14 +01:00
Lennart Poettering 517d56b1d0 missing: if RLIMIT_RTTIME is not defined by the libc, then we need a new define for the max number of rlimits, too 2014-03-05 02:31:09 +01:00
Lennart Poettering 6633045578 missing: simplifications 2014-02-21 03:07:42 +01:00
Holger Schurig 3b79431414 build-sys: Add setns() functions if not in the C library.
Debian Stable is still using glibc 2.13, which doesn't provide the setns().
So we detect this and provide a tiny wrapper that issues the setns syscall
towards the kernel.
2014-02-21 03:06:29 +01:00
Tom Gundersen d5eff74097 missing.h: add some IFLA_* constants
These were added to the kernel between 3.5 and 3.9, let's not require such
recent kernels (yet).
2014-02-19 15:50:24 +01:00
Zbigniew Jędrzejewski-Szmek 0f010ef213 Base mkostemp_safe on mkostemp
It is nice to wrap umask handling and return convention,
but glibc's mkostemp is async-signal-safe already.
2014-01-28 19:07:13 -05:00
Lennart Poettering c09918f97a util: define O_TMPFILE on x86/x86-64, where the generic value is used
On other archs we'll not define it so that open_tmpfile() falls back to
unguessable name + unlink.
2014-01-28 13:25:51 +01:00
Zbigniew Jędrzejewski-Szmek 65b3903ff5 journal: guarantee async-signal-safety in sd_journald_sendv
signal(7) provides a list of functions which may be called from a
signal handler. Other functions, which only call those functions and
don't access global memory and are reentrant are also safe.
sd_j_sendv was mostly OK, but would call mkostemp and writev in a
fallback path, which are unsafe.

Being able to call sd_j_sendv in a async-signal-safe way is important
because it allows it be used in signal handlers.

Safety is achieved by replacing mkostemp with open(O_TMPFILE) and an
open-coded writev replacement which uses write. Unfortunately,
O_TMPFILE is only available on kernels >= 3.11. When O_TMPFILE is
unavailable, an open-coded mkostemp is used.

https://bugzilla.gnome.org/show_bug.cgi?id=722889
2014-01-27 23:17:02 -05:00
David Herrmann 118ecf3242 logind: introduce session-devices
A session-device is a device that is bound to a seat and used by a
session-controller to run the session. This currently includes DRM, fbdev
and evdev devices. A session-device can be created via RequestDevice() on
the dbus API of the session. You can drop it via ReleaseDevice() again.
Once the session is destroyed or you drop control of the session, all
session-devices are automatically destroyed.

Session devices follow the session "active" state. A device can be
active/running or inactive/paused. Whenever a session is not the active
session, no session-device of it can be active. That is, if a session is
not in foreground, all session-devices are paused.
Whenever a session becomes active, all devices are resumed/activated by
logind. If it fails, a device may stay paused.

With every session-device you request, you also get a file-descriptor
back. logind keeps a copy of this fd and uses kernel specific calls to
pause/resume the file-descriptors. For example, a DRM fd is muted
by logind as long as a given session is not active. Hence, the fd of the
application is also muted. Once the session gets active, logind unmutes
the fd and the application will get DRM access again.
This, however, requires kernel support. DRM devices provide DRM-Master for
synchronization, evdev devices have EVIOCREVOKE (pending on
linux-input-ML). fbdev devices do not provide such synchronization methods
(and never will).
Note that for evdev devices, we call EVIOCREVOKE once a session gets
inactive. However, this cannot be undone (the fd is still valid but mostly
unusable). So we reopen a new fd once the session is activated and send it
together with the ResumeDevice() signal.

With this infrastructure in place, compositors can now run without
CAP_SYS_ADMIN (that is, without being root). They use RequestControl() to
acquire a session and listen for devices via udev_monitor. For every
device they want to open, they call RequestDevice() on logind. This
returns a fd which they can use now. They no longer have to open the
devices themselves or call any privileged ioctls. This is all done by
logind.
Session-switches are still bound to VTs. Hence, compositors will get
notified via the usual VT mechanisms and can cleanup their state. Once the
VT switch is acknowledged as usual, logind will get notified via sysfs and
pause the old-session's devices and resume the devices of the new session.

To allow using this infrastructure with systems without VTs, we provide
notification signals. logind sends PauseDevice("force") dbus signals to
the current session controller for every device that it pauses. And it
sends ResumeDevice signals for every device that it resumes. For
seats with VTs this is sent _after_ the VT switch is acknowledged. Because
the compositor already acknowledged that it cleaned-up all devices.
However, for seats without VTs, this is used to notify the active
compositor that the session is about to be deactivated. That is, logind
sends PauseDevice("force") for each active device and then performs the
session-switch. The session-switch changes the "Active" property of the
session which can be monitored by the compositor. The new session is
activated and the ResumeDevice events are sent.

For seats without VTs, this is a forced session-switch. As this is not
backwards-compatible (xserver actually crashes, weston drops the related
devices, ..) we also provide an acknowledged session-switch. Note that
this is never used for sessions with VTs. You use the acknowledged
VT-switch on these seats.

An acknowledged session switch sends PauseDevice("pause") instead of
PauseDevice("force") to the active session. It schedules a short timeout
and waits for the session to acknowledge each of them with
PauseDeviceComplete(). Once all are acknowledged, or the session ran out
of time, a PauseDevice("force") is sent for all remaining active devices
and the session switch is performed.
Note that this is only partially implemented, yet, as we don't allow
multi-session without VTs, yet. A follow up commit will hook it up and
implemented the acknowledgements+timeout.

The implementation is quite simple. We use major/minor exclusively to
identify devices on the bus. On RequestDevice() we retrieve the
udev_device from the major/minor and search for an existing "Device"
object. If no exists, we create it. This guarantees us that we are
notified whenever the device changes seats or is removed.

We create a new SessionDevice object and link it to the related Session
and Device. Session->devices is a hashtable to lookup SessionDevice
objects via major/minor. Device->session_devices is a linked list so we
can release all linked session-devices once a device vanishes.

Now we only have to hook this up in seat_set_active() so we correctly
change device states during session-switches. As mentioned earlier, these
are forced state-changes as VTs are currently used exclusively for
multi-session implementations.

Everything else are hooks to release all session-devices once the
controller changes or a session is closed or removed.
2013-09-17 17:15:30 -05:00
Michael Marineau 4b357e1587 build-sys: Add configure check for linux/btrfs.h
btrfs.h was added to uapi in Linux 3.9. To fix building with older
header versions this adds a configure check for the header and re-adds
btrfs definitions to missing.h which was removed in bed2e820 along with
two other ioctls used by gpt-auto-generator.

[ Apparently, btrfs.h was only added recently:
  http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=55e301fd57a6239ec14b91a1cf2e70b3dd135194
  let's re-add it for now -- kay ]
2013-08-16 23:29:41 +02:00
Lennart Poettering bed2e820db missing: use btrfs.h instead of defining our own btrfs structures 2013-08-13 10:12:35 +02:00
Shawn Landden f7db7a691c basic SO_REUSEPORT support 2013-07-11 03:09:18 +02:00
Jason St. John e9c1ea9de8 replace tabs with spaces in various files
The affected files in this patch had inconsistent use of tabs vs. spaces
for indentation, and this patch eliminates the stray tabs.

Also, the opening brace of sigchld_hdl() in activate.c was moved so the
opening braces are consistent throughout the file.
2013-07-02 23:06:22 -04:00
Chengwei Yang 28f30cf274 Fix syscall(__NR_fanotify_mark, ...) on arm 2013-05-15 21:02:46 -04:00
Aleksander Morgado a96215285a missing: define MS_REC and MS_SHARED if not defined already 2013-02-13 00:12:58 +01:00
Lennart Poettering 8742514c1a timer: recalculate next elapse for calendar timer units when the system clock is changed 2012-11-25 00:33:59 +01:00
Lennart Poettering 85210bffd8 journal: provide an API that allows client to figure out whether they need to recheck the journal manually for changes in regular intervals
Network file systems generally do not offer inotify() that would work
across the network. We hence cannot rely on inotify() exclusiely in
those case. Provide an API to determine these cases, and suggest doing
manual regular rechecks.

Note that this is not complete yet, as we need to rescan journal dirs on
network file systems explicitly to find new/removed files
2012-10-26 20:07:33 +02:00
Michael Olbrich f527b6b8e2 make sure __NR_name_to_handle_at is correctly defined
341 is only valid for x86, so don't use it for other architectures.
Add the correct numbers for ARM and PowerPC while at it.
2012-10-19 17:31:33 +02:00
Michael Olbrich 9388e99e20 build-sys: check for name_to_handle_at declaration instead of its definition
AC_CHECK_FUNCS may be successful, even though name_to_handle_at and
'struct file_handle'  are not available.
2012-10-16 01:30:29 +02:00