platform/upstream/systemd.git
9 years agoman: document the new DHCP settings added in the past commits
Lennart Poettering [Thu, 27 Aug 2015 15:32:30 +0000 (17:32 +0200)]
man: document the new DHCP settings added in the past commits

9 years agonetworkd: emit DNS/NTP/Timezone info via DHCP server by default
Lennart Poettering [Thu, 27 Aug 2015 14:47:26 +0000 (16:47 +0200)]
networkd: emit DNS/NTP/Timezone info via DHCP server by default

If we have the data, emit it by default.

9 years agonetworkd: propagate DNS/NTP server from uplink to dhcp server
Lennart Poettering [Thu, 27 Aug 2015 14:45:24 +0000 (16:45 +0200)]
networkd: propagate DNS/NTP server from uplink to dhcp server

When handing out DHCP leases, try to propagate DNS/NTP server
information from "uplink". The "uplink" is automatically determined as
the network interface with the highest priority default route on it.

9 years agodhcp,network: support emitting DNS/NTP server information from DHCP server
Lennart Poettering [Thu, 27 Aug 2015 12:48:37 +0000 (14:48 +0200)]
dhcp,network: support emitting DNS/NTP server information from DHCP server

For now, this is very simple and IP addresses have to be configured
manually.

9 years agonetworkd: split up networkd.h into per-object header files
Lennart Poettering [Thu, 27 Aug 2015 11:59:06 +0000 (13:59 +0200)]
networkd: split up networkd.h into per-object header files

No functional changes, just moving definitions into separate header
files.

9 years agonetworkd: port many log messages over to newer logging API
Lennart Poettering [Thu, 27 Aug 2015 11:04:33 +0000 (13:04 +0200)]
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.

9 years agosd-bus: it's not a user error to query the error contained in a bus message
Lennart Poettering [Thu, 27 Aug 2015 10:54:35 +0000 (12:54 +0200)]
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.

9 years agonetworkd: properly reset transient hostname when we lose a DHCP lease
Lennart Poettering [Thu, 27 Aug 2015 10:53:43 +0000 (12:53 +0200)]
networkd: properly reset transient hostname when we lose a DHCP lease

Previously we were setting the transient hostname again, rather than
resetting it.

9 years agonetworkd: optionally push dhcp timezone into timedated
Lennart Poettering [Thu, 27 Aug 2015 00:12:27 +0000 (02:12 +0200)]
networkd: optionally push dhcp timezone into timedated

9 years agodhcp: don't underflow in lease time calculations
Lennart Poettering [Wed, 26 Aug 2015 23:59:43 +0000 (01:59 +0200)]
dhcp: don't underflow in lease time calculations

Don't underflow when calculating lease time.

9 years agonetworkd: make DHCP lease timeouts configurable
Lennart Poettering [Wed, 26 Aug 2015 23:47:42 +0000 (01:47 +0200)]
networkd: make DHCP lease timeouts configurable

9 years agonetworkd: fix indentation
Lennart Poettering [Wed, 26 Aug 2015 23:18:10 +0000 (01:18 +0200)]
networkd: fix indentation

9 years agodhcp: NTP servers should be requested by networkd but not implicitly by sd-dhcp
Lennart Poettering [Wed, 26 Aug 2015 23:14:20 +0000 (01:14 +0200)]
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.

9 years agodhcp: clean up dhcp4 lease object
Lennart Poettering [Wed, 26 Aug 2015 23:05:13 +0000 (01:05 +0200)]
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

9 years agodhcp: rename index to ifindex
Lennart Poettering [Wed, 26 Aug 2015 21:31:47 +0000 (23:31 +0200)]
dhcp: rename index to ifindex

This avoids confusion what this is, in particular as libc knows an
index() function.

9 years agodhcp: store client id as void*, since we dont know what it is
Lennart Poettering [Wed, 26 Aug 2015 21:30:27 +0000 (23:30 +0200)]
dhcp: store client id as void*, since we dont know what it is

9 years agodhcp: properly handle error from ioctl()
Lennart Poettering [Wed, 26 Aug 2015 21:26:01 +0000 (23:26 +0200)]
dhcp: properly handle error from ioctl()

9 years agodhcp: generic data should be void*, not uint8_t*
Lennart Poettering [Wed, 26 Aug 2015 21:05:34 +0000 (23:05 +0200)]
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.

9 years agonetwork: s/user_data/userdata/
Lennart Poettering [Wed, 26 Aug 2015 20:47:53 +0000 (22:47 +0200)]
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.

9 years agodhcp: coding style fixes
Lennart Poettering [Wed, 26 Aug 2015 19:09:00 +0000 (21:09 +0200)]
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.

9 years agodhcp: stop using refcnt.h
Lennart Poettering [Wed, 26 Aug 2015 19:05:53 +0000 (21:05 +0200)]
dhcp: stop using refcnt.h

No need to invole atomic ops in single-threaded APIs, let's simplify
this.

9 years agobasic: document that people shouldn't use refcnt.h without reason
Lennart Poettering [Wed, 26 Aug 2015 19:04:38 +0000 (21:04 +0200)]
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.

9 years agodhcp: keep lease save/load functions private
Lennart Poettering [Wed, 26 Aug 2015 18:48:21 +0000 (20:48 +0200)]
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.

9 years agonetworkd: let's uppercase the first character in log messages
Lennart Poettering [Wed, 26 Aug 2015 18:43:28 +0000 (20:43 +0200)]
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.

9 years agodhcp: normalize DHCP host and domain names from leases
Lennart Poettering [Wed, 26 Aug 2015 18:12:17 +0000 (20:12 +0200)]
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.

9 years agodhcp: various simplifications
Lennart Poettering [Wed, 26 Aug 2015 18:11:35 +0000 (20:11 +0200)]
dhcp: various simplifications

9 years agonetwork: turn on DHCP timezone passing between container and host
Lennart Poettering [Wed, 26 Aug 2015 17:38:15 +0000 (19:38 +0200)]
network: turn on DHCP timezone passing between container and host

Let's turn on DHCP timezone passing from the host to a container, so
that the timezone is always in sync.

9 years agodhcp,network: implement RFC 4833 (DHCP Timezone option)
Lennart Poettering [Wed, 26 Aug 2015 17:19:32 +0000 (19:19 +0200)]
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.

9 years agodhcp: be more careful when parsing strings from DHCP packets
Lennart Poettering [Wed, 26 Aug 2015 17:18:11 +0000 (19:18 +0200)]
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.

9 years agonetworkd: don't leak memory of Hostname= is used twice in a .network file
Lennart Poettering [Wed, 26 Aug 2015 17:16:52 +0000 (19:16 +0200)]
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.

9 years agotime-util: add new get_timezone() call to get local timezone
Lennart Poettering [Wed, 26 Aug 2015 17:14:51 +0000 (19:14 +0200)]
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.

9 years agosd-dhcp6: fix domainname memleak
David Herrmann [Wed, 26 Aug 2015 10:37:56 +0000 (12:37 +0200)]
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.

9 years agosd-dhcp: don't randomly ref objects
David Herrmann [Wed, 26 Aug 2015 10:30:56 +0000 (12:30 +0200)]
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.

9 years agoMerge pull request #1048 from poettering/resolved-man
Daniel Mack [Wed, 26 Aug 2015 10:01:56 +0000 (12:01 +0200)]
Merge pull request #1048 from poettering/resolved-man

man: resolved man page updates (plus one to machinectl)

9 years agoMerge pull request #1047 from poettering/machinectl-TERM
David Herrmann [Wed, 26 Aug 2015 09:55:48 +0000 (11:55 +0200)]
Merge pull request #1047 from poettering/machinectl-TERM

machinectl: pass $TERM into "machinectl shell" sessions

9 years agoman: minor extension to the machinectl man page
Lennart Poettering [Wed, 26 Aug 2015 09:02:28 +0000 (11:02 +0200)]
man: minor extension to the machinectl man page

s/an/any/, as reported by Vito Caputo.

Also mention explicitly that the security properties (i.e. SELinux) are
also isolated when "machinectl shell" is used.

9 years agoman: document nss-resolve
Lennart Poettering [Wed, 26 Aug 2015 09:00:09 +0000 (11:00 +0200)]
man: document nss-resolve

9 years agoMerge pull request #1044 from d-hatayama/fix_systemctl_abspath
Martin Pitt [Wed, 26 Aug 2015 08:53:45 +0000 (10:53 +0200)]
Merge pull request #1044 from d-hatayama/fix_systemctl_abspath

selinux: fix regression of systemctl subcommands when absolute unit file paths are specified

9 years agoman: document resolved's RR synthesizing and query routing
Lennart Poettering [Wed, 26 Aug 2015 08:30:06 +0000 (10:30 +0200)]
man: document resolved's RR synthesizing and query routing

9 years agoMerge pull request #998 from vbatts/tar_nosparse_flag
Lennart Poettering [Wed, 26 Aug 2015 08:09:11 +0000 (10:09 +0200)]
Merge pull request #998 from vbatts/tar_nosparse_flag

import: don't create sparse tar archives

9 years agomachinectl: pass $TERM into "machinectl shell" sessions
Lennart Poettering [Wed, 26 Aug 2015 08:07:21 +0000 (10:07 +0200)]
machinectl: pass $TERM into "machinectl shell" sessions

9 years agoMerge pull request #1046 from poettering/resolved-dump
Tom Gundersen [Wed, 26 Aug 2015 08:02:37 +0000 (10:02 +0200)]
Merge pull request #1046 from poettering/resolved-dump

dump resolved cache/zone info on SIGSUR1, plus one fix

9 years agomanager: close hostname fd *after* removing it epoll
Lennart Poettering [Wed, 26 Aug 2015 07:42:06 +0000 (09:42 +0200)]
manager: close hostname fd *after* removing it epoll

Otherwise the epoll removal will fail and result in a warning.

9 years agoresolved: dump cache and zone contents to syslog on SIGUSR1
Lennart Poettering [Wed, 26 Aug 2015 07:41:45 +0000 (09:41 +0200)]
resolved: dump cache and zone contents to syslog on SIGUSR1

9 years agohwdb: Update database of Bluetooth company identifiers
Marcel Holtmann [Wed, 26 Aug 2015 07:21:02 +0000 (09:21 +0200)]
hwdb: Update database of Bluetooth company identifiers

9 years agoselinux: fix regression of systemctl subcommands when absolute unit file paths are...
HATAYAMA Daisuke [Wed, 26 Aug 2015 03:07:31 +0000 (12:07 +0900)]
selinux: fix regression of systemctl subcommands when absolute unit file paths are specified

The commit 4938696301a914ec26bcfc60bb99a1e9624e3789 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

9 years agoMerge pull request #1043 from phomes/master
Daniel Mack [Tue, 25 Aug 2015 22:05:33 +0000 (00:05 +0200)]
Merge pull request #1043 from phomes/master

test-util: fix a memleak

9 years agoMerge pull request #1039 from poettering/nspawn-machine-template
Daniel Mack [Tue, 25 Aug 2015 21:58:40 +0000 (23:58 +0200)]
Merge pull request #1039 from poettering/nspawn-machine-template

nspawn: make sure --template= and --machine= my be combined

9 years agoMerge pull request #1038 from poettering/coredumpctl-directory
Daniel Mack [Tue, 25 Aug 2015 21:58:03 +0000 (23:58 +0200)]
Merge pull request #1038 from poettering/coredumpctl-directory

Add --directory= option for reading alternate journal

9 years agoMerge pull request #1040 from poettering/cgroup-path-fix
Daniel Mack [Tue, 25 Aug 2015 21:57:28 +0000 (23:57 +0200)]
Merge pull request #1040 from poettering/cgroup-path-fix

fix "systemctl status idontexist.service" showing the full cgroup tree

9 years agotest-util: fix a memleak
Thomas Hindoe Paaboel Andersen [Tue, 25 Aug 2015 21:50:02 +0000 (23:50 +0200)]
test-util: fix a memleak

9 years agoresolve: fix regression in dns-scope
Daniel Mack [Tue, 25 Aug 2015 21:51:34 +0000 (23:51 +0200)]
resolve: fix regression in dns-scope

Bring back a return statement 106784eb errornously removed.

Thanks to @phomes for reporting.

9 years agoMerge pull request #1041 from phomes/master
Daniel Mack [Tue, 25 Aug 2015 21:48:07 +0000 (23:48 +0200)]
Merge pull request #1041 from phomes/master

trivial cleanups

9 years agoMerge pull request #1034 from poettering/resolved-fixes-2
Daniel Mack [Tue, 25 Aug 2015 21:47:30 +0000 (23:47 +0200)]
Merge pull request #1034 from poettering/resolved-fixes-2

various resolved fixes

9 years agomachinectl: remove unused variable
Thomas Hindoe Paaboel Andersen [Tue, 25 Aug 2015 19:10:21 +0000 (21:10 +0200)]
machinectl: remove unused variable

9 years agoexecute: make the invalid entry of the enum -1
Thomas Hindoe Paaboel Andersen [Tue, 25 Aug 2015 19:07:41 +0000 (21:07 +0200)]
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.

9 years agocore: report root cgroup as "/" over the bus
Lennart Poettering [Tue, 25 Aug 2015 18:42:50 +0000 (20:42 +0200)]
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.

9 years agoRevert "systemctl: properly handle empty control group paths in "status""
Lennart Poettering [Tue, 25 Aug 2015 18:37:54 +0000 (20:37 +0200)]
Revert "systemctl: properly handle empty control group paths in "status""

This reverts commit b04c25f9ef6359ed0ae403bdbfe4df840aba0f58.

9 years agonspawn: make sure --template= and --machine= my be combined
Lennart Poettering [Tue, 25 Aug 2015 18:26:51 +0000 (20:26 +0200)]
nspawn: make sure --template= and --machine= my be combined

Fixes #1018.

Based on a patch from Seth Jennings.

9 years agoman: minor fixes to coredumpctl(1)
Lennart Poettering [Tue, 25 Aug 2015 18:04:55 +0000 (20:04 +0200)]
man: minor fixes to coredumpctl(1)

9 years agocoredumpctl: Add --directory option for reading alternate journal
Stef Walter [Tue, 25 Aug 2015 08:36:49 +0000 (10:36 +0200)]
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.

9 years agoresolved: add comments to DNS_PACKET_MAKE_FLAGS() clarifying DNS vs LLMNR
Lennart Poettering [Tue, 25 Aug 2015 16:59:40 +0000 (18:59 +0200)]
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.

9 years agoresolved: make packet flags logic more expressive again
Lennart Poettering [Tue, 25 Aug 2015 16:54:55 +0000 (18:54 +0200)]
resolved: make packet flags logic more expressive again

This partially reverts 106784ebb7b303ae471851100a773ad2aebf5b80, 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.

9 years agoresolved: rename DNS UDP socket to 'dns_udp_fd'
Lennart Poettering [Tue, 25 Aug 2015 16:51:21 +0000 (18:51 +0200)]
resolved: rename DNS UDP socket to 'dns_udp_fd'

This hopefully makes this a bit more expressive and clarifies that the
fd is not used for the DNS TCP socket. This also mimics how the LLMNR
UDP fd is named in the manager object.

9 years agoMerge pull request #1033 from poettering/machine-fixes
Tom Gundersen [Tue, 25 Aug 2015 16:50:44 +0000 (18:50 +0200)]
Merge pull request #1033 from poettering/machine-fixes

misc machine fixes

9 years agobus-util: make more properties settable in --property=
Lennart Poettering [Tue, 25 Aug 2015 16:39:50 +0000 (18:39 +0200)]
bus-util: make more properties settable in --property=

Add a couple of new properties to the supported set we can pass in
systemd-run's and systemd-nspawn's --property= switch.

9 years agoman: add hyphen to improve man text
Lennart Poettering [Tue, 25 Aug 2015 16:37:53 +0000 (18:37 +0200)]
man: add hyphen to improve man text

9 years agocore: drop spurious new line
Lennart Poettering [Tue, 25 Aug 2015 16:37:31 +0000 (18:37 +0200)]
core: drop spurious new line

9 years agomachine: policykit string fixes
Lennart Poettering [Tue, 25 Aug 2015 16:37:16 +0000 (18:37 +0200)]
machine: policykit string fixes

9 years agoMerge pull request #1022 from poettering/machinectl-shell
Tom Gundersen [Tue, 25 Aug 2015 14:46:27 +0000 (16:46 +0200)]
Merge pull request #1022 from poettering/machinectl-shell

Add new "machinectl shell" command for su(1)-like behaviour

9 years agoMerge pull request #1029 from jsynacek/unprivileged-wall-message-v2
Lennart Poettering [Tue, 25 Aug 2015 13:54:23 +0000 (15:54 +0200)]
Merge pull request #1029 from jsynacek/unprivileged-wall-message-v2

logind/systemctl: introduce SetWallMessage and --message

9 years agoNEWS: preparations for v225 release
Daniel Mack [Tue, 25 Aug 2015 13:01:51 +0000 (15:01 +0200)]
NEWS: preparations for v225 release

9 years agoMerge pull request #1030 from zonque/resolve
Tom Gundersen [Tue, 25 Aug 2015 12:33:41 +0000 (14:33 +0200)]
Merge pull request #1030 from zonque/resolve

resolve: minor cleanups

9 years agoresolved: allow dns_cache_put() without a question
Daniel Mack [Tue, 4 Aug 2015 11:53:02 +0000 (13:53 +0200)]
resolved: allow dns_cache_put() without a question

Currently, dns_cache_put() does a number of things:

1) It unconditionally removes all keys contained in the passed
   question before adding keys from the newly arrived answers.

2) It puts positive entries into the cache for all RRs contained
   in the answer.

3) It creates negative entries in the cache for all keys in the
   question that are not answered.

Allow passing q = NULL in the parameters and skip 1) and 3), so
we can use that function for mDNS responses. In this case, the
question is irrelevant, we are interested in all answers we got.

9 years agosd-network: make LLMNR specific config parser generic
Daniel Mack [Tue, 28 Jul 2015 13:00:59 +0000 (15:00 +0200)]
sd-network: make LLMNR specific config parser generic

Rename the enum, the lookup functions and the parser for LLMNRSupport so
the type can be reused for mDNS.

9 years agoresolved: move assertion
Daniel Mack [Tue, 4 Aug 2015 08:37:59 +0000 (10:37 +0200)]
resolved: move assertion

Make a scope with invalid protocol state fail as soon as possible.

9 years agoresolved: use switch-case statements for protocol details
Daniel Mack [Sat, 11 Jul 2015 20:21:26 +0000 (16:21 -0400)]
resolved: use switch-case statements for protocol details

With more protocols to come, switch repetitive if-else blocks with a
switch-case statements.

9 years agologind/systemctl: introduce SetWallMessage and --message
Jan Synacek [Mon, 24 Aug 2015 12:54:22 +0000 (14:54 +0200)]
logind/systemctl: introduce SetWallMessage and --message

Enable unprivileged users to set wall message on a shutdown
operation. When the message is set via the --message option,
it is logged together with the default shutdown message.

$ systemctl reboot --message "Applied kernel updates."

$ journalctl -b -1
...
systemd-logind[27]: System is rebooting. (Applied kernel updates.)
...

9 years agoresolved: remove runtime check for previously asserted condition
Daniel Mack [Tue, 28 Jul 2015 16:09:08 +0000 (18:09 +0200)]
resolved: remove runtime check for previously asserted condition

9 years agoMerge pull request #1023 from poettering/resolved-fixes
Tom Gundersen [Tue, 25 Aug 2015 08:18:16 +0000 (10:18 +0200)]
Merge pull request #1023 from poettering/resolved-fixes

A variety of resolved fixes

9 years agoresolved: change error code when trying to resolve direct LLMNR PTR RRs
Lennart Poettering [Mon, 24 Aug 2015 21:47:28 +0000 (23:47 +0200)]
resolved: change error code when trying to resolve direct LLMNR PTR RRs

If we try to resoolve an LLMNR PTR RR we shall connect via TCP directly
to the specified IP address. We already refuse to do this if the address
to resolve is of a different address family as the transaction's scope.
The error returned was EAFNOSUPPORT. Let's change this to ESRCH which is
how we indicate "not server available" when connecting for LLMNR or DNS,
since that's what this really is: we have no server we could connect to
in this address family.

This allows us to ensure that no server errors are always handled the same
way.

9 years agoresolve-host: support parsing numeric interface names
Lennart Poettering [Mon, 24 Aug 2015 21:46:24 +0000 (23:46 +0200)]
resolve-host: support parsing numeric interface names

If the user specifies an interface by its ifindex we should handle this
nicely. Hence let's try to parse the ifindex as a number before we try
to resolve it as an interface name.

9 years agoresolved: remove duplicate handling of "no servers" query result
Lennart Poettering [Mon, 24 Aug 2015 21:44:33 +0000 (23:44 +0200)]
resolved: remove duplicate handling of "no servers" query result

So far we handled immediate "no server" query results differently from
"no server" results we ran into during operation: the former would cause
the dns_query_go() call to fail with ESRCH, the later would result in
the query completion callback to be called.

Remove the duplicate codepaths, by always going through the completion
callback. This allows us to remove quite a number of lines for handling
the ESRCH.

This commit should not alter behaviour at all.

9 years agoresolved: replace transaction list by hashmap
Lennart Poettering [Mon, 24 Aug 2015 21:15:51 +0000 (23:15 +0200)]
resolved: replace transaction list by hashmap

Right now we keep track of ongoing transactions in a linked listed for
each scope. Replace this by a hashmap that is indexed by the RR key.
Given that all ongoing transactions will be placed in pretty much the
same scopes usually this should optimize behaviour.

We used to require a list here, since we wanted to do "superset" query
checks, but this became obsolete since transactions are now single-key
instead of multi-key.

9 years agomachinectl: extend the "shell" syntax to take user@container names
Lennart Poettering [Mon, 24 Aug 2015 20:44:54 +0000 (22:44 +0200)]
machinectl: extend the "shell" syntax to take user@container names

In order to make "machinectl shell" more similar to ssh, allow the
following syntax to connect to a container under a specific username:

        machinectl shell lennart@fedora

Also beefs up related man page documentation.

9 years agomachinectl: make machine name parameters for "shell" and "login" optional
Lennart Poettering [Mon, 24 Aug 2015 20:17:52 +0000 (22:17 +0200)]
machinectl: make machine name parameters for "shell" and "login" optional

If no machine name is specified, imply that we connect to ".host", i.e.
the local host.

9 years agomachined: beef up PolicyKit actions
Lennart Poettering [Mon, 24 Aug 2015 19:27:37 +0000 (21:27 +0200)]
machined: beef up PolicyKit actions

Introduce separate actions for creating login or shell sessions for
the local host or a local container. By default allow local unprivileged
clients to create new login sessions (which is safe, since getty will
ask for username and authentication).

Also, imply login privs from shell privs, as well as shell and login
privs from manage privs.

9 years agosystemctl: properly handle empty control group paths in "status"
Lennart Poettering [Mon, 24 Aug 2015 19:09:49 +0000 (21:09 +0200)]
systemctl: properly handle empty control group paths in "status"

When showing the status of the "-.slice" slice root unit (whose reported
cgroup path is ""), we suppressed the cgroup tree so far, because
skipped it for all unit with an empty cgroup path. Let's fix that, and
properly handle the empty cgroup path.

9 years agomachined: userns is only supported for container-class machines
Lennart Poettering [Mon, 24 Aug 2015 19:09:16 +0000 (21:09 +0200)]
machined: userns is only supported for container-class machines

We do not support userns for VM machines or for the host itself.

9 years agomachinectl: don't show ".host" pseudo-machine in list by default
Lennart Poettering [Mon, 24 Aug 2015 19:08:04 +0000 (21:08 +0200)]
machinectl: don't show ".host" pseudo-machine in list by default

Let's hide all machines whose name begins with "." by default, thus
hiding the ".host" pseudo-machine, unless --all is specified. This
takes inspiration from the ".host" image handling in "machinectl
list-images" which also hides all images whose name starts with ".".

9 years agomachined: introduce pseudo-machine ".host" refererring to the host system
Lennart Poettering [Mon, 24 Aug 2015 19:05:09 +0000 (21:05 +0200)]
machined: introduce pseudo-machine ".host" refererring to the host system

Some of the operations machined/machinectl implement are also very
useful when applied to the host system (such as machinectl login,
machinectl shell or machinectl status), hence introduce a pseudo-machine
by the name of ".host" in machined that refers to the host system, and
may be used top execute operations on the host system with.

This copies the pseudo-image ".host" machined already implements for
image related commands.

(This commit also adds a PK privilege for opening a PTY in a container,
which was previously not accessible for non-root.)

9 years agomachined: validate machine names at more places
Lennart Poettering [Sun, 23 Aug 2015 12:33:50 +0000 (14:33 +0200)]
machined: validate machine names at more places

When enumerating machines from /run, and when accepting machine names
for operations, be more strict and always validate.

Note that these checks are strictly speaking unnecessary, since
enumeration happens only on the trusted /run...

9 years agoutil: make machine_name_is_valid() a macro and move it to hostname-util.h
Lennart Poettering [Sun, 23 Aug 2015 12:30:52 +0000 (14:30 +0200)]
util: make machine_name_is_valid() a macro and move it to hostname-util.h

As it turns out machine_name_is_valid() does the exact same thing as
hostname_is_valid() these days, as it just invoked that and checked the
name length was < 64. However, hostname_is_valid() checks the length
against HOST_NAME_MAX anyway (which is 64 on Linux), hence any
additional check is redundant.

We hence replace machine_name_is_valid() by a macro that simply maps it
to hostname_is_valid() but sets the allow_trailing_dot parameter to
false. We also move this this call to hostname-util.h, to the same place
as the hostname_is_valid() declaration.

9 years agoutil: make hostname_is_valid() easier to read
Lennart Poettering [Sun, 23 Aug 2015 12:29:59 +0000 (14:29 +0200)]
util: make hostname_is_valid() easier to read

Add more comments, and rename some parameters and variables to be more
expressive.

9 years agomachined: always look for leader PID first
Lennart Poettering [Sun, 23 Aug 2015 12:04:31 +0000 (14:04 +0200)]
machined: always look for leader PID first

When looking for the machine belonging to a PID, always look for the
leader first, only then fall back to a cgroup check. We keep direct
track of the leader PID, but only indirectly of the cgroup, hence prefer
the PID.

9 years agomachinectl: add new "machinectl shell" command
Lennart Poettering [Sun, 23 Aug 2015 11:24:10 +0000 (13:24 +0200)]
machinectl: add new "machinectl shell" command

This makes use of machined's new OpenShell() command and allows opening
a new interactive shell in any container.

9 years agomachined: add new OpenShell() bus call
Lennart Poettering [Sun, 23 Aug 2015 11:20:58 +0000 (13:20 +0200)]
machined: add new OpenShell() bus call

This new bus call opens an interactive shell in a container. It works
like the existing OpenLogin() call, but does not involve getty, and
instead opens an arbitrary command line.

This is similar to "systemd-run -t -M" but is controlled by a specific
PolicyKit privilege.

9 years agocore: open up more executable properties via the bus
Lennart Poettering [Sun, 23 Aug 2015 11:19:21 +0000 (13:19 +0200)]
core: open up more executable properties via the bus

This is preparation for a later commit that makes use of these
properties for spawning an interactive shell in a container.

9 years agocore: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries
Lennart Poettering [Sun, 23 Aug 2015 11:14:04 +0000 (13:14 +0200)]
core: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries

When generating utmp/wtmp entries, optionally add both LOGIN_PROCESS and
INIT_PROCESS entries or even all three of LOGIN_PROCESS, INIT_PROCESS
and USER_PROCESS entries, instead of just a single INIT_PROCESS entry.

With this change systemd may be used to not only invoke a getty directly
in a SysV-compliant way but alternatively also a login(1) implementation
or even forego getty and login entirely, and invoke arbitrary shells in
a way that they appear in who(1) or w(1).

This is preparation for a later commit that adds a "machinectl shell"
operation to invoke a shell in a container, in a way that is compatible
with who(1) and w(1).

9 years agoMerge pull request #1012 from gentoo-root/master
Tom Gundersen [Mon, 24 Aug 2015 16:37:02 +0000 (18:37 +0200)]
Merge pull request #1012 from gentoo-root/master

sd-device: fix enumeration of devices without subsystem