1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
Commit Graph

18477 Commits

Author SHA1 Message Date
Dave Reisner
7cd3aba6bd build-sys: always distribute systemd-consoled.service.in
Similar to how we handle other facilities that can be flagged out at
configure time, we should always distribute this input file.

http://lists.freedesktop.org/archives/systemd-devel/2014-December/026272.html
2014-12-14 10:40:25 -05:00
Ronny Chevalier
e9e310f8e9 systemctl: handle correctly template units for edit verb
Previously, if we provided getty@.service to systemctl edit it would
have failed when using the bus because it is an invalid unit name.
But it would have succeeded when searching in the filesystem.

Now, we check if we have a template, if we do we search in the
filesystem, if we don't have a templae and we can use the bus, we do.

Furthermore, if we provided getty@tty1.service it would not have worked
when searching the filesystem, but it would have worked with the bus.
So now, when using the filesystem we use the template name and not the
unit name, and the same when logging errors.

(Also did a refactoring to avoid a long function)
2014-12-13 15:29:47 +01:00
Ronny Chevalier
fee0a92183 test-unit-name: add more tests
Add more test cases for:
- unit_name_is_instance
- unit_name_to_instance

Add tests for:
- unit_name_template
- unit_name_is_template
2014-12-13 15:12:38 +01:00
Michal Schmidt
69adae5168 journal: replace contexts hashmap with a plain array
try_context() is such a hot path that the hashmap lookup is expensive.

The number of contexts is small - it is the number of object types.
Using a hashmap is overkill. A plain array will do.

Before:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null

real    0m9.445s
user    0m9.228s
sys     0m0.213s

After:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null
real    0m5.438s
user    0m5.266s
sys     0m0.170s
2014-12-13 00:47:23 +01:00
Michal Schmidt
634ed0ee34 journal: delete unused function mmap_cache_close_context
This never had any callers. Contexts are freed when the MMapCache is
freed.
2014-12-13 00:47:23 +01:00
Michal Schmidt
7a9dabea7e journal: push type_to_context conversion down to journal_file_move_to() 2014-12-13 00:47:23 +01:00
Michal Schmidt
7851983162 journal: have a named enum ObjectType 2014-12-13 00:47:23 +01:00
Michal Schmidt
d05089d86e journal: consistently use OBJECT_<type> names instead of numbers
Note that numbers 0 and -1 are both replaced with OBJECT_UNUSED,
because they are treated the same everywhere (e.g. type_to_context()
translates them both to 0).
2014-12-13 00:47:23 +01:00
Michal Schmidt
2df65e7d96 journal: consistently allow type==0 to mean "any type"
If type==0 and a non-NULL object were given as arguments to
journal_file_hmac_put_object(), its object type check would fail and it
would return -EBADMSG.

All existing callers use either a positive type or -1. Still, for
behavior consistency with journal_file_move_to_object() let's allow
type 0 to pass.
2014-12-13 00:47:23 +01:00
Michal Schmidt
d3d3208f60 journal: move type_to_context() to journal-file.c
It has no other callers. It does not need to be in the header file.
2014-12-13 00:47:23 +01:00
Michal Schmidt
1b8951e5bd journal: remove journal_file_object_keep/release functions
The only user is sd_journal_enumerate_unique() and, as explained in
the previous commit (fed67c38e3 "journal: map objects to context set by
caller, not by actual object type"), the use of them there is now
superfluous. Let's remove them.

This reverts major parts of commits:
  ae97089d49 journal: fix access to munmapped memory in
             sd_journal_enumerate_unique
  06cc69d44c sd-journal: fix sd_journal_enumerate_unique skipping values

Tested with an "--enable-debug" build and "journalctl --list-boots".
It gives the expected number of results. Additionally, if I then revert
the previous commit ("journal: map objects to context set by caller, not
to actual object type"), it crashes with SIGSEGV, as expected.
2014-12-13 00:46:40 +01:00
Michal Schmidt
fed67c38e3 journal: map objects to context set by caller, not by actual object type
When the caller of journal_file_move_to_object() specifies type==0,
the object header is at first mapped in context 0. Then after the header
is checked, the whole object is mapped in a context determined by
the actual object type (which is not even range-checked using
type_to_context()). This looks wrong. It should map in the
caller-specified context.

An old comment in sd_journal_enumerate_unique() supports this view:
    /* We do not use the type context here, but 0 instead,
     * so that we can look at this data object at the same
     * time as one on another file */
Clearly the expectation was that the data object will remain mapped
in context 0 without being pushed away by mapping other objects in
context OBJECT_DATA.

I suspect that this was the real bug that got fixed by ae97089d49
"journal: fix access to munmapped memory in sd_journal_enumerate_unique".
In other words, journal_file_object_keep/release are superfluous after
applying this patch.
2014-12-13 00:46:16 +01:00
Michal Schmidt
fad5a6c66e journal: add debug mode for mmap-cache (--enable-debug=mmap-cache)
This is useful for exposing unsafe access to mmapped objects after
the context that they were mapped in was already moved.

For example:
journal_file_move_to_object(f1, OBJECT_DATA, p1, &o1);
journal_file_move_to_object(f2, OBJECT_DATA, p2, &o2);
t = o1->object.type; /* this usually works, but is unsafe */
2014-12-13 00:46:16 +01:00
Michal Schmidt
fc86aa0ed2 configure.ac: add a generic --enable-debug, replace --enable-hashmap-debug
There will be more debugging options later.
 --enable-debug will enable them all.
 --enable-debug=hashmap will enable only hashmap debugging.

Also rename the C #define to ENABLE_DEBUG_* pattern.
2014-12-13 00:46:16 +01:00
Michal Schmidt
90df619ef5 shared/hashmap.h: fix comment
An early version used underscore prefixes for internal functions, but
the current version uses the prefix "internal_".
2014-12-13 00:46:16 +01:00
Zbigniew Jędrzejewski-Szmek
e31fc1417a hwdb: add more mice
https://bugs.freedesktop.org/show_bug.cgi?id=87271
2014-12-12 18:20:51 -05:00
Zbigniew Jędrzejewski-Szmek
7731320a14 hwdb: sort mice by brand,type,dpi,frequency
This way entries from the same brand with the same dpi and frequency
can be coalesced. It is also visually easier to find the right DPI
than order hexadecimal identifiers.
2014-12-12 18:17:37 -05:00
Thomas Hindoe Paaboel Andersen
b7378b89d2 networkctl: remove unused variable 2014-12-12 21:57:44 +01:00
Thomas Hindoe Paaboel Andersen
abc08d4d08 wrap a few *_FOREACH macros in curly braces
cppcheck would give up with "syntax error" without them. This led
to reports of syntax errors in unrelated locations and potentially
hid other errors
2014-12-12 21:57:44 +01:00
Lennart Poettering
308b571076 update TODO 2014-12-12 20:24:35 +01:00
Lennart Poettering
7d54a03a87 core: retry unmounting until we are done, in case of stacked mounts 2014-12-12 20:12:35 +01:00
Lennart Poettering
b1acce80cd networkctl: also draw a nice unicode cirlce when "networkctl status" is run without parameters 2014-12-12 19:11:35 +01:00
Lennart Poettering
1693a943ca networkctl: show interface names next to IP addresses if we dump adresses from all interfaces 2014-12-12 19:07:26 +01:00
Lennart Poettering
69fb1176c4 networkctl: also show gateway address when "networkctl status" without further arguments is passed 2014-12-12 18:57:15 +01:00
Lennart Poettering
888943fc62 networkctl: show MAC address OUI vendor next to MAC addresses 2014-12-12 18:56:35 +01:00
Lennart Poettering
4b7c1d5d6a test-cap-list: always check libcap comes to the same names as we do, for the names it knows 2014-12-12 18:42:19 +01:00
Lennart Poettering
34a3e4ecad cap-list: return lower-case capability names, similar to libcap's cap_to_name(), for compat reasons 2014-12-12 18:37:25 +01:00
Lennart Poettering
98cd265198 update TODO 2014-12-12 17:30:25 +01:00
Lennart Poettering
667993e88e man: fedora 21 has been release, suggest 21 as fedora version in example yum command line 2014-12-12 17:30:25 +01:00
Lennart Poettering
b9ba4dabba nspawn: when booting in ephemeral mode, append random token to machine name
Also, when booting up an ephemeral container of / use the system
hostname as default machine name.

This way specifiyng -M is unnecessary when booting up an ephemeral
container, while allowing any number of ephemeral containers to run from
the same tree.
2014-12-12 17:30:25 +01:00
Lennart Poettering
c4e34a612c nspawn: allow spawning ephemeral nspawn containers based on the root file system of the OS
This works now:

        # systemd-nspawn -xb -D / -M foobar

Which boots up an ephemeral container, based on the host's root file
system. Or in other words: you can now run the very same host OS you
booted your system with also in a container, on top of it, without
having it interfere. Great for testing whether the init system you are
hacking on still boots without reboot the system!
2014-12-12 17:30:25 +01:00
Lennart Poettering
df9a75e480 nspawn: don't link journals in ephemeral mode 2014-12-12 17:30:25 +01:00
Lennart Poettering
53e438e301 nspawn: properly unset arg_link_journal_try, when --link-journal= is specified 2014-12-12 17:30:25 +01:00
Lennart Poettering
7430ec6ac0 copy: use btrfs reflinking only whe we know we copy full files 2014-12-12 17:30:25 +01:00
David Herrmann
19ee32dc4d bus: send attach flags on BUS_MAKE
Make sure to set send-attach-flags on BUS_MAKE. These control which
information is revealed about the bus-owner.
2014-12-12 14:02:57 +01:00
David Herrmann
18ee085c15 bus: fix assert() on HELLO error-path
Make sure we don't call into any bus_kernel_*() functions before
b->is_kernel is set to true. Hard-code the CMD_FREE just like the other
helpers do.
2014-12-12 14:02:05 +01:00
Lennart Poettering
ec16945ebf nspawn: beef up nspawn with some btrfs magic
This adds --template= to duplicate an OS tree as btrfs snpashot and run
it

This also adds --ephemeral or -x to create a snapshot of an OS tree and
boot that, removing it after exit.
2014-12-12 13:35:32 +01:00
Lennart Poettering
0254b455e9 copy: teach copy_bytes() btrfs reflink magic 2014-12-12 13:35:32 +01:00
Lennart Poettering
f9ac15442e gpt-auto-generator: make use of new btrfs-util.h APIs 2014-12-12 13:35:32 +01:00
Lennart Poettering
d7c7c334f5 shared: add new btrfs-util.[ch] helpers for doing common btrfs operation 2014-12-12 13:35:32 +01:00
Lennart Poettering
700c6087eb shared: missing.h should include btrfs.h, before redefining some of its definitions 2014-12-12 13:35:32 +01:00
Lennart Poettering
6ce830fa61 util: minor simplification for loop_write() and loop_read() 2014-12-12 13:35:32 +01:00
Lennart Poettering
0c3c42847d nspawn: properly validate machine names 2014-12-12 13:35:32 +01:00
Lennart Poettering
a60e9f7fc8 seccomp-util.h: make sure seccomp-util.h can be included alone 2014-12-12 13:35:32 +01:00
Lennart Poettering
db594aef54 path-util: no need to check whether p is absolute twice 2014-12-12 13:35:32 +01:00
Lennart Poettering
a2e22d07c6 udev-builtin-btrfs: properly initialize ioctl struct to zeroes 2014-12-12 13:35:32 +01:00
Lennart Poettering
257224b0cd util: document why we have alloca_align() 2014-12-12 13:35:32 +01:00
Lennart Poettering
ae6c3cc009 util: when using basename() for creating temporary files, verify the resulting name is actually valid
Also, rename filename_is_safe() to filename_is_valid(), since it
actually does a full validation for what the kernel will accept as file
name, it's not just a heuristic.
2014-12-12 13:35:32 +01:00
David Herrmann
8d1c8bd746 journal: fix dangling 'else' ambiguity
Rework the sd-journal iterators to avoid dangling 'else' ambiguity. For a
detailed explanation, see:

    commit bff686e2a9
    Author: David Herrmann <dh.herrmann@gmail.com>
    Date:   Fri Dec 12 09:43:54 2014 +0100

        hwdb: fix dangling 'else' ambuguity
2014-12-12 09:52:06 +01:00
David Herrmann
bff686e2a9 hwdb: fix dangling 'else' ambuguity
Imagine the following use of hwdb:

    if (condition_A)
        SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value)
            operation_A(key, value);
    else
        log_error("...");

This should work just fine, but but definitely does not what you would
expect. Due to how SD_HWDB_FOREACH_PROPERTY is defined, the dangling
'else' is linked to the hidden 'if' statement in the macro instead of the
outer 'if (condition_A)'. This is unexpected and really annoying to debug.

Fix this by never leaving un-finished if-statements in
SD_HWDB_FOREACH_PROPERTY(). We simply inverse the if() statement and
explicitly add an 'else'-branch. This way, the statement is closed and all
ambuguities are resolved.
2014-12-12 09:43:54 +01:00