[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1011284: marked as done (popularity-contest: d/postinst: remove bash dependency, fix shellcheck)



Your message dated Sat, 03 Dec 2022 16:23:58 +0000
with message-id <E1p1VJ0-00FGlj-7x@fasolo.debian.org>
and subject line Bug#1011284: fixed in popularity-contest 1.75
has caused the Debian Bug report #1011284,
regarding popularity-contest: d/postinst: remove bash dependency, fix shellcheck
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1011284: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1011284
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Source: popularity-contest
Version: 1.74
Severity: wishlist
Tags: patch

Dear Maintainer,

d/postinst hard-depends on bash to generate random days/hours/minutes;
however,
  od -d -An -N2 /dev/urandom
is equivalent to
  bash -c 'echo $RANDOM'
‒ patch 1 replaces the latter with the former;
od is part of coreutils, and -d is a legacy switch so it's available on
all implementations (and we already use it as a fallback for hostid
generation).

If we did -N1 we'd read only one byte, instead of 2, but that'd impact
the distribution after mod, so I left that as-were.

Patch 2 fixes remaining shellcheck annotations in d/postinst.

Patches apply to current Salsa HEAD; I included gbp dch d/changelog
output inside, as seems to be the custom. Feel free to drop it,
of course.

Best,
наб

-- System Information:
Debian Release: 11.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-14-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
From 9e8bc1745a452a43c31a5b8142b12ee40602c32d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Thu, 19 May 2022 16:52:23 +0200
Subject: [PATCH 1/2] Use od instead of bash to generate random numbers in
 d/postinst
X-Mutt-PGP: OS

---
 debian/changelog | 6 ++++++
 debian/postinst  | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ceca4e4..f84d701 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+popularity-contest (1.75) UNRELEASED; urgency=medium
+
+  * Use od instead of bash to generate random numbers in d/postinst
+
+ -- наб <nabijaczleweli@nabijaczleweli.xyz>  Thu, 19 May 2022 16:52:49 +0200
+
 popularity-contest (1.74) unstable; urgency=medium
 
   * debian/rules: add missing targets. Closes: #999319 Thanks Lucas Nussbaum
diff --git a/debian/postinst b/debian/postinst
index 1501d5c..bb7b2b2 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -38,12 +38,12 @@ generate_id() {
 
 # Select a random day to submit on, to spread the load over time, unless it is already set.
 select_random_day() {
-        DAY=`bash -c 'echo $(($RANDOM % 7))'`
+	DAY=$(( $(od -d -An -N2 /dev/urandom) % 7))
 }
 
 generate_crond() {
-  MIN=`bash -c 'echo $(($RANDOM % 60))'`
-  HOUR=`bash -c 'echo $(($RANDOM % 24))'`
+  MIN=$(( $(od -d -An -N2 /dev/urandom) % 60))
+  HOUR=$(( $(od -d -An -N2 /dev/urandom) % 24))
   FILE=/etc/cron.daily/popularity-contest
   cat > /etc/cron.d/popularity-contest <<EOF
 SHELL=/bin/sh
-- 
2.30.2

From 6ffbb3d39e282924f4f354ee4508ab5ae3f38fda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Thu, 19 May 2022 16:53:45 +0200
Subject: [PATCH 2/2] Fix shellcheck warnings in d/postinst
X-Mutt-PGP: OS

---
 debian/changelog | 3 ++-
 debian/postinst  | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f84d701..242e98b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
 popularity-contest (1.75) UNRELEASED; urgency=medium
 
   * Use od instead of bash to generate random numbers in d/postinst
+  * Fix shellcheck warnings in d/postinst
 
- -- наб <nabijaczleweli@nabijaczleweli.xyz>  Thu, 19 May 2022 16:52:49 +0200
+ -- наб <nabijaczleweli@nabijaczleweli.xyz>  Thu, 19 May 2022 16:53:48 +0200
 
 popularity-contest (1.74) unstable; urgency=medium
 
diff --git a/debian/postinst b/debian/postinst
index bb7b2b2..d69629d 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -28,11 +28,11 @@ EMPTYID="d41d8cd98f00b204e9800998ecf8427e"
 
 generate_id() {
         if command -v uuidgen >/dev/null 2>&1; then
-                MY_HOSTID=`uuidgen -r | tr -d -`
+                MY_HOSTID=$(uuidgen -r | tr -d -)
         elif test -r /proc/sys/kernel/random/uuid; then
-                MY_HOSTID=`tr -d - < /proc/sys/kernel/random/uuid`
+                MY_HOSTID=$(tr -d - < /proc/sys/kernel/random/uuid)
         else
-                MY_HOSTID=`od -x -An -N16 /dev/urandom | tr -d ' '`
+                MY_HOSTID=$(od -x -An -N16 /dev/urandom | tr -d ' ')
         fi;
 }
 
@@ -98,7 +98,7 @@ case "$1" in
             # Workaround for bug #237874 triggered on hurd.  The
             # problem was fixed in version 1.15, 2004-03-20.
 
-              $EMPTYID) generate_id;;
+              "$EMPTYID") generate_id;;
             # Workaround for bug #240603 triggered by md5sums change
             # of behaviour with stdin. version 1.17, 2004-04-12.
               *-)  MY_HOSTID="${MY_HOSTID%  -}";;
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: popularity-contest
Source-Version: 1.75
Done: Bill Allombert <ballombe@debian.org>

We believe that the bug you reported is fixed in the latest version of
popularity-contest, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1011284@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Bill Allombert <ballombe@debian.org> (supplier of updated popularity-contest package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sat, 03 Dec 2022 16:46:10 +0100
Source: popularity-contest
Architecture: source
Version: 1.75
Distribution: unstable
Urgency: medium
Maintainer: Popularity Contest Developers <debian-popcon@lists.debian.org>
Changed-By: Bill Allombert <ballombe@debian.org>
Closes: 1011284
Changes:
 popularity-contest (1.75) unstable; urgency=medium
 .
   * Use shuf instead of bash to generate random numbers in d/postinst
     Closes: #1011284. Thanks нaб for the patch.
   * debian/control:
     - Updated Standards-Version from 4.6.0 to 4.6.1.  No change needed.
Checksums-Sha1:
 042cf0b6b670e37dff8b452ac636f2e923426e1a 1731 popularity-contest_1.75.dsc
 fdb6f438292b5e83200dd4f3eea508e0ce281bd6 79620 popularity-contest_1.75.tar.xz
 330b392bce4ef6057481ae6c7a7391bdbd8cd78b 5714 popularity-contest_1.75_source.buildinfo
Checksums-Sha256:
 2017bc7f738e5a254ca0016975ffa35da341c140c47e6110eb310944afe32e25 1731 popularity-contest_1.75.dsc
 85b8094978d417d0f3042977edf16da4c0076e832b4c7f9a9f38e41ab9148ad7 79620 popularity-contest_1.75.tar.xz
 c38d4d47b69a3b3de87d129b07f68fba2b5ce861292180e5aeedbf29abd35175 5714 popularity-contest_1.75_source.buildinfo
Files:
 ec04af749b862966022e55263a5d42d1 1731 misc optional popularity-contest_1.75.dsc
 3dc9756c7b0fb719461a7319ae61827f 79620 misc optional popularity-contest_1.75.tar.xz
 5f1f3987e98a392dd8aa602627e59f93 5714 misc optional popularity-contest_1.75_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEQgKOpASi6dgKxFMUjw58K0Ui44cFAmOLckwACgkQjw58K0Ui
44evLRAAnwE/N5rU0B54BLbBzWhL/3dblGMbSojBRR+ULRAHViHSVvQWQh616Dz9
In/v4c9COyMhC2j7Be2DnfdPopNqdYyZQ2FgMIzOrnsLmLsUBW3z/aOZrC+GI1OS
Eca6P/C4yH+052dlNJ2YJlZRy5xrVXfyTaEAkP6k4GL4gmNXGTMdTqga0//ZZ9Uw
egXOMKTQKNbLbMFvNWu4emIkZWlERjpLGsgZN4A8CBXofrk7EAFGcJ+knqzJB5Gx
DpwzBUm0SNFOE3JPqH+VP/rNrOcwQ2XxasjogAWdMvvCf6uNM7WQ+5p199YLPQG0
L7FcEXeRW4Uj4sgAkfusZt+tLOJcbZdOLffj+g95zwxHU0b1ntym/Atq8N+AU30a
5xeRCJLD9F/l2Ec6WLlHXPr6B419AfRPhZA78WtJNxRn18i8+3gbMC1pOcGsbt4Z
8rpUaKjaiXxWx0Tl1XKlmH9P/ozlyrzFxKuWjLcdrCbmfRq8g5fC953gFYgQ0qb2
ePJdAS8ar9d4d14wATSlZsfO0JFP27Cv6l6qX2s4Zr9PUG5VSLo6QPXSl0lJasbx
zwd9ntMoUAC3cVtl0bQg+2by0sgnMQlGdymeJB5itfgg6bZCAzgEROPQtBgoBlIU
lK+qjbNoEu87hwWfqik8sLMbJJ2vAwAsPfqRyb/4Zvvj8HtxIQo=
=2vce
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: