summaryrefslogtreecommitdiffstats
path: root/src/stdio-bridge (follow)
Commit message (Collapse)AuthorAgeFilesLines
* stdio-bridge: Use customized log message for forwarding busDaan De Meyer2024-10-111-1/+1
| | | | | | Let's more clearly indicate that we failed to set up the server which forwards messages from the remote client to the local bus instead of logging a generic bus client message.
* stdio-bridge: Use bus_log_connect_error()Daan De Meyer2024-10-111-1/+1
|
* tree-wide: Use log_setup() everywhereDaan De Meyer2024-04-251-3/+1
| | | | | Otherwise the default log target is the console and we won't use the journal socket even if it is available.
* stdio-bridge: return immediately if we canZbigniew Jędrzejewski-Szmek2023-12-021-6/+4
| | | | Follow-up for 0321248b79d14ceddd36140b327332f145ae68e7.
* stdio-bridge: properly handle org.freedesktop.DBus.Local.Disconnected signalLennart Poettering2023-11-291-5/+10
| | | | | | | | | | | | | Previously, we'd forward org.freedesktop.DBus.Local.Disconnected like any other message to the other side. But that's not OK, as messages in the org.freedesktop.DBus.Local.* namespace are supposed to never touch the wire, and are synthetic messages that the library uses to communicate with the app, but never with other apps. dbus-daemon never cared, but dbus-broker complains about this, hence clean this up. See: #28514
* various: use _NEG_ macros to reduce indentationZbigniew Jędrzejewski-Szmek2023-08-161-10/+5
| | | | No functional change intended.
* meson: move declarations of busctl, stdio-bridge, and runYu Watanabe2023-08-011-0/+9
|
* tree-wide: drop unnecessary inclusion of version.hYu Watanabe2023-07-291-1/+0
|
* basic: add RuntimeScope enumLennart Poettering2023-03-101-4/+4
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* stdio-bridge: don't be bothered with EINTRLennart Poettering2022-11-221-1/+4
| | | | | We handle signals via signal handlers, hence no need to be concerned about EINTR.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
|
* man: systemd-stdio-bridge doesn't connect "two busses"Lennart Poettering2022-02-041-1/+1
| | | | | | | | | | | | | | | In D-Bus, clients connect to a bus (the usual case), or use direct questions to each other (the unusual case). A bus is a program one can connect to and implemented by dbus-daemon or dbus-broker. HOwever, busses never connect between each other, that doesn't exist. Hence don't claim so. This is probably confusion about the fact that sd-bus calls D-Bus connection objects just "sd_bus" for simplicity, given they are used in 99% of the cases to connect to a bus — only in exceptional cases they are used for direct connections between peers without involving a bus. Follow-up for b7bb58ef70b0c876941a1c31ed4e2f5f1dc5ed0e
* stdio-bridge: trim whitespace and bracesZbigniew Jędrzejewski-Szmek2022-01-171-4/+1
|
* stdio-bridge: make the error more straightforwardZbigniew Jędrzejewski-Szmek2022-01-171-1/+1
|
* man: enhance the description of systemd-stdio-bridgeZbigniew Jędrzejewski-Szmek2022-01-171-1/+1
| | | | | | | | | I hope that this fixes the comment https://github.com/systemd/systemd/pull/22141#issuecomment-1013960371 > As someone who doesn't know what this prog does The listing in the man page is sorted according to logical use: all the options setting the address are now together.
* meson: simplify the BUILD_MODE conditionalZbigniew Jędrzejewski-Szmek2021-04-141-1/+1
| | | | | | | Using a enum is all nice and generic, but at this point it seems unlikely that we'll add further build modes. But having an enum means that we need to include the header file with the enumeration whenerever the conditional is used. I want to use the conditional in log.h, which makes it hard to avoid circular imports.
* tree-wide: use ppoll_usec()Yu Watanabe2021-03-031-26/+7
|
* stdio-bridge: add support for --system and --userLennart Poettering2020-12-151-3/+18
| | | | | | | | | | | | | | | So far, the bridge always acted as if "--system" was used, i.e. would unconditionally connect to the system bus. Let's add "--user" too, to connect to the users session bus. This is mostly for completeness' sake. I wanted to use this when making sd-bus's ability to connect to other user's D-Bus busses work, but it didn't exist so far. In the interest of keeping things compatible the implementation in sd-bus will not use the new "--user" switch, and instead manually construct the right bus path via "--path=", but we still should add the proper switches, as preparation for a brighter future, one day.
* sd-bus: add API for connecting to a specific user's user bus of a specific ↵Lennart Poettering2020-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | container This is unfortunately harder to implement than it sounds. The user's bus is bound a to the user's lifecycle after all (i.e. only exists as long as the user has at least one PAM session), and the path dynamically (at least theoretically, in practice it's going to be the same always) generated via $XDG_RUNTIME_DIR in /run/. To fix this properly, we'll thus go through PAM before connecting to a user bus. Which is hard since we cannot just link against libpam in the container, since the container might have been compiled entirely differently. So our way out is to use systemd-run from outside, which invokes a transient unit that does PAM from outside, doing so via D-Bus. Inside the transient unit we then invoke systemd-stdio-bridge which forwards D-Bus from the user bus to us. The systemd-stdio-bridge makes up the PAM session and thus we can sure tht the bus exists at least as long as the bus connection is kept. Or so say this differently: if you use "systemctl -M lennart@foobar" now, the bus connection works like this: 1. sd-bus on the host forks off: systemd-run -M foobar -PGq --wait -pUser=lennart -pPAMName=login systemd-stdio-bridge 2. systemd-run gets a connection to the "foobar" container's system bus, and invokes the "systemd-stdio-bridge" binary as transient service inside a PAM session for the user "lennart" 3. The systemd-stdio-bridge then proxies our D-Bus traffic to the user bus. sd-bus (on host) → systemd-run (on host) → systemd-stdio-bridge (in container) Complicated? Well, to some point yes, but otoh it's actually nice in various other ways, primarily as it makes the -H and -M codepaths more alike. In the -H case (i.e. connect to remote host via SSH) a very similar three steps are used. The only difference is that instead of "systemd-run" the "ssh" binary is used to invoke the stdio bridge in a PAM session of some other system. Thus we get similar implementation and isolation for similar operations. Fixes: #14580
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: check POLLNVAL everywhereLennart Poettering2020-06-101-9/+11
| | | | | | | | | | | | | poll() sets POLLNVAL inside of the poll structures if an invalid fd is passed. So far we generally didn't check for that, thus not taking notice of the error. Given that this specific kind of error is generally indication of a programming error, and given that our code is embedded into our projects via NSS or because people link against our library, let's explicitly check for this and convert it to EBADF. (I ran into a busy loop because of this missing check when some of my test code accidentally closed an fd it shouldn't close, so this is a real thing)
* stdio-bridge: slightly optimize formatting of structureLennart Poettering2019-03-191-3/+4
|
* stdio-bridge: use SYNTHETIC_ERRNO() where appropriateLennart Poettering2019-03-191-4/+2
|
* stdio-bridge: tweak getopt() case statement a bitLennart Poettering2019-03-191-8/+5
|
* stdio-bridge: fix getopt() parameter list to match realityLennart Poettering2019-03-191-1/+1
|
* stdio-bridge: use ERRNO_IS_DISCONNECT() to detect disconnectsLennart Poettering2019-03-191-2/+7
| | | | | Let's use the macro we already have to make this safer. Moreover log about all other errors.
* tree-wide: make sure to flush/close all bus connections when our daemons exitLennart Poettering2019-01-171-1/+1
| | | | | | | Let's make sure everything is written out ebfore we exit, so that no messages keep our bus connections referenced. Fixes: #11462
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-2/+2
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* util-lib: move main() definition macros to its own header fileLennart Poettering2018-11-191-1/+2
| | | | | | | | | This way, we can extend the macro a bit with stuff pulled in from other headers without this affecting everything which pulls in macro.h, which is one of our most basic headers. This is just refactoring, no change in behaviour, in prepartion for later changes.
* stdio-bridge: define main through macroZbigniew Jędrzejewski-Szmek2018-11-171-94/+48
|
* stdio-bridge: support --machineShawn Landden2018-08-061-3/+18
| | | | | --machine hasn't been supported since 798c486 Closes: #8116
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* stdio-bridge: add missing optionYu Watanabe2017-12-041-3/+4
|
* stio-bridge: list all short options in help textMarcus Folkesson2017-12-031-1/+1
| | | | Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* tree-wide: when %m is used in log_*, always specify errno explicitlyZbigniew Jędrzejewski-Szmek2017-05-191-1/+1
| | | | | | | | All those uses were correct, but I think it's better to be explicit. Using implicit errno is too error prone, and with this change we can require (in the sense of a style guideline) that the code is always specified. Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'
* tree-wide: fix incorrect uses of %mZbigniew Jędrzejewski-Szmek2017-05-131-2/+2
| | | | | In those cases errno was not set, so we would be logging some unrelated error or "Success".
* stdio-bridge: Correctly propagate errorBenjamin Robin2016-02-291-0/+3
| | | | Return EXIT_FAILURE and print the correct errno code if sd_bus_get_fd() or sd_bus_get_events() fail
* stdio-bridge: remove dead codeThomas Hindoe Paaboel Andersen2016-02-261-2/+0
|
* tree-wide: indentation fixesThomas Hindoe Paaboel Andersen2016-02-261-1/+1
|
* remove bus-proxydDaniel Mack2016-02-121-0/+301
| | | | | | | | | | As kdbus won't land in the anticipated way, the bus-proxy is not needed in its current form. It can be resurrected at any time thanks to the history, but for now, let's remove it from the sources. If we'll have a similar tool in the future, it will look quite differently anyway. Note that stdio-bridge is still available. It was restored from a version prior to f252ff17, and refactored to make use of the current APIs.
* rename stdio-bridge to bus-proxydKay Sievers2013-11-292-311/+0
|
* systemd-stdio-bridge: make it socket-activatable and usable as kdbus bridgeDaniel Mack2013-11-291-12/+90
| | | | | | | | | | | | Augment systemd-stdio-bridge a bit to make it a 1:1 bridge from legacy DBus clients to kdbus. In particular, * allow setting the bus path of the upstream bus as command line argument * use sd_listen_fds() for systemd's socket activation * omit calling sd_bus_negotiate_fds() when upstream bus is kdbus * reply to bus send errors with proper dbus error messages * treat -ECONNRESET as expected end-of-connection condition
* timedated: use libsystemd-bus instead of libdbus for bus communicationLennart Poettering2013-10-161-0/+1
| | | | | | | | | | | | | | | Among other things this also adds a few things necessary for the change: - Considerably more powerful error returning APIs in libsystemd-bus - Adapter for connecting an sd_bus to an sd_event - As I reworked the PolicyKit logic to the new library I also made it asynchronous, so that PolicyKit requests of one user cannot block out another user anymore. - We always use the macro names for common bus error. That way it is harder to mistype them since the compiler will notice
* bus: add APIs for negotiating what is attached to messagesLennart Poettering2013-05-171-2/+2
|
* Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek2013-04-061-9/+7
| | | | | | | | | | | | | | | | | | | | | | | Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
* stdio-bridge: rework stdio bridge to use libsystemd-busLennart Poettering2013-04-011-278/+144
|
* stdio-bridge: modernizationLennart Poettering2013-03-201-1/+1
|