Commit Graph
4747 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 105f345e6f Revert "systemctl: skip native unit file handling if sysv file handling already handled everything"
This patch only makes sense on top of patches which fix unit name
mangling when --root is used, but those patches have not been
cherry-picked for this branch.

This reverts commit 3a02c6b4dc.

https://bugzilla.redhat.com/show_bug.cgi?id=1128308
2014-08-14 21:38:09 -04:00
Lennart Poettering 6279f0e3c4 socket: add SocketUser= and SocketGroup= for chown()ing sockets in the file system
This is relatively complex, as we cannot invoke NSS from PID 1, and thus
need to fork a helper process temporarily.

(cherry picked from commit 3900e5fdff)

Conflicts:
	src/core/dbus-socket.c
	src/core/socket.c
	src/shared/exit-status.c
	src/shared/exit-status.h

(cherry picked from commit 45d1e4a990)

Conflicts:
        all over the place :(
2014-07-22 23:03:34 -04:00
Lennart Poettering c3545a1da8 socket: add SocketUser= and SocketGroup= for chown()ing sockets in the file system
This is relatively complex, as we cannot invoke NSS from PID 1, and thus
need to fork a helper process temporarily.

(cherry picked from commit 3900e5fdff)

Conflicts:
	src/core/dbus-socket.c
	src/core/socket.c
	src/shared/exit-status.c
	src/shared/exit-status.h

(cherry picked from commit 45d1e4a990)
2014-07-22 23:03:34 -04:00
Jon Severinsson 7a0687eb49 journal/compress: improve xz compression performance
The new lzma2 compression options at the top of compress_blob_xz are
equivalent to using preset "0", exept for using a 1 MiB dictionary
(the same as preset "1"). This makes the memory usage at most 7.5 MiB
in the compressor, and 1 MiB in the decompressor, instead of the
previous 92 MiB in the compressor and 8 MiB in the decompressor.

According to test-compress-benchmark this commit makes XZ compression
20 times faster, with no increase in compressed data size.
Using more realistic test data (an ELF binary rather than repeating
ASCII letters 'a' through 'z' in order) it only provides a factor 10
speedup, and at a cost if a 10% increase in compressed data size.
But that is still a worthwhile trade-off.

According to test-compress-benchmark XZ compression is still 25 times
slower than LZ4, but the compressed data is one eighth the size.
Using more realistic test data XZ compression is only 18 times slower
than LZ4, and the compressed data is only one quarter the size.

$ ./test-compress-benchmark
XZ: compressed & decompressed 2535300963 bytes in 42.30s (57.15MiB/s), mean compresion 99.95%, skipped 3570 bytes
LZ4: compressed & decompressed 2535303543 bytes in 1.60s (1510.60MiB/s), mean compresion 99.60%, skipped 990 bytes

(cherry picked from commit 1930eed2a7)

Conflicts:
	src/journal/compress.c

(cherry picked from commit 00464ad8a6)
(cherry picked from commit b4f5701719)
2014-07-22 23:03:34 -04:00
Zbigniew Jędrzejewski-Szmek 476a6ff396 journal/compress: add stream compression/decompression functions
(cherry picked from commit 355b59e252)

Conflicts:
	src/journal/test-compress.c
	src/shared/copy.c

Actually keep only compress_blob changes.

(cherry picked from commit 63f877db16)
2014-07-22 23:03:34 -04:00
Zbigniew Jędrzejewski-Szmek 43a123dad8 journal/compress: simplify compress_blob
(cherry picked from commit 76cc0bf682)
(cherry picked from commit b566dc04c9)
2014-07-22 23:03:34 -04:00
Lennart Poettering a431d9803c util: add timeout to generator execution
(cherry picked from commit aa62a8936f)
(cherry picked from commit d66226bce6
                and commit 5e2f14e62b)

Conflicts:
	src/core/manager.c

(cherry picked from commit 7bd1311e54)
2014-07-22 23:03:34 -04:00
Lennart Poettering 98c38334d7 core: gc half-created stub units
(cherry picked from commit c35fa384d0)
(cherry picked from commit 97a7eeadee)
2014-07-22 23:03:34 -04:00
Lennart Poettering ef41cc6f17 journal: downgrade vaccuum message to debug level
https://bugzilla.redhat.com/show_bug.cgi?id=1047148
(cherry picked from commit 3bb621e1e6)
(cherry picked from commit d5fdaa66bf)
2014-07-22 23:03:34 -04:00
Lennart Poettering 848678e4d5 journal: don't clobber return parameters of sd_journal_get_cutoff_realtime_usec() on failure
(cherry picked from commit 581483bf59)
(cherry picked from commit e19b6a48bf)
2014-07-22 23:03:33 -04:00
Jan Engelhardt e84fca4ab6 core: more exact test on the procfs special string "(deleted)"
In other parts of systemd, the code checks for " (deleted)",
but in one instance, it did not (yet). Make it do the same.

(cherry picked from commit a87f0f726c)
(cherry picked from commit 878ca1ee66)
2014-07-22 23:03:33 -04:00
Matt Mullins 6b63b4383a core: do not segfault if /proc/swaps cannot be opened
The refactoring in f84b1b1ff9 ('core: do not segfault if swap
activity happens when /proc/swaps is not open') caused
swap_dispatch_reload and swap_enumerate to continue even if fopen()
failed with ENOENT.

This should instead be modified to return from swap_dispatch_reload and
swap_enumerate, rather than continuing to load the list of swaps when
m->proc_swaps is NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=1069393
(cherry picked from commit 817a2d0c98)
2014-07-22 23:03:33 -04:00
Lennart Poettering 3a02c6b4dc systemctl: skip native unit file handling if sysv file handling already handled everything
Issue pointed out by Colin Guthrie.

(cherry picked from commit 67d6621059)
(cherry picked from commit 345151292f)
2014-07-22 23:03:33 -04:00
Lukas Nykryn 5a27f883fb coredumpctl: in case of error free pattern after print
(cherry picked from commit cf50a55277)
(cherry picked from commit e3d3ab4650)
2014-07-22 23:03:33 -04:00
Zbigniew Jędrzejewski-Szmek a739675c3c journal: fix access to munmapped memory in sd_journal_enumerate_unique
sd_j_e_u needs to keep a reference to an object while comparing it
with possibly duplicate objects in other files. Because the size of
mmap cache is limited, with enough files and object to compare to,
at some point the object being compared would be munmapped, resulting
in a segmentation fault.

Fix this issue by turning keep_always into a reference count that can
be increased and decreased. Other callers which set keep_always=true
are unmodified: their references are never released but are ignored
when the whole file is closed, which happens at some point. keep_always
is increased in sd_j_e_u and later on released.

(cherry picked from commit ae97089d49)
(cherry picked from commit 9e6366a959)

Conflicts:
	src/journal/journal-verify.c
2014-07-22 23:03:33 -04:00
Michele Curti 9930cd2e58 sleep.c: fix typo
(cherry picked from commit 096924092b)
(cherry picked from commit fdaa623f62)
2014-07-22 23:03:33 -04:00
Lennart Poettering eb87fe6a64 util: check for overflow in greedy_realloc()
(cherry picked from commit 98088803bb)

Conflicts:
	src/shared/util.c

(cherry picked from commit f0c730c540)
2014-07-22 23:03:31 -04:00
Shawn Landden 7d5f436c7d core/manager: remove infinite loop
(cherry picked from commit 145b1f799f)
(cherry picked from commit f980d7eccb)
2014-07-22 23:03:31 -04:00
Dan McGee 3b5a302b9f Ensure unit is journaled for short-lived or oneshot processes
In the time it takes to process incoming log messages, the process we
are logging details for may exit. This means the cgroup data is no
longer available from '/proc'. Unfortunately, the way the code was
structured before, we never log _SYSTEMD_UNIT if we don't have this
cgroup information.

Add an else if case that allows the passed in unit_id to be logged even
if we couldn't capture cgroup information. This ensures a command like
`journalctl -u run-XXX` will return all log messages from a oneshot
process.

(cherry picked from commit 2d43b19090)
(cherry picked from commit 66d0783137)
2014-07-22 23:03:31 -04:00
Adam Williamson 737959d9a7 correct name of Tajik kbd layout in kbd-model-map
(cherry picked from commit 18c92a4958)
(cherry picked from commit 062bbced23)
2014-07-22 23:03:31 -04:00
Adam Williamson 1d0f0080d7 drop several entries from kbd-model-map whose kbd layouts do not exist
kbd-model-map was generated from system-config-keyboard's keyboard_models.py.
Several of the kbd layouts referred in that file do not exist and, so far as I
can tell, never did. I believe these entries existed simply to provide the xkb
configuration information for those layouts, and there never were matching kbd
entries; the kbd names were entirely notional, to satisfy the need for some
entry or other in that field.

For systemd, the only function of kbd-model-map is to 'match' kbd and xkb
configurations, so it does not make any sense to maintain entries for cases
where only one or the other exists in this context.

(cherry picked from commit 70dc36d17f)
(cherry picked from commit 5abb54b939)
2014-07-22 23:03:31 -04:00
Zbigniew Jędrzejewski-Szmek 3f3b817cb4 hostnamed: avoid using NULL in error path
https://bugzilla.redhat.com/show_bug.cgi?id=1047335
(cherry picked from commit 04bbe7a7e0)
2014-07-22 23:03:31 -04:00
Dan McGee 4d7bbe40f3 Fix memory leak in stdout journal streams
Just as 'identifier' is strdup-ed and freed, we need to do the same for
unit_id.

(cherry picked from commit f92ae4968f)
(cherry picked from commit a345f4c7f5)
2014-07-22 23:03:31 -04:00
Zbigniew Jędrzejewski-Szmek f2caf835d3 journalctl: print proper IDs with --header
The same buffer was used for two different IDs, messing up
the output.

(cherry picked from commit 2765b7bb69)
2014-07-22 23:03:31 -04:00
Zbigniew Jędrzejewski-Szmek 701ba7165d journalctl: no color for --reboot-- when not on tty
(cherry picked from commit 3001c74580)
2014-07-22 23:03:31 -04:00
Zbigniew Jędrzejewski-Szmek e34f90aba7 Properly check for overflow in offsets
(cherry picked from commit b32ff51219)
2014-07-22 23:03:31 -04:00
Zbigniew Jędrzejewski-Szmek d5803b7753 core: do not segfault if swap activity happens when /proc/swaps is not open
In https://bugzilla.redhat.com/show_bug.cgi?id=969795 systemd crashes
in swap_dispatch_reload called from manager_loop becuase m->proc_swaps
is NULL. It can legitimately be NULL if something went wrong when
initially enumerating swap devices when starting the manager. This
is probably a sign of significant trouble, but let's do our best
to recover.
2014-01-12 15:40:29 -05:00
Zbigniew Jędrzejewski-Szmek 5ecc3465ea shared/install: modernization 2013-12-27 01:04:01 -05:00
Zbigniew Jędrzejewski-Szmek f84a0664ee systemd: fix NULL dereference when disabling a nonexistent instance
Assertion 'p' failed at src/shared/path-util.c:51, function path_get_file_name(). Aborting.

The unit file could not be found, and i->path would not be set.
In 02b9e969 a code path was added which attempts to remove symlinks
to a nonexistent (removed) unit file. This worked OK in case of
non-instance services, but broke in the case of instance services.

Behaviour wrt. to instance units is changed in the way that 02b9e969
changed it for non-instance units: it is now possible to remove
instance symlinks to a template unit that has been removed.

This patch isn't a full fix, because the behaviour wrt. to enabling
and disabling instance units is still broken: e.g it is possible to
start autovt@tty5.service, but it is not possible to enable it,
because autovt@.service is a symlink, and on the other hand, disabling
getty@tty5.service removes all symlinks to getty@.service, which is
wrong too. But segfaults make bad pr, so let's add at least this
partial fix for now.
2013-12-27 00:38:38 -05:00
Ross Lagerwall 627b653bec install: make "reenable" work with templated units
Before, "systemctl reenable getty@tty1.service" would fail with:
Failed to issue method call: File exists
To fix this, reimplement "reenable" explicitly as a disable followed by
an enable.
This is shorter and is how the man page documents its behavior.
2013-12-27 00:38:29 -05:00
Zbigniew Jędrzejewski-Szmek 7c7431b8ea shared/install: fix trivial memleak
We lost the reference when setting path second time.
2013-12-27 00:38:19 -05:00
Michael Tremer 28e67ad4ab systemctl: make systemctl is-enabled work for templated units
Patch resolves the problem that 'systemctl is-enabled' does
not work for templated units.

Without this patch, systemctl is-enabled something@abc.service
returned "No such file or directory", because it first checked
if /usr/lib/systemd/system/something@abc.service, etc. exists.
If systemctl is-enabled is called for templated units, this
check should be omitted and it should search for symlinks in
the .wants dirs right away.

This patch fixes the broken behaviour and resolves
  https://bugs.freedesktop.org/show_bug.cgi?id=55318.

[zj: fixed the patch to still check for broken symlinks and
     masked instances. Also removed untrue assumptions from
     the patch description.]
2013-12-27 00:36:08 -05:00
Lennart Poettering 917a0b110a utmp: turn systemd-update-utmp-shutdown.service into a normal runtime service
With this change systemd-update-utmp-shutdown.service is replaced by
systemd-update-utmp.service which is started at boot and stays around
until shutdown. This allows us to properly order the unit against both
/var/log and auditd.

https://bugzilla.redhat.com/show_bug.cgi?id=853104
https://bugs.freedesktop.org/show_bug.cgi?id=64365
2013-12-22 23:13:49 -05:00
Zbigniew Jędrzejewski-Szmek 818e7631dd localed: match converted keymaps before legacy
Before, X11 keymap fr-pc105-oss would be converted to fr,
even though fr-oss exists. Now, if
/usr/lib/kbd/keymaps/xkb/<layout>[-<variant>].map[.gz] exists,
<layout>[-<variant>] will be used as the console keymap,
falling back to the legacy mappings otherwise.

% sudo localectl set-x11-keymap pl pc105
% localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: pl                      (was pl2 before)
      X11 Layout: pl
       X11 Model: pc105
% sudo localectl set-x11-keymap fr pc105 oss
% localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: fr-oss                  (was fr before)
      X11 Layout: fr
       X11 Model: pc105
     X11 Variant: oss
% sudo localectl set-x11-keymap fr pc105
% localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: fr
      X11 Layout: fr
       X11 Model: pc105
% sudo localectl set-x11-keymap gb
% localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: gb                     (was uk before)
      X11 Layout: gb

Conflicts:
	src/locale/localed.c
	src/shared/def.h

Conflicts:
	src/locale/localectl.c
	src/shared/def.h
2013-12-08 21:52:44 -05:00
Lennart Poettering 04a3f098ea service: execute ExecStopPost= commands when the watchdog timeout hits
We can assume that a service for which a watchdog timeout was triggered
is unresponsive to a clean shutdown. However, it still makes sense to
execute the post-stop cleanup commands that can be configured with
ExecStopPost=. Hence, when the timeout is hit enter STOP_SIGKILL rather
than FINAL_SIGKILL.
2013-12-08 21:38:45 -05:00
Lennart Poettering 385f5f5e97 journald: bump the journal per-unit ratelimit defaults
Too many people kept hitting them, so let's increase the limits a bit.

https://bugzilla.redhat.com/show_bug.cgi?id=965803
2013-12-08 21:37:00 -05:00
Zbigniew Jędrzejewski-Szmek 80e4942892 systemctl,core: allow nuking of symlinks to removed units
Before, one the unit file was deleted, install_context_for_removal()
would refuse to look for symlinks. But we can remove dangling symlinks
anyway.

In principle, package installation/deinstallation scripts should do
that before the unit is uninstalled, but they don't always do. Also,
a user might have added additional symlinks manually.

https://bugs.freedesktop.org/show_bug.cgi?id=62395
2013-12-08 21:35:38 -05:00
Harald Hoyer 8494c349d1 journal: handle multiline syslog messages
Since the journal can handle multiple lines just well natively,
and rsyslog can be configured to handle them as well, there is no need
to truncate messages from syslog() after the first newline.

Reproducer:

1. Add following four lines to /etc/rsyslog.conf

   ----------
   $EscapeControlCharactersOnReceive off
   $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat
   $SpaceLFOnReceive on
   $DropTrailingLFOnReception off
   ----------

3. Restart rsyslog
  # service rsyslog restart

4. Compile and run the following program

   ----------
   #include <stdio.h>
   #include <syslog.h>

   int main()
   {
    syslog(LOG_INFO, "aaa%caaa", '\n');
    return 0;
   }
   ----------

Actual results:
Below message appears in /var/log/messages.

   ----------
   Sep  7 19:19:39 localhost test2: aaa
   ----------

Expected results:
Below message, which worked prior to systemd-journald
appears in /var/log/messages.

   ----------
   Sep  7 19:19:39 localhost test2: aaa aaa

https://bugzilla.redhat.com/show_bug.cgi?id=855313
2013-12-08 21:34:09 -05:00
Zbigniew Jędrzejewski-Szmek 9a184bf7fc journal: fail silently in sd_j_sendv() if journal is unavailable
"syslog(3) and sd_journal_print() may largely be used interchangeably
functionality-wise" according to sd_journal_print(3). This socket
should be always available except in rare circumstatances, and we
don't random applications to fail on logging, so let's do what syslog
did. The alternative of forcing all callers to do error handling for
this rare case doesn't really have any benefits, since if they can't
log there isn't much they can do anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1023041
2013-12-08 21:33:26 -05:00
Zbigniew Jędrzejewski-Szmek fd3b386881 systemd: treat reload failure as failure
systemctl reload "suceeded" on stopped units, but it is documented
to fail in this case.

https://bugzilla.redhat.com/show_bug.cgi?id=1036845
2013-12-08 21:33:21 -05:00
Zbigniew Jędrzejewski-Szmek 4194ac9b57 docs: remove unneeded the's in gudev docs
https://bugs.freedesktop.org/show_bug.cgi?id=72164
2013-12-08 21:33:02 -05:00
Thomas Hindoe Paaboel Andersen e068005b8f util.c: check if return value from ttyname_r is > 0 instead of != 0
We must return a negative error code from getttyname_malloc but
that would not be the case if ttyname_r returned a negative value.

ttyname_r should only return EBADF, ENOTTY, or ERANGE so it should
be safe to change.
2013-12-08 21:32:52 -05:00
Kay Sievers 3ed443abd1 automount: log info about triggering process
Conflicts:
	src/core/automount.c
2013-12-08 21:32:32 -05:00
Lennart Poettering b07c5b16a5 valgrind: make running PID 1 in valgrind useful
Since valgrind only generates useful output on exit() (rather than
exec()) we need to explicitly exit when valgrind is detected.

Conflicts:
	src/core/main.c
2013-12-08 21:32:16 -05:00
Lennart Poettering b48d4e5832 manager: don't do plymouth in a container
Given that plymouth listens on an abstract namespace socket and if
CLONE_NEWNET is not used the abstract namespace is shared with the host
we might actually end up send plymouth data to the host.
2013-12-08 21:32:07 -05:00
Olivier Brunel 5c294f2b21 Resolve /dev/console to the active tty instead of just "tty0"
When resolving /dev/console one would often get "tty0" meaning the active VT.
Resolving to the actual tty (e.g. "tty1") will notably help on boot when
determining whether or not PID1 can output to the console.
2013-12-08 21:29:25 -05:00
Umut Tezduyar Lindskog 1e74ecdeda journal: timestamp support on console messages
journald mimics the kernel here: timestamps will be printed if
/sys/module/printk/parameters/time contains "Y".
2013-12-08 21:28:19 -05:00
Mantas Mikulėnas 3a1149687f activate: fix crash when -s is passed
getopt_long() was told to accept -s which was never implemented.
2013-12-08 21:28:05 -05:00
Mantas Mikulėnas b3b1073e2b activate: mention -E in the help text 2013-12-08 21:27:59 -05:00
Lennart Poettering 3f870c6a21 timer: properly format relative timestamps in the future 2013-12-08 21:24:20 -05:00