Skip to content

netatalk: replace gsettings with dconf keyfile for indexer config#2902

Open
rdmark wants to merge 1 commit intomainfrom
rdmark-localsearch-commands
Open

netatalk: replace gsettings with dconf keyfile for indexer config#2902
rdmark wants to merge 1 commit intomainfrom
rdmark-localsearch-commands

Conversation

@rdmark
Copy link
Copy Markdown
Member

@rdmark rdmark commented Apr 19, 2026

The gsettings set approach was broken at runtime because gsettings requires a dconf-service on the session bus, which netatalk's private dbus-daemon does not auto-activate.

Replace set_sl_volumes() with a dconf keyfile writer: it creates /etc/dconf/db/netatalk.d/10-spotlight and runs dconf update, which works without any session bus. Add DCONF_PROFILE env so the indexer reads from the netatalk-specific database. Ship config/dconf/netatalk (system-db:netatalk) as the dconf profile, installed to sysconfdir/dconf/profile/. Detect the dconf binary at build time and gate have_spotlight on it instead of gsettings.

In meson, decouple indexer binary detection from GSettings schema detection:

On Debian Trixie, the localsearch binary is present but ships the Tracker3 GSettings schema rather than LocalSearch3. Decouple binary and schema selection so that any available binary (localsearch preferred, tracker3 as fallback) is paired with whichever schema is actually installed.

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 19, 2026

🤖 Augment PR Summary

Summary: This PR improves Spotlight indexer configuration by generating a system dconf database keyfile instead of issuing per-run gsettings set calls, and makes schema detection at build time more robust across Tracker3 vs LocalSearch3.

Changes:

  • Installs a dedicated dconf profile (config/dconf/netatalk) and hooks it into the build when Spotlight support is enabled
  • Updates set_sl_volumes() to write Spotlight volume paths into a dconf keyfile under /etc/dconf/db/netatalk.d and then run dconf update
  • Sets DCONF_PROFILE when starting the Spotlight indexer so dconf operations target the netatalk profile/database
  • Enhances Meson Spotlight detection by independently selecting an available indexer binary (preferring localsearch) and probing which GSettings schema is actually installed
  • Adds Meson config defines for the dconf key path, profile, and database directory

Technical Notes: Spotlight is now gated on dconf being present, and the chosen indexer binary is paired with whichever schema is detected via gsettings list-keys at configure time.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread meson.build Outdated
Comment thread meson.build
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch from 2adafe0 to 1f55edf Compare April 19, 2026 07:09
@rdmark rdmark marked this pull request as draft April 19, 2026 16:59
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch from 1f55edf to 16d8ab0 Compare April 19, 2026 17:35
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch from 16d8ab0 to 4914b28 Compare April 19, 2026 17:39
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch 2 times, most recently from e77b771 to d3ee288 Compare April 19, 2026 18:36
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch from d3ee288 to b3c165d Compare April 19, 2026 19:02
@rdmark rdmark marked this pull request as ready for review April 19, 2026 19:03
@rdmark
Copy link
Copy Markdown
Member Author

rdmark commented Apr 19, 2026

augment review

@rdmark rdmark changed the title meson: more versatile detection of GSettings schema for Spotlight netatalk: replace gsettings with dconf keyfile for indexer config Apr 19, 2026
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Spectest (AFP 3.4) - Flamegraph (AFP_ASSERT active)

Commit: b3c165d5739bda2c46f92825b4f6c9a98a2bca17
Profiling: On-CPU sampling @ 1009 Hz (prime), DWARF call-graph, x86_64
Build: debugoptimized (-O2 -g -fno-omit-frame-pointer)
Total Runtime: 67s, Netatalk Code-time: 8.9%,
Stacks: 1238, SVG size: 788K

🔥 Open interactive Flamegraph (SVG)

Flamegraph preview

📥 Download from artifacts →

🔝 Top 10 leaf functions
Function Samples
_raw_spin_unlock_irqrestore 302279400
dircache_remove_children 123885000
do_syscall_64 117938520
__cp_end 72348840
srso_alias_safe_ret 50545080
__syscall_cp_c 28741320
file_close_fd 21803760
tcp_sendmsg_locked 20812680
finish_task_switch.isra.0 18830520
x64_sys_call 17839440

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread etc/netatalk/netatalk.c Outdated
Comment thread etc/netatalk/netatalk.c Outdated

vollist->entry[vollist->qty] = volnamequot;
vollist->qty++;
fprintf(fp, "'%s'", vol->v_path);
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fprintf(fp, "'%s'", vol->v_path) writes volume paths into a GVariant string without escaping; a path containing a single quote/backslash/newline could corrupt the dconf keyfile and break dconf update.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread etc/netatalk/netatalk.c Outdated
Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread etc/netatalk/netatalk.c Outdated
}

fprintf(fp, "[" INDEXER_DCONF_PATH "]\n");
fprintf(fp, "index-recursive-directories=[");
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_sl_volumes() can emit index-recursive-directories=[] when no volumes have AFPVOL_SPOTLIGHT; an empty array in GVariant text typically needs an explicit type (e.g., @as []) or dconf update may fail to parse it. Consider ensuring the generated value is valid even when the list is empty.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread etc/netatalk/netatalk.c Outdated

vollist->entry[vollist->qty] = volnamequot;
vollist->qty++;
fprintf(fp, "'%s'", vol->v_path);
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vol->v_path is written into a GVariant string literal via '%s' without escaping; paths containing a single quote or backslash can produce an invalid dconf keyfile and cause dconf update/reads to fail. Consider escaping vol->v_path according to GVariant string rules before writing.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread etc/netatalk/netatalk.c
" index-single-directories \"[]\"");
fprintf(fp, "]\n");
fprintf(fp, "index-single-directories=@as []\n");
fclose(fp);
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return values of the preceding fprintf() calls and fclose(fp) aren’t checked, so write/flush errors (e.g., disk full) could go unnoticed while still proceeding to dconf update. Consider checking the stream error state before assuming the keyfile was written successfully.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

The gsettings set approach was broken at runtime because gsettings
requires a dconf-service on the session bus, which netatalk's private
dbus-daemon does not auto-activate.

Replace set_sl_volumes() with a dconf keyfile writer: it creates
/etc/dconf/db/netatalk.d/10-spotlight and runs dconf update, which
works without any session bus. Add DCONF_PROFILE env so the indexer
reads from the netatalk-specific database. Ship config/dconf/netatalk
(system-db:netatalk) as the dconf profile, installed to
sysconfdir/dconf/profile/. Detect the dconf binary at build time and
gate have_spotlight on it instead of gsettings.
@rdmark rdmark force-pushed the rdmark-localsearch-commands branch from b3c165d to b6921ac Compare April 19, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant