Commit graph

12362 commits

Author SHA1 Message Date
Lennart Poettering f6b8196f7c networkd: port many log messages over to newer logging API
Let's drop some strerror() invocations, and make use of the easier to
use newer logging APIs.
2015-08-27 13:04:33 +02:00
Lennart Poettering f02b961582 sd-bus: it's not a user error to query the error contained in a bus message
It's an OK way to check whether a message contains an erro, let's not
consider this a loggable assertion event.
2015-08-27 12:54:35 +02:00
Lennart Poettering dce391e78f networkd: properly reset transient hostname when we lose a DHCP lease
Previously we were setting the transient hostname again, rather than
resetting it.
2015-08-27 12:53:43 +02:00
Lennart Poettering 21b80ad126 networkd: optionally push dhcp timezone into timedated 2015-08-27 02:13:59 +02:00
Lennart Poettering fbcd420aa4 dhcp: don't underflow in lease time calculations
Don't underflow when calculating lease time.
2015-08-27 01:59:43 +02:00
Lennart Poettering 586ac6f711 networkd: make DHCP lease timeouts configurable 2015-08-27 01:47:42 +02:00
Lennart Poettering 39745a5afb networkd: fix indentation 2015-08-27 01:18:10 +02:00
Lennart Poettering 4b7b5abb78 dhcp: NTP servers should be requested by networkd but not implicitly by sd-dhcp
The library so far always requested the NTP servers. This might be
unnecessary in some uses, hence let's move the request into networkd
instead.
2015-08-27 01:17:30 +02:00
Lennart Poettering 0339cd7707 dhcp: clean up dhcp4 lease object
a) drop handling of obsolete or unused DHCP options time_offset,
   mtu_aging_timeout, policy filter, mdr, ttl, ip forwarding settings.
   Should this become useful one day we can readd support for this.

b) For subnet mask and broadcast it is not always clear whether 0 or
   255.255.255.255 might be valid, hence maintain a boolean indicating
   validity next to it.

c) serialize/deserialize broadcast address, lifetime, T1 and T2 together
   with the rest of the fields in dhcp_lease_save() and
   dhcp_lease_load().

d) consistently return ENODATA from getter functions for data that is
   missing in the lease.

e) add missing getter calls for broadcast, lifetime, T1, T2.

f) when decoding DHCP options, generate debug messages on parse
   failures, but try to proceed if possible.

g) Similar, when deserializing a lease in dhcp_lease_load(), make sure
   we deal nicely with unparsable fields, to provide upgrade compat.

h) fix some memory allocations
2015-08-27 01:05:13 +02:00
Lennart Poettering b3ec603ce8 dhcp: rename index to ifindex
This avoids confusion what this is, in particular as libc knows an
index() function.
2015-08-26 23:31:49 +02:00
Lennart Poettering 9a0f246fcd dhcp: store client id as void*, since we dont know what it is 2015-08-26 23:30:27 +02:00
Lennart Poettering 966d74c043 dhcp: properly handle error from ioctl() 2015-08-26 23:26:01 +02:00
Lennart Poettering e473522841 dhcp: generic data should be void*, not uint8_t*
If we handly arbitrary data we should use "void*" pointers, not
"uint8_t*", how go intended C to be used.
2015-08-26 23:05:34 +02:00
Lennart Poettering 89ca10c6a6 network: s/user_data/userdata/
Everywhere else we call the generic user data pointer just "userdata",
rather than "user_data". Let's do this here, too.
2015-08-26 22:47:53 +02:00
Lennart Poettering 0ae0e5cd96 dhcp: coding style fixes
We place the opening bracket of a function on the same line as the
function name. Let's do so in the DHCP sources too.
2015-08-26 21:09:00 +02:00
Lennart Poettering 3733eec3e2 dhcp: stop using refcnt.h
No need to invole atomic ops in single-threaded APIs, let's simplify
this.
2015-08-26 21:05:53 +02:00
Lennart Poettering 57de20dd8f basic: document that people shouldn't use refcnt.h without reason
refcnt.h only exists for cases where objects are simultaneously handled
by different threads. Otherwise it should not be used. The only case
where this applies is sd_bus, really, and pretty much none of our APIs,
since we do not claim thread-safety for them.
2015-08-26 21:04:38 +02:00
Lennart Poettering bd91b83e57 dhcp: keep lease save/load functions private
When we make sd-dhcp public one day we really should not make
sd_dhcp_lease_save() and sd_dhcp_lease_load() public, since it's pretty
much only useful as internal utility for networkd itself.
2015-08-26 20:48:21 +02:00
Lennart Poettering 2f3cf1f9e1 networkd: let's uppercase the first character in log messages
Let's try to generate log messages that resemble english language
sentences, hence uppercase the first character.
2015-08-26 20:45:29 +02:00
Lennart Poettering 9098162579 dhcp: normalize DHCP host and domain names from leases
Previoulsy, we just checked whether the domain names specified in
incoming DHCP leases are valid. Given that validation code actually
internally normalizes anyway, it's a good idea to simply do the full
normalization and store that in the lease structure. This allows us to
remove the manual removal of a trailing dot, if there is one.
2015-08-26 20:45:29 +02:00
Lennart Poettering 2d03c0b803 dhcp: various simplifications 2015-08-26 20:45:29 +02:00
Lennart Poettering 8eb9058dc1 dhcp,network: implement RFC 4833 (DHCP Timezone option)
This one is simply to add: encode the tzdata timezone in the DHCP
options and optionally make use of it.
2015-08-26 20:44:20 +02:00
Lennart Poettering 43f447b121 dhcp: be more careful when parsing strings from DHCP packets
Let's make sure there's no embedded 0 byte. Also, let's reset the string
if the length is zero.
2015-08-26 20:41:42 +02:00
Lennart Poettering 1ac608c9cc networkd: don't leak memory of Hostname= is used twice in a .network file
Also, we should only accept trailing dots where we have to, but not
everywhere, hence be more strict when validating configured hostnames.
2015-08-26 20:41:22 +02:00
Lennart Poettering 5c904ba5a5 time-util: add new get_timezone() call to get local timezone
Let's move the timedated-specific code to time-util.h and make it
generic.
2015-08-26 20:36:42 +02:00
David Herrmann a00458421d sd-dhcp6: fix domainname memleak
strv_extend() does not consume the passed entry, hence, we must properly
free it. Furthermore, we should *not* use strv_consume() as we do greedy
allocations on 'ret'; and greedy-allocations should only be used for short
lived objects or caches.

Fix the domainname parser to properly free temporary storage when done.
2015-08-26 12:37:56 +02:00
David Herrmann e6b18ffaea sd-dhcp: don't randomly ref objects
In our API design, getter-functions don't ref objects. Calls like
foo_get_bar() will not ref 'bar'. We never do that and there is no real
reason to do it in single threaded APIs. If you need a ref-count, you
better take it yourself *BEFORE* doing anything else on the parent object
(as this might invalidate your pointer).

Right now, sd_dhcp?_get_lease() refs the lease it returns. A lot of
code-paths in systemd do not expect this and thus leak the lease
reference. Fix this by changing the API to not ref returned objects.
2015-08-26 12:30:56 +02:00
David Herrmann 86d17e1d73 Merge pull request #1047 from poettering/machinectl-TERM
machinectl: pass $TERM into "machinectl shell" sessions
2015-08-26 11:55:48 +02:00
Martin Pitt be5afe9f5f Merge pull request #1044 from d-hatayama/fix_systemctl_abspath
selinux: fix regression of systemctl subcommands when absolute unit file paths are specified
2015-08-26 10:53:45 +02:00
Lennart Poettering 031fc5a1ac Merge pull request #998 from vbatts/tar_nosparse_flag
import: don't create sparse tar archives
2015-08-26 10:09:11 +02:00
Lennart Poettering 89fec31893 machinectl: pass $TERM into "machinectl shell" sessions 2015-08-26 10:07:21 +02:00
Lennart Poettering d9fcf2ba1a manager: close hostname fd *after* removing it epoll
Otherwise the epoll removal will fail and result in a warning.
2015-08-26 09:42:06 +02:00
Lennart Poettering 4d506d6bb7 resolved: dump cache and zone contents to syslog on SIGUSR1 2015-08-26 09:41:45 +02:00
HATAYAMA Daisuke 9fa7c1aeb9 selinux: fix regression of systemctl subcommands when absolute unit file paths are specified
The commit 4938696301 overlooked the
fact that unit files can be specified as unit file paths, not unit
file names, wrongly passing a unit file path to the 1st argument of
manager_load_unit() that handles it as a unit file name. As a result,
the following 4 systemctl subcommands:

    enable
    disable
    reenable
    link
    mask
    unmask

fail with the following error message:

    # systemctl enable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl disable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl reenable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # cp /usr/lib/systemd/system/kdump.service /tmp/
    # systemctl link /tmp/kdump.service
    Failed to execute operation: Unit name /tmp/kdump.service is not valid.
    # systemctl mask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl unmask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.

To fix the issue, first check whether a unit file is passed as a unit
file name or a unit file path, and then pass the unit file to the
appropreate argument of manager_load_unit().

By the way, even with this commit mask and unmask reject unit file
paths as follows and this is a correct behavior:

    # systemctl mask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Invalid argument
    # systemctl unmask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Invalid argument
2015-08-26 15:00:05 +09:00
Daniel Mack 7c268a0489 Merge pull request #1043 from phomes/master
test-util: fix a memleak
2015-08-26 00:05:33 +02:00
Daniel Mack 487ebe593c Merge pull request #1039 from poettering/nspawn-machine-template
nspawn: make sure --template= and --machine= my be combined
2015-08-25 23:58:40 +02:00
Daniel Mack 6a18bd1616 Merge pull request #1038 from poettering/coredumpctl-directory
Add --directory= option for reading alternate journal
2015-08-25 23:58:03 +02:00
Daniel Mack a0cb22c475 Merge pull request #1040 from poettering/cgroup-path-fix
fix "systemctl status idontexist.service" showing the full cgroup tree
2015-08-25 23:57:28 +02:00
Thomas Hindoe Paaboel Andersen 21e5a0bea0 test-util: fix a memleak 2015-08-25 23:52:18 +02:00
Daniel Mack d8b7e75f51 resolve: fix regression in dns-scope
Bring back a return statement 106784eb errornously removed.

Thanks to @phomes for reporting.
2015-08-25 23:51:34 +02:00
Daniel Mack 13918f62ff Merge pull request #1041 from phomes/master
trivial cleanups
2015-08-25 23:48:07 +02:00
Daniel Mack 4ece412faf Merge pull request #1034 from poettering/resolved-fixes-2
various resolved fixes
2015-08-25 23:47:30 +02:00
Thomas Hindoe Paaboel Andersen c615b4ba9f machinectl: remove unused variable 2015-08-25 21:15:54 +02:00
Thomas Hindoe Paaboel Andersen 2307f37e46 execute: make the invalid entry of the enum -1
Set _EXEC_UTMP_MODE_INVALID to -1. This matches the return value from
string_table_lookup.
2015-08-25 21:15:54 +02:00
Lennart Poettering 98bac6058c core: report root cgroup as "/" over the bus
Internally, the root cgroup is stored as the empty string in
Unit.cgroup_path, and "no cgroup" as NULL. Unfortunately, D-Bus does not
know a NULL concept, hence when reporting the cgroup to clients we
should turn the root cgroup into "/", and leave the empty string for the
"no cgroup" case.

This should make sure that "systemctl status -- -.slice" works correctly
and shows the entire cgroup tree.
2015-08-25 20:42:50 +02:00
Lennart Poettering 37a0d5bf21 Revert "systemctl: properly handle empty control group paths in "status""
This reverts commit b04c25f9ef.
2015-08-25 20:37:54 +02:00
Lennart Poettering c1521918b4 nspawn: make sure --template= and --machine= my be combined
Fixes #1018.

Based on a patch from Seth Jennings.
2015-08-25 20:28:31 +02:00
Stef Walter b73e9a024b coredumpctl: Add --directory option for reading alternate journal
In the Cockpit integration tests we hang onton the journal files
for a failed test and would like to inspect them using coredumpctl.

This commit adds the ability to specify an alternate directory
for coredumpctl to read the journal from.
2015-08-25 20:06:43 +02:00
Lennart Poettering f0258e4736 resolved: add comments to DNS_PACKET_MAKE_FLAGS() clarifying DNS vs LLMNR
Some flags are defined differently on unicast DNS and LLMNR, let's
document this in the DNS_PACKET_MAKE_FLAGS() macro.
2015-08-25 19:04:04 +02:00
Lennart Poettering 069360a66a resolved: make packet flags logic more expressive again
This partially reverts 106784ebb7, ad
readds separate DNS_PACKET_MAKE_FLAGS() invocations for the LLMNR and
DNS case. This is important since SOme flags have different names and
meanings on LLMNR and on DNS and we should clarify that via the comments
and how we put things together.
2015-08-25 18:54:55 +02:00