#621020 mysql-server-5.0: Init script should not 'set -e'

Package:
mysql-server
Source:
mysql-8.0
Submitter:
Gleim Publications NOC
Date:
2025-08-22 19:15:03 UTC
Severity:
important
Tags:
#621020#5
Date:
2011-04-05 20:59:58 UTC
From:
To:
/etc/init.d/mysql uses "set -e" for most of the script, but that is not
compatible with the LSB library /lib/lsb/init-functions. This
particularly causes problems whenever log_end_msg is called with a
nonzero argument, as log_end_msg will return that argument and halt the
script. So there are several chunks of code that will never be called
(some informational messages and the stop-using-kill bit).

This applies to the squeeze package as well.

#621020#14
Date:
2012-04-11 19:37:16 UTC
From:
To:
tag 621020 +moreinfo
thanks


Regarding #621020

"/etc/init.d/mysql uses "set -e" for most of the script, but that is not
compatible with the LSB library /lib/lsb/init-functions. This
particularly causes problems whenever log_end_msg is called with a
nonzero argument, as log_end_msg will return that argument and halt the
script. So there are several chunks of code that will never be called
(some informational messages and the stop-using-kill bit)."

Hmm... This contradicts section 6.1 of the Debian policy.

"The package management system looks at the exit status from these
scripts. It is important that they exit with a non-zero status if there
is an error, so that the package management system can stop its
processing. For shell scripts this means that you almost always need to
use set -e (this is usually true when writing shell scripts, in fact).
It is also important, of course, that they exit with a zero status if
everything went well."

Copying "debian-devel" for more general comments.

#621020#21
Date:
2012-04-11 20:04:31 UTC
From:
To:
Hi,

Here "these scripts" refer to "package maintainer scripts"
({pre,post}{inst,rm}) and not to "init scripts". So there's no
contradiction.

The problem of using "set -e" in init script is even documented
in policy 9.3.2:
http://www.debian.org/doc/debian-policy/ch-opersys.html#s-writing-init

| Be careful of using set -e in init.d scripts. Writing correct init.d
| scripts requires accepting various error exit statuses when daemons are
| already running or already stopped without aborting the init.d script, and
| common init.d function libraries are not safe to call with set -e in
| effect[72]. For init.d scripts, it's often easier to not use set -e and
| instead check the result of each command separately.
|
| [72] /lib/lsb/init-functions, which assists in writing LSB-compliant
| init scripts, may fail if set -e is in effect and echoing status messages
| to the console fails, for example.

Cheers,

#621020#26
Date:
2012-04-11 20:10:40 UTC
From:
To:
Ah thanks.  YEs that rings a bell now.
#621020#35
Date:
2012-04-12 12:45:22 UTC
From:
To:
Le 11.04.2012 22:04, Raphael Hertzog a écrit :

For what is worth, this has been discussed at length in #546743 and is
now documented as the #661002 bug against lsb-base.

Please note that #661002 "lsb-base:/lib/lsb/init-functions may fail if
`set -e` is used" is tagged as +help: patches are welcome and could
eventually lead to a fix in policy.

(Deciding whether energy should be put in functions for SysVinit is up
to each reader.)

Cheers,

OdyX

#621020#40
Date:
2012-05-30 11:46:08 UTC
From:
To:
  Hi,

  I run into this bug today:
Setting up mysql-server-5.5 (5.5.23+dfsg-2) ...
/lib/lsb/init-functions: line 428: FANCYTTY: unbound variable
invoke-rc.d: initscript mysql, action "stop" failed.
/lib/lsb/init-functions: line 428: FANCYTTY: unbound variable
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

In /lib/lsb/init-functions, at line 428, there is:
FANCYTTY=$([ -e /etc/default/rcS ] && . /etc/default/rcS && echo $FANCYTTY)
As FANCYTTY is not defined in my /etc/default/rcS and init script is
called with "set -e", the init script fails.

I will raise the severity because this bug does not only happen when
console is not working (as reported initially)

  Regards,
   Vincent

#621020#45
Date:
2012-05-30 12:13:43 UTC
From:
To:
  In fact, the problem with mysql-server is worst because it also use
set -u
So missing variables lead to errors and lsb-base with FANCYTTY will often
trigger the bug

  Regards,
    Vincent

#621020#52
Date:
2012-05-31 20:54:36 UTC
From:
To:
I think we aleady have
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=621020 for this. We'll
have to pay some attention to this .

#621020#57
Date:
2025-08-22 19:12:47 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
mysql-8.0, 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 621020@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Lena Voytek <lena.voytek@canonical.com> (supplier of updated mysql-8.0 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)
Format: 1.8
Date: Fri, 22 Aug 2025 13:53:55 -0400
Source: mysql-8.0
Built-For-Profiles: noudeb
Architecture: source
Version: 8.0.43-3
Distribution: unstable
Urgency: medium
Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
Changed-By: Lena Voytek <lena.voytek@canonical.com>
Closes: 544013 621020 1006717 1092213
Changes:
 mysql-8.0 (8.0.43-3) unstable; urgency=medium
 .
   * Fix permissions and startup race condition in logrotate config.
     (Closes: #544013)
   * Update uploaders list, removing those who are no longer involved with the
     package. Thank you all for your work! (Closes: #1006717)
   * Add missing full stops to translations. (Closes: #1092213)
   * Update debian compat to 13.
     - Use dh_installsystemd to match compatibility.
     - Replace install --fail-missing with dh_missing.
   * Update standards version.
   * Remove set -e and set -u usage in init script. (Closes: #621020)
   * Clean up license text in d/copyright.
   * Remove file permissions updates in d/rules, fixed upstream.
   * Add missing symbols to symbols file.
Checksums-Sha1:
 a0bb4e982246092cec4cc4255fd3ee1dc94e64a3 3582 mysql-8.0_8.0.43-3.dsc
 6c3f2f7156047f9d04c1e4661a12e5c28177e2d1 146044 mysql-8.0_8.0.43-3.debian.tar.xz
 3a164acff0d8f7938c6db758a0278597fba08957 9123 mysql-8.0_8.0.43-3_source.buildinfo
Checksums-Sha256:
 2a64f1d4b9705f1b5926d001ac4c33c9fc307caea3d477b4c675e3ee21080d56 3582 mysql-8.0_8.0.43-3.dsc
 7917ba92c53a5529284d602cfbaa99aca473ccd6a3b1658d91584976548a44f5 146044 mysql-8.0_8.0.43-3.debian.tar.xz
 5d81ac1e6ad517be6c9b23112651359b2930bcd631adc05117ba5ef7ef3bcf01 9123 mysql-8.0_8.0.43-3_source.buildinfo
Files:
 a465f95259e4cde5820d23b921f0ab98 3582 database optional mysql-8.0_8.0.43-3.dsc
 c66640586cabbc978bfc410d219ca955 146044 database optional mysql-8.0_8.0.43-3.debian.tar.xz
 1c87d1e48617b9b4336db27afe2eb2e9 9123 database optional mysql-8.0_8.0.43-3_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEY+78PeFNUUbOfyS/NLitfZUp55MFAmiou4EACgkQNLitfZUp
55OiYxAAkByP1ax2IE/dNaueNY/D8CKjXjri1GHaggfIp3SY3a5rQPgdKln0KU/Q
ndretvxbpUao2mo0FSw6ps0zQhHLPnJv73Mt98Hlcfnzl4GRU8cBT5WHVMfd99PQ
8y1ukjpSRzIW77XJW97KPhPb4YesHQhe/DC6HL+3BYAkkewtK1bXIzFZQDhq7Z+I
5KPnrQtJzb2GvIX+hz9+JMv4Pccr93MFJvV6hJgCQIVt/lNFyxYmGVYk52n0ijiR
OnRJUSVEoVA9Uv0RcTikrrXe/yBZPK+nmlfopOHJ075VnN7B6TJdPvc/sECB9VHu
EJcnEg90CH1ebFjEOVpLqikCBaRQYLTG5n7mpryK5cakC2VgALghZz6cqWWN18cs
VUc8pMdey7Z1L2lAh7f4lZyN8nTBMKHfY0Wag/E7JCRWPN7V4nAZiIfoSCgSRXQe
8njxK/YXJyyaHQ4yg7hbubVmooHwZJMDW9JHUCNpj2tJaqjENWK3r31gXqBd3Fme
Dv3WjMn0PDqtMT/g55+RMBVDsF+l5WtjrZgiJ5JQZ0vuLIKcMfrmtbMtpGj9mjuH
h1CAIkDlUf09JWdKE8NS4tgQHtdeFmfOXji9jSB0w9jK0b5z2hUl+LSBv7NNp6jt
H0Xc5qEZ9aiLh2PFlQdrlWwDH/yY8DRlEJYhXLprFW0P0qrVa/8=
=qYi+
-----END PGP SIGNATURE-----