summaryrefslogtreecommitdiff
path: root/src/bus-proxyd
Commit message (Collapse)AuthorAge
* bus-proxyd: temporarily disable policy checks againDaniel Mack2014-11-13
| | | | | | There are issues to investigate on with policies shipped by some packages, which we'll address later. Move that topic out of the way for now to bring sd-bus in sync with upstream kdbus.
* bus-proxyd: explicitly address messages to unique and well-known nameDaniel Mack2014-11-11
| | | | | | | | | | | | | | | | | | | | | | In order to check for matching policy entries at message transfers, we have to consider the following: * check the currently owned names of both the sending and the receiving peer. If the sending peer is connected via kdbus, the currently owned names are already attached to the message. If it was originated by the connection we're proxying for, we store the owned names in our own strv so we can check against them. * Walk the list of names to check which name would allow the message to pass, and explicitly use that name as destination of the message. If the destination is on kdbus, store both the connection's unique name and the chosen well-known-name in the message. That way, the kernel will make sure the supplied name is owned by the supplied unique name, at the time of sending, and return -EREMCHG otherwise. * Make the policy checks optional by retrieving the bus owner creds, and when the uid matches the current user's uid and is non-null, don't check the bus policy.
* Revert "bus-proxyd: make policy checks optional"Michal Schmidt2014-11-11
| | | | | | This reverts commit 5bb24cccbce846c0d77e71b70a3be7f4b2ba6c0e. It does not even compile (unbalanced {)
* bus-proxyd: make policy checks optionalDaniel Mack2014-11-11
| | | | | Retrieve the bus owner creds, and when the uid matches the current user's uid and is non-null, don't check the bus policy.
* bus-proxyd: move name list iteration to policy usersDaniel Mack2014-11-11
| | | | | | | | We need to figure out which of the possible names satisfied the policy, so we cannot do the iteration in check_policy_item() but have to leave it to the users. Test cases amended accordingly.
* bus-proxyd: enforce policy for method callsDaniel Mack2014-11-11
|
* bus-proxyd: enforce policy for name ownershipDaniel Mack2014-11-11
|
* bus-proxyd: enforce policy for Hello messagesDaniel Mack2014-11-11
|
* bus-proxyd: keep track of names acquired by legacy clientDaniel Mack2014-11-11
| | | | | Store names successfully acquired by the legacy client into a hashmap. We need to take these names into account when checking for send policies.
* sd-bus: rename sd_bus_get_server_id() to sd_bus_get_owner_id()Lennart Poettering2014-11-04
| | | | | | | In kdbus a "server id" is mostly a misnomer, as there isn't any "server" involved anymore. Let's rename this to "owner" id hence, since it is an ID that is picked by the owner of a bus or direct connection. This matches nicely the sd_bus_get_owner_creds() call we already have.
* sd-bus: rename "connection name" to "description" for the sd-bus API tooLennart Poettering2014-11-04
| | | | | kdbus recently renamed this concept, and so should we in what we expose in userspace.
* sd-bus: sync kdbus.h (ABI break)Daniel Mack2014-11-04
| | | | | | | | | | | | | | | | | Catch up with some changes in kdbus.h: * KDBUS_{ITEM,ATTACH}_CONN_NAME were renamed to KDBUS_{ITEM,ATTACH}_CONN_DESCRIPTION, so the term 'name' is not overloaded as much. * The item types were re-ordered a little so they are lined up to the order of the corresponding KDBUS_ATTACH flags * A new item type KDBUS_ITEM_OWNED_NAME was introduced, designated to store a struct kdbus_name in item->name. KDBUS_ITEM_NAME soley stores data in item->str now * Some kerneldoc fixes
* bus-proxy: it's OK if getpeercred doesn't workLennart Poettering2014-10-24
| | | | | | | | We should use the data if we can (if stdin/stdout is an AF_UNIX socket), but still work if we can't (if stdin/stdout are pipes, like in the SSH case). This effectively reverts 55534fb5e4742b0db9ae5e1e0202c53804147697
* sd-bus: rename sd_bus_get_owner_uid(), sd_bus_get_owner_machine_id() and ↵Daniel Mack2014-10-22
| | | | | | | | | | sd_bus_get_peer_creds() Clean up the function namespace by renaming the following: sd_bus_get_owner_uid() → sd_bus_get_name_creds_uid() sd_bus_get_owner_machine_id() → sd_bus_get_name_machine_id() sd_bus_get_peer_creds() → sd_bus_get_owner_creds()
* sd-bus: sync kdbus.h (ABI break)Daniel Mack2014-10-21
| | | | | | | | | | | | | | | | | In kdbus.h, the following details changed: * All commands gained a 'kernel_flags' field to report the flags supported by the driver. Before, this was done in the 'flags' field in a bidirectional way, which turned out to be a problem for the code in sd-bus, as many parts of it reuse the same ioctl struct more than once and consider them to be owned by userspace. * Name listings are now returned by a new struct instead of reusing struct kdbus_cmd_name for that matter. This way, we don't add more unneeded fields to it and make the API cleaner. * 'conn_flags' was renamed to 'flags' in struct kdbus_cmd_hello to make the API a bit more unified.
* bus-proxy: let's make use of the translated errors get_creds_by_name() ↵Lennart Poettering2014-10-20
| | | | provides us with
* Revert "bus-proxyd: improve compatibility with dbus-1"Lennart Poettering2014-10-20
| | | | | | | This reverts commit b0f84d4d7832659f2216bda7a7cdf51f5e79c6eb. get_creds_by_name() already translate the error nicely, we just need to make use of it.
* bus-proxyd: add missing flag translation for RequestNameLukasz Skalski2014-10-15
|
* bus-proxyd: improve compatibility with dbus-1Lukasz Skalski2014-10-14
| | | | | | | | | | | | | | | 'GetConnectionUnixProcessID', 'GetConnectionUnixUser' and 'GetConnectionSELinuxSecurityContext' methods should return 'NameHasNoOwner' error (if chosen name is not available on bus) with more detailed description - like dbus-1: Could not get PID of name 'org.freedesktop.test': no such name. Could not get UID of name 'org.freedesktop.test': no such name. Could not get security context of name 'org.freedesktop.test': no such name. Otherwise we have only laconic message without proper dbus error: Error System.Error.ENXIO: No such device or address
* bus-proxyd: fix compatibility with old dbus-1Lukasz Skalski2014-10-10
| | | | | 'ListQueuedOwners' method should return 'NameHasNoOwner' error if chosen name is not available on bus.
* bus-proxy: allow getpeersec() to failDaniel Mack2014-10-09
| | | | | getpeersec() will fail for non-SELinux enabled machines, so don't make that a hard error.
* bus-policy: move name list iteration to policy usersDaniel Mack2014-10-09
| | | | | | | | We need to figure out which of the possible names satisfied the policy, so we cannot do the iteration in check_policy_item() but have to leave it to the users. Test cases amended accordingly.
* bus-proxyd: assorted cleanups and fixesDaniel Mack2014-10-07
| | | | | Just some cleanups around policy checks that came up during review. The code is still not productive.
* bus-proxyd: check return values of getpeercred() and getpeersec()Daniel Mack2014-10-07
| | | | | | If we can't get the remote peer or security creds, bail out. Spotted by coverity.
* sd-bus: sync kdbus.h (ABI break)Daniel Mack2014-10-06
| | | | | | | | The KDBUS_CMD_FREE ioctl now uses a struct rather than a direct pointer to the offset to free. The KDBUS_CMD_MSG_CANCEL ioctl has also changes, but there's no user of it yet in systemd.
* Remove repeated includesThomas Hindoe Paaboel Andersen2014-10-01
| | | | | | In pty.c there was both an include of our pty.h and the system installed pty.h. The latter contains only two functions openpty and forkpty. We use neither so I assume it was a typo and removed it. We still compile and pass all tests.
* test-bus-policy: silence coverityThomas Hindoe Paaboel Andersen2014-09-28
| | | | | | | Check if strjoin worked and also use _cleanup_free_ since we are here. Found with Coverity. Fixes CID#1241962
* test-bus-policy: load policy files from TEST_DIRDaniel Mack2014-09-26
| | | | | 'make distcheck' calls test-bus-policy outside of the source tree, so it must consider the TEST_DIR variable to access its files.
* bus-proxy: drop one wrong assert()Tom Gundersen2014-09-25
|
* bus-proxyd: add some assertsTom Gundersen2014-09-25
| | | | | | Both as documentation, and to make Coverity happy. Fixes CID #1241495 and #1241496.
* bus-policy: split API for bus-proxydDaniel Mack2014-09-24
| | | | | | | | | | | | | | | | Instead of operating on an sd_bus_message object, expose an API that has 4 functions: policy_check_own() policy_check_hello() policy_check_recv() policy_check_send() This also allows dropping extra code to parse message contents - the bus proxy already has dedicated code paths for that, and we can hook into those later. Tests amended accordingly.
* sd-bus: sync kdbus.h (API+ABI break)Daniel Mack2014-09-22
| | | | | | | | | | The kdbus logic name registry logic was changed to transport the actual name to acquire, release or report in a kdbus item. This brings the name API a little more in line with other calls, and allows for later augmentation. Follow that change on the systemd side.
* bus-policy: add test utilityDaniel Mack2014-09-20
| | | | Add some test files and routines for dbus policy checking.
* bus-policy: add policy check functionDaniel Mack2014-09-20
| | | | | Add policy_check() to actually check whether an incoming message is allowed by the policy. The code is not yet used from the proxy daemon, though.
* bus-policy: print numeric [gu]id in dump_items()Daniel Mack2014-09-20
|
* bus-policy: do not exit() from policy_dump()Daniel Mack2014-09-20
| | | | | This function is quite useful for debugging. Exiting from it seems unnecessary.
* bus-policy: implement dump_items() with LIST_FOREACHDaniel Mack2014-09-20
| | | | Instead of making the function call itself recursively.
* bus-policy: resolve [ug]id of POLICY_ITEM_{USER,GROUP}Daniel Mack2014-09-20
| | | | | Do the lookup during parsing already, and set i->uid, or i->gid to the numerical values.
* bus_policy: set i->[ug]id_validDaniel Mack2014-09-20
|
* bus-policy: append items rather than prepending themDaniel Mack2014-09-20
| | | | | In the D-Bus policy, the order of items matters, so make sure to store them in the same order as they are parsed by the sax parser.
* bus-policy: story mandatory items in right listDaniel Mack2014-09-20
|
* hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt2014-09-15
| | | | | | | | | It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
* notify: send STOPPING=1 from our daemonsLennart Poettering2014-08-21
|
* bus-proxy: service_name_is_valid will never be < 0Thomas Hindoe Paaboel Andersen2014-08-05
|
* bus: always explicitly close bus from main programsLennart Poettering2014-08-04
| | | | | | | | | | | | | | Since b5eca3a2059f9399d1dc52cbcf9698674c4b1cf0 we don't attempt to GC busses anymore when unsent messages remain that keep their reference, when they otherwise are not referenced anymore. This means that if we explicitly want connections to go away, we need to close them. With this change we will no do so explicitly wherver we connect to the bus from a main program (and thus know when the bus connection should go away), or when we create a private bus connection, that really should go away after our use. This fixes connection leaks in the NSS and PAM modules.
* Unify parse_argv styleZbigniew Jędrzejewski-Szmek2014-08-03
| | | | | | | | | | | | | | | | getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
* bus-proxyd: fix incorrect comparisonLukas Nykryn2014-07-25
| | | | We should be interested in k variable.
* bus-proxyd: fix incorrect comparisonLukas Nykryn2014-07-25
| | | | Err can't be bigger then zero. Rest of the code uses negative Exxxx values.
* test-tables: add new entriesZbigniew Jędrzejewski-Szmek2014-07-16
| | | | | | One missing string found. A few things had to be moved around to make it possible to test them.
* sd-bus: support connecting to remote hosts, directly into containersLennart Poettering2014-07-03
| | | | | | | | | | systemctl -H root@foobar:waldi will now show a list of services running on container "waldi" on host "foobar", using "root" for authenticating at "foobar". Since entereing a container requires priviliges, this will only work correctly for root logins.