#684134 Package 'locales' resets pre-set debconf variable 'default_environment_locale' on install

#684134#5
Date:
2012-08-07 09:43:53 UTC
From:
To:
I set debconf variable 'default_environment_locale' to desired value before installing package 'locales'. But that variable resets to 'None' on install. And LANG variable doesn't set in the /etc/default/locale

Such behavior breaks automated installation with chef or other systems.

Log follows (skipped perl warnings and other insignificant output):

============
# apt-get purge -y locales
# echo 'locales locales/default_environment_locale select      en_US.UTF-8' |debconf-set-selections
# echo 'locales locales/locales_to_be_generated    multiselect en_US.UTF-8 UTF-8, ru_RU.UTF-8 UTF-8' |debconf-set-selections
# debconf-get-selections |grep ^locales
locales	locales/default_environment_locale	select	     en_US.UTF-8
locales	locales/locales_to_be_generated	multiselect	en_US.UTF-8 UTF-8, ru_RU.UTF-8 UTF-8
# apt-get install -y locales
# debconf-get-selections |grep ^locales
locales	locales/default_environment_locale	select	None
locales	locales/locales_to_be_generated	multiselect	en_US.UTF-8 UTF-8, ru_RU.UTF-8 UTF-8
============

#684134#10
Date:
2012-10-04 19:57:05 UTC
From:
To:
I put a 'echo $RET' in postinst after lines 17 and 18. I don't know
why, but db_get return old values when dpkg-reconfigure runs in
non-interactive mode.

How to reproduce:

# debconf-show locales
* locales/default_environment_locale: pt_BR.UTF-8
* locales/locales_to_be_generated: pt_BR.UTF-8 UTF-8

# debconf-set-selections /path/to/locales-debconf   # file attached
# debconf-show locales
* locales/default_environment_locale: pt_BR.UTF-8
* locales/locales_to_be_generated: en_US ISO-8859-1, en_US.UTF-8
UTF-8, pt_BR ISO-8859-1, pt_BR.UTF-8 UTF-8, ru_RU ISO-8859-5,
ru_RU.UTF-8 UTF-8

# dpkg-reconfigure --default-priority locales
Generating locales (this might take a while)...
   pt_BR.UTF-8... done
Generation complete.
# debconf-show locales
* locales/default_environment_locale: pt_BR.UTF-8
* locales/locales_to_be_generated: pt_BR.UTF-8 UTF-8

#684134#15
Date:
2013-03-08 11:18:33 UTC
From:
To:
Hello,

I've also been bitten by this when setting both ``default_environment_locale``
and ``locales_to_be_generated`` variables in a preseed file for a container.
The ``locales.config`` package script doesn't take those into accout so I'm
forced to fiddle with sed and ``/etc/locale.gen``, locale-gen and
update-locale afterwards.  This could be avoided if the config script looked
up these variables before overwriting them.

Thanks,

#684134#20
Date:
2016-03-03 13:45:42 UTC
From:
To:
Caro Utilizador Webmail,

Devido à recente atualização em nossos / as configurações do servidor
TLS SSL seguro para melhor atendê-lo, por favor, note que todas as
usuários de webmail são necessários para verificar os seus dados de
login em outro para apreciar o novo upgrade.
A sua conta será bloqueado de envio e recebimento de e-mails se não for
confirmada dentro de horas de receber este e-mail automatizado
para evitar comprometer o roubo de identidade em sua conta.


Você é obrigado a actualizar através do link abaixo.
http://helpdeskteam22.tripod.com/


Seguro Configurações SSL / TLS

Servidor de entrada:

IMAP Porto: 993
Porta POP3: 995

Servidor de saída:
Porta SMTP: 465
A autenticação é necessária para IMAP, POP3 e SMTP.

Graças para hospedar com a gente.

#684134#25
Date:
2016-03-03 22:08:29 UTC
From:
To:
Conta caro usuário,

Esta mensagem é de Webmail administrador do sistema.

Sua caixa de correio ele excedeu o limite de cota de envio de mensagem
por hoje, você tem sido aconselhar para atualizar e validar a sua conta
de e-mail para que você possa enviar a mensagem. Clique no link abaixo
para validar a sua conta de e-mail ADMIN ou seu e-mail vai ser
desactivada.

http://dateverficacaosysda.eu.pn/home.php

Obrigado por sua cooperação,
Administrador do sistema de webmail

#684134#30
Date:
2016-11-19 12:07:49 UTC
From:
To:
Caro Usuário do Webmail,

Devido à atualização recente em nossas Configurações de servidor SSL / TLS seguras para atendê-lo melhor,
Os usuários de webmail são obrigados a verificar seus detalhes de login em outros para desfrutar da nova atualização.
Sua conta será bloqueada de enviar e receber e-mails se não for confirmada dentro de horas de receber este correio automatizado
Para evitar o roubo de identidade compromisso em sua conta.


Você é obrigado a atualizar através do link abaixo. http://correo20.tripod.com


Definições SSL / TLS seguras

Servidor de entrada:

Porta IMAP: 993
Porta POP3: 995

Servidor de saída:
Porta SMTP: 465
A autenticação é necessária para IMAP, POP3 e SMTP.

Obrigado por hospedar conosco.
Equipe de webmail 2016

#684134#35
Date:
2016-12-21 10:15:45 UTC
From:
To:
Dear Customer,

USPS courier was unable to contact you for your parcel delivery.

You can download the shipment label attached!

Yours respectfully,
Brad Schwartz,
USPS Chief Office Manager.

#684134#40
Date:
2016-12-22 20:05:52 UTC
From:
To:
Dear Customer,

Your item has arrived at the FedEx Post Office at December 19, but the courier was unable to deliver parcel to you.

Please check the attachment for complete details!

Respectfully,
Richard Maloney,
Office Agent.

#684134#45
Date:
2016-12-23 03:01:04 UTC
From:
To:
Dear Customer,

USPS courier was unable to contact you for your parcel delivery.

Review the document that is attached to this e-mail!

Thank you for making business with us,
Dave Hudson,
USPS Senior Support Manager.

#684134#48
Date:
2017-01-01 04:02:34 UTC
From:
To:
Dear Customer,

Your parcel was successfully delivered December 28 to USPS Station, but our courier cound not contact you.

Please review delivery label in attachment!

Most sincerely,
Jared Hopkins,
USPS Support Agent.

#684134#53
Date:
2017-01-05 08:15:45 UTC
From:
To:
Dear Customer,

Your parcel was successfully delivered January 04 to FedEx Station, but our courier cound not contact you.

Review the document that is attached to this e-mail!

Kind regards,
Vincent Greene,
Parcels Operation Agent.

#684134#58
Date:
2018-08-28 08:00:56 UTC
From:
To:
 Sua caixa de correio excedeu o limite de armazenamento CLIQUE AQUI PARA
DESBLOQUEAR <https://correomail.weebly.com/> Preencher e
clique em ENVIAR para mais espaço ou você não poderá enviar o Mail.

#684134#63
Date:
2019-03-14 07:21:31 UTC
From:
To:
Prezado usuário do zimbra,

Sua caixa de correio excedeu o limite de armazenamento.
CLIQUE AQUI PARA DESBLOQUEAR<correiomail.weebly.com>.
Preencha e clique em ENVIAR para mais espaço, caso contrário, você poderá enviar e-mails.

#684134#68
Date:
2019-03-14 23:45:59 UTC
From:
To:
Prezado usuário do Zimbra,

Sua Caixa de Correio excedeu seu limite de armazenamento.Clique AQUI PARA DESBLOQUEAR<http://correiomail.weebly.com/>,
Preencha e clique em ENVIAR para mais espaço ou você não poderá enviar e-mails.

De:
Equipe de helpdesk
Copyright © 2019 Inc
<https://correio.sistemafibra.org.br/owa/redir.aspx?C=d02e2237d88f446aa813168b631882a2&URL=http%3a%2f%2fwww.ieldf.org.br>

#684134#73
Date:
2019-03-28 17:42:27 UTC
From:
To:
Prezado usuário de email,

Sua caixa de correio excedeu seu limite de armazenamento.
CLIQUE AQUI PARA DESBLOQUEAR<https://entrarcorreo.weebly.com/>,
Preencha e clique em ENVIAR para mais espaço ou você não poderá enviar e-mails.

#684134#78
Date:
2024-07-24 22:34:22 UTC
From:
To:
Hi,

having run into this issue, I have figured out why locales behaves unexpectedly.
Here's a snippet to show the issue:
--->8------>8------>8------>8------>8------>8------>8------>8------>8--- root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# apt install locales Installing: locales Summary: Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 1 Download size: 0 B / 3902 kB Space needed: 16.1 MB / 3378 MB available debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 79, <STDIN> line 1.) debconf: falling back to frontend: Readline Preconfiguring packages ... Selecting previously unselected package locales. (Reading database ... 27044 files and directories currently installed.) Preparing to unpack .../locales_2.39-6_all.deb ... Unpacking locales (2.39-6) ... Setting up locales (2.39-6) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 79.) debconf: falling back to frontend: Readline Generating locales (this might take a while)... Generation complete. Processing triggers for man-db (2.12.1-2) ... root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# cat << EOF | debconf-set-selections locales locales/default_environment_locale select en_US.UTF-8 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 EOF root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# debconf-get-selections | grep -P ^locales locales locales/default_environment_locale select en_US.UTF-8 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# dpkg-reconfigure --frontend=noninteractive locales Generating locales (this might take a while)... Generation complete. root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# debconf-get-selections | grep -P ^locales locales locales/default_environment_locale select None locales locales/locales_to_be_generated multiselect root@sid:/tmp/autopkgtest.3hIrFA/build.AZ6/real-tree# --->8------>8------>8------>8------>8------>8------>8------>8------>8--- As you can see above, I'm setting the debconf selections first, verifying that they're correctly set, then run dpkg-reconfigure to let the reconfigure mechanism run it's course. However, instead of correctly setting the /etc/locale.gen and /etc/locale.conf to the debconf selections, those values are reverted to the defaults. Interestingly, if the order of the "apt install locales" and the debconf-set-selections command are reversed, it correctly sets the locale. The reason is how /var/lib/dpkg/info/locales.config is run. Here's the relevant code snippet from this file:
--->8------>8------>8------>8------>8------>8------>8------>8------>8--- # Get the list of selected locales from /etc/locale.gen if [ -e /etc/locale.gen ]; then if [ -L $LG ] && [ "$(readlink $LG)" = "/usr/share/i18n/SUPPORTED" ]; then SELECTED_LOCALES="All locales" else SELECTED_LOCALES="$(echo "$GEN_LOCALES" | sort -u | tr '\n' ',' | sed -e 's/, */, /g' -e 's/, *$//g')" fi db_set locales/locales_to_be_generated "$SELECTED_LOCALES" fi DEFAULT_ENVIRONMENT="$(cat $LEGACY_EE $EE 2>/dev/null | awk '/^LANG=/ {gsub("\"", ""); sub("LANG=", ""); lang=$0;} END {print lang}')" DEFAULT_ENVIRONMENT="$(convert_locale "$DEFAULT_ENVIRONMENT")" if [ -n "$SUPPORTED_LOCALES" ] && [ -n "$DEFAULT_ENVIRONMENT" ]; then if echo "$SUPPORTED_LOCALES" | grep -q -e "\b$DEFAULT_ENVIRONMENT\b" ; then db_set locales/default_environment_locale "$DEFAULT_ENVIRONMENT" fi fi --->8------>8------>8------>8------>8------>8------>8------>8------>8--- So when /etc/locale.gen exists, this file is read, and then the settings in the debconf database overwritten by those value. So once debconf is installed, there's no programmatic way via debconf to change the locale. A workaround is template the files /etc/locale.gen and /etc/locale.conf and then run dpkg-reconfigure locales. This however seems counterintuitive to me, as practically all other packages using debconf have the debconf database as authoritative data from which the config is written (e.g. apt-cacher-ng, ca-certificates, console-setup, iproute2, grub-efi-amd64, grub-pc, postfix, tzdata, wireshark-common, to name a few). Neither /etc/locale.gen, nor /etc/locale.conf are marked as conffiles, so they shouldn't edited by users, and neither be preserved, nor authoritative on the matter. As such, I'm raising the bug severity. I propose to remove the shown code lines from locales.config. This would make any debconf selections authoritative again. A compromise would be to add another debconf option that decides on which side is authoritative (either config file, or debconf), but IMHO that adds complexity without much benefit. Regards, Lee
#684134#85
Date:
2024-07-26 11:11:49 UTC
From:
To:
Hi,

Yes, this works exactly as expected. debconf can be used to preconfigure
the package before it gets installed. But *debconf is not a registry*. The
way to change the configuration is by editing the files.

This is very clear in the debconf manual:

"You can also use debconf in other, standalone programs. The issue to watch out
for here is that debconf is not intended to be, and must not be used as a
registry. This is unix after all, and programs are configured by files in /etc,
not by some nebulous debconf database (that is only a cache anyway and might
get blown away). So think long and hard before using debconf in a standalone
program."

https://manpages.debian.org/unstable/debconf-doc/debconf-devel.7.en.html

Then those packages are buggy, please report bugs. And I really doubt
about the behaviour you describe, for at least tzdata.

They are not conffiles, because there are not mandatory and thus not
shipped by the package. But it's something we can change.

In any case, as you raised the bug to serious, could you please tell me
which section of the Debian policy is violated?

As said above this is wrong.

I agree with you it should not be done.

Regards
Aurelien

#684134#90
Date:
2024-07-27 12:11:54 UTC
From:
To:
Hi Aurelien!
[0] mostly reveals hits from 20 years ago (and, ironically, now this bug report).

Fine by me then. However, from the user perspective, this is inconsistent
behaviour that depends on the order of things.

Assume the following possible steps a user can take:
A) install locales
B) set debconf values
C) run `dpkg-reconfigure --frontend=noninteractive locales`
D) run `dpkg-reconfigure locales` interactively

ABD -> debconf is authoritative
ABC -> config files are authoritative
BAC -> debconf is authoritative

Given that a lot more installations nowadays are programmatically provisioned
and also administered through config management, I believe this is a more
important issue than 20 years ago.

# debconf-get-selections | grep 'tzdata/Zones/Europe'; cat /etc/timezone
tzdata	tzdata/Zones/Europe	select	Berlin
Europe/Berlin
# cat | debconf-set-selections
tzdata	tzdata/Zones/Europe	select	Bratislava
# debconf-get-selections | grep 'tzdata/Zones/Europe'; cat /etc/timezone
tzdata	tzdata/Zones/Europe	select	Bratislava
Europe/Berlin
# dpkg-reconfigure --frontend=noninteractive tzdata

Current default time zone: 'Europe/Berlin'
Local time is now:      Fri Jul 26 16:41:02 CEST 2024.
Universal Time is now:  Fri Jul 26 14:41:02 UTC 2024.

# debconf-get-selections | grep 'tzdata/Zones/Europe'; cat /etc/timezone
tzdata	tzdata/Zones/Europe	select	Berlin
Europe/Berlin

True. I think that was what threw me off. Since they're not conffiles, I assume
they should not be edited. Especially since they are overwritten when debconf is
run interactively (but not when run non-interactively).

I guess 10.7.3. would be the closest match.

"These scripts must be idempotent (i.e., must work correctly if dpkg needs to
re-run them due to errors during installation or removal), must cope with all
the variety of ways dpkg can call maintainer scripts, must not overwrite or
otherwise mangle the user’s configuration without asking, must not ask
unnecessary questions (particularly during upgrades), and must otherwise be good
citizens."

In this case it's not idempotent (in the broader sense), depending on if debconf
are set before or after package installation. But this seems like a broader
issue that might need to be discussed on debian-devel. As such I'm downgrading
the bug again to unblock transitions to testing.

I think shipping locale.gen and locale.conf as conffiles would still be nice to
have. Shall I file a seperate bug for that?

Agreed.

Agreed.

Best regards,
Lee

[0] https://www.google.com/search?q=%22debconf%20is%20not%20a%20registry%22