summaryrefslogtreecommitdiffstats
path: root/src/xdg-autostart-generator (follow)
Commit message (Collapse)AuthorAgeFilesLines
* path-lookup: move xdg_user_dirs() to xdg-autostart-generatorMike Yuan2024-10-061-1/+34
| | | | | | This is the only place where xdg_user_dir() is needed and makes sense. All other invocations have been replaced with user_search_dirs() - see previous commits for details.
* path-lookup: deduplicate xdg_user_*() with sd_path_lookup()Mike Yuan2024-10-061-1/+1
| | | | While at it, place ret param at last.
* various: move ptr indicator to return valueZbigniew Jędrzejewski-Szmek2024-06-192-2/+2
|
* strv: add helper to extend strv from both sidesZbigniew Jędrzejewski-Szmek2024-03-071-1/+1
| | | | | | Also, use the more correct type of 'const char* const*' for the input strv. This requires adding the cast in a few places, but also allows to remove some casts in others.
* xdg-autostart: downgrade warning for missing executablesZbigniew Jędrzejewski-Szmek2023-11-071-1/+4
| | | | | | | | | | | | | | | On a system with a shared home directory, I'm getting a bunch of warnings: systemd-xdg-autostart-generator[76]: Exec binary '/usr/bin/flatpak' does not exist: No such file or directory systemd-xdg-autostart-generator[76]: /home/zbyszek/.config/autostart/org.signal.Signal.desktop: not generating unit, error parsing Exec= line: No such file or directory systemd-xdg-autostart-generator[76]: Exec binary '/usr/bin/flatpak' does not exist: No such file or directory systemd-xdg-autostart-generator[76]: /home/zbyszek/.config/autostart/im.riot.Riot.desktop: not generating unit, error parsing Exec= line: No such file or directory systemd-xdg-autostart-generator[76]: Exec binary '/usr/libexec/gnome-tweak-tool-lid-inhibitor' does not exist: No such file or directory systemd-xdg-autostart-generator[76]: /home/zbyszek/.config/autostart/ignore-lid-switch-tweak.desktop: not generating unit, error parsing Exec= line: No such file or directory systemd-xdg-autostart-generator[76]: Exec binary '/usr/bin/flatpak' does not exist: No such file or directory systemd-xdg-autostart-generator[76]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop: not generating unit, error parsing Exec= line: No such file or directory This isn't really a problem. Let's just print an info message.
* fuzz: unify logging setupFrantisek Sumsal2023-10-191-4/+1
| | | | | | | | | | Make sure we don't log anything when running in "fuzzing" mode. Also, when at it, unify the setup logic into a helper, pretty similar to the test_setup_logging() one. Addresses: - https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607 - https://github.com/systemd/systemd/pull/29558#discussion_r1358940663
* generators: use generator_open_unit_file where appropriateMike Yuan2023-08-191-9/+9
|
* meson: also merge declarations of fuzzers with other executablesYu Watanabe2023-08-031-4/+1
|
* meson: merge declarations of normal and test executablesYu Watanabe2023-08-031-4/+1
|
* meson: move declarations of several generatorsYu Watanabe2023-07-311-0/+14
|
* Drop split-usr and unmerged-usr supportLuca Boccassi2023-07-281-1/+1
| | | | | | | | | | As previously announced, execute order 66: https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html The meson options split-usr, rootlibdir and rootprefix become no-ops that print a warning if they are set to anything other than the default values. We can remove them in a future release.
* tree-wide: fix typo found by Fossies Codespell reportYu Watanabe2023-07-211-1/+1
|
* xdg-autostart-generator: extend start timeoutLennart Poettering2023-06-081-1/+1
| | | | | | | | | | | | | | | The current start + stop timeouts for xdg autostart files are *very* short with 5s. On a busy system this might be too easy to hit even in unintended case. Apparently, the intention here was to cut the shutdown logic short. (https://github.com/systemd/systemd/issues/27919#issuecomment-1580576178) Let's hence stick to the very short timeout for that (under the assumption that apps are written in a safe enough style to not lose data if killed too early). But for starting XGD autostrat services, use our regular timeouts. See: #27919
* tree-wide: use _cleanup_set_free_ and friendsYu Watanabe2023-05-311-1/+1
| | | | Instead of _cleanup_(set_freep) or so.
* tree-wide: Fix false positives on newer gccDaan De Meyer2023-05-231-2/+2
| | | | | | Recent gcc versions have started to trigger false positive maybe-uninitialized warnings. Let's make sure we initialize variables annotated with _cleanup_ to avoid these.
* xdg-autostart-service: handle gnome autostart phase better on other desktopsDavid Edmundson2023-04-281-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Autostart files which contain the line gnome-autostart-phase are currently completely skipped by systemd. This is because these are handled internally by gnome startup through other means. The problem is a number of desktop files that need to run on KDE too have this flag set. Ideally they should just create systemd user units, but we're not at this point universally yet. This patch changes the logic so if the flag is set, we set NotShowIn-gnome, which in turn would just not load decided at runtime. As an optimisation if we would get conflicting OnlyShowIn lines we still skip the file completely. Example: $ rg 'Exec|Autostart-Phase' /etc/xdg/autostart/gnome-keyring-pkcs11.desktop Exec=/usr/bin/gnome-keyring-daemon --start --components=pkcs11 X-GNOME-Autostart-Phase=PreDisplayServer $ cat '/tmp/xxx/app-gnome\x2dkeyring\x2dpkcs11@autostart.service' # Automatically generated by systemd-xdg-autostart-generator [Unit] SourcePath=/etc/xdg/autostart/gnome-keyring-pkcs11.desktop ... [Service] ... ExecCondition=/usr/lib/systemd/systemd-xdg-autostart-condition "Unity:MATE" "GNOME" Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
* xdg-autostart-generator: do not warn about unknown fieldsZbigniew Jędrzejewski-Szmek2023-03-251-1/+2
| | | | | | | | | | | | | My user manager says: systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:256: Unknown key name 'Actions' in section 'Desktop Entry', ignoring. systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:258: Unknown section 'Desktop Action new-window'. Ignoring. systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:343: Unknown section 'Desktop Action preferences'. Ignoring. systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:12: Unknown key name 'Actions' in section 'Desktop Entry', ignoring. systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:13: Unknown key name 'SingleMainWindow' in section 'Desktop Entry', ignoring. systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:19: Unknown section 'Desktop Action Quit'. Ignoring. This is not useful. Those are externally-provided files, and they are likely to have entries which we know nothing about.
* meson: Use dicts for fuzzer definitionsJan Janssen2023-02-211-2/+6
|
* meson: Use dicts for test definitionsJan Janssen2023-02-211-2/+6
| | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* meson: Do not include headers in source listsJan Janssen2023-01-241-5/+3
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* xdg-autostart-service: Add comments to tilde expansion, use path_join()David Edmundson2022-10-171-2/+5
| | | | Follow-ups for https://github.com/systemd/systemd/pull/24658
* xdg-autostart-service: expand tilde in Exec linesDavid Edmundson2022-09-152-2/+31
| | | | | | | | In typical desktop file parsing it is expected that "~" expands to a home directory. Users may write an autostart file with "Exec=myCoolService ~/.someSpecialConfig" which worked before the systemd migration.
* xdg-autostart-service: Use common boolean parserDavid Edmundson2022-09-132-9/+11
| | | | | | | | | | | Technically the desktop entry specification says value should be the string "true" or "false". Pragmatically every desktop has their own parsing rules which are typically less strict on how to interpret other values. This caused some regressions downstream when we switched to the xdg-autostart-generator where existing handmade files contained values with "True" or "False".
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-6/+3
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* tree-wide: allow ASCII fallback for … in logsDavid Tardon2022-06-282-4/+7
|
* fuzzers: ignore size limits when compiled standaloneZbigniew Jędrzejewski-Szmek2022-05-121-1/+1
| | | | | This way we can still call fuzzers on old samples, but oss-fuzz will not waste its and our time finding overly large inputs.
* fuzzers: add input size limits, always configure limits in two waysYu Watanabe2022-05-122-0/+5
| | | | | | | | | | | | | | | | | Without the size limits, oss-fuzz creates huge samples that time out. Usually this is because some of our code has bad algorithmic complexity. For data like configuration samples we don't need to care about this: non-rogue configs are rarely more than a few items, and a bit of a slowdown with a few hundred items is acceptable. This wouldn't be OK for processing of untrusted data though. We need to set the limit in two ways: through .options and in the code. The first because it nicely allows libFuzzer to avoid wasting time, and the second because fuzzers like hongfuzz and afl don't support .options. While at it, let's fix an off-by-one (65535 is the largest offset for a power-of-two size, but we're checking the size here). Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
* xdg-autostart-service: Fix binary escaping and simplify code a bitBenjamin Berg2022-03-252-19/+8
| | | | | | | | Instead of escaping each component separately, we can instead use quote_command_line. Doing so simplifies the code and fixes an issue where spaces inside the executable name were not escaped. Co-Authored-By: David Edmundson <kde@davidedmundson.co.uk>
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-192-2/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* test: Use TEST macros in more placesJan Janssen2022-03-161-12/+7
|
* conf-parser: update config_item_*_lookup() to follow modern coding styleLennart Poettering2022-02-091-7/+7
| | | | | Let's rename the return parameters ret_xyz, and always initialize them if we return >= 0, as per our current coding style.
* xdg-autostart-service: Ignore missing desktop-sepcific condition binaryBenjamin Berg2022-01-121-1/+1
| | | | | | | | | If a desktop specific ExecCondition= binary does not exist, this just means that the desktop environment is not available. As such, it is not an error condition that should prevent the service from being installed in the .wants target. Fix this by simply returning zero.
* meson: Use files() for fuzzersJan Janssen2022-01-111-3/+3
| | | | | | Not having to provide the full path in the source tree is much nicer and the produced lists can also be used anywhere in the source tree.
* meson: Use files() for testsJan Janssen2022-01-111-3/+3
| | | | | | Not having to provide the full path in the source tree is much nicer and the produced lists can also be used anywhere in the source tree.
* xdg-autostart-generator: rework debug loggingZbigniew Jędrzejewski-Szmek2022-01-102-29/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logs used the service name as the primary log key. But the service name often needs to contain escape symbols, and the logs are rather hard to read because of this. Thus the logs are changed to use the path to the source desktop file. I think this is much more useful because the user will want to look at the source file too and maybe change it if something goes wrong. A bit more logging to show which directories we are looking at and why we skip certain units is added too. $ rm -rf /tmp/out && mkdir /tmp/out && SYSTEMD_LOG_LEVEL=debug SYSTEMD_LOG_TARGET=console build/systemd-xdg-autostart-generator /tmp/{out,out,out} Scanning autostart directory "/home/zbyszek/.config/autostart"… Scanning autostart directory "/etc/xdg/autostart"… /etc/xdg/autostart/tracker-miner-rss-3.desktop: not generating unit, marked as skipped by generator. /etc/xdg/autostart/gnome-initial-setup-first-login.desktop: ExecCondition executable gnome-systemd-autostart-condition not found, unit will not be started automatically: No such file or directory /etc/xdg/autostart/geoclue-demo-agent.desktop: symlinking app-geoclue\x2ddemo\x2dagent@autostart.service in xdg-desktop-autostart.target/.wants… SELinux enabled state cached to: disabled Directory "/tmp" already exists, but has mode 0777 that is too permissive (0755 was requested), refusing. /etc/xdg/autostart/polkit-mate-authentication-agent-1.desktop: symlinking app-polkit\x2dmate\x2dauthentication\x2dagent\x2d1@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/mate-settings-daemon.desktop: symlinking app-mate\x2dsettings\x2ddaemon@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/user-dirs-update-gtk.desktop: symlinking app-user\x2ddirs\x2dupdate\x2dgtk@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/org.freedesktop.problems.applet.desktop: symlinking app-org.freedesktop.problems.applet@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/org.gnome.SettingsDaemon.Datetime.desktop: not generating unit, startup phases are not supported. /etc/xdg/autostart/org.gnome.SettingsDaemon.XSettings.desktop: not generating unit, startup phases are not supported. /etc/xdg/autostart/org.gnome.SettingsDaemon.DiskUtilityNotify.desktop: symlinking app-org.gnome.SettingsDaemon.DiskUtilityNotify@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/gnome-initial-setup-copy-worker.desktop: not generating unit, startup phases are not supported. /etc/xdg/autostart/org.gnome.Evolution-alarm-notify.desktop: symlinking app-org.gnome.Evolution\x2dalarm\x2dnotify@autostart.service in xdg-desktop-autostart.target/.wants… /etc/xdg/autostart/tracker-miner-fs-3.desktop: not generating unit, marked as skipped by generator. /etc/xdg/autostart/orca-autostart.desktop: ExecCondition executable gnome-systemd-autostart-condition not found, unit will not be started automatically: No such file or directory ... Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=2038750. The return value from xdg_autostart_service_generate_unit() is ignored by the caller, so we can do a shortcut return without functional change. This is nicer because we're now consistently always returning an error if something failed.
* xdg-autostart-generator: make parameter constZbigniew Jędrzejewski-Szmek2022-01-102-3/+2
|
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* 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
| |