Debian Bug report logs - #540141
bashisms in /etc/cron.daily/apt

version graph

Package: apt; Maintainer for apt is APT Development Team <deity@lists.debian.org>; Source for apt is src:apt (PTS, buildd, popcon).

Reported by: Yves-Alexis Perez <corsac@debian.org>

Date: Thu, 6 Aug 2009 06:33:02 UTC

Severity: important

Found in version apt/0.7.22.1

Done: Julian Andres Klode <jak@debian.org>

Bug is archived. No further changes may be made.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>:
Bug#540141; Package apt. (Thu, 06 Aug 2009 06:33:04 GMT) (full text, mbox, link).


Acknowledgement sent to Yves-Alexis Perez <corsac@debian.org>:
New Bug report received and forwarded. Copy sent to APT Development Team <deity@lists.debian.org>. (Thu, 06 Aug 2009 06:33:05 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Yves-Alexis Perez <corsac@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: bashisms in /etc/cron.daily/apt
Date: Thu, 06 Aug 2009 08:26:37 +0200
Package: apt
Version: 0.7.22.1
Severity: important
User: debian-release@lists.debian.org
Usertags: goal-dash


Hey,

seems that apt has a bashism in /etc/cron.daily/apt, by using $RANDOM which
doesn't exist on dash:

corsac@hidalgo: checkbashisms /etc/cron.daily/apt
possible bashism in /etc/cron.daily/apt line 297 ($RANDOM):
    if [ -z "$RANDOM" ] ; then
possible bashism in /etc/cron.daily/apt line 301 ($RANDOM):
    TIME=$(($RANDOM % $RandomSleep))


Suggested solution is to use /dev/urandom like:

random="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")"

Cheers,
--
Yves-Alexis Perez


-- Package-specific info:

-- apt-config dump --

APT "";
APT::Architecture "amd64";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
APT::Install-Recommends "false";
APT::Install-Suggests "false";
APT::Acquire "";
APT::Acquire::Translation "environment";
APT::Authentication "";
APT::Authentication::TrustCDROM "true";
APT::NeverAutoRemove "";
APT::NeverAutoRemove:: "^linux-image.*";
APT::NeverAutoRemove:: "^linux-restricted-modules.*";
Dir "/";
Dir::State "var/lib/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::State::userstatus "status.user";
Dir::State::status "/var/lib/dpkg/status";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::sourceparts "sources.list.d";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Etc::preferencesparts "preferences.d";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::dpkg "/usr/bin/dpkg";
Dir::Log "var/log/apt";
Dir::Log::Terminal "term.log";
DPkg "";
DPkg::Pre-Install-Pkgs "";
DPkg::Pre-Install-Pkgs:: "/usr/bin/apt-listchanges --apt || test $? -ne 10";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true";
DPkg::Tools "";
DPkg::Tools::Options "";
DPkg::Tools::Options::/usr/bin/apt-listchanges "";
DPkg::Tools::Options::/usr/bin/apt-listchanges::Version "2";
Acquire "";
Acquire::Pdiffs "false";

-- (no /etc/apt/preferences present) --


-- /etc/apt/sources.list --

deb http://ftp.fr.debian.org/debian/ stable main contrib non-free
deb http://ftp.fr.debian.org/debian/ testing main contrib non-free
deb http://ftp.fr.debian.org/debian/ sid main contrib non-free
deb http://ftp.fr.debian.org/debian/ experimental main contrib non-free

deb-src http://ftp.fr.debian.org/debian/ stable main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ sid main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ experimental main contrib non-free

# kernel
#deb http://kernel-archive.buildserver.net/debian-kernel sid main 
#deb http://kernel-archive.buildserver.net/debian-kernel/ trunk main
#deb-src http://kernel-archive.buildserver.net/debian-kernel/ trunk main

# Multimedia
#deb http://ftp.debian-unofficial.org/debian sid main contrib non-free restricted 

# Perso
deb file:///home/corsac/debian/pkg-xfce/scripts/pbuilder/xfce/build ./
deb file:///home/corsac/debian/builds ./

#maemo
#deb http://www.ipi.fi/~pablo/sbox_amd64 /

#deb http://www.vislab.uq.edu.au/debian/ lenny/

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt depends on:
ii  debian-archive-keyring        2009.01.31 GnuPG archive keys of the Debian a
ii  libc6                         2.9-23     GNU C Library: Shared libraries
ii  libgcc1                       1:4.4.1-1  GCC support library
ii  libstdc++6                    4.4.1-1    The GNU Standard C++ Library v3

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc                   <none>         (no description available)
ii  aptitude                  0.4.11.11-1+b2 terminal-based package manager
ii  bzip2                     1.0.5-3        high-quality block-sorting file co
ii  dpkg-dev                  1.15.3.1       Debian package development tools
ii  lzma                      4.43-14        Compression method of 7z format in
ii  python-apt                0.7.12.1       Python interface to libapt-pkg

-- no debconf information




Information forwarded to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>:
Bug#540141; Package apt. (Thu, 06 Aug 2009 09:00:06 GMT) (full text, mbox, link).


Acknowledgement sent to Sven Joachim <svenjoac@gmx.de>:
Extra info received and forwarded to list. Copy sent to APT Development Team <deity@lists.debian.org>. (Thu, 06 Aug 2009 09:00:06 GMT) (full text, mbox, link).


Message #10 received at 540141@bugs.debian.org (full text, mbox, reply):

From: Sven Joachim <svenjoac@gmx.de>
To: Yves-Alexis Perez <corsac@debian.org>
Cc: 540141@bugs.debian.org
Subject: Re: Bug#540141: bashisms in /etc/cron.daily/apt
Date: Thu, 06 Aug 2009 10:58:46 +0200
On 2009-08-06 08:26 +0200, Yves-Alexis Perez wrote:

> Package: apt
> Version: 0.7.22.1
> Severity: important
> User: debian-release@lists.debian.org
> Usertags: goal-dash
>
>
> Hey,
>
> seems that apt has a bashism in /etc/cron.daily/apt, by using $RANDOM which
> doesn't exist on dash:
>
> corsac@hidalgo: checkbashisms /etc/cron.daily/apt
> possible bashism in /etc/cron.daily/apt line 297 ($RANDOM):
>     if [ -z "$RANDOM" ] ; then
> possible bashism in /etc/cron.daily/apt line 301 ($RANDOM):
>     TIME=$(($RANDOM % $RandomSleep))
>

These are false positives.

> Suggested solution is to use /dev/urandom like:
>
> random="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")"

If you read the code, you will notice that it does just that if /bin/sh
does not define RANDOM by itself.

Sven




Information forwarded to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>:
Bug#540141; Package apt. (Thu, 06 Aug 2009 09:27:02 GMT) (full text, mbox, link).


Acknowledgement sent to Yves-Alexis Perez <corsac@debian.org>:
Extra info received and forwarded to list. Copy sent to APT Development Team <deity@lists.debian.org>. (Thu, 06 Aug 2009 09:27:04 GMT) (full text, mbox, link).


Message #15 received at 540141@bugs.debian.org (full text, mbox, reply):

From: Yves-Alexis Perez <corsac@debian.org>
To: Sven Joachim <svenjoac@gmx.de>
Cc: 540141@bugs.debian.org
Subject: Re: Bug#540141: bashisms in /etc/cron.daily/apt
Date: Thu, 06 Aug 2009 11:19:47 +0200
On jeu, 2009-08-06 at 10:58 +0200, Sven Joachim wrote:
> 
> If you read the code, you will notice that it does just that if /bin/sh
> does not define RANDOM by itself.

Uh oh, good point. I was fooled by an error from cron.daily/apt in my
mailbox and thought it was related to the dash change, so I check the
checkbashisms output. Fail.

Though I still get an unrelated error:

/etc/cron.daily/apt:
[: 324: Illegal number: 

which I don't really explain ($VERBOSE is empty but that shouldn't pose
problems, even to dash).

Cheers,
> 
-- 
Yves-Alexis





Information forwarded to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>:
Bug#540141; Package apt. (Thu, 06 Aug 2009 09:51:08 GMT) (full text, mbox, link).


Acknowledgement sent to Sven Joachim <svenjoac@gmx.de>:
Extra info received and forwarded to list. Copy sent to APT Development Team <deity@lists.debian.org>. (Thu, 06 Aug 2009 09:51:08 GMT) (full text, mbox, link).


Message #20 received at 540141@bugs.debian.org (full text, mbox, reply):

From: Sven Joachim <svenjoac@gmx.de>
To: Yves-Alexis Perez <corsac@debian.org>
Cc: 540141@bugs.debian.org
Subject: Re: Bug#540141: bashisms in /etc/cron.daily/apt
Date: Thu, 06 Aug 2009 11:49:49 +0200
On 2009-08-06 11:19 +0200, Yves-Alexis Perez wrote:

> Though I still get an unrelated error:
>
> /etc/cron.daily/apt:
> [: 324: Illegal number: 
>
> which I don't really explain ($VERBOSE is empty but that shouldn't pose
> problems, even to dash).

That's #539366.

Cheers,
       Sven




Information forwarded to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>:
Bug#540141; Package apt. (Thu, 06 Aug 2009 10:06:02 GMT) (full text, mbox, link).


Acknowledgement sent to Julian Andres Klode <jak@debian.org>:
Extra info received and forwarded to list. Copy sent to APT Development Team <deity@lists.debian.org>. (Thu, 06 Aug 2009 10:06:02 GMT) (full text, mbox, link).


Message #25 received at submit@bugs.debian.org (full text, mbox, reply):

From: Julian Andres Klode <jak@debian.org>
To: Yves-Alexis Perez <corsac@debian.org>, 540141-done@bugs.debian.org
Cc: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Re: Bug#540141: bashisms in /etc/cron.daily/apt
Date: Thu, 6 Aug 2009 12:02:37 +0200
Version: 0.7.22.1

On Thu, Aug 06, 2009 at 08:26:37AM +0200, Yves-Alexis Perez wrote:
> Hey,
> seems that apt has a bashism in /etc/cron.daily/apt, by using $RANDOM which
> doesn't exist on dash:
> 
> corsac@hidalgo: checkbashisms /etc/cron.daily/apt
> possible bashism in /etc/cron.daily/apt line 297 ($RANDOM):
>     if [ -z "$RANDOM" ] ; then
Just look two lines below.

> possible bashism in /etc/cron.daily/apt line 301 ($RANDOM):
>     TIME=$(($RANDOM % $RandomSleep))
Just look two lines above.

> random="$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")"
Have you read line 299?

-- 
Julian Andres Klode  - Free Software Developer
   Debian Developer  - Contributing Member of SPI
   Ubuntu Member     - Fellow of FSFE

Website: http://jak-linux.org/   XMPP: juliank@jabber.org
Debian:  http://www.debian.org/  SPI:  http://www.spi-inc.org/
Ubuntu:  http://www.ubuntu.com/  FSFE: http://www.fsfe.org/




Reply sent to Julian Andres Klode <jak@debian.org>:
You have taken responsibility. (Thu, 06 Aug 2009 10:06:05 GMT) (full text, mbox, link).


Notification sent to Yves-Alexis Perez <corsac@debian.org>:
Bug acknowledged by developer. (Thu, 06 Aug 2009 10:06:05 GMT) (full text, mbox, link).


No longer marked as fixed in versions 0.7.22.1. Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Mon, 04 Nov 2013 12:03:33 GMT) (full text, mbox, link).


Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 03 Dec 2013 07:37:38 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Jan 23 19:37:01 2026; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.