chiark / gitweb /
elogind.git
7 years agopath-util: Change path_is_mount_point() symlink arg from bool to flags
Martin Pitt [Fri, 29 May 2015 15:13:12 +0000 (17:13 +0200)]
path-util: Change path_is_mount_point() symlink arg from bool to flags

This makes path_is_mount_point() consistent with fd_is_mount_point() wrt.
flags.

7 years agologind: Fix user_elect_display() to be more stable
Philip Withnall [Fri, 29 May 2015 09:49:21 +0000 (10:49 +0100)]
logind: Fix user_elect_display() to be more stable

The previous implementation of user_elect_display() could easily end up
overwriting the user’s valid graphical session with a new TTY session.
For example, consider the situation where there is one session:
   c1, type = SESSION_X11, !stopping, class = SESSION_USER
it is initially elected as the user’s display (i.e. u->display = c1).

If another session is started, on a different VT, the sessions_by_user
list becomes:
   c1, type = SESSION_X11, !stopping, class = SESSION_USER
   c2, type = SESSION_TTY, !stopping, class = SESSION_USER

In the previous code, graphical = c1 and text = c2, as expected.
However, neither graphical nor text fulfil the conditions for setting
u->display = graphical (because neither is better than u->display), so
the code falls through to check the text variable. The conditions for
this match, as u->display->type != SESSION_TTY (it’s actually
SESSION_X11). Hence u->display is set to c2, which is incorrect, because
session c1 is still valid.

Refactor user_elect_display() to use a more explicit filter and
pre-order comparison over the sessions. This can be demonstrated to be
stable and only ever ‘upgrade’ the session to a more graphical one.

https://bugs.freedesktop.org/show_bug.cgi?id=90769

7 years agosd-bus: dump sync messages in debug mode
Umut Tezduyar Lindskog [Fri, 29 May 2015 07:48:11 +0000 (09:48 +0200)]
sd-bus: dump sync messages in debug mode

7 years agosd-device: enumerator - fix matching on properties and sysattrs
Tom Gundersen [Thu, 28 May 2015 15:18:33 +0000 (17:18 +0200)]
sd-device: enumerator - fix matching on properties and sysattrs

This was a regression that broke

  $ udevadm trigger -nv --property-match=DEVNAME=/dev/sda1 --attr-match=size=409600

Reported by David Reisner.

7 years agosd-device: fix device_get_properties_strv()
Tom Gundersen [Wed, 27 May 2015 21:26:39 +0000 (23:26 +0200)]
sd-device: fix device_get_properties_strv()

A NULL pointer was inserted as the first element of the strv.

This had the effect of always passing the empty environment to processes
spawned by udev.

Reported by Michał Bartoszkiewicz.

7 years agosystemctl: drop hardcoded chkconfig invocation
Martin Pitt [Wed, 27 May 2015 15:04:49 +0000 (17:04 +0200)]
systemctl: drop hardcoded chkconfig invocation

Introduce /usr/lib/systemd/systemd-sysv-install [--root=] <action> <name>
abstraction, replacing the direct calling of chkconfig. This allows
distributions to call their specific tools like update-rc.d without patching
systemd.

Ship systemd-sysv-install.SKELETON as an example for packagers how to implement
this.

Drop the --enable-chkconfig configure option.

Document this in README and point to it in NEWS.

7 years agologind: prefix some calls to unlink with (void)
Daniel Mack [Wed, 27 May 2015 13:20:58 +0000 (15:20 +0200)]
logind: prefix some calls to unlink with (void)

Make Coverity happy and tell it we're not interested in the return
value of these two calls.

7 years agoman: generate configured paths in manpages
Filipe Brandenburger [Wed, 27 May 2015 09:38:19 +0000 (02:38 -0700)]
man: generate configured paths in manpages

In particular, use /lib/systemd instead of /usr/lib/systemd in distributions
like Debian which still have not adopted a /usr merge setup.

Use XML entities from man/custom-entities.ent to replace configured paths while
doing XSLT processing of the original XML files. There was precedent of some
files (such as systemd.generator.xml) which were already using this approach.

This addresses most of the (manual) fixes from this patch:
http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/patches/Fix-paths-in-man-pages.patch?h=experimental-220

The idea of using generic XML entities was presented here:
http://lists.freedesktop.org/archives/systemd-devel/2015-May/032240.html

This patch solves almost all the issues, with the exception of:
- Path to /bin/mount and /bin/umount.
- Generic statements about preference of /lib over /etc.

These will be handled separately by follow up patches.

Tested:
- With default configure settings, ran "make install" to two separate
  directories and compared the output to confirm they matched exactly.
- Used a set of configure flags including $CONFFLAGS from Debian:
  http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/rules
  Installed the tree and confirmed the paths use /lib/systemd instead of
  /usr/lib/systemd and that no other unexpected differences exist.
- Confirmed that `make distcheck` still passes.

7 years agopath-util: Fix path_is_mount_point for files
Martin Pitt [Wed, 27 May 2015 07:56:03 +0000 (09:56 +0200)]
path-util: Fix path_is_mount_point for files

Commits 27cc6f166 and f25afeb broke path_is_mount_point() for files (such as
/etc/machine-id → /run/machine-id bind mounts) as with the factorization of
fd_is_mount_point() we lost the parent directory. We cannot determine that from
an fd only as openat(fd, "..") only works for directory fds.

Change fd_is_mount_point() to behave like openat(): It now takes a file
descriptor of the containing directory, a file name in it, and flags (which can
be 0 or AT_SYMLINK_FOLLOW). Unlike name_to_handle_at() or openat(), fstatat()
only accepts the inverse flag AT_SYMLINK_NOFOLLOW and complains with EINVAL
about AT_SYMLINK_FOLLOW; so we need to transform the flags for that fallback.

Adjust rm_rf_children() accordingly (only other caller of fd_is_mount_point()
aside from path_is_mount_point()).

Add test cases for files, links, and file bind mounts (the latter will only
work when running as root). Split out a new test_path_is_mount_point() test
case function as it got significantly larger now.

7 years agotreewide: fix typos
Torstein Husebø [Tue, 26 May 2015 17:17:30 +0000 (19:17 +0200)]
treewide: fix typos

7 years agologind: unlink /run/nologin when shutdown is cancelled
Daniel Mack [Tue, 26 May 2015 16:56:40 +0000 (18:56 +0200)]
logind: unlink /run/nologin when shutdown is cancelled

When a scheduled is cancelled, make sure to remove /run/nologin.
This is a regression from the recent shutdownd removal and logind rework.

7 years agobus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask
Zbigniew Jędrzejewski-Szmek [Mon, 25 May 2015 00:20:06 +0000 (20:20 -0400)]
bus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask

Also reorder the code a bit to be easier to parse.

7 years agoshared: generator - correct path to systemd-fsck
Mike Gilbert [Sun, 24 May 2015 20:33:35 +0000 (16:33 -0400)]
shared: generator - correct path to systemd-fsck

In generated systemd-fsck-root.service. This would break if rootprefix
is not /usr/lib/systemd.

[tomegun: flesh out commit message]

7 years agosd-bus,sd-event: make public APIs
Lennart Poettering [Fri, 22 May 2015 12:32:51 +0000 (14:32 +0200)]
sd-bus,sd-event: make public APIs

With the v221 release these APIs should be public, stable APIs, hence
let's install their headers by default now, and add their symbols to the
.sym file.

7 years agoRename systemd-logind to logind.
Ricardo Wurmus [Sun, 3 May 2015 20:26:52 +0000 (22:26 +0200)]
Rename systemd-logind to logind.

7 years agoRemove unused and invalid udev definitions
Andy Wingo [Mon, 20 Apr 2015 19:10:49 +0000 (21:10 +0200)]
Remove unused and invalid udev definitions

These definitions were not valid when compiling against eudev.

7 years agoGet rid of some more unused defines and dirs
Andy Wingo [Sun, 19 Apr 2015 15:02:47 +0000 (17:02 +0200)]
Get rid of some more unused defines and dirs

7 years agologind will always be built
Andy Wingo [Sun, 19 Apr 2015 13:58:17 +0000 (15:58 +0200)]
logind will always be built

7 years agoCompiling.
Andy Wingo [Wed, 8 Apr 2015 09:08:16 +0000 (11:08 +0200)]
Compiling.

7 years agoRemove SysV compat
Andy Wingo [Wed, 8 Apr 2015 06:45:34 +0000 (08:45 +0200)]
Remove SysV compat

7 years agoremove non-login things from man
Andy Wingo [Wed, 8 Apr 2015 06:11:45 +0000 (08:11 +0200)]
remove non-login things from man

7 years agojson: minor style fixes
Lennart Poettering [Thu, 21 May 2015 21:30:37 +0000 (23:30 +0200)]
json: minor style fixes

7 years agotmpfiles: create /etc/resolv.conf symlink only on boot
Zbigniew Jędrzejewski-Szmek [Thu, 21 May 2015 18:22:30 +0000 (14:22 -0400)]
tmpfiles: create /etc/resolv.conf symlink only on boot

We will create the symlink on boot as a fallback to provide name
resolution. But if the symlink was removed afterwards, it most likely
should not be recreated. Creating it only on boot also solves the
issue where it would be created prematurely during installation,
before the system was actually booted.

https://bugzilla.redhat.com/show_bug.cgi?id=1197204

7 years agoutil: an array with one entry is always ordered
Lennart Poettering [Thu, 21 May 2015 17:49:03 +0000 (19:49 +0200)]
util: an array with one entry is always ordered

7 years agoutil: introduce PERSONALITY_INVALID as macro for 0xffffffffLU
Lennart Poettering [Thu, 21 May 2015 17:48:49 +0000 (19:48 +0200)]
util: introduce PERSONALITY_INVALID as macro for 0xffffffffLU

7 years agonspawn: finish user namespace support
Lennart Poettering [Thu, 21 May 2015 14:30:58 +0000 (16:30 +0200)]
nspawn: finish user namespace support

7 years agosd-device: fix return codes on error
Zbigniew Jędrzejewski-Szmek [Thu, 21 May 2015 03:34:12 +0000 (23:34 -0400)]
sd-device: fix return codes on error

asprintf() does not set errno.

7 years agojson: avoid cleanup of unitialized variable
Zbigniew Jędrzejewski-Szmek [Thu, 21 May 2015 03:25:48 +0000 (23:25 -0400)]
json: avoid cleanup of unitialized variable

7 years agounits: conditionalize audit multicast socket on CAP_AUDIT_READ
Lennart Poettering [Wed, 20 May 2015 15:40:05 +0000 (17:40 +0200)]
units: conditionalize audit multicast socket on CAP_AUDIT_READ

The multicast logic can only work if the capability is available, hence
require it.

7 years agoutil: introduce reset_uid_gid() for resetting all uids and gids to 0
Lennart Poettering [Wed, 20 May 2015 12:41:39 +0000 (14:41 +0200)]
util: introduce reset_uid_gid() for resetting all uids and gids to 0

7 years agojson: fix a mem leak
Thomas Hindoe Paaboel Andersen [Tue, 19 May 2015 21:19:29 +0000 (23:19 +0200)]
json: fix a mem leak

7 years agocore,nspawn: unify code that moves the root dir
Lennart Poettering [Tue, 19 May 2015 18:32:44 +0000 (20:32 +0200)]
core,nspawn: unify code that moves the root dir

7 years agoimport/pull-dkr: V2 image specification and manifest support
Pavel Odvody [Tue, 19 May 2015 14:30:33 +0000 (16:30 +0200)]
import/pull-dkr: V2 image specification and manifest support

The maximum number of layers changed to 127, as in Dkr.

7 years agoshared/json: Added DOM-like JSON parser
Pavel Odvody [Tue, 19 May 2015 14:29:42 +0000 (16:29 +0200)]
shared/json: Added DOM-like JSON parser

This makes working with complexly structured documents easy
and more reliable as the parser is not susceptible to
element re-ordering.

Also fixes a bug when the tokenizer would choke after reading
a number.

7 years agoshared/import-util: Tag renamed to reference
Pavel Odvody [Tue, 19 May 2015 14:29:29 +0000 (16:29 +0200)]
shared/import-util: Tag renamed to reference

Added (sha256) digest validation function

7 years agoutil: fix typo
Jan Synacek [Tue, 19 May 2015 12:26:09 +0000 (14:26 +0200)]
util: fix typo

7 years agohostname: Allow comments in /etc/hostname
Martin Pitt [Tue, 19 May 2015 05:49:56 +0000 (07:49 +0200)]
hostname: Allow comments in /etc/hostname

The hostname(1) tool allows comments in /etc/hostname. Introduce a new
read_hostname_config() in hostname-util which reads a hostname configuration
file like /etc/hostname, strips out comments, whitespace, and cleans the
hostname. Use it in hostname-setup.c and hostnamed and remove duplicated code.

Update hostname manpage. Add tests.

https://launchpad.net/bugs/1053048

7 years agocore: introduce seperate reverse dependencies for Requires= and Requisite=
Lennart Poettering [Mon, 18 May 2015 23:24:28 +0000 (01:24 +0200)]
core: introduce seperate reverse dependencies for Requires= and Requisite=

This allows us to ensure that Requisite= dependencies never cause
propagation between units, while Requires= dependencies might.

http://lists.freedesktop.org/archives/systemd-devel/2015-May/031742.html

7 years agojournalctl: clean up how we log errors
Lennart Poettering [Mon, 18 May 2015 22:25:45 +0000 (00:25 +0200)]
journalctl: clean up how we log errors

All functions should either log the errors they run into, or only return
them in which case the caller should log them.

Make sure this rule is followed, so that each error is logged precisely
once, and neither never, nor more than once.

7 years agoresolved: fix crash when shutting down
Lennart Poettering [Mon, 18 May 2015 21:23:17 +0000 (23:23 +0200)]
resolved: fix crash when shutting down

Reported by Cristian Rodríguez

http://lists.freedesktop.org/archives/systemd-devel/2015-May/031626.html

7 years agoutil: split all hostname related calls into hostname-util.c
Lennart Poettering [Mon, 18 May 2015 15:10:07 +0000 (17:10 +0200)]
util: split all hostname related calls into hostname-util.c

7 years agofstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for
Karel Zak [Mon, 18 May 2015 10:30:37 +0000 (12:30 +0200)]
fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for

Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

The patch introduces new systemd fstab options:

x-systemd.requires=<PATH>

 - to specify dependence an another mount (PATH is translated to unit name)

x-systemd.requires=<UNIT>

 - to specify dependence on arbitrary UNIT

x-systemd.requires-mounts-for=<PATH ...>

 - to specify dependence on another paths, implemented by
   RequiresMountsFor=. The option may be specified more than once.

For example two bind mounts where B depends on A:

 /mnt/test/A    /mnt/test/A     none    bind,defaults
 /mnt/test/A    /mnt/test/B     none    bind,x-systemd.requires=/mnt/test/A

More complex example with overlay FS where one mount point depends on
"low" and "upper" directories:

 /dev/sdc1   /mnt/low    ext4     defaults
 /dev/sdc2   /mnt/high   ext4     defaults
 overlay     /mnt/merged overlay  lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low,x-systemd.requires-mounts-for=mnt/high

https://bugzilla.redhat.com/show_bug.cgi?id=812826
https://bugzilla.redhat.com/show_bug.cgi?id=1164334

7 years agobus-socket: simplify initalization of struct msghdr
Zbigniew Jędrzejewski-Szmek [Sat, 16 May 2015 15:06:43 +0000 (11:06 -0400)]
bus-socket: simplify initalization of struct msghdr

7 years agoutil: loop_write - accept 0-length message
Tom Gundersen [Fri, 15 May 2015 23:07:45 +0000 (01:07 +0200)]
util: loop_write - accept 0-length message

write() can send empty messages, so make sure loop_write() can do the same.

7 years agounits: make networkd pull in its own .busname unit
Tom Gundersen [Fri, 15 May 2015 20:59:24 +0000 (22:59 +0200)]
units: make networkd pull in its own .busname unit

The daemon requires the busname unit to operate (on kdbus systems),
since it contains the policy that allows it to acquire its service
name.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=90287

7 years agosocket-util: socket_address_parse() should not log errors on its own
Lennart Poettering [Fri, 15 May 2015 18:15:59 +0000 (20:15 +0200)]
socket-util: socket_address_parse() should not log errors on its own

Given that socket_address_parse() is mostly a "library" call it
shouldn't log on its own, but leave that to its caller.

This patch removes logging from the call in case IPv6 is not available
but and IPv6 address shall be parsed. Instead a new call
socket_address_parse_and_warn() is introduced which first invokes
socket_address_parse() and then logs if necessary.

This should fix "make check" on ipv6-less kernels:

http://lists.freedesktop.org/archives/systemd-devel/2015-April/031385.html

7 years agogenerator: use fflush_and_check() where appropriate
Lennart Poettering [Fri, 15 May 2015 15:06:59 +0000 (17:06 +0200)]
generator: use fflush_and_check() where appropriate

7 years agocore: don't consider umask for SocketMode=
Davide Bettio [Fri, 15 May 2015 14:36:28 +0000 (16:36 +0200)]
core: don't consider umask for SocketMode=

https://bugs.freedesktop.org/show_bug.cgi?id=89248

7 years agosystemctl: introduce --now for enable, disable and mask
Jan Synacek [Fri, 15 May 2015 07:54:10 +0000 (09:54 +0200)]
systemctl: introduce --now for enable, disable and mask

https://bugs.freedesktop.org/show_bug.cgi?id=42940

7 years agonspawn: allow access to device nodes listed in --bind= and --bind-ro= switches
Stefan Junker [Thu, 14 May 2015 20:51:05 +0000 (22:51 +0200)]
nspawn: allow access to device nodes listed in --bind= and --bind-ro= switches

https://bugs.freedesktop.org/show_bug.cgi?id=90385

7 years agotest-bus-chat: various modernizations
Lennart Poettering [Thu, 14 May 2015 20:41:19 +0000 (22:41 +0200)]
test-bus-chat: various modernizations

7 years agoutil: introduce memmem_safe() and make use of it
Lennart Poettering [Thu, 14 May 2015 09:30:59 +0000 (11:30 +0200)]
util: introduce memmem_safe() and make use of it

GNU memmem() requires a nonnull first parameter. Let's introduce
memmem_safe() that removes this restriction for zero-length parameters,
and make use of it where appropriate.

http://lists.freedesktop.org/archives/systemd-devel/2015-May/031705.html

7 years agoutil: use GNU comparison function prototype for qsort_safe()
Lennart Poettering [Thu, 14 May 2015 09:30:14 +0000 (11:30 +0200)]
util: use GNU comparison function prototype for qsort_safe()

7 years agoutil: add generic calls for prefixing a root directory to a path
Lennart Poettering [Wed, 13 May 2015 15:42:10 +0000 (17:42 +0200)]
util: add generic calls for prefixing a root directory to a path

So far a number of utilities implemented their own calls for this, unify
them in prefix_root() and prefix_roota(). The former uses heap memory,
the latter allocates from the stack via alloca().

Port over most users of a --root= logic.

7 years agonspawn: skip symlink to a combined cgroup hierarchy if it already exists
Iago López Galeiras [Wed, 13 May 2015 13:45:49 +0000 (15:45 +0200)]
nspawn: skip symlink to a combined cgroup hierarchy if it already exists

If a symlink to a combined cgroup hierarchy already exists and points to
the right path, skip it. This avoids an error when the cgroups are set
manually before calling nspawn.

7 years agoinstall: when exporting prefix InstallInfo to become UnitFileInstallInfo
Lennart Poettering [Mon, 11 May 2015 20:53:54 +0000 (22:53 +0200)]
install: when exporting prefix InstallInfo to become UnitFileInstallInfo

All other types exported from install.h should be namespaces like this,
hence namespace InstallInfo the same way.

Also, remove external forward definition of UnitFileScope type.

7 years agocore: rename SystemdRunningAs to ManagerRunningAs
Lennart Poettering [Mon, 11 May 2015 20:51:49 +0000 (22:51 +0200)]
core: rename SystemdRunningAs to ManagerRunningAs

It's primarily just a property of the Manager object after all, and we
try to refer to PID 1 as "manager" instead of "systemd", hence let's to
stick to this here too.

7 years agoudevd: make udev_ctrl_connection global
Tom Gundersen [Mon, 11 May 2015 20:17:49 +0000 (22:17 +0200)]
udevd: make udev_ctrl_connection global

This allows us to simplify the ctrl_msg handler. Eventually all this global state should move to
a Manager object or so.

7 years agocore,network: major per-object logging rework
Lennart Poettering [Mon, 11 May 2015 18:38:21 +0000 (20:38 +0200)]
core,network: major per-object logging rework

This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.

Also contains a couple of other logging improvements:

- Drops a couple of strerror() invocations in favour of using %m.

- Not only .mount units now warn if a symlinks exist for the mount
  point already, .automount units do that too, now.

- A few invocations of log_struct() that didn't actually pass any
  additional structured data have been replaced by simpler invocations
  of log_unit_info() and friends.

- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
  that works like LOG_MESSAGE() but prefixes the message with the unit
  name. Similar, there's now LOG_LINK_MESSAGE() and
  LOG_NETDEV_MESSAGE().

- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
  LOG_NETDEV_INTERFACE() macros have been added that generate the
  necessary per object fields. The old log_unit_struct() call has been
  removed in favour of these new macros used in raw log_struct()
  invocations. In addition to removing one more function call this
  allows generated structured log messages that contain two object
  fields, as necessary for example for network interfaces that are
  joined into another network interface, and whose messages shall be
  indexed by both.

- The LOG_ERRNO() macro has been removed, in favour of
  log_struct_errno(). The latter has the benefit of ensuring that %m in
  format strings is properly resolved to the specified error number.

- A number of logging messages have been converted to use
  log_unit_info() instead of log_info()

- The client code in sysv-generator no longer #includes core code from
  src/core/.

- log_unit_full_errno() has been removed, log_unit_full() instead takes
  an errno now, too.

- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
  avoid double evaluation of their parameters

7 years agoutil: optimize free_and_strdup() if NOP
Lennart Poettering [Mon, 11 May 2015 18:09:58 +0000 (20:09 +0200)]
util: optimize free_and_strdup() if NOP

Under the assumption that strcmp() is cheaper than memory allocation,
let's avoid the allocation, if the new value is identical to the old.

7 years agoshared: Use O_EXCL with O_TMPFILE in open_tmpfile
Cristian Rodríguez [Mon, 11 May 2015 18:01:37 +0000 (15:01 -0300)]
shared: Use O_EXCL with O_TMPFILE in open_tmpfile

In this usecase, the file will never be materialized
with linkat().

7 years agotreewide: Correct typos and spell plural of bus consistent
Torstein Husebø [Mon, 11 May 2015 11:49:29 +0000 (13:49 +0200)]
treewide: Correct typos and spell plural of bus consistent

7 years agosd-bus: fix memory leak in test-bus-chat
Cristian Rodríguez [Sun, 10 May 2015 01:14:09 +0000 (22:14 -0300)]
sd-bus: fix memory leak in test-bus-chat

Building with address sanitizer enabled on GCC 5.1.x a memory leak
is reported because we never close the bus, fix it by using
cleanup variable attribute.

7 years agobus: don't switch to kdbus if not requested
David Herrmann [Wed, 6 May 2015 16:18:43 +0000 (18:18 +0200)]
bus: don't switch to kdbus if not requested

Whenever systemd is re-executed, it tries to create a system bus via
kdbus. If the system did not have kdbus loaded during bootup, but the
module is loaded later on manually, this will cause two system buses
running (kdbus and dbus-daemon in parallel).

This patch makes sure we never try to create kdbus buses if it wasn't
explicitly requested on the command-line.

7 years agoGenerate systemd-fsck-root.service in the initramfs
Zbigniew Jędrzejewski-Szmek [Wed, 6 May 2015 05:09:53 +0000 (01:09 -0400)]
Generate systemd-fsck-root.service in the initramfs

In the initrafms, generate a systemd-fsck-root.service to replace
systemd-fsck@<sysroot-device>.service. This way, after we transition
to the real root, systemd-fsck-root.service is marked as already done.

This introduces an unnecessary synchronization point, because
systemd-fsck@* is ordered after systemd-fsck-root also in the
initramfs. In practice this shouldn't be a problem.

https://bugzilla.redhat.com/show_bug.cgi?id=1201979

C.f. 956eaf2b8d6c9999024705ddadc7393bc707de02.

7 years agocore: be more strict when manipulating slices names and unescaping paths from unit...
Lennart Poettering [Tue, 5 May 2015 20:39:14 +0000 (13:39 -0700)]
core: be more strict when manipulating slices names and unescaping paths from unit names

Let's better be safe then sorry.

7 years agoFix permissions on /run/systemd/nspawn/locks
Seth Jennings [Tue, 5 May 2015 18:31:01 +0000 (13:31 -0500)]
Fix permissions on /run/systemd/nspawn/locks

machined is getting an EACCES when trying to create the lock file for
images because the mode on /run/systemd/nspawn/locks is 0600.

mkdir("/run/systemd/nspawn/locks", 0600) = -1 EEXIST (File exists)
stat("/run/systemd/nspawn/locks", {st_mode=S_IFDIR|0600, st_size=40, ...}) = 0
open("/run/systemd/nspawn/locks/inode-41:256", O_RDWR|O_CREAT|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC, 0600) = -1 EACCES (Permission denied)

This commit adjusts the mode to 0700 to correct the issue.

7 years agolockfile-util.[ch]: Split out from util.[ch]
Colin Walters [Mon, 4 May 2015 20:12:46 +0000 (16:12 -0400)]
lockfile-util.[ch]: Split out from util.[ch]

Continuing the general trend of splitting up util.[ch].  I specifically
want to reuse this code in https://github.com/GNOME/libglnx and
having it split up will make future copy-pasting easier.

7 years agogenerators: rename add_{root,usr}_mount to add_{sysroot,sysroot_usr}_mount
Zbigniew Jędrzejewski-Szmek [Sat, 2 May 2015 17:01:29 +0000 (12:01 -0500)]
generators: rename add_{root,usr}_mount to add_{sysroot,sysroot_usr}_mount

This makes it obvious that those functions are only usable in the
initramfs.

Also, add a warning when noauto, nofail, or automount is used for the
root fs, instead of silently ignoring. Using those options would be a
sign of significant misconfiguration, and if we bother to check for
them, than let's go all the way and complain.

Other various small cleanups and reformattings elsewhere.

7 years agocore: rework unit name validation and manipulation logic
Lennart Poettering [Thu, 30 Apr 2015 18:21:00 +0000 (20:21 +0200)]
core: rework unit name validation and manipulation logic

A variety of changes:

- Make sure all our calls distuingish OOM from other errors if OOM is
  not the only error possible.

- Be much stricter when parsing escaped paths, do not accept trailing or
  leading escaped slashes.

- Change unit validation to take a bit mask for allowing plain names,
  instance names or template names or an combination thereof.

- Refuse manipulating invalid unit name

7 years agoutil: be a bit safer in path_is_safe()
Lennart Poettering [Thu, 30 Apr 2015 17:44:10 +0000 (19:44 +0200)]
util: be a bit safer in path_is_safe()

We should be more strict when verifying paths with path_is_safe() for
potentially dangerous constructs, and that includes lengths of
PATH_MAX-1 and larger. Be more accurate here.

7 years agocore: catch some special cases in cg_slice_to_path()
Lennart Poettering [Thu, 30 Apr 2015 10:33:35 +0000 (12:33 +0200)]
core: catch some special cases in cg_slice_to_path()

7 years agosym: adding missing symbols to .sym file
Lennart Poettering [Thu, 30 Apr 2015 10:01:19 +0000 (12:01 +0200)]
sym: adding missing symbols to .sym file

7 years agosd-bus,sd-login: add api for querying the slice within the the user systemd instance...
Lennart Poettering [Thu, 30 Apr 2015 09:58:06 +0000 (11:58 +0200)]
sd-bus,sd-login: add api for querying the slice within the the user systemd instance of a process

units are organized in slice trees, not only for the system instance,
but also for user systemd instances, expose this properly.

7 years agosd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version
Lennart Poettering [Wed, 29 Apr 2015 23:24:48 +0000 (01:24 +0200)]
sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version

As perparation for future incompatible kdbus kernel API changes.

7 years agocore: rework cgroup path parse logic
Lennart Poettering [Wed, 29 Apr 2015 22:47:41 +0000 (00:47 +0200)]
core: rework cgroup path parse logic

Various cleanups, be stricter when parsing unit paths.

Most importantly: return the root slice "-.slice" when asked for slice
of paths that contain no slice component.

7 years agoman: document when the various sd-login.h calls return ENXIO
Lennart Poettering [Wed, 29 Apr 2015 19:45:45 +0000 (21:45 +0200)]
man: document when the various sd-login.h calls return ENXIO

7 years agosd-bus: properly handle creds that are known but undefined for a process
Lennart Poettering [Wed, 29 Apr 2015 19:40:54 +0000 (21:40 +0200)]
sd-bus: properly handle creds that are known but undefined for a process

A number of fields do not apply to all processes, including: there a
processes without a controlling tty, without parent process, without
service, user services or session. To distuingish these cases from the
case where we simply don't have the data, always return ENXIO for them,
while returning ENODATA for the case where we really lack the
information.

Also update the credentials dumping code to show this properly. Fields
that are known but do not apply are now shown as "n/a".

Note that this also changes some of the calls in process-util.c and
cgroup-util.c to return ENXIO for these cases.

7 years agosd-bus: allow passing NULL as bus parameter to sd_bus_send()
Lennart Poettering [Wed, 29 Apr 2015 16:58:30 +0000 (18:58 +0200)]
sd-bus: allow passing NULL as bus parameter to sd_bus_send()

If NULL is specified for the bus it is now automatically derived from
the passed in message.

This commit also changes a number of invocations of sd_bus_send() to
make use of this.

7 years agosd-bus: drop bus parameter from message callback prototype
Lennart Poettering [Wed, 29 Apr 2015 16:35:10 +0000 (18:35 +0200)]
sd-bus: drop bus parameter from message callback prototype

This should simplify the prototype a bit. The bus parameter is redundant
in most cases, and in the few where it matters it can be derived from
the message via sd_bus_message_get_bus().

7 years agobus-util: drop redundant bus argument from bus_message_map_all_properties() and relat...
Lennart Poettering [Tue, 28 Apr 2015 18:48:54 +0000 (20:48 +0200)]
bus-util: drop redundant bus argument from bus_message_map_all_properties() and related calls

7 years agoexit-status: introduce common exit_status_set_test() call for testing exit status...
Lennart Poettering [Tue, 28 Apr 2015 16:24:20 +0000 (18:24 +0200)]
exit-status: introduce common exit_status_set_test() call for testing exit status set membership

7 years agobus-util: print correct warnings for units that fail but for which we have a NULL...
Lennart Poettering [Tue, 28 Apr 2015 10:12:29 +0000 (12:12 +0200)]
bus-util: print correct warnings for units that fail but for which we have a NULL result only

7 years agopath-util: fix fstat fallback in fd_is_mount_point
Thomas Hindoe Paaboel Andersen [Sun, 26 Apr 2015 13:57:29 +0000 (15:57 +0200)]
path-util: fix fstat fallback in fd_is_mount_point

7 years agosd-device: don't retry loading uevent/db files more than once
Tom Gundersen [Sat, 25 Apr 2015 23:07:42 +0000 (01:07 +0200)]
sd-device: don't retry loading uevent/db files more than once

If for whatever reason there was nothing to load or loading failed, don't keep trying.

7 years agosd-device: don't complain if the uevent file is missing
Tom Gundersen [Sat, 25 Apr 2015 23:04:33 +0000 (01:04 +0200)]
sd-device: don't complain if the uevent file is missing

Only 'real' devices are required to have an uevent file.

7 years agologind: kill newline characters from log_error_errno() calls
Daniel Mack [Fri, 24 Apr 2015 19:44:51 +0000 (21:44 +0200)]
logind: kill newline characters from log_error_errno() calls

log_error_errno() already adds a newline, so drop them.

7 years agosysctl: minor simplifications
Lennart Poettering [Fri, 24 Apr 2015 17:56:24 +0000 (19:56 +0200)]
sysctl: minor simplifications

7 years agoUpdate Spanish translation
Daniel Mustieles [Fri, 24 Apr 2015 13:13:34 +0000 (09:13 -0400)]
Update Spanish translation

https://bugs.freedesktop.org/show_bug.cgi?id=90163

7 years agosd-bus: add controlling tty field to sd_creds object
Lennart Poettering [Thu, 23 Apr 2015 17:43:40 +0000 (19:43 +0200)]
sd-bus: add controlling tty field to sd_creds object

This is useful to print wall messages from logind with the right client
tty. (to be added in a later patch)

7 years agoshutdownd: kill the old implementation
Daniel Mack [Thu, 23 Apr 2015 15:30:23 +0000 (17:30 +0200)]
shutdownd: kill the old implementation

Not that all functionality has been ported over to logind, the old
implementation can be removed. There goes one of the oldest parts of
the systemd code base.

7 years agologind: add support for /run/nologin and /run/systemd/shutdown/scheduled
Daniel Mack [Thu, 23 Apr 2015 15:11:28 +0000 (17:11 +0200)]
logind: add support for /run/nologin and /run/systemd/shutdown/scheduled

Port over more code from shutdownd and teach logind to write /run/nologin at
least 5 minutes before the system is going down, and
/run/systemd/shutdown/scheduled when a shutdown is scheduled.

7 years agosd-bus: when bus operations are to be executed on direct connections always fail
Lennart Poettering [Thu, 23 Apr 2015 14:23:15 +0000 (16:23 +0200)]
sd-bus: when bus operations are to be executed on direct connections always fail

Also, don't consider this an loggable event, so that code that tries to
read creds from a direct connection, doesn't generate logs.

7 years agoudevd: fix REMOVE handling
Tom Gundersen [Thu, 23 Apr 2015 13:19:13 +0000 (15:19 +0200)]
udevd: fix REMOVE handling

This reverts b67f944. Lazy loading of device properties does not work for devices
that are received over netlink, as these are sealed. Reinstate the unconditional
loading of the device db.

Reported by: Mantas Mikulėnas <grawity@gmail.com>.

7 years agosd-bus: don't inherit connection creds into message creds when we have a direct conne...
Lennart Poettering [Thu, 23 Apr 2015 11:37:03 +0000 (13:37 +0200)]
sd-bus: don't inherit connection creds into message creds when we have a direct connection

It's never a good idea, let's just not do it, not even on dierct
connections.

7 years agopath-util: make use of "mnt_id" field exported in /proc/self/fdinfo/<fd> to test...
Lennart Poettering [Thu, 23 Apr 2015 11:23:03 +0000 (13:23 +0200)]
path-util: make use of "mnt_id" field exported in /proc/self/fdinfo/<fd> to test for mount points

It's a very recent kernel addition, but certainly makes sense to
support.

7 years agohwdb: fix typo - "sort by by..." -> "sort by..."
Peter Hutterer [Thu, 23 Apr 2015 01:10:04 +0000 (11:10 +1000)]
hwdb: fix typo - "sort by by..." -> "sort by..."

7 years agocore: explicitly specify credentials for direct connections, too
Lennart Poettering [Wed, 22 Apr 2015 22:37:47 +0000 (00:37 +0200)]
core: explicitly specify credentials for direct connections, too

So far we authenticate direct connections primarily at connection time,
but let's also do this for each method individually, by attaching the
creds we need for that right away.

7 years agojournalctl: rework code that checks whether we have access to /var/log/journal
Lennart Poettering [Wed, 22 Apr 2015 20:54:23 +0000 (22:54 +0200)]
journalctl: rework code that checks whether we have access to /var/log/journal

- fix some memory leaks on error conditions

- handle all error cases properly, and log about failures

- move HAVE_ACL and no-HAVE_ACL code closer to each other

7 years agolibudev-device: fix lazy loading of devlinks, properties and tags
Tom Gundersen [Wed, 22 Apr 2015 17:01:50 +0000 (19:01 +0200)]
libudev-device: fix lazy loading of devlinks, properties and tags

If the underlying device has not read in the properties yet, the generation will be 0, so
make sure we trigger the reading at least once.