Commit Graph

4468 Commits

Author SHA1 Message Date
Harald Hoyer dbd3dedfaf core/execute.c: debug log final execve() with argv[]
https://bugzilla.redhat.com/show_bug.cgi?id=772073
2013-12-22 23:36:31 -05:00
Kay Sievers a63ba5f1c5 libudev: fix hwdb validation to look for the *new* file 2013-10-29 11:14:43 -04:00
Kay Sievers 646ed3b5d1 tmpfiles: log unaccessible FUSE mount points only as debug message 2013-10-29 11:14:43 -04:00
Zbigniew Jędrzejewski-Szmek b7a6e42e91 drop-ins: check return value
If the function failed, nothing serious would happen
because unlink would probably return EFAULT, but this
would obscure the real error and is a bit sloppy.

Conflicts:
	src/core/unit.c
2013-10-29 11:14:42 -04:00
Zbigniew Jędrzejewski-Szmek 3288a531d6 dbus-common: avoid leak in error path
src/shared/dbus-common.c:968:33: warning: Potential leak of memory pointed to by 'l'
                        return -EINVAL;
                                ^~~~~~
2013-10-29 11:14:42 -04:00
Zbigniew Jędrzejewski-Szmek 03e321c7b6 journald: remove rotated file from hashmap when rotation fails
Before, when the user journal file was rotated, journal_file_rotate
could close the old file and fail to open the new file. In that
case, we would leave the old (deallocated) file in the hashmap.
On subsequent accesses, we could retrieve this stale entry, leading
to a segfault.

When journal_file_rotate fails with the file pointer set to 0,
old file is certainly gone, and cannot be used anymore.

https://bugzilla.redhat.com/show_bug.cgi?id=890463
2013-10-29 11:14:42 -04:00
Lennart Poettering e8fc3ef0fc journald: fix minor memory leak 2013-10-29 11:14:42 -04:00
Zbigniew Jędrzejewski-Szmek 79271854cc journald: be a bit more verbose when vacuuming
Vacuuming behaviour is a bit confusing, and/or we have some bugs,
so those additional messages should help to find out what's going
on. Also, rotation of journal files shouldn't be happening too
often, so the level of the messages is bumped to info, so that
they'll be logged under normal operation.

Conflicts:
	src/journal/journalctl.c
2013-10-29 11:14:42 -04:00
George McCollister 4d28dc9086 journald: fix fd leak in journal_file_empty
Before my previous patch, journal_file_empty wasn't be called with the
correct filename. Now that it's being called with the correct filename
it leaks file descriptors. This patch closes the file descriptors before
returning.

Signed-off-by: George McCollister <george.mccollister@gmail.com>

[Edit harald@redhat.com: make use of _cleanup_close_ instead]
2013-10-29 11:14:42 -04:00
George McCollister 1fc56e5b7f journald: fix vacuuming of archived journals
d_name is modified on line 227 so if the entire journal name is needed
again p must be used. Before this change when journal_file_empty was called
on archived journals it would always return with -2.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
2013-10-29 11:14:42 -04:00
Zbigniew Jędrzejewski-Szmek a2c483fc0b journald: always vacuum empty offline files
Corrupted empty files are relatively common. I think they are created
when a coredump for a user who never logged anything before is
attempted to be written, but the write does not succeed because the
coredump is too big, but there are probably other ways to create
those, especially if the machine crashes at the right time.
Non-corrupted empty files can also happen, e.g. if a journal file is
opened, but nothing is ever successfully written to it and it is
rotated because of MaxFileSec=. Either way, each "empty" journal file
costs around 3 MB, and there's little point in keeping them around.
2013-10-29 11:14:42 -04:00
Zbigniew Jędrzejewski-Szmek eccaffa038 journal/vacuum: cleanup 2013-10-29 11:14:42 -04:00
Lennart Poettering 03b589c60c core: unify the way we denote serialization attributes 2013-10-29 11:14:42 -04:00
Sylvia Else 7157e4b7a6 systemd: serialize/deserialize forbid_restart value
The Service type's forbid_restart field was not preserved by
serialization/deserialization, so the fact that the service should not
be restarted after stopping was lost.

If a systemctl stop foo command has been given, but the foo service
has not yet stopped, and then the systemctl --system daemon-reload was
given, then when the foo service eventually stopped, systemd would
restart it.

https://bugs.freedesktop.org/show_bug.cgi?id=69800
2013-10-29 11:14:42 -04:00
Harald Hoyer 67c230aa88 core/mount.c:mount_dump(): don't segfault, if mount is not mounted anymore
Don't segfault, if m->from_proc_self_mountinfo and m->from_fragment is
false.

https://bugzilla.redhat.com/show_bug.cgi?id=957783#c9
2013-10-29 11:14:41 -04:00
Lennart Poettering a203e13d0b mount: when learning about the root mount from mountinfo, don't add conflicting dep for umount.target
That way systemd won't try to umount it at shutdown.
2013-10-29 11:14:41 -04:00
Kay Sievers 337722373b libudev: add missing 'global' to symbol export 2013-10-29 11:14:41 -04:00
Zbigniew Jędrzejewski-Szmek 5dd95bcdf1 systemd: order remote mounts from mountinfo before remote-fs.target
Usually the network is stopped before filesystems are umounted.
Ordering network filesystems before remote-fs.target means that their
unmounting will be performed earlier, and can terminate sucessfully.

https://bugs.freedesktop.org/show_bug.cgi?id=70002
2013-10-29 11:14:41 -04:00
Zbigniew Jędrzejewski-Szmek f94b45c027 execute.c: always set $SHELL
In e6dca81 $SHELL was added to user@.service. Let's
instead provide it to all units which have a user.

Conflicts:
	TODO
	man/systemd.exec.xml
2013-10-29 11:14:41 -04:00
Lennart Poettering a8c35776cd strv: don't access potentially NULL string arrays 2013-10-29 11:14:41 -04:00
Lennart Poettering d475d0fa21 efi: never call qsort on potentially NULL arrays 2013-10-29 11:14:41 -04:00
Lennart Poettering b0aa79e3d8 modules-load: fix error handling 2013-10-29 11:14:41 -04:00
Lennart Poettering dc9f98c23e dbus: fix return value of dispatch_rqueue() 2013-10-29 11:14:41 -04:00
Lennart Poettering 6fcec98acd journald: add missing error check 2013-10-29 11:14:41 -04:00
Lennart Poettering b76652a28e cryptsetup: fix OOM handling when parsing mount options
Conflicts:
	src/cryptsetup/cryptsetup.c
2013-10-29 11:14:40 -04:00
Chen Jie de55428968 util.c: ignore pollfd.revent for loop_read/loop_write
Let read()/write() report any error/EOF.
2013-10-29 11:14:40 -04:00
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