Merge ~krenshaw/ubuntu/+source/command-not-found:focal-lp1953610 into ubuntu/+source/command-not-found:ubuntu/focal-proposed

Proposed by Kellen Renshaw
Status: Merged
Merge reported by: Robie Basak
Merged at revision: a7e9755ab845661b1328cc28ea244b00a24530d4
Proposed branch: ~krenshaw/ubuntu/+source/command-not-found:focal-lp1953610
Merge into: ubuntu/+source/command-not-found:ubuntu/focal-proposed
Diff against target: 59 lines (+20/-1)
4 files modified
CommandNotFound/CommandNotFound.py (+1/-1)
cnf-update-db (+2/-0)
debian/changelog (+12/-0)
debian/tests/smoke (+5/-0)
Reviewer Review Type Date Requested Status
Julian Andres Klode (community) Approve
git-ubuntu import Pending
Review via email: mp+414978@code.launchpad.net

Description of the change

Cherry-picks the patches contributed to cnf by Arnaud Rebillout to Focal to address LP: #1953610.

To post a comment you must log in.
a7e9755... by Kellen Renshaw

Cherry-pick of cnf-update-db fixes from 22.04

 Fixes: LP: #1953610

Signed-off-by: Kellen Renshaw <email address hidden>

Revision history for this message
Julian Andres Klode (juliank) wrote :

We sponsored these uploads, this should be merged

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CommandNotFound/CommandNotFound.py b/CommandNotFound/CommandNotFound.py
2index 742851b..dfdd21c 100644
3--- a/CommandNotFound/CommandNotFound.py
4+++ b/CommandNotFound/CommandNotFound.py
5@@ -75,7 +75,7 @@ class CommandNotFound(object):
6 def __init__(self, data_dir="/usr/share/command-not-found"):
7 self.sources_list = self._getSourcesList()
8 # a new style DB means we can skip loading the old legacy static DB
9- if os.path.exists(dbpath):
10+ if os.path.exists(dbpath) and os.access(dbpath, os.R_OK):
11 self.db = SqliteDatabase(dbpath)
12 else:
13 raise FileNotFoundError("Cannot find database")
14diff --git a/cnf-update-db b/cnf-update-db
15index 18cba1e..6174635 100755
16--- a/cnf-update-db
17+++ b/cnf-update-db
18@@ -22,6 +22,8 @@ if __name__ == "__main__":
19
20 command_files = glob.glob("/var/lib/apt/lists/*Commands-*")
21 if len(command_files) > 0:
22+ umask = os.umask(0o22)
23 col = DbCreator(command_files)
24 col.create(db)
25+ os.umask(umask)
26
27diff --git a/debian/changelog b/debian/changelog
28index d435bf3..9504cc9 100644
29--- a/debian/changelog
30+++ b/debian/changelog
31@@ -1,3 +1,15 @@
32+command-not-found (20.04.6) focal; urgency=medium
33+
34+ [ Arnaud Rebillout ]
35+ * cnf: Bail out early if the database is not readable
36+ * cnf-update-db: Creates a world-readable database (Closes: #986461)
37+ * Add test to make sure that the database is world-readable
38+
39+ [ Kellen Renshaw ]
40+ * Cherry-pick cnf-update-db umask fixes from 22.04 (LP: #1953610)
41+
42+ -- Kellen Renshaw <kellen.renshaw@canonical.com> Mon, 14 Feb 2022 10:10:22 -0700
43+
44 command-not-found (20.04.5) focal; urgency=medium
45
46 * Correctly handle compressed APT index files (LP: #1876034)
47diff --git a/debian/tests/smoke b/debian/tests/smoke
48index 4f0e5ae..949e637 100755
49--- a/debian/tests/smoke
50+++ b/debian/tests/smoke
51@@ -18,3 +18,8 @@ adduser --gecos="no" --disabled-password testuser
52
53 echo "Ensure c-n-f works as user"
54 su -l testuser -c "/usr/lib/command-not-found --ignore-installed konsole" 2>&1 | grep konsole
55+
56+echo "Ensure c-n-f database is world-readable" # cf. #986461
57+rm -f /var/lib/command-not-found/*
58+(umask 0077 && /usr/lib/cnf-update-db)
59+su -l testuser -c "/usr/lib/command-not-found --ignore-installed emacs" 2>&1 | grep emacs

Subscribers

People subscribed via source and target branches