Commit graph

25696 commits

Author SHA1 Message Date
Lennart Poettering bd30fdf213 journal-file: always generate the same error when encountering corrupted files
Let's make sure EBADMSG is the one error we throw when we encounter corrupted
data, so that we can neatly test for it.
2016-04-26 12:00:03 +02:00
Lennart Poettering d00f1d57cc journal: when dumping journal contents, react nicer to lines we can't read
If journal files are not cleanly closed it might happen that intermediaery
journal entries cannot be read. Handle this nicely, skip over the unreadable
entries, and log a debug message about it; after all we generally follow the
logic that we try to make the best of corrupted files.
2016-04-26 12:00:03 +02:00
Lennart Poettering 50809d7a9c sd-journal: detect earlier if we try to read an object from an invalid offset
Specifically, detect early if we try to read from offset 0, i.e. are using
uninitialized offset data.
2016-04-26 12:00:02 +02:00
Zbigniew Jędrzejewski-Szmek 1000522a60 systemd --user: call pam_loginuid when creating user@.service (#3120)
This way the user service will have a loginuid, and it will be inherited by
child services. This shouldn't change anything as far as systemd itself is
concerned, but is nice for various services spawned from by systemd --user
that expect a loginuid.

pam_loginuid(8) says that it should be enabled for "..., crond and atd".
user@.service should behave similarly to those two as far as audit is
concerned.

https://bugzilla.redhat.com/show_bug.cgi?id=1328947#c28
2016-04-26 11:19:10 +02:00
Zbigniew Jędrzejewski-Szmek 47005cf1cf Merge pull request #3109 from poettering/journal-by-fd
rework "journalctl -M"
2016-04-25 15:57:36 -04:00
Zbigniew Jędrzejewski-Szmek 61837e19c6 Merge pull request #3114 from poettering/journalctl-b
Fix endless loops in journalctl --list-boots (closes #617).
2016-04-25 15:56:17 -04:00
EMOziko 833f2c2414 Hp Folio 1040g2 micmute and toggle touchpad fn keys fix (#3118)
Added HP Folio 1040g2 Fn+F8 MICMUTE FIx
2016-04-25 15:42:35 -04:00
Lennart Poettering c34b73d050 machined: add CAP_MKNOD to capabilities to run with (#3116)
Container images from Debian or suchlike contain device nodes in /dev. Let's
make sure we can clone them properly, hence pass CAP_MKNOD to machined.

Fixes: #2867 #465
2016-04-25 15:38:56 -04:00
Lennart Poettering f56012a57c machined: generate a nicer error when the user tries "machinectl clone" on non-btrfs file systems (#3117)
Fixes: #2060

(Of course, in the long run, we should probably add a copy-based fall-back. But
given how slow that is, this probably requires some asynchronous forking logic
like the CopyFrom() and CopyTo() method calls already implement.)
2016-04-25 15:37:51 -04:00
Lennart Poettering 0b2de9d90d core: fix description of "resources" service error (#3119)
The "resources" error is really just the generic error we return when
we hit some kind of error and we have no more appropriate error for the case to
return, for example because of some OS error.

Hence, reword the explanation and don't claim any relation to resource limits.

Admittedly, the "resources" service error is a bit of a misnomer, but I figure
it's kind of API now.

Fixes: #2716
2016-04-25 15:36:25 -04:00
Lennart Poettering e2aa7c3a39 Merge pull request #3113 from ssahani/route-fix
netwotkd: fix address and route conf
2016-04-25 20:02:03 +02:00
Vito Caputo b8f99e27e1 journal: fix already offline check and thread leak (#2810)
Early in journal_file_set_offline() f->header->state is tested to see if
it's != STATE_ONLINE, and since there's no need to do anything if the
journal isn't online, the function simply returned here.

Since moving part of the offlining process to a separate thread, there
are two problems here:

1. We can't simply check f->header->state, because if there is an
offline thread active it may modify f->header->state.

2. Even if the journal is deemed offline, the thread responsible may
still need joining, so a bare return may leak the thread's resources
like its stack.

To address #1, the helper journal_file_is_offlining() is called prior to
accessing f->header->state.

If journal_file_is_offlining() returns true, f->header->state isn't even
checked, because an offlining journal is obviously online, and we'll
just continue with the normal set offline code path.

If journal_file_is_offlining() returns false, then it's safe to check
f->header->state, because the offline_state is beyond the point of
modifying f->header->state, and there's a memory barrier in the helper.

If we find f->header->state is != STATE_ONLINE, then we call the
idempotent journal_file_set_offline_thread_join() on the way out of the
function, to join a potential lingering offline thread.
2016-04-25 19:58:16 +02:00
Lennart Poettering 52051dd84c journalctl: turn --unit= in combination with --user into --user-unit=
Let's be nice to users, and let's turn the nonsensical "--unit=… --user" into
"--user-unit=…" which the user more likely meant.

Fixes #1621
2016-04-25 19:29:01 +02:00
Lennart Poettering 2aab2fabbd man: document the new by-fd journal calls
Also, remove documentation for sd_journal_open_container() as we consider it
deprecated now.
2016-04-25 19:29:01 +02:00
Lennart Poettering 4706fbaa17 man: don't include history sections in man pages
I am pretty sure we shouldn't carry history sections in man pages, since it's
very hard to keep them correctly updated, the current ones are very
out-of-date, and they tend to make APIs appear unnecessarily complex.
2016-04-25 19:29:01 +02:00
Lennart Poettering 2daa9cbdda sd-journal: "soft" deprecate sd_journal_open_container()
Let's document the call as deprecated, since it doesn't cover containers with
directories that aren#t visible to the host properly.
2016-04-25 19:29:01 +02:00
Lennart Poettering d38c62cc76 journalctl: port --machine= switch to use machined's OpenMachineRootDirectory()
This way, the switch becomes compatible with nspawn containers using --image=,
and those which only store journal data in /run (i.e. have persistant logs
off).

Fixes: #49
2016-04-25 19:29:01 +02:00
Lennart Poettering dc00966228 journalctl: don't trust the per-field entry tables when looking for boot IDs
When appending to a journal file, journald will:

a) first, append the actual entry to the end of the journal file
b) second, add an offset reference to it to the global entry array stored at
   the beginning of the file
c) third, add offset references to it to the per-field entry array stored at
   various places of the file

The global entry array, maintained by b) is used when iterating through the
journal without matches applied.

The per-field entry array maintained by c) is used when iterating through the
journal with a match for that specific field applied.

In the wild, there are journal files where a) and b) were completed, but c)
was not before the files were abandoned. This means, that in some cases log
entries are at the end of these files that appear in the global entry array,
but not in the per-field entry array of the _BOOT_ID= field. Now, the
"journalctl --list-boots" command alternatingly uses the global entry array
and the per-field entry array of the _BOOT_ID= field. It seeks to the last
entry of a specific _BOOT_ID=field by having the right match installed, and
then jumps to the next following entry with no match installed anymore, under
the assumption this would bring it to the next boot ID. However, if the
per-field entry wasn't written fully, it might actually turn out that the
global entry array might know one more entry with the same _BOOT_ID, thus
resulting in a indefinite loop around the same _BOOT_ID.

This patch fixes that, by updating the boot search logic to always continue
reading entries until the boot ID actually changed from the previous. Thus, the
per-field entry array is used as quick jump index (i.e. as an optimization),
but not trusted otherwise.  Only the global entry array is trusted.

This replaces PR #1904, which is actually very similar to this one. However,
this one actually reads the boot ID directly from the entry header, and doesn't
try to read it at all until the read pointer is actually really located on the
first item to read.

Fixes: #617

Replaces: #1904
2016-04-25 18:08:42 +02:00
Lennart Poettering 0808b92f02 journalctl: improve output of --header a bit
Show the various timestamps in hexadecimal too. This is useful for matching the
timestamps included in cursor strings (which are encoded in hex, too), with the
references in the journal header.
2016-04-25 18:06:47 +02:00
Lennart Poettering d2773e59de nspawn: explicitly remove veth links after use (#3111)
* sd-netlink: permit RTM_DELLINK messages with no ifindex

This is useful for removing network interfaces by name.

* nspawn: explicitly remove veth links we created after use

Sometimes the kernel keeps veth links pinned after the namespace they have been
joined to died. Let's hence explicitly remove veth links after use.

Fixes: #2173
2016-04-25 17:36:51 +02:00
Lennart Poettering d1bf9dc963 journalctl: simplify discover_next_boot() a bit
Drop the "read_realtime" parameter. Getting the realtime timestamp from an
entry is cheap, as it is a normal header field, hence let's just get this
unconditionally, and simplify our code a bit.
2016-04-25 16:37:09 +02:00
Lennart Poettering d4723fb501 journalctl: simplify get_boots() a bit, by getting rid of one BootId object
Let's store the reference as simple sd_id128_t, since we don't actually need a
BootId for it.
2016-04-25 16:34:55 +02:00
Lennart Poettering c4fbc6b6e4 journalctl: add some explanatory comments to get_boots() 2016-04-25 16:34:55 +02:00
Lennart Poettering d077390cdf sd-journal: add logic to open journal files of a specific OS tree
With this change a new flag SD_JOURNAL_OS_ROOT is introduced. If specified
while opening the journal with the per-directory calls (specifically:
sd_journal_open_directory() and sd_journal_open_directory_fd()) the passed
directory is assumed to be the root directory of an OS tree, and the journal
files are searched for in /var/log/journal, /run/log/journal relative to it.

This is useful to allow usage of sd-journal on file descriptors returned by the
OpenRootDirectory() call of machined.
2016-04-25 15:24:46 +02:00
Lennart Poettering ae20320785 machined: add new OpenRootDirectory() call to Machine objects
This new call returns a file descriptor for the root directory of a container.
This file descriptor may then be used to access the rest of the container's
file system, via openat() and similar calls. Since the file descriptor returned
is for the file system namespace inside of the container it may be used to
access all files of the container exactly the way the container itself would
see them. This is particularly useful for containers run directly from
loopback media, for example via systemd-nspawn's --image= switch. It also
provides access to directories such as /run of a container that are normally
not accessible to the outside of a container.

This replaces PR #2870.

Fixes: #2870
2016-04-25 15:24:46 +02:00
Lennart Poettering 5d1ce25728 sd-journal: add API for opening journal files or directories by fd
Also, expose this via the "journalctl --file=-" syntax for STDIN. This feature
remains undocumented though, as it is probably not too useful in real-life as
this still requires fds that support mmaping and seeking, i.e. does not work
for pipes, for which reading from STDIN is most commonly used.
2016-04-25 15:24:46 +02:00
Michal Koutný d3bd0986bb Always create dependencies for loop device mounts
In case a file is on a networked filesystem, we may tag the fstab record with
_netdev option, however, corrrect dependencies will be created for this mount.
2016-04-25 13:25:00 +02:00
Michal Koutný 26919ac110 Always create dependencies for bind mounts
Dependencies were not created for _netdev mountpoints, the reasoning for this
is in the commit fc676b00, i.e. to avoid adding dependencies for network
mountpoints where What= appears like a path. Thus proposing this semantically
more correct condition when dependencies are added for _actual_ bind mounts
irrespectively of network flag.

Consequently it allows to add _netdev option to bind mounts, which includes
them in remote-fs.target, which simplifies configuration.
2016-04-25 13:12:02 +02:00
Lennart Poettering 4aeb20f5aa nspawn: when readjusting UID/GID ownership of OS trees, skip read-only subtrees
This should allow tools like rkt to pre-mount read-only subtrees in the OS
tree, without breaking the patching code.

Note that the code will still fail, if the top-level directory is already
read-only.
2016-04-25 12:50:13 +02:00
Lennart Poettering 88cd066e11 nspawn: don't try to patch UIDs/GIDs of procfs and suchlike 2016-04-25 12:50:06 +02:00
Lennart Poettering af88764ff8 units: turn on user namespace by default in systemd-nspawn@.service
Now that user namespacing is supported in a pretty automatic way, actually turn
it on by default if the systemd-nspawn@.service template is used.
2016-04-25 12:16:03 +02:00
Lennart Poettering ccabee0d64 nspawn: make -U a tiny bit smarter
With this change -U will turn on user namespacing only if the kernel actually
supports it and otherwise gracefully degrade to non-userns mode.
2016-04-25 12:16:02 +02:00
Lennart Poettering d2e5535f9d man: document the new user namespacing options 2016-04-25 12:16:02 +02:00
Lennart Poettering 0de7accea9 nspawn: allow configuration of user namespaces in .nspawn files
In order to implement this we change the bool arg_userns into an enum
UserNamespaceMode, which can take one of NO, PICK or FIXED, and replace the
arg_uid_range_pick bool with it.
2016-04-25 12:16:02 +02:00
Lennart Poettering 19aac838fc nspawn: add -U as shortcut for --private-users=pick
Given that user namespacing is pretty useful now, let's add a shortcut command
line switch for the logic.
2016-04-25 12:16:02 +02:00
Lennart Poettering 0e7ac7515f nspawn: optionally, automatically allocate a UID/GID range for userns containers
This adds the new value "pick" to --private-users=. When specified a new
UID/GID range of 65536 users is automatically and randomly allocated from the
host range 0x00080000-0xDFFF0000 and used for the container. The setting
implies --private-users-chown, so that container directory is recursively
chown()ed to the newly allocated UID/GID range, if that's necessary. As an
optimization before picking a randomized UID/GID the UID of the container's
root directory is used as starting point and used if currently not used
otherwise.

To protect against using the same UID/GID range multiple times a few mechanisms
are in place:

- The first and the last UID and GID of the range are checked with getpwuid()
  and getgrgid(). If an entry already exists a different range is picked. Note
  that by "last" UID the user 65534 is used, as 65535 is the 16bit (uid_t) -1.

- A lock file for the range is taken in /run/systemd/nspawn-uid/. Since the
  ranges are taken in a non-overlapping fashion, and always start on 64K
  boundaries this allows us to maintain a single lock file for each range that
  can be randomly picked. This protects nspawn from picking the same range in
  two parallel instances.

- If possible the /etc/passwd lock file is taken while a new range is selected
  until the container is up. This means adduser/addgroup should safely avoid
  the range as long as nss-mymachines is used, since the allocated range will
  then show up in the user database.

The UID/GID range nspawn picks from is compiled in and not configurable at the
moment. That should probably stay that way, since we already provide ways how
users can pick their own ranges manually if they don't like the automatic
logic.

The new --private-users=pick logic makes user namespacing pretty useful now, as
it relieves the user from managing UID/GID ranges.
2016-04-25 12:16:02 +02:00
Lennart Poettering 7336138eed nspawn: optionally fix up OS tree uid/gids for userns
This adds a new --private-userns-chown switch that may be used in combination
with --private-userns. If it is passed a recursive chmod() operation is run on
the OS tree, fixing all file owner UID/GIDs to the right ranges. This should
make user namespacing pretty workable, as the OS trees don't need to be
prepared manually anymore.
2016-04-25 12:15:57 +02:00
Lennart Poettering 6402d5c628 util: copy_file_range() returns EBADF when used on a tty
In nspawn we invoke copy_bytes() on a TTY fd. copy_file_range() returns EBADF
on a TTY and this error is considered fatal by copy_bytes() so far. Correct
that, so that nspawn's copy_bytes() operation works again.

This is a follow-up for a44202e98b.
2016-04-25 12:14:17 +02:00
Lennart Poettering cb306f5d50 sd-journal: minor simplification 2016-04-25 12:00:03 +02:00
Lennart Poettering 0f7488722d journalctl: improve error message when we have trouble reading journal files
Let's output the actual error code encountered, and let's not claim this was
purely triggered by files, because it can also be triggered by directories.
2016-04-25 12:00:03 +02:00
Lennart Poettering f637726130 sd-journal: properly collect errors from readdir()
Let's also collect errors returned by readdir() into our set of errors, like we
do this for all other errors from journal files.
2016-04-25 12:00:03 +02:00
Lennart Poettering 430fbf8e7f journal: add inotify watches by-fd instead of by-path
This is slightly nicer, since we actually watch the directories we opened and
enumerate. However, primarily this is preparation for adding support for
opening journal files by fd without specifying any path, to be added in a later
commit.
2016-04-25 12:00:03 +02:00
Susant Sahani 5215524dbe networkd: Address- initialize the node before adding to list.
It make more sense to initalize the node first then
we add to the list.
2016-04-25 12:38:56 +05:30
Susant Sahani cacc1dbf17 networkd: Fix route properties.
We are not able to add multiple properties.

wlp3s0.network:
[Match]
Name=wlp3s0

[Route]
Gateway=10.68.5.26
Metric=10

 sudo ./systemd-networkd
Failed to parse file '/usr/lib/systemd/network/wlp3s0.network': File
exists
Could not load configuration files: File exists

This patch fixes it.
2016-04-25 12:37:10 +05:30
Evgeny Vereshchagin 4f4d6ee4be tests: add test for coredump handler hanging at shutdown (#3101)
Test for #2691.
2016-04-24 20:24:41 -04:00
Sylvain Plantefève 3b2df79b66 po: Update French translation (#3108) 2016-04-24 19:56:42 -04:00
Piotr Drąg 530d4b7064 catalog,po: update Polish translation (#3100) 2016-04-24 12:31:10 +02:00
Lennart Poettering 368d264387 machinectl: don't parse command line switches after "shell" verb (#3095)
Fixes: #2420
2016-04-22 21:01:55 -04:00
Evgeny Vereshchagin 07bd0e02ef man: document the default for systemd.timer's Persistent flag (#3099)
Closes #3096
2016-04-22 20:49:47 -04:00
Thomas H. P. Andersen 0f5e13822d tree-wide: remove unused variables (#3098) 2016-04-22 20:49:07 -04:00