Commit graph

1085 commits

Author SHA1 Message Date
Lennart Poettering 3f624df6cf sd-bus: ignore BLOOM_FILTER kdbus items
The kernel nowadays sends these along, and that's OK, hence don't even
debug log about it, but completely ignore it.
2015-08-06 15:48:33 +03:00
Karel Zak 0610939d6b libsystemd: fix RTNL_CONTAINER_DEPTH assert
The m->n_containers is index and has to be smaller than the array
size.
2015-08-06 13:33:53 +02:00
Thomas Hindoe Paaboel Andersen 7d6884b65e tree-wide: fix indentation 2015-08-06 00:44:19 +02:00
Lennart Poettering 38a03f06a7 sd-event: make sure sd_event_now() cannot fail
Previously, if the event loop never ran before sd_event_now() would
fail. With this change it will instead fall back to invoking now(). This
way, the function cannot fail anymore, except for programming error when
invoking it with wrong parameters.

This takes into account the fact that many callers did not handle the
error condition correctly, and if the callers did, then they kept simply
invoking now() as fall back on their own. Hence let's shorten the code
using this call, and make things more robust, and let's just fall back
to now() internally.

Whether now() is used or the cache timestamp may still be detected via
the return value of sd_event_now(). If > 0 is returned, then the fall
back to now() was used, if == 0 is returned, then the cached value was
returned.

This patch also simplifies many of the invocations of sd_event_now():
the manual fall back to now() can be removed. Also, in cases where the
call is invoked withing void functions we can now protect the invocation
via assert_se(), acknowledging the fact that the call cannot fail
anymore except for programming errors with the parameters.

This change is inspired by #841.
2015-08-03 17:34:49 +02:00
Namhyung Kim ba243e5155 sd-bus: cleanup bus_reset_parsed_address()
Both strv_free() and mfree() return NULL pointer after free.
2015-08-02 23:12:08 +09:00
Namhyung Kim 253f96e53e sd-bus: use mfree() in bus_reset_queues()
Recently mfree() was introduced to reduce work of tedious free + reset
pointers.  Use it in bus_reset_queues() too.
2015-08-02 23:12:08 +09:00
Namhyung Kim 0fd8d506f4 sd-bus: cleanup bus_close_fds()
The safe_close() already checks the fd and returns -1.
2015-08-02 23:12:08 +09:00
Lennart Poettering 58d5d500d8 Merge pull request #813 from dvdhrm/bus-client
busctl: make sure --address connects as bus-client
2015-07-31 20:24:47 +02:00
Daniel Mack 6f7897f9d2 Merge pull request #814 from dvdhrm/mfree
tree-wide: introduce mfree()
2015-07-31 20:17:33 +02:00
David Herrmann 8d87d4a989 busctl: make sure --address connects as bus-client
There is really no reason to use `busctl` to connect to legacy private
bus endpoints. Fix this and make sure `busctl --address=unix:path=/foo`
works!
2015-07-31 20:00:21 +02:00
David Herrmann 97b11eedff tree-wide: introduce mfree()
Pretty trivial helper which wraps free() but returns NULL, so we can
simplify this:
        free(foobar);
        foobar = NULL;
to this:
        foobar = mfree(foobar);
2015-07-31 19:56:38 +02:00
Namhyung Kim cbfa6a4131 busctl: fix assertion failure on --size option
Using --size option triggers an assert failure below because
parse_size() requires the second argument, base, being either 1000 or
1024.  As it's for a packet size, it'd be better using IEC binary
suffix (base 1024) IMHO.

  $ busctl --size 2048
  Assertion 'base == 1000 || base == 1024' failed at src/basic/util.c:2222,
  function parse_size(). Aborting.
  Aborted (core dumped)
2015-08-01 02:20:47 +09:00
Namhyung Kim d28ebe27f2 busctl: add missing description of --size option
The size option was to specify maximum captured patch length but was
missing its description in the command line help.  Add it.
2015-08-01 02:20:37 +09:00
Namhyung Kim c030a850ba busctl: add and use strcmp_ptr()
In member_compare_func(), it compares interface, type and name of
members.  But as it can contain NULL pointer, it needs to check them
before calling strcmp().  So make it as a separate strcmp_ptr
function (named after streq_ptr) so that it can be used by others.

Also let streq_ptr() to use it in order to make the code simpler.
2015-08-01 02:16:24 +09:00
David Herrmann e3c57a86f6 bus-proxy: fix NameAcquired and NameLost to be directed
The NameAcquired and NameLost signals are _directed_ signals. Make sure
we properly set the destination correctly, and verify it in our
proxy-test.
2015-07-31 13:28:21 +02:00
Daniel Mack ed070f131f Merge pull request #787 from dvdhrm/bus-list
sd-bus: fix parsing of KDBUS_CMD_LIST
2015-07-30 15:35:52 +02:00
David Herrmann 89c240e3a5 sd-bus: fix parsing of KDBUS_CMD_LIST
We *must not* assume that an entry returned by KDBUS_CMD_LIST only
carries a single KDBUS_ITEM_OWNED_NAME. Similarly, we already parse
multiple such items for message-metadata, so make sure we support the
same on KDBUS_CMD_LIST.

By relying on the kernel to return all names separately, we limit the
kernel API significantly. Stop this and let the kernel decide how to
return its data.
2015-07-30 14:12:09 +02:00
Daniel Mack 2fc09a9cdd tree-wide: use free_and_strdup()
Use free_and_strdup() where appropriate and replace equivalent,
open-coded versions.
2015-07-30 13:09:01 +02:00
Daniel Mack 65c85ef511 Merge pull request #779 from poettering/fflush-and-check
tree-wide: port everything over to fflush_and_check()
2015-07-29 20:43:54 +02:00
Tom Gundersen 1051d049a8 Merge pull request #764 from ssahani/vxlan1
networkd: Add VXLAN Netlink attributes
2015-07-29 20:40:17 +02:00
Lennart Poettering dacd6cee76 tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error
checking, let's unify all that by using fflush_and_check().

This also unifies the general error paths of fflush()+rename() file
writers.
2015-07-29 20:31:07 +02:00
David Herrmann 03ebf5e89b sd-bus: fix encoding/decoding gvariant root container
The gvariant root container contains a 'variant' at the end, which embeds
the whole message body. This variant *must* contain a structure so we are
compatible to dbus1. Otherwise, it could encode at most 1 type, instead
of a full signature.

Our gvariant message parser already parses the variant-content as a
structure, so we're mostly good. However, it does *not* include the
opening and closing parantheses, nor does it parse them.

This patch fixes the decoder to verify a message contains the
parantheses, and also make the encoder add those parantheses into the
marshaled message.
2015-07-29 16:46:24 +02:00
David Herrmann e53d21d007 sd-bus: fix marshaling of unary type
The unary type has a fixed size of 1 in gvariant. Make sure we properly
encode it as such. Right now, we encode/decode it as empty sequence.
2015-07-29 16:38:14 +02:00
David Herrmann 9a8fb5ae17 sd-bus: drop redundant code
If c->item_size is 0, the next item to parse in a structure is empty.
However, this also implies that the signature must be empty. The latter
case is already handled just fine by enter_struct_or_dict_entry() so
there is no reason to handle the same case in the caller.
2015-07-29 13:03:09 +02:00
David Herrmann a388569f60 sd-bus: don't assert() on valid signatures
Right now sd_bus_message_skip() will abort execution if passed a
signature of the unary type "()". Regardless whether this should be
supported or not, we really must not abort. Drop the incorrect assertion
and add a test-case for this.
2015-07-29 13:03:09 +02:00
Susant Sahani c06aead0c3 sd-netlink: introduce api for new NL type NLA_FLAG 2015-07-29 11:59:16 +05:30
Susant Sahani de566208ee sd-netlink: add support for new type NETLINK_TYPE_FLAG
NETLINK_TYPE_FLAG is NLA_FLAG.

This new type will be used in NLA_FLAG for example

IFLA_VXLAN_GBP  and IFLA_VXLAN_REMCSUM_NOPARTIAL
2015-07-29 11:29:04 +05:30
Susant Sahani 452c956933 sd-netlink: add support for vxlan attributes 2015-07-29 11:28:57 +05:30
Tom Gundersen a494468652 Merge pull request #732 from ssahani/macvtap
networkd: add support for Macvtap
2015-07-28 19:44:02 +02:00
David Herrmann 2d5c8a2756 sd-bus: fix path of object-manager signals
Each signal of the ObjectManager interface carries the path of the object
in question as an argument. Therefore, a caller will deduce the object
this signal is generated for, by parsing the _argument_. A caller will
*not* use the object-path of the message itself (i.e., message->path).
This is done on purpose, so the caller can rely on message->path to be
the path of the actual object-manager that generated this signal, instead
of the path of the object that triggered this signal.

This commit fixes all InterfacesAdded/Removed signals to use the path of
the closest object-manager as message->path. 'closest' in this case means
closest parent with at least one object-manager registered.

This fix raises the question what happens if we stack object-managers in
a hierarchy. Two implementations are possible: First, we report each
object only on the nearest object-manager. Second, we report it on each
parent object-manager. This patch chooses the former. This is compatible
with other existing ObjectManager implementations, which are required to
call GetManagedObjects() recursively on each object they find, which
implements the ObjectManager interface.
2015-07-27 19:15:08 +02:00
Susant Sahani d13125752d sd-netlink: Add macvtap support 2015-07-27 11:18:07 +05:30
Zbigniew Jędrzejewski-Szmek 6e74cadeef netlink-types: use consistent whitespace at EOL
Follow up for v222-124-g79e27dbcb1.
2015-07-24 23:43:51 -04:00
daurnimator 09c8a7c63c sd-bus: add 'offset' member for vtable methods
Defaults to zero, which retains the current behaviour.
Fixes #577
2015-07-24 22:22:54 +10:00
David Herrmann 95cdf5e3a9 sd-bus: don't treat KDBUS_ITEM_TIMESTAMP as unknown item
In bus_kernel_translate_message(), we print a DEBUG message on unknown
items. But right now, we also print this message for KDBUS_ITEM_TIMESTAMP
despite parsing it properly. Fix this!
2015-07-24 12:53:23 +02:00
Susant Sahani 0c1f248ef6 sd-netlink: add bridge NL params 2015-07-23 15:06:03 +05:30
David Herrmann 8cd4eb791a Merge pull request #537 from poettering/nss-mymachines-userns
Hook up container userns with nss-mymachines
2015-07-23 09:53:47 +02:00
Susant Sahani 8aee0f1ff3 sd-netlink: add tunnel params 2015-07-22 15:01:58 +05:30
Tom Gundersen e89f2a98e6 Merge pull request #625 from ssahani/tun2
sd-netlink: add tunnel parameters
2015-07-20 22:30:18 +02:00
Namhyung Kim d41eee127a sd-bus: use isempty() consistently
Instead of open-coding, use isempty() to check NULL or empty string
for consistency.
2015-07-20 23:41:18 +09:00
Susant Sahani 79e27dbcb1 sd-netlink: add tunnel NL parameters 2015-07-20 10:17:14 +05:30
David Herrmann 9afd2b46f2 sd-bus: add new test for NameAcquired via proxy/dbus-daemon
This adds test-bus-proxy which should be used to test correct behavior of
systemd-bus-proxyd. The first test that was added is to verify we actually
receive NameAcquired signals for ourselves on bus-connect.
2015-07-16 16:35:09 +02:00
David Herrmann 1845880757 sd-bus: properly match ID changes
If the caller does not specify arg1 for NameOwnerChanged matches, we
really must take the ID from arg2 or arg3, if provided. They are
guaranteed to be identical to arg1 if either is supplied, but there is no
strict requiredment that arg1 is supplied. Hence, make sure to always
take the more restrictive match. Otherwise, we install rather wide
matches without anyone requiring them.
2015-07-16 15:01:52 +02:00
David Herrmann 1af5f746d5 sd-bus: destination-matches cannot match NameOwnerChanged
Make sure we don't install NameOwnerChanged matches if the caller passed
a destination='' match (except if it is the broadcast address). Per spec,
all NameOwnerChanged signals are broadcasts.

Only the NameLost/NameAcquired signals are unicasts, but those are never
received through sd-bus. Instead, the bus-proxy synthesizes them and it
already installs proper matches for them.
2015-07-16 15:01:52 +02:00
David Herrmann 4f1d774135 sd-bus: fix invalid stack access on test-bus-marshal
Make sure we actually parse "unsigned long long" if we encode a uint64_t.
Otherwise, we will get random data from the stack.
2015-07-16 15:01:52 +02:00
David Herrmann 443a559813 sd-bus: fix gvariant structure encoding
In gvariant, all fixed-size objects need to be sized a multiple of their
alignment. If a structure has only fixed-size members, it is required to
be fixed size itself. If you imagine a structure like (ty), you have an
8-byte member followed by an 1-byte member. Hence, the overall inner-size
is 9. The alignment of the object is 8, though. Therefore, the specs
mandates final padding after fixed-size structures, to make sure it's
sized a multiple of its alignment (=> 16).

On the gvariant decoder side, we already account for this in
bus_gvariant_get_size(), as we apply overall padding to the size of the
structure. Therefore, our decoder correctly skips such final padding when
parsing fixed-size structure.

On the gvariant encoder side, however, we don't account for this final
padding. This patch fixes the structure and dict-entry encoders to
properly place such padding at the end of non-uniform fixed-size
structures.

The problem can be easily seen by running:
    $ busctl --user monitor
and
    $ busctl call --user org.freedesktop.systemd1 / org.foobar foobar "(ty)" 777 8

The monitor will fail to parse the message and print an error. With this
patch applied, everything works fine again.

This patch also adds a bunch of test-cases to force non-uniform
structures with non-pre-aligned positions.

Thanks to Jan Alexander Steffens <jan.steffens@gmail.com> for spotting
this and narrowing it down to non-uniform gvariant structures. Fixes #597.
2015-07-16 11:23:34 +02:00
David Herrmann 7d67077f78 sd-bus: fix object tree to be deeper than 2 levels
So right now our object-tree is limited to 2 levels at most
('/' and '/foo/...../bar'). We never link any intermediate levels, even
though that was clearly the plan. Fix the bus_node_allocate() helper to
actually link all intermediate nodes, too, not just the root node.

This fixes a simple inverse ptr-diff bug.

The downside of this fix is that we clearly never tested (nor used) the
object tree in any way. The only reason that the introspection works is
that our enumerators shortcut the object tree.

Lets see whether that code actually works..

Thanks to: Nathaniel McCallum <nathaniel@themccallums.org>
..for reporting this. See #524 for an actual example code.
2015-07-15 14:39:12 +02:00
David Herrmann bf4c113e17 sd-device: never return NULL+0
It is highly confusing if a getter function returns 0, but the value is
set to NULL. This, right now, triggers assertions as code relies on the
returned values to be non-NULL.

Like with sd-bus-creds and friends, return 0 only if a value is actually
available.

Discussed with Tom, and actually fixes real bugs as in #512.
2015-07-15 12:31:21 +02:00
David Herrmann ca970016b7 Merge commit 'refs/pull/436/head' of https://github.com/systemd/systemd
This merges:
  sd-netlink: respect attribute type flags

..fixing a conflict due to a typo fix.
2015-07-14 19:19:39 +02:00
Tom Gundersen 30494563f2 basic: util - fix errorhandling in unhexmem()
We were ignoring failures from unhexchar, which meant that invalid
hex characters were being turned into garbage rather than the string
rejected.

Fix this by making unhexmem return an error code, also change the API
slightly, to return the size of the returned memory, reflecting the
fact that the memory is a binary blob,and not a string.

For convenience, still append a trailing NULL byte to the returned
memory (not included in the returned size), allowing callers to
treat it as a string without doing a second copy.
2015-07-12 19:11:34 +02:00
Lennart Poettering c01ff965b4 nss-mymachines: map userns users of containers to real user names
Given a container "foo", that maps user id $UID to container user, using
user namespaces, this NSS module extenstion will now map the $UID to a
name "vu-foo-$TUID" for the translated UID $UID.

Similar, userns groups are mapped to "vg-foo-$TGID" for translated GIDs
of $GID.

This simple change should make userns users more discoverable. Also,
given that many tools like "adduser" check NSS before allocating a UID,
should lower the chance of UID range conflicts between tools.
2015-07-09 14:46:20 -03:00
Lennart Poettering 0aa7a4c225 Merge pull request #532 from dvdhrm/bus-managed-root
sd-bus: include queried path in GetManagedObjects
2015-07-09 11:47:55 -03:00
David Herrmann 92d16a53e3 sd-bus: include queried path in GetManagedObjects
If GetManagedObjects is called on /foo/bar, then it should also include
the object /foo/bar, if it exists. Right now, we only include objects
underneath /foo/bar/.

This follows the behavior of existing dbus implementations.

Obsoletes #527 and fixes #525. Reported by: Nathaniel McCallum
2015-07-09 13:30:16 +02:00
David Herrmann 839b6dbba9 sd-bus: sd_bus_slot_get_description() should return const strings
All other *_get_description() functions use 'const char**', so make sure
sd_bus_slot_get_description() does the same.

This changes API, but ABI stays stable. I think this is fine, but I
wouldn't mind bumping SONAME.

Reported in #528.
2015-07-09 10:44:04 +02:00
David Herrmann b80120c4cb logind: fail on CreateSession if already in session
Right now, if you're already in a session and call CreateSession, we
return information about the current session of yours. This is highy
confusing and a nasty hack. Avoid that, and instead return a commonly
known error, so the caller can detect that.

This has the side-effect, that we no longer override XDG_VTNR and XDG_SEAT
in pam_systemd, if you're already in a session. But this sounds like the
right thing to do, anyway.
2015-07-07 19:38:41 +02:00
Zbigniew Jędrzejewski-Szmek af86c44038 Remove repeated 'the's 2015-07-07 07:40:53 -04:00
David Herrmann e1141a9622 sd-bus: support matching on destination names
Right now, we never install destination matches on kdbus as the kernel did
not support MATCH rules on those. With the introduction of
KDBUS_ITEM_DST_ID we can now match on destination IDs, so add explicit
support for those.

This requires a recent kdbus module to work. However, there seems to be no
user-space that uses "Destination=''" matches, yet, so old kdbus modules
still work fine (we couldn't find any real user).

This is needed to match on unicast signals in bus-proxy. A followup will
add support for this.
2015-07-06 17:45:33 +02:00
Torstein Husebø aa6b0ac449 treewide: fix typos 2015-07-06 12:51:16 +02:00
David Herrmann 6acc94b621 Merge pull request #485 from poettering/sd-bus-flush-close-unref
sd-bus: introduce new sd_bus_flush_close_unref() call
2015-07-04 12:41:01 +02:00
David Herrmann 1d44f7584a busctl: flush stdout after dumping data
Running `busctl monitor` currently buffers data for several seconds /
kilobytes before writing stdout. This is highly confusing if you dump in a
file, ^C busctl and then end up with a file with data of the last few
_seconds_ missing.

Fix this by explicitly flushing after each signal.
2015-07-04 12:23:39 +02:00
Lennart Poettering 03976f7b4a sd-bus: introduce new sd_bus_flush_close_unref() call
sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush()
(which writes all unwritten messages out) + sd_bus_close() (which
terminates the connection, releasing all unread messages) +
sd_bus_unref() (which frees the connection).

The combination of this call is used pretty frequently in systemd tools
right before exiting, and should also be relevant for most external
clients, and is hence useful to cover in a call of its own.

Previously the combination of the three calls was already done in the
_cleanup_bus_close_unref_ macro, but this was only available internally.

Also see #327
2015-07-03 19:49:03 +02:00
David Herrmann 0c9cc10dcc sd-bus: don't leak kdbus notifications
When we get notifications from the kernel, we always turn them into
synthetic dbus1 messages. This means, we do *not* consume the kdbus
message, and as such have to free the offset.

Right now, the translation-helpers told the caller that they consumed the
message, which is wrong. Fix this by explicitly releasing all kernel
messages that are translated.
2015-07-02 12:24:05 +02:00
Tom Gundersen 4c641e99fa sd-netlink: respect attribute type flags
Though currently unused by us, netlink attribute types support embedding flags to indicate
if the type is encoded in network byte-order and if it is a nested attribute. Read out
these flags when parsing the message.

We will now swap the byteorder in case it is non-native when reading out integers (though
this is not needed by any of the types we currently support). We do not enforce the NESTED
flag, as the kernel gets this wrong in many cases.
2015-06-30 23:14:53 +02:00
Tom Gundersen 8c2a0730f4 sd-netlink: message - remove unused next_rta_offset field
This was a left-over from before we supported containers.
2015-06-28 19:16:04 +02:00
Tom Gundersen f663aeb80b netlink: rework containers
Instead of representing containers as several arrays, make a new
netlink_container struct and keep one array of these structs. We
also introduce netlink_attribute structs that in the future will
hold meta-information about each atribute.
2015-06-28 19:16:04 +02:00
Tom Gundersen 4203fc8b81 sd-netlink: make a couple of helper functions static
Also rename from rtnl_* to netlink_*.
2015-06-28 19:10:51 +02:00
Tom Gundersen da041d69d1 sd-netlink: mark union containers as nested
This was an oversight, they are no different from regular containers in this respect.
2015-06-28 19:10:51 +02:00
David Herrmann dd906398dd sd-netlink: don't export internal type-system details
The kernel bonding layer allows passing an array of ARP IP targets as
bond-configuration. Due to the weird implementation of arrays in netlink
(which we haven't figure out a generic way to support, yet), we usually
hard-code the supported array-sizes. However, this should not be exported
from sd-netlink.

Instead, make sure the caller just uses it's current hack of enumerating
the types, and the sd-netlink core will have it's own list of supported
array-sizes (to be removed in future extensions, btw!). If either does not
match, we will just return a normal error.

Note that we provide 2 constants for ARP_IP_TARGETS_MAX now. However, both
have very different reasons:
 - the constant in netdev-bond.c is used to warn the user that the given
   number of targets might not be supported by the kernel (even though the
   kernel might increase that number at _any_ time)
 - the constant in sd-netlink is solely used due to us missing a proper
   array implementation. Once that's supported in the type-system, it can
   be removed without notice

Last but not least, this patch turns the log_error() into a log_warning().
Given that the previous condition was off-by-one, anyway, it never hit at
the right time. Thus, it was probably of no real use.
2015-06-24 13:46:15 +02:00
David Herrmann 846a6b3d89 sd-netlink: don't treat NULL as root type-system
Explicitly export the root type-system to the type-system callers. This
avoids treating NULL as root, which for one really looks backwards (NULL
is usually a leaf, not root), and secondly prevents us from properly
debugging calling into non-nested types.

Also rename the root to "type_system_root". Once we support more than
rtnl, well will have to revisit that, anyway.
2015-06-24 13:46:11 +02:00
David Herrmann e7de105cf6 sd-netlink: don't treat type_system->count==0 as invalid
Empty type-systems are just fine. Avoid the nasty hack in
union-type-systems that treat empty type-systems as invalid. Instead check
for the actual types-array and make sure it's non-NULL (which is even true
for empty type-systems, due to "empty_types" array).
2015-06-24 13:45:56 +02:00
David Herrmann 12b7dff45b sd-netlink: make sure the root-level type is nested
In sd-netlink-message, we always guarantee that the currently selected
type-system is non-NULL. Otherwise, we would be unable to parse any types
in the current container level. Hence, this assertion must be true:
    message->container_type_system[m->n_containers] != NULL

During message_new() we currently do not verify that this assertion is
true. Instead, we blindly access nl_type->type_system and use it (which
might be NULL for basic types and unions). Fix this, by explicitly
checking that the root-level type is nested.

Note that this is *not* a strict requirement of netlink, but it's a strict
requirement for all message types we currently support. Furthermore, all
the callers of message_new() already verify that only supported types are
passed, therefore, this is a pure cosmetic check. However, it might be
needed on the future, so make sure we don't trap into this once we change
the type-system.
2015-06-24 13:45:56 +02:00
David Herrmann 979e7eb9cc sd-netlink: drop NETLINK_TYPE_META
The NETLINK_TYPE_META pseudo-type is actually equivalent to an empty
nested type. Drop it and define an empty type-system instead.

This also has the nice side-effect that m->container_type_system[0] is
never NULL (which has really nasty side-effects if you try to read
attributes).
2015-06-24 13:45:56 +02:00
David Herrmann c1df8dee28 sd-netlink: turn 'max' into 'count' to support empty type-systems
Right now we store the maximum type-ID of a type-system. This prevents us
from creating empty type-systems. Store the "count" instead, which should
be treated as max+1.

Note that type_system_union_protocol_get_type_system() currently has a
nasty hack to treat empty type-systems as invalid. This might need some
modification later on as well.
2015-06-24 13:45:47 +02:00
David Herrmann 6c14ad61db sd-netlink: avoid casting size_t into int
size_t is usually 64bit and int 32bit on a 64bit machine. This probably
does not matter for netlink message sizes, but nevertheless, avoid
hard-coding it anywhere.
2015-06-24 13:45:47 +02:00
David Herrmann 435bbb0233 sd-netlink: make NLTypeSystem internal
Same as NLType, move NLTypeSystem into netlink-types.c and hide it from
the outside. Provide an accessor function for the 'max' field that is used
to allocate suitable array sizes.

Note that this will probably be removed later on, anyway. Once we support
bigger type-systems, it just seems impractical to allocate such big arrays
for each container entry. An RBTree would probably do just fine.
2015-06-24 13:45:47 +02:00
David Herrmann 817d1cd824 sd-netlink: make NLType internal
If we extend NLType to support arrays and further extended types, we
really want to avoid hard-coding the type-layout outside of
netlink-types.c. We already avoid accessing nl_type->type_system outside
of netlink-types.c, extend this to also avoid accessing any other fields.

Provide accessor functions for nl_type->type and nl_type->size and then
move NLType away from the type-system header.

With this in place, follow-up patches can safely turn "type_system" and
"type_system_union" into a real "union { }", and then add another type for
arrays.
2015-06-24 13:45:47 +02:00
David Herrmann c658008f50 sd-netlink: don't access type->type_system[_union] directly
Make sure we never access type->type_system or type->type_system_union
directly. This is an implementation detail of the type-system and we
should always use the accessors. Right now, they only exist for 2-level
accesses (type-system to type-system). This patch introduces the 1-level
accessors (type to type-system) and makes use of it.

This patch makes sure the proper assertions are in place, so we never
accidentally access sub-type-systems for non-nested/union types.

Note that this places hard-asserts on the accessors. This should be fine,
as we expect callers to only access sub type-systems if they *know*
they're dealing with nested types.
2015-06-24 13:45:47 +02:00
David Herrmann cafbc790d1 sd-netlink: rename NLA_ to NETLINK_TYPE_
The NLA_ names are used to name real datatypes we extract out of netlink
messages. The kernel has an internal enum with the same names
(NLA_foobar), which is *NOT* binary compatible to our types. Furthermore,
we support a different set of types than the kernel (as we try to treat
some kernel peculiarities as our own types to simplify the API).

Rename NLA_ to NETLINK_TYPE_ to make clear that this is our own set of
types.
2015-06-24 13:45:47 +02:00
Kay Sievers 2c8849add4 build-sys: add all source files and no built files to the tar ball
This fully synchronizes the content of a "make dist" and a "git archive"
tar ball.

  http://lists.freedesktop.org/archives/systemd-devel/2015-June/033214.html
2015-06-23 12:43:15 +02:00
Geert Jansen 969a9685d9 export sd_bus_object_added() / _removed()
Fixes #306.
2015-06-21 22:21:38 -04:00
David Herrmann 9ee7a50c0b bus: fix installing DRIVER matches on kdbus
In kdbus we still have to support org.freedesktop.DBus matches even though
there is no real bus driver. The reason is that bus-control.c turns
NameOwnerChanged matches into proper kdbus matches. If we drop DRIVER
matches early, we will never match on name-changes for kdbus.

Two ways to fix this:

 1) Install DRIVER matches on kdbus (which is the simple way our and which
    is what this patch does).

 2) Properly fix the scope-detection to let NameOwnerChanged matches
    through (or better: block anything with Member!=NameOwnerChanged).
2015-06-17 19:18:37 +02:00
Kay Sievers 1b09f548c7 turn kdbus support into a runtime option
./configure --enable/disable-kdbus can be used to set the default
behavior regarding kdbus.

If no kdbus kernel support is available, dbus-dameon will be used.

With --enable-kdbus, the kernel command line option "kdbus=0" can
be used to disable kdbus.

With --disable-kdbus, the kernel command line option "kdbus=1" is
required to enable kdbus support.
2015-06-17 18:01:49 +02:00
Kay Sievers 73a7e4615d libsystemd: remove list of symbols to export only in the future 2015-06-17 16:21:13 +02:00
Lennart Poettering afc4290e2c Merge pull request #246 from smcv/xpg-not-xdg
Stop talking about the "XDG" version of basename()
2015-06-17 13:08:15 +02:00
Simon McVittie 11c9f1e48a Stop talking about the "XDG" version of basename()
XDG refers to X Desktop Group, a former name for freedesktop.org.
This group is responsible for specifications like basedirs,
.desktop files and icon naming, but as far as I know, it has never
tried to redefine basename().

I think these references were meant to say XPG (X/Open Portability
Guide), a precursor of POSIX. POSIX is better-known and less easily
confused with XDG, and is how the basename(3) man page describes
the libgen.h version of basename().

The other version of basename() is glibc-specific and is described
in basename(3) as "the GNU version"; specifically mention that
version, to disambiguate.
2015-06-17 11:23:46 +01:00
David Herrmann 9d8a5fd3e6 Merge pull request #244 from poettering/sdbus-suppress-local
sd-bus: suppress installing local bus matches server side
2015-06-17 12:20:03 +02:00
Lennart Poettering cc65fe5e14 sd-bus: suppress installing local bus matches server side
Matches that can only match against messages from the
org.freedesktop.DBus.Local service (or the local interfaces or path)
should never be installed server side, suppress them hence.

Similar, on kdbus matches that can only match driver messages shouldn't
be passed to the kernel.
2015-06-17 11:42:39 +02:00
Lennart Poettering 59787a5c66 Merge pull request #239 from dvdhrm/event-assert
sd-event: make errors on EPOLL_CTL_DEL pseudo-fatal
2015-06-17 10:37:43 +02:00
David Herrmann 366e641139 sd-event: make errors on EPOLL_CTL_DEL pseudo-fatal
If we call EPOLL_CTL_DEL, we *REALLY* expect the file-descriptor to be
present in that given epoll-set. We actually track such state via our
s->io.registered flag, so it better be true.

Make sure if that's not true, we treat it similar to assert_return() (ie.,
print a loud warning).
2015-06-17 09:13:48 +02:00
Kay Sievers aac7c5ed8b build-sys: hide magic section variables from exported symbols
https://github.com/systemd/systemd/issues/234
2015-06-17 07:29:15 +02:00
Michal Schmidt 9ef41ffeec Merge pull request #197 from dvdhrm/hashmap
hashmap: fix iterators to not skip entries
2015-06-16 14:44:43 +02:00
Umut Tezduyar Lindskog dcf6952028 sd-bus: use proper cleanup macro 2015-06-16 11:20:10 +02:00
Lennart Poettering 72c0a2c255 everywhere: port everything to sigprocmask_many() and friends
This ports a lot of manual code over to sigprocmask_many() and friends.

Also, we now consistly check for sigprocmask() failures with
assert_se(), since the call cannot realistically fail unless there's a
programming error.

Also encloses a few sd_event_add_signal() calls with (void) when we
ignore the return values for it knowingly.
2015-06-15 20:13:23 +02:00
David Herrmann 8927b1dad2 hashmap: fix iterators to not skip entries
Currently, the HASHMAP iterators stop at the first NULL entry in a
hashmap. This is non-obvious and breaks users like sd-device, which
legitimately store NULL values in a hashmap.

Fix all the iterators by taking a pointer to the value storage, instead of
returning it. The iterators now return a boolean that tells whether the
end of the list was reached.

Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check
for NULL. If it turns out, there were users that inserted NULL into
hashmaps, but didn't properly check for it during iteration, then we
really want to find those and fix them.
2015-06-14 16:56:02 +02:00
Tom Gundersen b95cc756de sd-netlink: socket - move some functions from main source file 2015-06-13 21:25:05 +02:00
Tom Gundersen 89489ef7d4 sd-netlink: message - split up source file
Split netlink-socket.c and rtnl-message.c from netlink-message.c.
2015-06-13 21:11:01 +02:00
Tom Gundersen bbe181b489 sd-netlink: drop the write-queue
AF_NETLINK is not write-buffered, so this was actually never used.
2015-06-13 20:51:56 +02:00
Tom Gundersen 1c4baffc18 sd-netlink: rename from sd-rtnl 2015-06-13 19:52:54 +02:00
David Herrmann ed810b68d3 Merge pull request #171 from teg/rtnl-broadcast-2
sd-rtnl: make joining broadcast groups implicit
2015-06-11 18:05:18 +02:00
Tom Gundersen 31710be527 sd-rtnl: make joining broadcast groups implicit 2015-06-11 17:47:40 +02:00
Tom Gundersen 2ce8483538 sd-rtnl: use netlink header rather than ucred in socket_recv_message()
Lets us simplify the function and drop SO_PASSCRED.

Thanks to Alexander Larsson and David Herrmann.
2015-06-11 16:14:59 +02:00
Lennart Poettering 64b8c0d030 Merge pull request #158 from ssahani/net
Net
2015-06-11 11:52:58 +02:00
Kay Sievers a095315b3c build-sys: split internal basic/ library from shared/
basic/      can be used by everything
            cannot use anything outside of basic/

libsystemd/ can use basic/
            cannot use shared/

shared/     can use libsystemd/
2015-06-11 10:52:46 +02:00
Susant Sahani 3de1c8ceab sd-network: fix CID 1306198 2015-06-11 14:08:56 +05:30
Lennart Poettering d112701190 Merge pull request #148 from teg/sd-network-race
sd-network: allow the state dir to be created after the monitor
2015-06-10 20:43:38 +02:00
David Herrmann 26589352b2 bus: we now support path_namespace=/
Our bloom-filters support root-path matching. Make sure we properly add
the path_namespace= tag.
2015-06-10 20:22:40 +02:00
David Herrmann 744dccdd36 bus: fix pattern matching
DBus-spec defines two different pattern matchings:

  1) Path and namespace prefix matching. In this case, A matches B either
     if both are equal, or if B is fully included in the namespace of A.
     In other words, A has to be a prefix of B, but end with a separator
     character (or the following character in B must be one).

     This is used for path_namespace= and arg0namespace=

  2) The other pattern matching is used for arg0path= which does a two-way
     matching. That is, A must be a prefix of B, or B a prefix of A.
     Furthermore, the prefix must end with a separator.

Fix the sd-bus helpers to reflect that. The 'simple_' and 'complex_'
prefixes don't make any sense now, but.. eh..
2015-06-10 20:22:40 +02:00
David Herrmann 2e90f867f9 bus: fix test-bus-kerne-bloom.c to match properly
Make sure we actually verify our match-rules are executed properly. Right
now all we test is the bloom-matches, which are non-reliable as they leave
through false-positives.
2015-06-10 20:22:40 +02:00
David Herrmann a867b00226 bus: fix arg0path= two-way matching
DBus spec clearly defines arg0path= to be a two-way matching. That is,
either the matcher or the matchee can be a prefix of the other to match.
This is not possible to implement with bloom-filters. Instead, we'd have
to add a separate filter for each prefix. This is non-trivial, though.
Hence, just skip the match for now and match locally.
2015-06-10 20:22:40 +02:00
David Herrmann 7cd4dbe9ca bus: fix bloom_add_prefixes() to add all required data
Lets look at an example where we add arg0="/foo/bar/waldo" to a
bloom-filter. The following strings are added:
  "arg0:/foo/bar/waldo"
  "arg0-slash-prefix:/foo/bar"
  "arg0-slash-prefix:/foo"

Two problems arise:

1) If we match on "arg0path=/foo/bar/waldo", the dbus-spec explicitly
states that equal strings are also considered prefixes. However, in the
bloom-match, we can only provide a single match-filter. Therefore, we have
to add "arg0-slash-prefix:/foo/bar/waldo" there, but this never occured in
the bloom-mask of the message.
Hence, this patch makes sure bloom_add_prefixes() adds the full path as
prefix, too.

2) If we match on "arg0path=/foo/", the dbus-spec states that arg0path
does prefix-matching with the trailing slash _included_, unlike
path_namespace= matches, which does *not* include them. This is
inconsistent, but we have to support the specs. Therefore, we must add
prefixes with _and_ without trailing separators.
Hence, this patch makes sure bloom_add_prefixes() adds all prefixes with
the trailing slash included.

The final set of strings added therefore is:
  "arg0:/foo/bar/waldo"
  "arg0-slash-prefix:/foo/bar/waldo"
  "arg0-slash-prefix:/foo/bar/"
  "arg0-slash-prefix:/foo/bar"
  "arg0-slash-prefix:/foo/"
  "arg0-slash-prefix:/foo"
  "arg0-slash-prefix:/"
2015-06-10 20:22:40 +02:00
Tom Gundersen 870395a4d8 sd-network: allow the state dir to be created after the monitor
We now listen for new subdirs of /run/systemd, and /run/systemd/netif in case
/run/systemd/netif/links does not exist.
2015-06-10 20:08:11 +02:00
Lennart Poettering 2a1288ff89 util: introduce CMSG_FOREACH() macro and make use of it everywhere
It's only marginally shorter then the usual for() loop, but certainly
more readable.
2015-06-10 19:29:47 +02:00
Lennart Poettering 5410b2ed62 Merge pull request #142 from teg/sd-network-unref-NULL
sd-network: allow NULL in sd_network_monitor_unref
2015-06-10 16:59:43 +02:00
Tom Gundersen 0b3476266f sd-network: allow NULL in sd_network_monitor_unref
Match rest of codebase, we always allow unref'ing NULL.
2015-06-10 16:34:43 +02:00
Zbigniew Jędrzejewski-Szmek b078b5a7ab Merge pull request #85 from keszybz/selinux-context 2015-06-10 10:20:50 -04:00
Lennart Poettering aa0d0ed6b8 sd-bus: remove ucred parameter from bus_message_from_header() since we don't use it anymore 2015-06-10 15:52:52 +02:00
Lennart Poettering 3c42e8b281 sd-bus: fix early exit when we lack all data in bus_get_owner_creds_dbus1() 2015-06-10 15:52:52 +02:00
Lennart Poettering b56c4604fa bus-message: remove shadow warning with log_debug_bus_message() 2015-06-10 15:52:52 +02:00
Zbigniew Jędrzejewski-Szmek c4e6556c46 sd-bus: store selinux context at connection time
This appears to be the right time to do it for SOCK_STREAM
unix sockets.

Also: condition bus_get_owner_creds_dbus1 was reversed. Split
it out to a separate variable for clarity and fix.

https://bugzilla.redhat.com/show_bug.cgi?id=1224211
2015-06-10 09:12:57 -04:00
Zbigniew Jędrzejewski-Szmek d868f2a3a1 sd-bus: do not use per-datagram auxiliary information
SELinux information cannot be retrieved this way, since we are
using stream unix sockets and SCM_SECURITY does not work for
them.

SCM_CREDENTIALS use dropped to be consistent. We also should
get this information at connection time.

https://bugzilla.redhat.com/show_bug.cgi?id=1224211
"SCM_SECURITY was only added for datagram sockets."
2015-06-10 09:03:57 -04:00
Torstein Husebø 348d8cc8d7 sd-bus: Correct typo 2015-06-10 13:08:31 +02:00
Lennart Poettering 9eb212568f Merge pull request #117 from utezduyar/feat/dump-sync-dbus-message-with-logging-on
sd-bus: dump sync messages in debug mode
2015-06-10 11:38:12 +02:00
Umut Tezduyar Lindskog f9f97ca692 sd-bus: dump sync messages in debug mode 2015-06-10 09:22:32 +02:00
Lennart Poettering cde40acc80 logind,sd-event: drop spurious new-lines 2015-06-10 01:28:58 +02:00
Lennart Poettering ce30c8dcb4 tree-wide: whenever we fork off a foreign child process reset signal mask/handlers
Also, when the child is potentially long-running make sure to set a
death signal.

Also, ignore the result of the reset operations explicitly by casting
them to (void).
2015-06-10 01:28:58 +02:00
Zbigniew Jędrzejewski-Szmek 236f83afa9 bus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask
Also reorder the code a bit to be easier to parse.
2015-06-09 09:13:35 -04:00
Umut Tezduyar Lindskog 5d941c92bd sd-bus: add async convenience method call API 2015-06-09 08:14:56 +02:00
David Herrmann ed47f6397d bus: don't force send-masks on kdbus buses
Right now we always pass KDBUS_ITEM_ATTACH_FLAGS_RECV to
KDBUS_CMD_BUS_MAKE, effectively forcing every bus connection to do the
same during KDBUS_CMD_HELLO. This used to be a workaround to make sure all
metadata is always present. However, we refrained from that approach and
intend to make all metadata collection solely rely on /proc access
restrictions. Therefore, there is no need to force the send-flags mask on
newly created buses.
2015-06-05 15:23:03 +02:00
David Herrmann a34333a1d1 bus: update kdbus.h
Sync with upstream.
2015-06-04 20:26:21 +02:00
Tom Gundersen f68067348f sd-event: don't touch fd's accross forks
We protect most of the API from use accross forks, but we still allow both
sd_event and sd_event_source objects to be unref'ed. This would cause
problems as it would unregister sources from the underlying eventfd, hence
also affecting the original instance in the parent process.

This fixes the issue by not touching the fds on unref when done accross a fork,
but still free the memory.

This fixes a regression introduced by
        "udevd: move main-loop to sd-event": 693d371d30

where the worker processes were disabling the inotify event source in the
main daemon.
2015-06-04 19:04:26 +02:00
Kay Sievers f9748d8148 Merge pull request #65 from teg/enumerate-accept-null
libudev: enumerate - accept NULL parameters in add_match()
2015-06-03 22:48:01 +02:00
Kay Sievers 6517217d49 kdbus: remove attach_flags_mask module parameter setting 2015-06-03 22:24:16 +02:00
Tom Gundersen 54f0b4d9a3 libudev: enumerate - accept NULL parameters in add_match()
This was a regression introduced when moving to sd-device.
2015-06-03 22:08:46 +02:00
Thomas Hindoe Paaboel Andersen 7e518afab9 fix double semicolon typo 2015-06-02 23:29:20 +02:00
Tom Gundersen 7283a80d10 sd-device: get_driver - remember if a device does not have a driver
Don't try to read it again.
2015-06-02 18:12:47 +02:00
Tom Gundersen 4189708ad0 sd-device: get_subsystem - don't complain if a device does not have a subsystem 2015-06-02 18:12:47 +02:00
Tom Gundersen ccc1002a1c sd-device: ensure update_properties_buf() is a noop on failure
Don't clobber the sd_device struct, and don't leak memory when memory allocation fails.
2015-06-01 16:28:58 +02:00
Martin Pitt d854ba50a8 sd-device: fix invalid property strv pointers
In device_update_properties_bufs(), the strv is built from pointers into the
single nul-terminated buf_nulstr string, to avoid allocating the key=value
strings twice. However, we must not do that while building and
GREEDY_REALLOC0()'ing buf_nulstr, as each time when this actually reallocates
memory the pointers we wrote into buf_strv so far become invalid.

So change the logic to first completely build the new buf_nulstr, and then
iterate over it to pick out the pointers to the individual key=value strings
for properties_strv.

This fixes invalid environment for udev callouts.
2015-06-01 12:04:37 +02:00
Lennart Poettering 24882e06c1 util: split out signal-util.[ch] from util.[ch]
No functional changes.
2015-05-29 20:14:11 +02:00
Tom Gundersen 5f529f4c97 sd-device: enumerator - fix matching on properties and sysattrs
This was a regression that broke

  $ udevadm trigger -nv --property-match=DEVNAME=/dev/sda1 --attr-match=size=409600

Reported by David Reisner.
2015-05-28 17:35:46 +02:00
Tom Gundersen 0e3e605613 sd-device: fix device_get_properties_strv()
A NULL pointer was inserted as the first element of the strv.

This had the effect of always passing the empty environment to processes
spawned by udev.

Reported by Michał Bartoszkiewicz.
2015-05-27 23:30:02 +02:00
Torstein Husebø 45afd51974 treewide: fix typos 2015-05-26 19:55:51 +02:00
Lennart Poettering 882897afee sd-bus,sd-event: make public APIs
With the v221 release these APIs should be public, stable APIs, hence
let's install their headers by default now, and add their symbols to the
.sym file.
2015-05-22 14:32:51 +02:00
Zbigniew Jędrzejewski-Szmek 53fae771bc sd-device: fix return codes on error
asprintf() does not set errno.
2015-05-20 23:44:46 -04:00
Zbigniew Jędrzejewski-Szmek 7f4e6a1ceb bus-socket: simplify initalization of struct msghdr 2015-05-19 23:41:38 -04:00
Jan Synacek 57ab2eabb8 systemctl: introduce --now for enable, disable and mask
https://bugs.freedesktop.org/show_bug.cgi?id=42940
2015-05-15 11:59:36 +02:00
Lennart Poettering 0e85114376 test-bus-chat: various modernizations 2015-05-14 22:41:19 +02:00
Cristian Rodríguez 2f50a2d55b sd-bus: fix memory leak in test-bus-chat
Building with address sanitizer enabled on GCC 5.1.x a memory leak
is reported because we never close the bus, fix it by using
cleanup variable attribute.
2015-05-14 22:36:35 +02:00
Lennart Poettering 6e6c21c894 util: introduce memmem_safe() and make use of it
GNU memmem() requires a nonnull first parameter. Let's introduce
memmem_safe() that removes this restriction for zero-length parameters,
and make use of it where appropriate.

http://lists.freedesktop.org/archives/systemd-devel/2015-May/031705.html
2015-05-14 11:32:41 +02:00
Torstein Husebø ff9b60f38b treewide: Correct typos and spell plural of bus consistent 2015-05-11 15:51:30 +02:00
David Herrmann d79acc3093 bus: don't switch to kdbus if not requested
Whenever systemd is re-executed, it tries to create a system bus via
kdbus. If the system did not have kdbus loaded during bootup, but the
module is loaded later on manually, this will cause two system buses
running (kdbus and dbus-daemon in parallel).

This patch makes sure we never try to create kdbus buses if it wasn't
explicitly requested on the command-line.
2015-05-06 18:21:51 +02:00
Lennart Poettering 6bd68a1aa2 sym: adding missing symbols to .sym file 2015-04-30 12:01:19 +02:00
Lennart Poettering 329ac4bc54 sd-bus,sd-login: add api for querying the slice within the the user systemd instance of a process
units are organized in slice trees, not only for the system instance,
but also for user systemd instances, expose this properly.
2015-04-30 11:58:06 +02:00
Lennart Poettering 524d896ac1 sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version
As perparation for future incompatible kdbus kernel API changes.
2015-04-30 01:24:48 +02:00
Susant Sahani 9011ce771f networkd: introduce vti6 tunnel
This patch add support to create vti6 tunnel

test:

vt6.network
[Match]
Name=wlan0

[Network]
Tunnel=ip6vti

vti6.netdev
[NetDev]
Name=ip6vti
Kind=vti6

[Tunnel]
Local=2a00:ffde:4567:edde::4987
Remote=2001:473:fece:cafe::5179

ip link

11: ip6_vti0@NONE: <NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default
    link/tunnel6 :: brd ::
12: ip6vti@wlan0: <POINTOPOINT,NOARP> mtu 1500 qdisc noop state DOWN
mode DEFAULT group default
    link/tunnel6 2a00:ffde:4567:edde::4987 peer 2001:473:fece:cafe::5179
2015-04-29 21:54:00 +02:00
Lennart Poettering cfeaa44a09 sd-bus: properly handle creds that are known but undefined for a process
A number of fields do not apply to all processes, including: there a
processes without a controlling tty, without parent process, without
service, user services or session. To distuingish these cases from the
case where we simply don't have the data, always return ENXIO for them,
while returning ENODATA for the case where we really lack the
information.

Also update the credentials dumping code to show this properly. Fields
that are known but do not apply are now shown as "n/a".

Note that this also changes some of the calls in process-util.c and
cgroup-util.c to return ENXIO for these cases.
2015-04-29 21:45:58 +02:00
Lennart Poettering 9030ca462b sd-bus: allow passing NULL as bus parameter to sd_bus_send()
If NULL is specified for the bus it is now automatically derived from
the passed in message.

This commit also changes a number of invocations of sd_bus_send() to
make use of this.
2015-04-29 18:58:30 +02:00
Lennart Poettering 190700621f sd-bus: drop bus parameter from message callback prototype
This should simplify the prototype a bit. The bus parameter is redundant
in most cases, and in the few where it matters it can be derived from
the message via sd_bus_message_get_bus().
2015-04-29 18:36:25 +02:00
Tom Gundersen a9beb123d1 test: rename test-bus-kernel-benchmark to test-bus-benchmark
This can now benchmark more than just kdbus.
2015-04-29 17:08:31 +02:00
Tom Gundersen 77cfd1139c sd-bus: benchmark - also support testing non-kdbus transports
We introduce two news types of benchmarks in chart-mode:
 - 'legacy' connects using the session bus
 - 'direct' connects using a peer-to-peer socket

We should probably also introduce a mode for testing the dbus1-kdbus proxy.
2015-04-29 17:08:31 +02:00
Lennart Poettering fe506d569d bus-util: drop redundant bus argument from bus_message_map_all_properties() and related calls 2015-04-28 21:34:23 +02:00
Lennart Poettering de158ed22d run: synchronously wait until the scope unit we create is started
Otherwise it might happen that by the time PID 1 adds our process to the
scope unit the process might already have died, if the process is
short-running (such as an invocation to /bin/true).

https://bugs.freedesktop.org/show_bug.cgi?id=86520
2015-04-28 12:21:31 +02:00
Lennart Poettering 373a99e489 bus-util: print correct warnings for units that fail but for which we have a NULL result only 2015-04-28 12:12:29 +02:00
Tom Gundersen 7141e4f62c sd-device: don't retry loading uevent/db files more than once
If for whatever reason there was nothing to load or loading failed, don't keep trying.
2015-04-26 01:30:23 +02:00
Tom Gundersen 2a2137401b sd-device: don't complain if the uevent file is missing
Only 'real' devices are required to have an uevent file.
2015-04-26 01:30:23 +02:00
Daniel Mack d71618654a sd-bus: teach bus_print_property() how to print SD_BUS_TYPE_INT64 2015-04-24 17:51:08 +02:00
Tom Gundersen 107f2e2526 udevd: fix REMOVE handling
This reverts b67f944. Lazy loading of device properties does not work for devices
that are received over netlink, as these are sealed. Reinstate the unconditional
loading of the device db.

Reported by: Mantas Mikulėnas <grawity@gmail.com>.
2015-04-23 22:31:25 +02:00
Lennart Poettering 4761e880ae sd-bus: add controlling tty field to sd_creds object
This is useful to print wall messages from logind with the right client
tty. (to be added in a later patch)
2015-04-23 19:43:40 +02:00
Lennart Poettering 33c62dcbd7 sd-bus: when bus operations are to be executed on direct connections always fail
Also, don't consider this an loggable event, so that code that tries to
read creds from a direct connection, doesn't generate logs.
2015-04-23 16:23:15 +02:00
Lennart Poettering 038f9863e2 sd-bus: don't inherit connection creds into message creds when we have a direct connection
It's never a good idea, let's just not do it, not even on dierct
connections.
2015-04-23 13:40:54 +02:00
Lennart Poettering 0674bbea9c core: explicitly specify credentials for direct connections, too
So far we authenticate direct connections primarily at connection time,
but let's also do this for each method individually, by attaching the
creds we need for that right away.
2015-04-23 00:37:47 +02:00
Lennart Poettering 3a69881704 sd-bus: handle ppid=0 more gracefully (which happens for pid=1) 2015-04-22 13:27:53 +02:00
Lennart Poettering 1386e47db5 sd-bus: expose ppid field
kdbus has been passing us the ppid file for a while, actually make use
of it.
2015-04-21 20:58:09 +02:00
Tom Gundersen 52d629010d sd-device: set_syspath - return ENODEV when passed something that is not a device 2015-04-21 14:41:13 +02:00
Lennart Poettering 0f51442056 sd-bus: when augmenting creds, remember which ones were augmented
Also, when we do permissions checks using creds, verify that we don't do
so based on augmented creds, as extra safety check.
2015-04-21 00:58:56 +02:00
Lennart Poettering 822d9b6e4c sd-bus: augmenting cgroups-based creds when we have the cgroup path already is free 2015-04-21 00:58:56 +02:00
Lennart Poettering f887fa73ee sd-bus: when augmenting creds, don't override any creds in any case
Let's better be safe than sorry.
2015-04-21 00:58:56 +02:00
Lennart Poettering da634f97eb sd-bus: when copying creds objects, make sure we copy even the implicit well known names 2015-04-21 00:58:56 +02:00
Susant Sahani 81bd37a85f networkd: Add support for bond option.
This patch adds configurational support for bond option.

Test conf:

bond.netdev

 ---
[NetDev]
Name=bond1
Kind=bond

[Bond]
ArpAllTargets=all
PrimaryReselect=better
ArpIntervalSec=10s
ArpIpTargets= 192.168.8.102 192.168.8.101 192.168.8.102
 ---

$cat /proc/net/bonding/bond1
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 10000
ARP IP target/s (n.n.n.n form): 192.168.8.100, 192.168.8.101, 192.168.8.102
2015-04-20 20:14:34 +02:00
David Herrmann 18ae3d98d9 sd-device: simplify enumerator hacks
Boolean arithmetic is great, use it!

    if (a && !b)
      return 1;
    if (!a && b)
      return -1,

is equivalent to

    if (a != b)
      return a - b;

Furthermore:

    r = false;
    if (condition)
        r = true;

is equivalent to:

    r = condition;
2015-04-17 15:22:13 +02:00
Tom Gundersen 08232a020b sd-device: uniformly handle missing devices
sd_device_new_from_* now returns -ENODEV when the device does not exist, and the enumerator
silently drops these errors as missing devices is exepected.
2015-04-17 14:55:40 +02:00
Tom Gundersen dee5e0b6c2 sd-device: enumerator - match only on initialized devices by default
It is still possible to include uninitialized ones, but now that is opt-in. In most
cases people only want initialized devices. Exception is if you want to work without
udev running.

Suggested by David Herrmann.
2015-04-17 14:16:16 +02:00
Tom Gundersen 19c9df4492 sd-device: enumerator - don't expose add_device()
This is rarely, if ever, used. Drop it from the new public API and only keep it for
the legacy API.

Suggested by David Herrmann.
2015-04-17 14:15:47 +02:00
Tom Gundersen 96df036fe3 sd-device: add device-enumerator library 2015-04-16 16:47:23 +01:00
Lennart Poettering 2d0c156134 sd-bus: add more comments to the credential decision logic 2015-04-16 17:28:15 +02:00
Zbigniew Jędrzejewski-Szmek 813a71a206 sd-device: fix typo 2015-04-14 20:16:02 -04:00
Tom Gundersen 5a917c064b sd-devcie: fix typo 2015-04-14 16:55:18 +02:00
Tom Gundersen 85091685af sd-device: fix reading of subsystem 2015-04-14 16:19:37 +02:00
Tom Gundersen bba061662b sd-device: allow uevent files to be write-only 2015-04-14 16:19:37 +02:00
Zbigniew Jędrzejewski-Szmek a61cc460e8 bus-util: add articles to explanation messages
We are talking about one member of a group of things (resource limits, signals,
timeouts), without specifying which one. An indenfinite article is in order.

When we are talking about the control process, it's a specific one, so the
definite article is used.
2015-04-12 10:20:36 -04:00
David Herrmann 98a4c30ba1 bus: implement bus_path_{en,de}code_unique()
Whenever we provide a bus API that allows clients to create and manage
server-side objects, we need to provide a unique name for these objects.
There are two ways to provide them:
  1) Let the server choose a name and return it as method reply.
  2) Let the client pass its name of choice in the method arguments.

The first method is the easiest one to implement. However, it suffers from
a race condition: If a client creates an object asynchronously, it cannot
destroy that object until it received the method reply. It cannot know the
name of the new object, thus, it cannot destroy it. Furthermore, this
method enforces a round-trip. If the client _depends_ on the method call
to succeed (eg., it would close() the connection if it failed), the client
usually has no reason to wait for the method reply. Instead, the client
can immediately schedule further method calls on the newly created object
(in case the API guarantees in-order method-call handling).

The second method fixes both problems: The client passes an object name
with the method-call. The server uses it to create the object. Therefore,
the client can schedule object destruction even if the object-creation
hasn't finished, yet (again, requiring in-order method-call handling).
Furthermore, the client can schedule further method calls on the newly
created object, before the constructor returned.

There're two problems to solve, though:
  1) Object names are usually defined via dbus object paths, which are
     usually globally namespaced. Therefore, multiple clients must be able
     to choose unique object names without interference.
  2) If multiple libraries share the same bus connection, they must be
     able to choose unique object names without interference.

The first problem is solved easily by prefixing a name with the
unique-bus-name of a connection. The server side must enforce this and
reject any other name.
The second problem is solved by providing unique suffixes from within
sd-bus. As long as sd-bus always returns a fresh new ID, if requested,
multiple libraries will never interfere. This implementation re-uses
bus->cookie as ID generator, which already provides unique IDs for each
bus connection.

This patch introduces two new helpers:
  bus_path_encode_unique(sd_bus *bus,
                         const char *prefix,
                         const char *sender_id,
                         const char *external_id,
                         char **ret_path);
    This creates a new object-path via the template
    '/prefix/sender_id/external_id'. That is, it appends two new labels to
    the given prefix. If 'sender_id' is NULL, it will use
    bus->unique_name, if 'external_id' is NULL, it will allocate a fresh,
    unique cookie from bus->cookie.

  bus_path_decode_unique(const char *path,
                         const char *prefix,
                         char **ret_sender,
                         char **ret_external);
    This reverses what bus_path_encode_unique() did. It parses 'path' from
    the template '/prefix/sender/external' and returns both suffix-labels
    in 'ret_sender' and 'ret_external'. In case the template does not
    match, 0 is returned and both output arguments are set to NULL.
    Otherwise, 1 is returned and the output arguments contain the decoded
    labels.

Note: Client-side allocated IDs are inspired by the Wayland protocol
      (which itself was inspired by X11). Wayland uses those IDs heavily
      to avoid round-trips. Clients can create server-side objects and
      send method calls without any round-trip and waiting for any object
      IDs to be returned. But unlike Wayland, DBus uses gobally namespaced
      object names. Therefore, we have to add the extra step by adding the
      unique-name of the bus connection.
2015-04-11 13:27:49 +02:00
Ronny Chevalier 288a74cce5 shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
Ronny Chevalier 3df3e884ae shared: add random-util.[ch] 2015-04-11 00:11:13 +02:00
Ronny Chevalier 0b452006de shared: add process-util.[ch] 2015-04-10 23:54:49 +02:00
Ronny Chevalier 6482f6269c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
Lennart Poettering 53bac4e0e3 sd-event: simplify sd_event_run() 2015-04-10 18:45:39 +02:00
Michal Sekletar d5cad22109 bus-util: be more verbose if dbus job fails
Users might have hard time figuring out why exactly their systemctl request
failed. If dbus job fails try to figure out more details about failure by
examining Result property of the service.

https://bugzilla.redhat.com/show_bug.cgi?id=1016680
2015-04-10 17:36:07 +02:00
David Herrmann 43ef760376 bus: simplify bus_message_read_strv_extend()
Avoid unbound for(;;) loop and use the established coding-style:
  while ((r = sd_bus_message_read*(...)) > 0) {
  }
  if (r < 0)
          return r;

This is much easier to read and used all over the code base.
2015-04-09 22:59:59 +02:00
David Herrmann 0704ea57b7 bus: use free_and_strdup()
Save some LOCs by replacing strdup()+error-handling+free+assign with
free_and_strdup().
2015-04-09 22:59:59 +02:00
Lennart Poettering 019c7fba75 util: add shell_maybe_quote() call for preparing a string for shell cmdline inclusion
If necessary the passed string is enclosed in "", and all special
characters escapes.

This also ports over usage in bus-util.c and job.c to use this, instead
of a incorrect local implementation that forgets to properly escape.
2015-04-09 18:32:21 +02:00
Lennart Poettering de79f906ab sd-rtnl: properly size attribute array if IFA_FLAGS was missing 2015-04-08 12:56:57 +02:00
Lennart Poettering ceb2422926 polkit: rename bus_verify_polkit() to bus_test_polkit() and make it strictly non-interactive
Interactive authorization should only happen asynchronously, hence
disallow it in synchronous bus_verify_polkit(), and rename it to
bus_test_polkit(). This way even if the bus message header asks for
interactive authorization, we'll ask for non-interactive authorization
which is actually the desired behaviour if CanSuspend, CanHibernate and
friends, which call this function.
2015-04-07 15:42:25 +02:00
Lennart Poettering 527b7a421f util: rework cunescape(), improve error handling
Change cunescape() to return a normal error code, so that we can
distuingish OOM errors from parse errors.

This also adds a flags parameter to control whether "relaxed" or normal
parsing shall be done. If set no parse failures are generated, and the
only reason why cunescape() can fail is OOM.
2015-04-07 15:42:25 +02:00
David Herrmann 24eb4a3098 device: fix sysattr newline cutter
Right now, we always drop the last character of all values we write to
sysfs. Fix this!
2015-04-07 13:11:18 +02:00
Tom Gundersen de9b34b6d4 sd-device: don't use alloca() within loops
I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
...
2015-04-05 12:17:29 +02:00
Tom Gundersen 401cb61499 sd-device,udevd: fix spelling /ammend/amend/ 2015-04-03 22:51:09 +02:00
Tom Gundersen 4df4fd1127 sd-device: fix deserialization from netlink
Use the standard FOREACH_WORD* macros.

The current code was broken in the devlink case so the last one received
was being dropped, causing https://bugs.freedesktop.org/show_bug.cgi?id=89894
2015-04-03 22:17:52 +02:00
Tom Gundersen aa20f49a1c sd-device: get_properties_{nulstr,strv} - don't recreate the buffer unnecessarily 2015-04-03 22:17:41 +02:00
Tom Gundersen 2fe29a46a3 sd-device: get_sysattr_value - don't leak returned value
This was getting leaked as a copy was added to the hashmap, simply add the
returned value instead.

This should fix CID #1292806.
2015-04-03 17:45:51 +02:00
Tom Gundersen afcac065c0 sd-device: initialize variable
sysnum would not be initialized if sysname had no trailing digits.
2015-04-03 17:27:00 +02:00
Tom Gundersen 57fa1d094c libsystemd: add sd-device library
This provides equivalent functionality to libudev-device, but in the
systemd style. The public API only caters to creating sd_device objects
from for devices that already exist in /sys, there is no support for
listening for monitoring events or creating devices received over
the udev netlink protocol.

The private API contains the necessary functionality to make sd-device
a drop-in replacement for libudev-device, but which we would not
otherwise want to export.
2015-04-02 00:18:27 +02:00
Harald Hoyer a7f7d1bde4 fix gcc warnings about uninitialized variables
like:

src/shared/install.c: In function ‘unit_file_lookup_state’:
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
         return r < 0 ? r : state;
                ^
src/shared/install.c:1796:13: note: ‘r’ was declared here
         int r;
             ^
2015-03-27 14:57:38 +01:00
Patrik Flykt 350e7a14dd sd-rtnl: Always enable IFA_FLAGS
IFA_FLAGS is a discrete value and has no preprocessor #define defined for
it. Fix this by always using the value.
2015-03-27 13:56:43 +02:00
Alin Rauta ea342a99fd sd-rtnl: handle empty multi-part message from the kernel
We strips out NLMSG_DONE piece from a multi-part message adding into the
receive queue only the messages containing actual data.

If we send a request to the kernel for getting the forwarding database table (just an example),
the response will be a multi-part message like below:
1. FDB entry 1;
2. FDB entry 2;
3. NLMSG_DONE;

We strip out "3. NLMSG_DONE;" part and places into the receive queue a pointer to
"1. FDB entry 1; 2. FDB entry 2".

But if the FDB table is empty, the respose from the kernel will look like below:
1. NLMSG_DONE;

We strip out "1. NLMSG_DONE;" part and since there is no actual data got, it continues
waiting until reaching timeout.

Therefore, a call to "sd_rtnl_call" to send and wait for a response from kernel will exit
with timeout which is interpreted as error in communication.

This patch puts the NLMSG_DONE message on the receive queue if it ends an empty multi-part
message. This situation is detected in sd_rtnl_call() and in the callback code and NULL is
returned to the caller instead.

[tomegun:
  - added/reworded commit message
  - extend the same support to sd_rtnl_call_async()
  - drop debug logging from library, we only do this if something is really wrong, but an
    empty multi-part message is perfectly normal
  - modernize the code we touch whilst we are at it]
2015-03-23 22:36:17 +01:00
Zbigniew Jędrzejewski-Szmek e62d9b8192 Add (void) where we don't care about return value 2015-03-15 17:26:58 -04:00
Tom Gundersen 02d30981b1 sd-event: sd_event_run - only return 0 on timeout
sd_event_dispatch() returns 0 on FINISH, so let's eat that up.
2015-03-14 12:17:24 +01:00
Tom Gundersen 2b0c9ef735 sd-event: rename PASSIVE/PREPARED to INITIAL/ARMED 2015-03-14 12:17:24 +01:00
Zbigniew Jędrzejewski-Szmek 64144440a5 sd-daemon: simplify sd_pid_notify_with_fds
Coverity was complaining that CMSG_NXTHDR is used without
checking the return value. In this case it cannot fail, but
it is a good excuse to simplify the function a bit.

CID #1261726.
2015-03-13 23:42:17 -04:00
Zbigniew Jędrzejewski-Szmek d3839740fa bus: explicitly ignore failure during error handling
CID #1237548.
2015-03-13 23:42:17 -04:00
Zbigniew Jędrzejewski-Szmek dc75168823 Use space after a silencing (void)
We were using a space more often than not, and this way is
codified in CODING_STYLE.
2015-03-13 23:42:17 -04:00
Zbigniew Jędrzejewski-Szmek d448c7927a sd-resolve: use different element of union to make code more readable
They both point to the same location, but the reader
is not forced to look back to the beginning of the function
to see that.
2015-03-13 23:42:17 -04:00
Tom Gundersen 0964dcd772 sd-rtnl: read_message - don't set group if not needed 2015-03-13 16:15:03 +01:00
Tom Gundersen f436aa11f7 sd-rtnl: process - only apply matches to broadcast messages 2015-03-13 16:13:24 +01:00
Tom Gundersen 3f42446d28 sd-rtnl: improve detection of broadcast messages
Do not rely on nl_pid == 0, but check the groups instead. We currently avoid using
nl_pid == 0 for unicast anyway, so this should be redundant, but let's try to be
correct.
2015-03-13 16:12:57 +01:00
Tom Gundersen 913b0eef1a sd-rtnl: never set serial to 0
In the unlikely event that we wrap the counter, skip 0 as this is used
for broadcasts.

Suggested by Richard Maw.
2015-03-13 15:56:08 +01:00
David Herrmann 15411c0cb1 tree-wide: there is no ENOTSUP on linux
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13 14:10:39 +01:00
David Herrmann 32a568fb90 bus: stop using EDEADLOCK
The error code is called EDEADLK, stop using legacy names like EDEADLOCK.
Note that _some_ weird architectures define them differently (namely, mips
and sparc), but on all sane architectures they're exactly the same. So
stay with the widely used code, which is EDEADLK.
2015-03-13 14:10:39 +01:00
Zbigniew Jędrzejewski-Szmek a2360a467b sd-event: fix typo 2015-03-13 00:26:02 -04:00
Richard Maw d422e52a35 networkd: Begin with serial number 1 for netlink requests
"Notifications are of informal nature and no reply is expected, therefore the
sequence number is typically set to 0."[1]

If networkd is started soon after recent netlink activity, then there
will be messages with sequence number 0 in the buffer.

The first thing networkd does is to request a dump of all the links. If
it uses sequence number 0 for this, then it may confuse the dump request's
response with that of a notification.

This will result in it failing to properly enumerate all the links,
but more importantly, when it comes to enumerate all the addresses, it
will still have the link dump in progress, so the address enumeration
will fail with -EBUSY.

[1]: http://www.infradead.org/~tgr/libnl/doc/core.html#core_msg_types

[tomegun: sequence -> serial]
2015-03-12 19:34:35 +01:00
David Herrmann 908b8a42e6 bus: remarshal kdbus messages received from the kernel
If we receive an sd_bus_message from the kernel, m->kdbus will contain
additional items that cannot be used when sending a message. Therefore,
always remarshal the message if it is used again.
2015-03-11 16:36:41 +01:00
David Herrmann 8b9972db83 bus: drop redundant assignment
This assignment is already done in the parent context, no need to do it
again.
2015-03-11 16:36:41 +01:00
Shawn Landden 3b1c524154 add REMOTE_ADDR and REMOTE_PORT for Accept=yes 2015-03-10 09:00:27 -04:00
Zbigniew Jędrzejewski-Szmek a6dcc7e592 Introduce loop_read_exact helper
Usually when using loop_read(), we want to read the full buffer.
Add a helper that mirrors loop_write(), and returns 0 when full buffer
was read, and an error otherwise.

Use -ENODATA for the short read, to distinguish it from a read error.
2015-03-09 22:10:54 -04:00
Zbigniew Jędrzejewski-Szmek bcf88fc3f1 bus: fix leak in error path
CID #1271349.
2015-03-07 15:05:50 -05:00
Zbigniew Jędrzejewski-Szmek 42115af0c3 bus-util: remove stray errno assignment 2015-03-07 14:09:50 -05:00
Hannes Reinecke 1c724e9e0e Remove the cap on epoll events
Currently the code will silently blank out events if there are more
then 512 epoll events, causing them never to be handled at all. This
patch removes the cap on the number of events for epoll_wait, thereby
avoiding this issue.
2015-03-04 21:43:17 -05:00
Lennart Poettering d4a144fadf sd-daemon: replace VLA with alloca(), to make llvm happy
https://bugs.freedesktop.org/show_bug.cgi?id=89379
2015-03-02 20:55:38 +01:00
Daniel Mack 606303a93e sd-bus: sync kdbus.h (ABI break)
After some reconsideration, we decided to move the binary protocol
back to 64-bit wide UIDs and GIDs. After all, it should be possible
to redefine [gu]id_t to uint64_t and things should continue to
work. As we want to avoid such data types in kdbus.h, let's move
back to 64-bit values and be safe.

In sd-bus, we have to do a translation between uint64_t and gid_t
now for supplementary gids.

Some inline comments have also been updated in kdbus upstream.
2015-03-02 11:36:35 +01:00
Alin Rauta 0d4ad91dd4 networkd: add support for Uplink Failure Detection
Introduce BindCarrier= to indicate the set of links that determine if
the current link should be brought UP or DOWN.

[tomegun: add a bit to commit message]
2015-02-27 13:58:30 -05:00
Tom Gundersen 09c41feef3 sd-rtnl: types - fix check for unsupported type
Spotted by Thomas H.P. Andersen <phomes@gmail.com>
2015-02-26 17:31:08 -05:00
Tom Gundersen f8a6ca1bab sd-rtnl: types - don't assert_return in private API 2015-02-26 17:31:08 -05:00
Daniel Mack def3f524a1 sd-bus: test-bus-kernel-benchmark: don't rely on fixed unique names
The kernel part of kdbus does not allow userspace to make any assumption on
which unique address the first user on the bus will get.

Instead, use sd_bus_get_unique_name() to get the server's address.
2015-02-24 14:01:36 +01:00
Daniel Mack 6ad4a4fc43 sd-bus: sync kdbus.h
Follow two small changes in the kdbus API:

 * Flags are now returned in cmd->return_flags by KDBUS_CMD_NAME_ACQUIRE

 * struct kdbus_item_list has been dropped. The information stored in
   this struct was redundant since awhile already, as all commands
   report their returned slice size anyway.
2015-02-24 12:10:13 +01:00
Zbigniew Jędrzejewski-Szmek e410b07d2a libsystemd: revert one hunk of duplicate ifdef removal
This change exposed a bug in kernel headers:

/usr/include/linux/if_bridge.h:184:20: error: field 'ip6' has incomplete type
    struct in6_addr ip6;
                    ^
/usr/include/linux/if_tunnel.h:76:19: error: field 'prefix' has incomplete type
  struct in6_addr  prefix;
                   ^
2015-02-23 20:08:05 -05:00
Daniel Mack 2c35d880de sd-bus, shared: fix includes
Include <sys/socket.h> from util.h and bus-message.h in order to
build errors like the ones below on kdbus enabled systems.

./src/shared/util.h:976:32: warning: its scope is only this definition or declaration, which is probably not what you want
In file included from src/libsystemd/sd-bus/bus-kernel.c:37:0:
./src/shared/util.h:1081:28: warning: 'struct msghdr' declared inside parameter list
 void cmsg_close_all(struct msghdr *mh);
                            ^
  CC       src/libsystemd/sd-bus/libsystemd_la-bus-creds.lo
In file included from src/libsystemd/sd-bus/bus-creds.c:25:0:
./src/shared/util.h:976:32: warning: 'struct ucred' declared inside parameter list
 int getpeercred(int fd, struct ucred *ucred);
                                ^
2015-02-24 00:42:13 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
David Herrmann 00d053d3ca bus: sync with kdbus.git (ABI break)
This syncs up the new KDBUS_CMD_CONN_INFO behavior:
 - attach-flags are passed in .attach_flags, instead of directly merged
   with the command flags.
2015-02-19 20:02:40 +01:00
Lennart Poettering c529695e7a logind: open up most bus calls for unpriviliged processes, using PolicyKit
Also, allow clients to alter their own objects without any further
priviliges. i.e. this allows clients to kill and lock their own sessions
without involving PK.
2015-02-18 12:55:25 +01:00
Lennart Poettering c0765ddb74 sd-bus: allow setting a per-connection default value for the "allow-interactive-authentication" message flag
Most of our client tools want to set this bit for all their method
calls, even though it defaults to off in sd-bus, and rightfully so.
Hence, to simplify thing, introduce a per sd_bus-object flag that sets
the default value for all messages created on the connection.
2015-02-18 11:43:18 +01:00
David Herrmann 83e30358f2 bus: sync with kdbus
Pull in new kdbus changes, namely:
 - EOVERFLOW is replaces by KDBUS_RECV_RETURN_DROPPED_MSGS
 - ENOMSG is merged with EAGAIN for consistency
2015-02-17 18:16:07 +01:00
David Herrmann 4d2b1e0a3f bus: don't rely on static IDs in tests
We should never put any constraints on the IDs returned by the kernel. Use
sd_bus_get_unique_name() to retrieve the ID of a peer.
2015-02-17 18:16:07 +01:00