Commit Graph
4442 Commits
Author SHA1 Message Date
Lennart Poettering 8e3aceb513 main: don't free fds array twice 2013-10-29 11:14:40 -04:00
Andrey Borzenkov 8d0879b970 set IgnoreOnIsolate=true for systemd-cryptsetup@.service
When crypttab contains noauto, cryptsetup service does not have any
explicit dependencies. If service is started later manually (directly or via
mount dependency) it will be stopped on isolate.

mount units already have IgnoreOnIsolate set by default. Set it by
default for cryptsetup units as well.
2013-10-29 11:14:40 -04:00
Zbigniew Jędrzejewski-Szmek bbe5efee5e Fix buffer overrun when enumerating files
https://bugs.freedesktop.org/show_bug.cgi?id=69887

Based-on-a-patch-by: Hans Petter Jansson <hpj@copyleft.no>

Conflicts:
	src/test/test-util.c
2013-10-29 11:14:40 -04:00
Zbigniew Jędrzejewski-Szmek 85d23bd3d5 Remove duplicated line
Conflicts:
	src/core/load-fragment.c
2013-10-29 10:59:07 -04:00
Lennart Poettering ab093f2760 swap: properly expose timeout property on the bus 2013-10-29 10:59:01 -04:00
Lennart Poettering eb31913712 dbus: fix introspection for TimerSlackNSec 2013-10-29 10:58:56 -04:00
Lennart Poettering 412c2eb9b8 logind: if a user is sitting in front of the computer and can shutdown the machine anyway he should also be able to reboot it 2013-10-29 10:58:53 -04:00
Zbigniew Jędrzejewski-Szmek f494120944 journald: accept EPOLLERR from /dev/kmsg
Also print out unexpected epoll events explictly.
2013-10-29 10:58:48 -04:00
Dave Reisner d03880f0c3 fix grammatical error 2013-10-29 10:57:51 -04:00
Dave Reisner 78d87cec49 nspawn: be less liberal about creating bind mount destinations
Previously, if a file's bind mount destination didn't exist, nspawn
would blindly create a directory, and the subsequent bind mount would
fail. Examine the filetype of the source and ensure that, if the
destination does not exist, that it is created appropriately.

Also go one step further and ensure that the filetypes of the source
and destination match.
2013-10-29 10:57:48 -04:00
Dave Reisner 908d0910ba udev-builtin-blkid: export ID_PART_TABLE_UUID 2013-10-29 10:57:42 -04:00
Brandon Philips 14fd27f679 cgtop: fixup the online help
The online help shows the keys as uppercase but the code and manpage say
lower case. Make the online help follow reality.
2013-10-29 10:57:33 -04:00
Michal Sekletar cd2430aee0 systemctl: process only signals for jobs we really wait for
wait_filter() callback shouldn't process JobRemove signals for arbitrary
jobs. It should only deal with signals for jobs which are included in
set of jobs we wait for.
2013-10-29 10:57:31 -04:00
Zbigniew Jędrzejewski-Szmek 43ac008a93 Actually allow tabs in environment files
Fixup for ac4c8d6da8.
2013-10-29 10:57:27 -04:00
Zbigniew Jędrzejewski-Szmek 7802260b72 Allow tabs in environment files
bash allows them, and so should we.

string_has_cc is changed to allow tabs, and if they are not wanted,
they must be now checked for explicitly. There are two other callers,
apart from the env file loaders, and one already checked anyway, and
the other is changed to check.

https://bugs.freedesktop.org/show_bug.cgi?id=68592
https://bugs.gentoo.org/show_bug.cgi?id=481554

Conflicts:
	src/test/test-fileio.c
2013-10-29 10:57:22 -04:00
David Herrmann c12b91d458 libudev: enumerate: fix NULL-deref for subsystem-matches
udev_device_get_subsystem() may return NULL if no subsystem could be
figured out by libudev. This might be due to OOM or if the device
disconnected between the udev_device_new() call and
udev_device_get_subsystem(). Therefore, we need to handle subsystem==NULL
safely.

Instead of testing for it in each helper, we treat subsystem==NULL as
empty subsystem in match_subsystem().

Backtrace of udev_enumerate with an input-device disconnecting in exactly
this time-frame:
 (gdb) bt
 #0  0x00007ffff569dc24 in strnlen () from /usr/lib/libc.so.6
 #1  0x00007ffff56d9e04 in fnmatch@@GLIBC_2.2.5 () from /usr/lib/libc.so.6
 #2  0x00007ffff5beb83d in match_subsystem (udev_enumerate=0x7a05f0, subsystem=0x0) at src/libudev/libudev-enumerate.c:727
 #3  0x00007ffff5bebb30 in parent_add_child (enumerate=enumerate@entry=0x7a05f0, path=<optimized out>) at src/libudev/libudev-enumerate.c:834
 #4  0x00007ffff5bebc3f in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x7a56b0 "/sys/devices/<shortened>/input/input97", maxdepth=maxdepth@entry=254) at src/libudev/libudev-enumerate.c:866
 #5  0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x79e8c0 "/sys/devices/<shortened>/input", maxdepth=maxdepth@entry=255) at src/libudev/libudev-enumerate.c:868
 #6  0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=path@entry=0x753190 "/sys/devices/<shortened>", maxdepth=maxdepth@entry=256) at src/libudev/libudev-enumerate.c:868
 #7  0x00007ffff5bec7df in scan_devices_children (enumerate=0x7a05f0) at src/libudev/libudev-enumerate.c:882
 #8  udev_enumerate_scan_devices (udev_enumerate=udev_enumerate@entry=0x7a05f0) at src/libudev/libudev-enumerate.c:919
 #9  0x00007ffff5df8777 in <random_caller> () at some/file.c:181
2013-10-29 10:56:24 -04:00
David Herrmann d6a6429441 libudev: fix memleak when enumerating childs
We need to free udev-devices again if they don't match. Funny that no-one
noticed it yet since valgrind is quite verbose about it.
Fix it and free non-matching devices.
2013-10-29 10:56:22 -04:00
Zbigniew Jędrzejewski-Szmek b4987c2ae0 journal: fix parsing of facility in syslog messages
In 49998b383 (journald: do not overwrite syslog facility when
parsing priority) journald started ignoring facility part when
reading service stderr to convert to syslog messages. In this
case it is fine, because only the priority is allowed.

But the same codepath is used for syslog messages, where the
facility should be used. Split the two codepaths by explicitly
specyfing whether the facility should be ignored or not.

https://bugzilla.redhat.com/show_bug.cgi?id=988814
2013-10-29 10:56:20 -04:00
Zbigniew Jędrzejewski-Szmek de2ebe8ea8 journald: do not overwrite syslog facility when parsing priority
https://bugs.freedesktop.org/show_bug.cgi?id=65610
2013-10-29 10:56:17 -04:00
WANG Chao 3e95626052 fstab-generator: log_oom() if automount_name is null 2013-10-29 10:56:14 -04:00
WANG Chao ffc196d5b1 fstab-generator: read rd.fstab=on/off switch correctly 2013-10-29 10:56:11 -04:00
George McCollister 81be5f2e03 journal: fix hashmap leak in mmap-cache
hashmap_free() wasn't being called on m->contexts and m->fds resulting
in a leak.

To reproduce do:
	while(1) {
		sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
		sd_journal_close(j);
	}

Memory usage will increase until OOM.
2013-10-29 10:56:07 -04:00
Zbigniew Jędrzejewski-Szmek 85f06598d7 journal: letting (interleaved) seqnums go
In the following scenario:
  server creates system.journal
  server creates user-1000.journal
both journals share the same seqnum_id.
Then
  server writes to user-1000.journal first,
  and server writes to system.journal a bit later,
and everything is fine.
The server then terminates (crash, reboot, rsyslog testing,
whatever), and user-1000.journal has entries which end with
a lower seqnum than system.journal. Now
  server is restarted
  server opens user-1000.journal and writes entries to it...
BAM! duplicate seqnums for the same seqnum_id.

Now, we usually don't see that happen, because system.journal
is closed last, and opened first. Since usually at least one
message is written during boot and lands in the system.journal,
the seqnum is initialized from it, and is set to a number higher
than than anything found in user journals. Nevertheless, if
system.journal is corrupted and is rotated, it can happen that
an entry is written to the user journal with a seqnum that is
a duplicate with an entry found in the corrupted system.journal~.
When browsing the journal, journalctl can fall into a loop
where it tries to follow the seqnums, and tries to go the
next location by seqnum, and is transported back in time to
to the older duplicate seqnum. There is not way to find
out the maximum seqnum used in a multiple files, without
actually looking at all of them. But we don't want to do
that because it would be slow, and actually it isn't really
possible, because a file might e.g. be temporarily unaccessible.

Fix the problem by using different seqnum series for user
journals. Using the same seqnum series for rotated journals
is still fine, because we know that nothing will write
to the rotated journal anymore.

Likely related:
https://bugs.freedesktop.org/show_bug.cgi?id=64566
https://bugs.freedesktop.org/show_bug.cgi?id=59856
https://bugs.freedesktop.org/show_bug.cgi?id=64296
https://bugs.archlinux.org/task/35581
https://bugzilla.novell.com/show_bug.cgi?id=817778

Possibly related:
https://bugs.freedesktop.org/show_bug.cgi?id=64293
2013-10-29 10:55:52 -04:00
Zbigniew Jędrzejewski-Szmek 93dcf37024 journal: remember last direction of search and keep offset cache
The fields in JournalFile are moved around to avoid wasting
7 bytes because of alignment.

Conflicts:
	TODO
2013-10-29 10:55:46 -04:00
Ross Lagerwall c3926429ef service: don't report alien child as alive when it's not
When a sigchld is received from an alien child, main_pid is set to
0 then service_enter_running calls main_pid_good to check if the
child is running.  This incorrectly returned true because
kill(main_pid, 0) would return >= 0.

This fixes an error where a service would die and the cgroup would
become empty but the service would still report as active (running).
2013-10-29 10:54:40 -04:00
Eelco Dolstra b6f25a95f8 Fix CPUShares configuration option
This fixes the error message "Unknown or unsupported cgroup attribute
CPUShares".
2013-10-29 10:54:02 -04:00
Michael Olbrich 05e3a4c68c service: kill processes with SIGKILL on watchdog failure
Just calling service_enter_dead() does not kill any processes.
As a result, the old process may still be running when the new one is
started.

After a watchdog failure the service is in an undefined state.
Using the normal shutdown mechanism makes no sense. Instead all processes
are just killed and the service can try to restart.
2013-10-29 10:53:55 -04:00
Michał Bartoszkiewicz 7082b70cd0 journal: correctly convert usec_t to timespec.
Use timespec_store instead of (incorrectly) doing it inline.
2013-10-29 10:52:27 -04:00
Colin Walters 3c08015f7e polkit: Avoid race condition in scraping /proc
If a calling process execve()s a setuid program, it can appear to be
uid 0.  Since we're receiving requests over DBus, avoid this by simply
passing system-bus-name as a subject.
2013-10-29 10:42:40 -04:00
Harald Hoyer 652bba47f7 core/execute: only clean the environment, if we have one (cherry picked from commit 5521d69856) 2013-10-29 10:42:40 -04:00
Lennart Poettering 356482f8f8 fileio: unify how we chop off whitespace from key and value in parse_env_file_internal() (cherry picked from commit 2b77f67e78)
Conflicts:
	TODO
2013-10-29 10:42:40 -04:00
Harald Hoyer fe5db02576 fileio.c: do not parse comments after non-whitespace chars
systemd does not want to understand comments after the first
non-whitespace char occured.

key=foo #comment  will result into key == "foo #comment"
key="foo" #comment  will result into key == "foo#comment"
"key= #comment" will result into key == "#comment"
"key #comment" is an invalid line
(cherry picked from commit 98f59e59e0)
2013-10-29 10:42:40 -04:00
Harald Hoyer be2cf34fef core/execute: report invalid environment variables from files
Because "export key=val" is not supported by systemd, an error is logged
where the invalid assignment is coming from.

Introduce strv_env_clean_log() to log invalid environment assignments,
where logging is possible and allowed.

parse_env_file_internal() is modified to allow WHITESPACE in keys, to
report the issues later on.
(cherry picked from commit ebc05a09ad)
2013-10-29 10:42:40 -04:00
Harald Hoyer 780297602e fileio:parse_env_file_internal() fix environment file parsing
parse_env_file_internal() could not parse the following lines correctly:

export key="val"
key="val"#comment
(cherry picked from commit db53720916)
2013-10-29 10:42:40 -04:00
Mantas Mikulėnas 457fd0ab5e fileio: also escape $ and ` when writing out env vars
These are also considered special by sh and bash.
(cherry picked from commit ced2d10a28)
2013-10-29 10:42:39 -04:00
Lennart Poettering f3893bd709 journald: be more careful when we try to flush the runtime journal to disk and the disk is close to being full
Bump the minimal size of the journal so that we can be sure creating the
journal file will always succeed. Previously the minimum size was
smaller than a empty jounral file...
(cherry picked from commit 253f59dff9)
2013-10-29 10:42:39 -04:00
MUNEDA Takahiro 577aa8fce8 core: escape unit name from udev
This patch escapes a unit name which was derived from udev.

Please imagine following udev rule.

  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%p.service"
  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%r.service"
  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%S.service"

When unit name is derived from udev via
udev_device_get_property_value(), the name may contains '/' if
ENV{SYSTEMD_WANTS} has the udev options $devpath(%p), $root(%r), or
$sys(%S).  However, '/' is a invalid char for unit name so processing
of this rule fails as Invalid argument with following message.

Apr 22 13:21:37 localhost systemd[1]: Failed to load device unit: Invalid argument
Apr 22 13:21:37 localhost systemd[1]: Failed to process udev device event: Invalid argument

This patch escapes those invalid chars in a unit name.
Tested with 202, and confirmed to apply cleanly on top of commit 195f8e36.

Thanks,
Takahiro
(cherry picked from commit d9abd1493d)
2013-10-29 10:42:39 -04:00
Lennart Poettering 4adb14d65c core: unit_inactive_or_pending() should actually do as it claims (cherry picked from commit d956ac29a1) 2013-10-29 10:42:39 -04:00
Lennart Poettering f44089f615 core: bump simultaneous bus connection limit to 512 (cherry picked from commit 417b1a62ed) 2013-10-29 10:42:39 -04:00
Lennart Poettering 5ecec44b34 unit: rework stop pending logic
When a trigger unit wants to know if a stop is queued for it, we should
just check precisely that and do not check whether it is actually
stopped already. This is because we use these checks usually from state
change calls where the state variables are not updated yet.

This change splits unit_pending_inactive() into two calls
unit_inactive_or_pending() and unit_stop_pending(). The former checks
state and pending jobs, the latter only pending jobs.
(cherry picked from commit 31afa0a44c)
2013-10-29 10:42:39 -04:00
Ronny Chevalier 13aaa0295c dbus-execute: fix introspection
Add missing property and remove duplicate properties already in
src/core/dbus-kill.h
(cherry picked from commit 92dd3633b4)
2013-10-29 10:42:39 -04:00
Zbigniew Jędrzejewski-Szmek 775334bc92 man: clarify what Restart= means
Related to https://bugzilla.redhat.com/show_bug.cgi?id=957135.
(cherry picked from commit a827e37371)
2013-10-29 10:42:38 -04:00
Mirco Tischler 9cd67f9df4 core: remove duplicate MESSAGE= from log message
This was needed with log_struct_unit() but log_notice_unit() adds it
anyway.
(cherry picked from commit fcf8c44041)
2013-10-29 10:42:38 -04:00
Lennart Poettering db97c7f66e logind: don't busy loop if a job is still running but the delay timeout expires (cherry picked from commit 842865365e) 2013-10-29 10:42:38 -04:00
Lennart Poettering 9f5510ae6e timer: make sure we restart timers even if units are still running or if one of their conditions fails (cherry picked from commit e41e194340)
Conflicts:
	TODO
2013-10-29 10:42:38 -04:00
Lennart Poettering 77529d5944 unit: rework trigger dependency logic
Instead of having explicit type-specific callbacks that inform the
triggering unit when a triggered unit changes state, make this generic
so that state changes are forwarded betwee any triggered and triggering
unit.

Also, get rid of UnitRef references from automount, timer, path units,
to the units they trigger and rely exclsuively on UNIT_TRIGGER type
dendencies.
(cherry picked from commit 3ecaa09bcc)
2013-10-29 10:42:38 -04:00
Simon Peeters 34be942435 Move bus_error to dbus-common and remove bus_error_message_or_strerror
bus_error and bus_error_message_or_strerror dit almost exactly the same,
so use only one of them and place it in dbus-common.
(cherry picked from commit 449101fce2)
2013-10-29 10:42:38 -04:00
Zbigniew Jędrzejewski-Szmek 9b37b0f4ac core: log a few more things under UNIT=... (cherry picked from commit c1b6628d64) 2013-10-29 10:42:38 -04:00
Lennart Poettering ff85663ec0 core: let's make our log messages proper sentences with full stops (cherry picked from commit 7a9ec5c902) 2013-10-29 10:42:38 -04:00
Zbigniew Jędrzejewski-Szmek 825404a9ac Report about syntax errors with metadata
The information about the unit for which files are being parsed
is passed all the way down. This way messages land in the journal
with proper UNIT=... or USER_UNIT=... attribution.

'systemctl status' and 'journalctl -u' not displaying those messages
has been a source of confusion for users, since the journal entry for
a misspelt setting was often logged quite a bit earlier than the
failure to start a unit.

Based-on-a-patch-by: Oleksii Shevchuk <alxchk@gmail.com>
(cherry picked from commit e8e581bf25)
2013-10-29 10:42:38 -04:00