summaryrefslogtreecommitdiff
path: root/src/core/dbus-job.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-14/+7
|
* core: add basic infrastructure to record unit activation informationLuca Boccassi2022-08-231-0/+2
| | | | | | | Not wired in by any unit type yet, just the basic to allocate, ref, deref and plug in to other unit types. Includes recording the trigger unit name and passing it to the triggered unit as TRIGGER_UNIT= env var.
* core/dbus-job: Use new way of specifying sd-bus vtable parameter namesClyde Byrd III2022-03-111-8/+6
|
* treewide: tighten variable scope in loops (#18372)Susant Sahani2021-01-271-2/+2
| | | | Also use _cleanup_free_ in one more place.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-2/+1
|
* tree-wide: drop pointless zero initialization (#16884)fangxiuning2020-08-281-1/+1
| | | tree-wide: drop pointless zero initialization
* shared: split out property get helpersLennart Poettering2020-06-301-0/+1
| | | | No code changes, just some refactoring.
* pid1: convert to the new schemeZbigniew Jędrzejewski-Szmek2020-05-051-0/+52
| | | | | | | | In all the other cases, I think the code was clearer with the static table. Here, not so much. And because of the existing dump code, the vtables cannot be made static and need to remain exported. I still think it's worth to do the change to have the cmdline introspection, but I'm disappointed with how this came out.
* manager: add dbus parameter namesZbigniew Jędrzejewski-Szmek2020-04-161-2/+14
|
* core: move bus-util include out of selinux-access headerChristian Göttsche2020-02-041-0/+1
|
* Create src/shared/unit-file.[ch] for unit-file related opsZbigniew Jędrzejewski-Szmek2019-07-191-0/+1
| | | | | So far we put such functinos in install.[ch], but that is tied too closely to enable/disable. Let's start moving things to a place with a better name.
* core: before returning new job path to clients, force out JobNew signalsLennart Poettering2018-12-011-0/+15
| | | | | | | When a client requests a new job, let's make sure we for out the JobNew signals for it, before we return successfully from the method call. After all we shouldn't return a path that is not announced yet, as announcement of jobs should be considered part of the job setup.
* core: before sending out a job new/change/removal message, send out unit ↵Lennart Poettering2018-12-011-0/+7
| | | | | | | | | change message for job's unit We always want the state of the unit to be reflected first to the client before we claim the job has changed state, after all the job is the request to change unit state, and thus job changes are kinda the confirmation that the state changed as requested.
* tree-wide: use "polkit" to refer to PolicyKit/polkitZbigniew Jędrzejewski-Szmek2018-07-161-1/+1
| | | | | | | | | | | Back in 2012 the project was renamed, see the release notes for v 0.105 [https://cgit.freedesktop.org/polkit/tree/NEWS#n754]. Let's update our documentation and comments to do the same. Referring to PolicyKit is confusing to users because at the time the polkit api changed too, and we support the new version. I updated NEWS too, since all the references to PolicyKit there were added after the rename. "PolicyKit" is unchanged in various URLs and method call names.
* 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.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* 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.
* core/dbus-job, systemctl: shorten some codeZbigniew Jędrzejewski-Szmek2016-11-161-15/+10
|
* core: add bus calls for determining jobs waiting for other jobsLennart Poettering2016-11-161-0/+52
| | | | This should make it easier to debug job deadlocks.
* core: GC redundant device jobs from the run queueLennart Poettering2016-11-161-0/+68
| | | | | | | | | | | | | | | | | | | | | | In contrast to all other unit types device units when queued just track external state, they cannot effect state changes on their own. Hence unless a client or other job waits for them there's no reason to keep them in the job queue. This adds a concept of GC'ing jobs of this type as soon as no client or other job waits for them anymore. To ensure this works correctly we need to track which clients actually reference a job (i.e. which ones enqueued it). Unfortunately that's pretty nasty to do for direct connections, as sd_bus_track doesn't work for them. For now, work around this, by simply remembering in a boolean that a job was requested by a direct connection, and reset it when we notice the direct connection is gone. This means the GC logic works fine, except that jobs are not immediately removed when direct connections disconnect. In the longer term, a rework of the bus logic should fix this properly. For now this should be good enough, as GC works for fine all cases except this one, and thus is a clear improvement over the previous behaviour. Fixes: #1921
* core: rename "clients" field of Job structure to "bus_track"Lennart Poettering2016-11-161-3/+3
| | | | | Let's make semantics of this field more similar to the same functionality in the Unit object, in particular as we add new functionality to it later on.
* core: don't log job status message in case job was effectively NOP (#3199)Michal Sekletar2016-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | We currently generate log message about unit being started even when unit was started already and job didn't do anything. This is because job was requested explicitly and hence became anchor job of the transaction thus we could not eliminate it. That is fine but, let's not pollute journal with useless log messages. $ systemctl start systemd-resolved $ systemctl start systemd-resolved $ systemctl start systemd-resolved Current state: $ journalctl -u systemd-resolved | grep Started May 05 15:31:42 rawhide systemd[1]: Started Network Name Resolution. May 05 15:31:59 rawhide systemd[1]: Started Network Name Resolution. May 05 15:32:01 rawhide systemd[1]: Started Network Name Resolution. After patch applied: $ journalctl -u systemd-resolved | grep Started May 05 16:42:12 rawhide systemd[1]: Started Network Name Resolution. Fixes #1723
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-1/+2
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-3/+5
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* sd-bus: drop bus parameter from message callback prototypeLennart Poettering2015-04-291-2/+1
| | | | | | 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().
* core: rework policykit hookupLennart Poettering2015-02-181-20/+11
| | | | | | | | | - Always issue selinux access check as early as possible, and PK check as late as possible. - Introduce a new policykit action for altering environment - Open most remaining bus calls to unprivileged clients via PK
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-2/+2
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-2/+2
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* mac: add mac_ prefix to distinguish origin security apisWaLyong Cho2014-10-281-1/+1
|
* remove unused variablesThomas Hindoe Paaboel Andersen2014-08-191-1/+0
|
* core: Verify systemd1 DBus method callers via polkitStef Walter2014-08-181-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | DBus methods that retrieve information can be called by anyone. DBus methods that modify state of units are verified via polkit action: org.freedesktop.systemd1.manage-units DBus methods that modify state of unit files are verified via polkit action: org.freedesktop.systemd1.manage-unit-files DBus methods that reload the entire daemon state are verified via polkit action: org.freedesktop.systemd1.reload-daemon DBus methods that modify job state are callable from the clients that started the job. root (ie: CAP_SYS_ADMIN) can continue to perform all calls, property access etc. There are several DBus methods that can only be called by root. Open up the dbus1 policy for the above methods. (Heavily modified by Lennart, making use of the new bus_verify_polkit_async() version that doesn't force us to always pass the original callback around. Also, interactive auhentication must be opt-in, not unconditional, hence I turned this off.)
* core: Rename Job.subscribed field to Job.clientsStef Walter2014-08-151-2/+2
| | | | | | This reflects how this field will be used, to not only track where to send signals, but also which callers (other than root) are allowed to call DBus methods on the Job.
* core: Common code for DBus methods that Cancel a jobStef Walter2014-08-151-2/+2
| | | | | Both ofs.Job.Cancel() and ofs.Manager.CancelJob() now use same implementation. So we can add caller verify logic appropriately.
* core: no need to pass bus object to selinux access check calls anymoreLennart Poettering2014-05-141-1/+1
|
* bus: add sd_bus_track object for tracking peers, and port core over to itLennart Poettering2014-03-031-53/+11
| | | | | | | | | | | | | | | | | | | This is primarily useful for services that need to track clients which reference certain objects they maintain, or which explicitly want to subscribe to certain events. Something like this is done in a large number of services, and not trivial to do. Hence, let's unify this at one place. This also ports over PID 1 to use this to ensure that subscriptions to job and manager events are correctly tracked. As a side-effect this makes sure we properly serialize and restore the track list across daemon reexec/reload, which didn't work correctly before. This also simplifies how we distribute messages to broadcast to the direct busses: we only track subscriptions for the API bus and implicitly assume that all direct busses are subscribed. This should be a pretty OK simplification since clients connected via direct bus connections are shortlived anyway.
* api: in constructor function calls, always put the returned object pointer ↵Lennart Poettering2014-02-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | first (or second) Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
* bus: decorate the various object vtables with SD_BUS_VTABLE_PROPERTY_CONST ↵Lennart Poettering2013-12-221-3/+3
| | | | where appropriate
* core: don't warn loudly if we cannot send a bus signal to a disconnected clientLennart Poettering2013-11-221-8/+12
|
* bus: rework message handlers to always take an error argumentLennart Poettering2013-11-211-4/+8
| | | | | | | | | | | | | | | | | | | | Message handler callbacks can be simplified drastically if the dispatcher automatically replies to method calls if errors are returned. Thus: add an sd_bus_error argument to all message handlers. When we dispatch a message handler and it returns negative or a set sd_bus_error we send this as message error back to the client. This means errors returned by handlers by default are given back to clients instead of rippling all the way up to the event loop, which is desirable to make things robust. As a side-effect we can now easily turn the SELinux checks into normal function calls, since the method call dispatcher will generate the right error replies automatically now. Also, make sure we always pass the error structure to all property and method handlers as last argument to follow the usual style of passing variables for return values as last argument.
* bus: let's simplify things by getting rid of unnecessary bus parametersLennart Poettering2013-11-211-1/+1
|
* core: convert PID 1 to libsystemd-busLennart Poettering2013-11-201-268/+126
| | | | | | | | | | | | | | | | | | | | | | This patch converts PID 1 to libsystemd-bus and thus drops the dependency on libdbus. The only remaining code using libdbus is a test case that validates our bus marshalling against libdbus' marshalling, and this dependency can be turned off. This patch also adds a couple of things to libsystem-bus, that are necessary to make the port work: - Synthesizing of "Disconnected" messages when bus connections are severed. - Support for attaching multiple vtables for the same interface on the same path. This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus calls which used an inappropriate signature. As a side effect we will now generate PropertiesChanged messages which carry property contents, rather than just invalidation information.
* bus: remove static introspection file exportKay Sievers2013-10-211-1/+1
|
* list: make our list macros a bit easier to use by not requring type spec on ↵Lennart Poettering2013-10-141-1/+1
| | | | | | | each invocation We can determine the list entry type via the typeof() gcc construct, and so we should to make the macros much shorter to use.
* dbus: use _cleanup_free_ instead of freeing ourselfRonny Chevalier2013-08-081-9/+2
|
* dbus: fix minor memory leak when sending job change signalsLennart Poettering2013-06-281-25/+17
|