command-not-found unable to open database file (because it is readable only by root)

Bug #1843606 reported by Sergio Callegari
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

On Ubuntu 19.04 I repeatedly encounter command-not-found crashing because it is unable to open its database.

Inspection reveals that files in /var/lib/command-not-found are owned by root and have permissions set so that they are readable only by the owner.

Deleting these files or changing their permission to be universally readable fixes the issue.

ProblemType: Bug
DistroRelease: Ubuntu 19.04
Package: command-not-found 18.10.0~pre2
ProcVersionSignature: Ubuntu 5.0.0-27.28-generic 5.0.21
Uname: Linux 5.0.0-27-generic x86_64
ApportVersion: 2.20.10-0ubuntu27.1
Architecture: amd64
CurrentDesktop: KDE
Date: Wed Sep 11 17:48:29 2019
EcryptfsInUse: Yes
InstallationDate: Installed on 2013-12-12 (2098 days ago)
InstallationMedia: Kubuntu 13.10 "Saucy Salamander" - Release amd64 (20131016.1)
PackageArchitecture: all
SourcePackage: command-not-found
UpgradeStatus: Upgraded to disco on 2019-06-12 (91 days ago)

Revision history for this message
Sergio Callegari (callegar) wrote :
summary: - command-not-found unable to open database file (because it is readonly)
+ command-not-found unable to open database file (because it is readable
+ only by root)
Revision history for this message
Sergio Callegari (callegar) wrote :

> Deleting these files or changing their permission to be universally readable fixes the issue.

Temporarily fixes the issue. For some reason, at some point the files go back to being -rw------- rather than -rw-r--r--.

Revision history for this message
Sergio Callegari (callegar) wrote :

Again! The database files have been again marked as readable by root only by some system action.

What I get as a result is:

Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.7.3 final 0
Distributor ID: Ubuntu
Description: Ubuntu 19.04
Release: 19.04
Codename: disco
Exception information:

unable to open database file
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 89, in main
    cnf = CommandNotFound.CommandNotFound(options.data_dir)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 81, in __init__
    self.db = SqliteDatabase(dbpath)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 12, in __init__
    self.con = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file

Revision history for this message
Sergio Callegari (callegar) wrote :

My feeling is that the file permissions are changed whenever apt installs something on the system. Is apt running some update script with a wrong umask?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in command-not-found (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.