[Pkg-dkms-maint] Bug#848608: dkms: bogus warning: version 'xxx\nyyy' has bad syntax: invalid character in version number

Marc Haber mh+debian-bugs at zugschlus.de
Sun Feb 19 13:46:14 UTC 2017


On Sun, Dec 18, 2016 at 11:29:46PM +0100, Adam Borowski wrote:
> When doing any package installation that involves dkms building new modules,
> I get the following message:
> 
> dpkg: warning: version '4.8.15+
> 4.9.0-debug3+' has bad syntax: invalid character in version number
> dpkg: warning: version '4.8.15+
> 4.9.0-debug3+' has bad syntax: invalid character in version number
> 
> As you can see, both version numbers are concatenated with a \n in between.

I can confirm this. The root cause is in
/usr/lib/dkms/common.postinst. In line 155, the variable KERNELS is
initialized with a list of all installed kernels:

KERNELS=$(ls /lib/modules/ 2>/dev/null || true)

On most Debian systems, this is more than one. Usually, the list
contains also kernel versions that have been deinstalled and/or purged
long ago since Debian's kernel mechanisms are notoriously bad in
cleaning up /lib/modules, but that's a different story.

In line 202, get_newest_kernel gets called with this variable as
parameter:

NEWEST_KERNEL=$(get_newest_kernel "$KERNELS")

This funktion is defined starting line 112, and the Debian-related
part of the code:

get_newest_kernel() {
    NEWEST_KERNEL=
    # Try Debian first as rpm can be installed in Debian based distros
    if [ -e /usr/bin/dpkg ]; then
        # If DEB based
        CURRENT_KERNEL=$1
        CURRENT_VERSION=${CURRENT_KERNEL%%-*}
        CURRENT_ABI=${CURRENT_KERNEL#*-}
        CURRENT_FLAVOUR=${CURRENT_ABI#*-}
        CURRENT_ABI=${CURRENT_ABI%%-*}
        NEWEST_KERNEL=$(_get_newest_kernel_debian "$CURRENT_VERSION-$CURRENT_ABI")

Clearly expects only one kernel version in $1, the current one. The
entire mechanism with the shell string functions being used chokes on
the input, which results in _get_newest_kernel_debian getting called
with another multi-line-string, which ends up in the COMPARE_TO
variable in line 64, and dpkg --compare-version in line 71 finally
complains about the multi-line argument.

I have not yet grokked about how this mechanism is supposed to work,
and therefore can't comment about how things should be correct. All I
can say that this at least looks grossly wrong.

Greetings
Marc

-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany    |  lose things."    Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421



More information about the Pkg-dkms-maint mailing list