summaryrefslogtreecommitdiffstats
path: root/src/xdg-autostart-generator/xdg-autostart-generator.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-10 12:06:38 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-10 13:22:01 +0100
commit0d1610c9c93c10da737d0741d327d3f78bd1119b (patch)
tree69c7199564d32d5cbcffeb5b7f8c9f2f7edfddd5 /src/xdg-autostart-generator/xdg-autostart-generator.c
parentxdg-autostart-generator: make parameter const (diff)
downloadsystemd-0d1610c9c93c10da737d0741d327d3f78bd1119b.tar.xz
systemd-0d1610c9c93c10da737d0741d327d3f78bd1119b.zip
xdg-autostart-generator: rework debug logging
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.
Diffstat (limited to 'src/xdg-autostart-generator/xdg-autostart-generator.c')
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-generator.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/xdg-autostart-generator/xdg-autostart-generator.c b/src/xdg-autostart-generator/xdg-autostart-generator.c
index c5c6b54fdc..8bc16831e7 100644
--- a/src/xdg-autostart-generator/xdg-autostart-generator.c
+++ b/src/xdg-autostart-generator/xdg-autostart-generator.c
@@ -44,38 +44,42 @@ static int enumerate_xdg_autostart(Hashmap *all_services) {
STRV_FOREACH(path, autostart_dirs) {
_cleanup_closedir_ DIR *d = NULL;
+ log_debug("Scanning autostart directory \"%s\"…", *path);
d = opendir(*path);
if (!d) {
- if (errno != ENOENT)
- log_warning_errno(errno, "Opening %s failed, ignoring: %m", *path);
+ log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, errno,
+ "Opening %s failed, ignoring: %m", *path);
continue;
}
FOREACH_DIRENT(de, d, log_warning_errno(errno, "Failed to enumerate directory %s, ignoring: %m", *path)) {
- _cleanup_free_ char *fpath = NULL, *name = NULL;
- _cleanup_(xdg_autostart_service_freep) XdgAutostartService *service = NULL;
struct stat st;
-
if (fstatat(dirfd(d), de->d_name, &st, 0) < 0) {
- log_warning_errno(errno, "stat() failed on %s/%s, ignoring: %m", *path, de->d_name);
+ log_warning_errno(errno, "%s/%s: stat() failed, ignoring: %m", *path, de->d_name);
continue;
}
- if (!S_ISREG(st.st_mode))
+ if (!S_ISREG(st.st_mode)) {
+ log_debug("%s/%s: not a regular file, ignoring.", *path, de->d_name);
continue;
+ }
- name = xdg_autostart_service_translate_name(de->d_name);
+ _cleanup_free_ char *name = xdg_autostart_service_translate_name(de->d_name);
if (!name)
return log_oom();
- if (hashmap_contains(all_services, name))
+ if (hashmap_contains(all_services, name)) {
+ log_debug("%s/%s: we have already seen \"%s\", ignoring.",
+ *path, de->d_name, name);
continue;
+ }
- fpath = path_join(*path, de->d_name);
+ _cleanup_free_ char *fpath = path_join(*path, de->d_name);
if (!fpath)
return log_oom();
- service = xdg_autostart_service_parse_desktop(fpath);
+ _cleanup_(xdg_autostart_service_freep) XdgAutostartService *service =
+ xdg_autostart_service_parse_desktop(fpath);
if (!service)
return log_oom();
service->name = TAKE_PTR(name);