summaryrefslogtreecommitdiffstats
path: root/src/xdg-autostart-generator (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use ExitType=cgroup for autostart generated servicesHenri Chain2021-11-081-0/+1
| | | | | | | | | | | | | | | | | This fixes a bug[1] with some generated autostart app services which fork and exit immediately after main application process start, that caused them not to launch during session startup, as the entire cgroup was immediately killed by systemd. This can also happen with apps such as file browsers, whose initial process will exit after the window is closed, but who intend to leave a daemon child running. Since the forking model of a .desktop application cannot be known at service generation time otherwise, ExitType=cgroup is the only effective way to fix this bug. [1] https://bugs.kde.org/show_bug.cgi?id=433299
* xdg-autostart-service: rely on the new double-eval-free free_and_replace()Lennart Poettering2021-07-291-4/+2
| | | | These semi-reverts 2744c7bb0176dc6b86a69acd4c449ea9e269e097
* xdg-autostart: minor refactoringZbigniew Jędrzejewski-Szmek2021-07-091-4/+4
| | | | | | We can't say free_and_replace(exec_split[n++], quoted), because the the argument is evaluated multiple times. But I think that this form is still easier to read.
* tree-wide: make cunescape*() functions return ssize_tZbigniew Jędrzejewski-Szmek2021-07-091-3/+4
| | | | | Strictly speaking, we are returning the size of a memory chunk of arbitrary size, so ssize_t is more appropriate than int.
* Revert "Introduce ExitType"Zbigniew Jędrzejewski-Szmek2021-06-301-1/+0
| | | | | | | | | | | This reverts commit cb0e818f7cc2499d81ef143e5acaa00c6e684711. After this was merged, some design and implementation issues were discovered, see the discussion in #18782 and #19385. They certainly can be fixed, but so far nobody has stepped up, and we're nearing a release. Hopefully, this feature can be merged again after a rework. Fixes #19345.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* Introduce ExitTypeHenri Chain2021-03-311-0/+1
|
* xdg-autostart-generator: ignore DBusActivatable=trueZbigniew Jędrzejewski-Szmek2021-02-191-0/+1
| | | | | | | | | | | | | | | | | | | See https://wiki.gnome.org/HowDoI/DBusApplicationLaunching and https://wiki.gnome.org/Initiatives/GnomeGoals/DBusActivatable for a description of this key: > Instead of the typical UNIX-style fork()/exec() approach to process creation, > launching an application is done by sending a D-Bus message to the well-known > name of that application, causing a D-Bus activation. > > Starting processes with D-Bus activation ensures that each application gets > started in its own pristine environment, as a direct descendent of the > session -- not in the environment of whatever its parent happened to be. This > is important for ensuring the app ends up in the correct cgroup, for example. So this motivation is not important for us: we launch stuff ourselves better. This fixes warnings during boot: systemd-xdg-autostart-generator[2274]: /etc/xdg/autostart/org.freedesktop.problems.applet.desktop:92: Unknown key name 'DBusActivatable' in section 'Desktop Entry', ignoring.
* xdg-autostart-generator: reindentZbigniew Jędrzejewski-Szmek2021-02-191-50/+43
|
* Merge pull request #18506 from keszybz/fuzz-systemctl-parse-argvYu Watanabe2021-02-101-1/+1
|\ | | | | Fuzzer for systemctl argline parsing
| * xdg-autostart-generator: sort header includesZbigniew Jędrzejewski-Szmek2021-02-081-1/+1
| |
* | Merge pull request #18470 from mrc0mmand/ci-clang-12Luca Boccassi2021-02-091-9/+9
|\ \ | |/ |/| ci: run build test with clang-12 as well
| * tree-wide: fix the string concatenation warning with clang-12Frantisek Sumsal2021-02-081-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | e.g.: ./src/shared/dissect-image.c:2218:39: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation] "/usr/lib/os-release\0", ^ ../src/shared/dissect-image.c:2217:39: note: place parentheses around the string literal to silence warning [META_OS_RELEASE] = "/etc/os-release\0" ^ 1 error generated. See: https://reviews.llvm.org/D85545
* | xdg-autostart: Generate autostart services with templated nameDavid Edmundson2021-02-042-2/+2
|/ | | | | | | | | | | | The "XDG standardization for applications" specification states that services should be in the form: app[-<launcher>]-<ApplicationID>[@<RANDOM>].service or app[-<launcher>]-<ApplicationID>-<RANDOM>.scope In this case "autostart" takes the place of [RANDOM] to provide a unique identifier if the same app is launched elsewhere. As it is a service that means it should be set as a template not using a hyphen delimiter.
* meson: move source file list for systemd-xdg-autostart-generator and its testsYu Watanabe2021-01-181-0/+18
|
* xdg: move tests for xdg-autostart-generatorYu Watanabe2021-01-182-0/+129
| | | | | Then, we can drop src/xdg-autostart-generator from include directories later.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-094-4/+4
|
* xdg-autostart-generator: use Type=execZbigniew Jędrzejewski-Szmek2020-10-221-1/+1
| | | | | | | We check that the binary exists before writing the service file, but let's also not consider the service started until the fork has happened. This is still relatively new stuff, so we're can change the implementation details like this.
* xdg-autostart: Lower most info messages to debug levelBenjamin Berg2020-10-121-7/+7
| | | | | | | | | | | | | | It is expected for numerous autostart files to not be convertible to corresponding units. The information is only useful for someone debugging why a file might not be started, but it is not generally useful for users in most situations. As such, lower the warnings. Anyone wondering why an application is not started will easily notice that the unit is not generated. From there it will be somewhat harder to figure out why, but the overall trade-off is still improved. Fixes: #17305
* xdg-autostart: Ignore more common XDG Desktop Entry fieldsBenjamin Berg2020-10-091-0/+3
| | | | | | | | It makes sense to ignore all the common fields that are expected and that we can safely ignore. Note that it is fine to ignore URL as we will already warn about the type= being wrong in that case. Closes: #17276
* xdg-autostart: Add support for Path= in XDG Desktop FileBenjamin Berg2020-10-092-0/+13
| | | | This sets the working directory of the application.
* Rename find_binary to find_executableZbigniew Jędrzejewski-Szmek2020-09-181-4/+4
| | | | "executable" is more correct than "binary", since scripts are OK too.
* xdg-autostart-generator: downgrade error level when the error will be ignoredYu Watanabe2020-09-101-3/+3
|
* Merge pull request #16635 from keszybz/do-not-for-each-wordLennart Poettering2020-09-091-3/+3
|\ | | | | Drop FOREACH_WORD
| * Rename strv_split_extract() to strv_split_full()Zbigniew Jędrzejewski-Szmek2020-09-091-1/+1
| | | | | | | | | | Now that _full() is gone, we can rename _extract() to have the usual suffix we use for the more featureful version.
| * tree-wide: replace strv_split_full() with strv_split_extract() everywhereZbigniew Jędrzejewski-Szmek2020-09-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Behaviour is not identical, as shown by the tests in test-strv. The combination of EXTRACT_UNQUOTE without EXTRACT_RELAX only appears in the test, so it doesn't seem particularly important. OTOH, the difference in handling of squished parameters could make a difference. New behaviour is what both bash and python do, so I think we can ignore this corner case. This change has the following advantages: - the duplication of code paths that do a very similar thing is removed - extract_one_word() / strv_split_extract() return a proper error code.
* | tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-2/+1
|/
* xdg-autostart: ignore all empty entries in multi-string entriesZbigniew Jędrzejewski-Szmek2020-07-071-8/+9
| | | | | | | | | | | | | | | | | | | The desktop file specification allows entries like ";;;;;;", full of empty strings. But looking at the actual list of supported keys [1], empty entries are meaningless (unless we would allow e.g. the desktop name to be the empty string. But that doesn't seem very useful either). So let's just simplify our life and skip any empty substrings entirely. This would also resolve the fuzzer case: $ valgrind build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812 test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812... ok ==2899241== HEAP SUMMARY: ==2899241== in use at exit: 0 bytes in 0 blocks ==2899241== total heap usage: 484,385 allocs, 484,385 frees, 12,411,330 bytes allocated ↓ ==2899650== HEAP SUMMARY: ==2899650== in use at exit: 0 bytes in 0 blocks ==2899650== total heap usage: 1,325 allocs, 1,325 frees, 1,463,602 bytes allocated
* xdg-autostart: avoid quadratic behaviour in strv parsingZbigniew Jędrzejewski-Szmek2020-07-071-20/+48
| | | | | | | | | | | | | | | | | | | The fuzzer test case has a giant line with ";;;;;;;;;;;..." which is turned into a strv of empty strings. Unfortunately, when pushing each string, strv_push() needs to walk the whole array, which leads to quadratic behaviour. So let's use greedy_allocation here and also keep location in the string to avoid iterating. build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812 51.10s user 0.01s system 99% cpu 51.295 total ↓ build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812 0.07s user 0.01s system 96% cpu 0.083 total Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22812. Other minor changes: - say "was already defined" instead of "defined multiple times" to make it clear that we're ignoring this second definition, and not all definitions of the key - unescaping needs to be done also for the last entry
* xdg-autostart: Ignore all files with GNOME autostart phaseBenjamin Berg2020-06-231-6/+4
| | | | | | | | | If an autostart file for GNOME has a phase specified, then this implies it is a session service that needs to be started at a specific time. We have no way of handling the ordering, and while it does make sense to explicitly hide these services with X-systemd-skip, there is no point in even trying to handle them.
* xdg-autostart: Fix info message if Type= is not ApplicationBenjamin Berg2020-06-231-1/+1
| | | | | The message was copy-pasted and not changed to correctly specify what the problem was.
* conf-parser: return mtime in config_parse() and friendsLennart Poettering2020-06-021-1/+2
| | | | | | | | | | | | | This is a follow-up for 9f83091e3cceb646a66fa9df89de6d9a77c21d86. Instead of reading the mtime off the configuration files after reading, let's do so before reading, but with the fd we read the data from. This is not only cleaner (as it allows us to save one stat()), but also has the benefit that we'll detect changes that happen while we read the files. This also reworks unit file drop-ins to use the common code for determining drop-in mtime, instead of reading system clock for that.
* xdg-autostart: fix two coverity found issuesLennart Poettering2020-05-281-2/+1
| | | | | Fixes: CID#1429003 Fixes: CID#1429004
* xdg-autostart-generator: Add a generator for XDG autostart filesBenjamin Berg2020-05-274-0/+816
This generator can be used by desktop environments to launch autostart applications and services. The feature is an opt-in, triggered by xdg-desktop-autostart.target being activated. Also included is the new binary xdg-autostart-condition. This binary is used as an ExecCondition to test the OnlyShowIn and NotShowIn XDG desktop file keys. These need to be evaluated against the XDG_CURRENT_DESKTOP environment variable which may not be known at generation time. Co-authored-by: Henri Chain <henri.chain@enioka.com>