Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1041872: command-not-found: Problem with user permission

36 views
Skip to first unread message

robert

unread,
Jul 24, 2023, 2:20:04 PM7/24/23
to
Package: command-not-found
Version: 23.04.0-1
Severity: important

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

* What led up to the situation?
Installing "command-not-found" using aptitude, enabling it in /etc/bashrc, and
misspelling a command. A warning was displayed:

"WARNING:root:could not open file
'/etc/apt/sources.list.d/DebianRepositories.sources': Unable to parse section
data".

Nothing else.

* What exactly did you do (or not do) that was effective (or
ineffective)?

Searching the DBTS provided information about similar behaviors (#965020,
#1021953), but specially #966307 because to be able to make it work the same
non-sense steps described there must be taken. A similar solution can be found
at StackExchange [1].

1) According to the documentation of "command-not-found"[2], issuing "update-
command-not-found(8)" must create a list of programs from whatever is at
/var/cache/apt/apt-file/. It did nothing, not even an error, because there was
nothing there.

2) Therefore, apt-file(1) must be executed manually as "root" user! Even when
it is a normal user command (again, according to its documentation man page):

~$ LANG=C apt-file update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission
denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13:
Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches
(13: Permission denied)

3) After the previous step, and issuing another "update-command-not-found"
(also as root), the database of programs appears at /var/lib/command-not-found/
as described in [1] and [2]. However, the directory /var/cache/apt/apt-file
still does not exist. So, what will happen the next time "update-command-not-
found" is issued?

4) Currently, when misspelling a command in a CLI, the warning about not being
able to open the sources.list file is still displayed.

~$ LANG=C datE


WARNING:root:could not open file
'/etc/apt/sources.list.d/DebianRepositories.sources': Unable to parse section
data

Command 'datE' not found, did you mean:
command 'dat' from deb liballegro4-dev
command 'date' from deb coreutils
Try: apt install <deb name>

I do not really know whether the permission of the user play any role in the
crazy behavior of the "command-not-found" tool. However, the fact of getting a
warning about not being able to access a file usually available (mode 644)
every time I misspelled a command was the cause of investigating it.

As a user, I think this is too much trouble.

Anyway, I take advantage of the message to thank you in advance for your work
and help.

Regards, robert

[1] https://unix.stackexchange.com/questions/585107/debian-command-not-found-
error-local-variable-cnf-referenced-before-assignme

[2] /usr/share/doc/command-not-found/README.Debian

*** End of the template - remove these template lines ***


-- System Information:
Debian Release: trixie/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.3.0-2-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=ca_ES.UTF-8, LC_CTYPE=ca_ES.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages command-not-found depends on:
ii apt-file 3.3
ii lsb-release 12.0-2
ii python3 3.11.4-5
ii python3-apt 2.6.0

command-not-found recommends no packages.

Versions of packages command-not-found suggests:
pn snapd <none>

-- no debconf information

robert

unread,
Aug 14, 2023, 1:00:05 PM8/14/23
to
Package: command-not-found
Version: 23.04.0-1
Followup-For: Bug #1041872

Dear Maintainer,

I am writing to say that I fixed (at least) one of the problems I described in
the initial bug report.

Every time I typed a wrong command, a warning about "not being able to parse
the sources file" was shown, which was bizarre because "apt" and "aptitude"
work as expected. At the moment of filling the bug report I thought it was a
problem with the file permissions because I had problems to generate the
database even working as root.

After a few weeks, reviewing the status of this bug, I noticed another one
(#1042872) reporting the same warning but with a different file name. It was
pointed out (message #10) that the source file in DEB822-format should not have
a blank line before the 1st APT source. I removed the line in my file and the
warning is gone.

What I don't know is whether this problem was also the origin of not being able
to generate the database initially.

Feel free to close the bug, although I think there should be a note somewhere
about this issue when installing this package. The sources.list(5) man page is
clear when it describes the format of the sources files in DEB822 style.

".... Individual entries are separated by an empty line; additional
empty lines are ignored, and a # character at the start of the line
marks the entire line as a comment."

Thank you for maintaining the package. Regards.


-- System Information:
Debian Release: trixie/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.4.0-2-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=ca_ES.UTF-8, LC_CTYPE=ca_ES.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages command-not-found depends on:
ii apt-file 3.3
ii lsb-release 12.0-2
ii python3 3.11.4-5+b1
0 new messages