Skip to content

pkg -N fails for non-root users when database is in WAL mode (breaks zsh completion) #2663

@nuclight

Description

@nuclight

After recent pkg upgrade a week ago on quarterly branch (reproducible in 2.6.2) I've noticed that Tab-completion in zsh have broken after typing pkg info (no matter with -l or not) and pressing Tab - it says that it can't find any packages. The same completion under root user, however, works OK. Moreover, after trying by root it begins to work under non-privileged user - but stops to do so on the next day (after nightly periodic).

Tracing problem in zsh I've reproduced to just one command:

$ /usr/local/sbin/pkg -N query %n-%v
pkg: package database non-existent

which, however, works without -N or from root.

Probable Root Cause

  • pkg now defaults to WAL mode for SQLite (or somewhat similar journal-related commit was done this year)
  • SQLite requires creating/opening -shm and -wal files even for read-only access in WAL mode.
  • The -N flag (used by shell completion scripts) fails immediately when it cannot initialize these files due to EACCES (Permission denied) in /var/db/pkg
  • This creates a "flaky" bug: completion works if root left -shm/-wal files with world-readable permissions, but fails after periodic scripts or pkg clean up these files.

That is, I observe it fails when only local.sqlite is present in /var/db/pkg, but works OK when local.sqlite-shm (32K) and local.sqlite-wal (zero bytes) are also present, left there by pkg info in root's terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions