test-metadata: more corner cases to metdata test

To inspect our metadata handling

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
Merge branch 'master' of https://code.google.com/p/d-bus
metadata-test: check all the cred fields and clean the code

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
metadata: switch to zmalloc to null terminate kdbus items by default

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
metadata: provide module-option to set attach-flags masks

A new module option, called "kdbus.attach_flags_mask", can be used to set
a mask of attach-flags that is applied to the input mask on
kdbus_meta_export(). In other words, attach-flags not listed in that mask
will never be returned to user-space.

We still collect the metadata in the kernel, and we still have all
code-paths enabled. However, missing flags are never handled in any
user-space interactions.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
test-fd: attach bloom filter when sending to broadcast address

Make sure we don't fail due to other errors in this test. In order
to satify the incoming QA check of a message, a broadcast must carry
a bloom filter.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message.c: split kdbus_msg_scan_items

Split code that pins files from code that sets internal pointers in
kmsg. This way, we can re-use kdbus_msg_scan_items() when
reconstructing messages.

Signed-off-by: Daniel Mack <daniel@zonque.org>
metadata: don't use kzalloc if all bytes of the buffer are written

In such cases, an extra memset is unnecessary.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message: make kdbus_msg_scan_items() public

We'll need that later for message reconstruction.

Signed-off-by: Daniel Mack <daniel@zonque.org>
message: clean up parameter passing

Let kdbus_msg_scan_items() take a bus, and drop conn argument from
kdbus_msg_pin_files().

Signed-off-by: Daniel Mack <daniel@zonque.org>
names: unnecessary call to flush after name acquire

since kdbus_name_acquire in all paths (error or success) flush the notify there
is no need to called again in the command implementation.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
(David: cmd_acquire() doesn't call any notify handlers, anyway, so this
        flush call was bogus right from the beginning)
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
names: validate return when queueing name

if fail to alloc mem when queueing name, go out through well defined error path
and do not set the KDBUS_NAME_IN_QUEUE flag.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: split per_user and uncounted queue limits

Avoid using the same define for two diferent limits, also give a meaningful name
to the uncount limit.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
(David: fix two errors in the test-suite)
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: allow activators to change receive flags

since now activators are allowed to receive message, they may also need to
change the receive flags.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
(David: re-order policy checks to be symmetric again)
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
util: provide generic kdbus_verify_uid_prefix()

Move the UID prefix validation of bus-names into a generic helper so we
can re-use it elsewhere (eg., for endpoint names).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
endpoint: move user-creation to ep_new()

Avoid setting ep->user from outside endpoint.c. Lifetime rules should
really be controlled from the endpoint.c file. As custom users are always
created for custom endpoints, just move the user allocation into
kdbus_ep_new().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
handle: simplify ep_new() call

We used the "access" variable to avoid over-long lines. Now that ep_new()
is no longer called from the huge ioctl-switch() statement, we can just
inline it again.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
endpoint: restrict custom endpoint names to "<uid>-<name>"

Make sure custom endpoint names follow the same restriction as custom
buses. They must be prefixed with "<uid>-".

This will allow adding more custom files to a bus subdirectory later,
without any name clashes with possibly already used endpoints.

Note that the UID *MUST* be provided in the user-namespace of the parent
domain. A domain always has a user-namespace that it is attached to and
*any* accounting for *all* entities on that domain is always done in the
owning user-namespace!

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Update docs

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
bus: return bus-name in KDBUS_CMD_BUS_CREATOR_INFO

Return the bus-name as KDBUS_ITEM_MAKE_NAME in KDBUS_CMD_BUS_CREATOR_INFO
so callers can load policies based on the bus they're connected to.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>