first_boot: Move first wizard secret generation to this app

- Generating files in postinst script makes working with image-based systems
harder as postinst scripts are not run when booting from a pristine image. So,
move this to first_boot app's setup() method.

- This means that first wizard secret is no longer displayed during package
installation. This is a loss in usability, but might be acceptable:

  - We want to reduce the number of dialog box messages shown to the user during
  the installation of FreedomBox as a blend in Debian installer. Along with this
  change, if we migrate away from LDAP, then no messages will be shown anymore.

  - When users are installing using Debian installer, they don't have access to
  console to note down the secret. They can only note down on a physical medium.
  This is not the best way. Most of the time when I installed on machines, I
  just looked at the secret file later.

  - It is not expected that user will loose root access to the machine on which
  they installed 'freedombox' package (manually or through Debian installer)
  before they can type in the secret into the first wizard. Earlier, we had
  restrictions on the type of users who can login to the console and this could
  have happened.

  - We can eliminate a lintian warning that we are showing messages in a dialog
  in the postinst script instead of configure script.

Tests:

- Unit tests work.

- Building Debian package with changes works.

- Lintian warning about debconf has been eliminated.

- On a fresh Debian Trixie machine, installing the newly built Debian package
succeeds. It does not show first wizard secret related message. When web
interface is accessed, secret is asked. Skipping the secret is not possible.
Even before the creation of the secret file.

- Providing incorrect secret leads to error message. Secret file can be read by
root. The file is owned by plinth:plinth. The file has 0400 permissions.

- The secret file contains a newline at the file but entering the secret without
the newline character works.

- The secret contains uppercase and lowercase ASCII characters and digits. The
secret is 16 chars in length.

- Incrementing the version number of first_boot app does not lead to change in
the secret file contents.

- The message in the first wizard secret form is as expected.

- Building a disk image with newly built Debian package works. When the image is
booted, it does not ask for first wizard secret.

- When an existing machine is upgraded, if it is a disk image, first wizard
secret file is not created and first wizard is not shown to the user.

- When an existing machine is upgraded, if it is not a disk image, first wizard
secret file is not changed and first wizard is not shown to the user.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
[jvalleroy: Correct comment]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2026-07-28 14:50:22 -07:00 committed by James Valleroy
parent 485391620b
commit 1e2fb8171f
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
19 changed files with 35 additions and 480 deletions

View File

@ -1,7 +1,3 @@
# debconf is used only to display a message, and not to get
# configuration.
freedombox binary: no-debconf-config
# Apache configuration for the Plinth itself is shipped with proper
# name plinth.conf. However, due to the nature of the package, Plinth
# takes the responsibility of configuring various other services

View File

@ -2,27 +2,12 @@
set -e
# Source debconf library.
. /usr/share/debconf/confmodule
# Due to a change in sudo, now it runs PAM modules even on password-less
# invocations. This leads to plinth not being able to run root privileges. This
# is because of our own restrictions in /etc/security/access.conf. Since Plinth
# is locked out after upgrade, we need to do this in postinst.
sed -i 's+-:ALL EXCEPT root fbx (admin) (sudo):ALL+-:ALL EXCEPT root fbx plinth (admin) (sudo):ALL+' /etc/security/access.conf
case "$1" in
configure)
if [ ! -e '/var/lib/freedombox/is-freedombox-disk-image' ]; then
umask 377
base64 < /dev/urandom | head -c 16 | sed -e 's+$+\n+' > /var/lib/plinth/firstboot-wizard-secret
db_subst plinth/firstboot_wizard_secret secret $(cat /var/lib/plinth/firstboot-wizard-secret)
db_input high plinth/firstboot_wizard_secret || true
db_go
fi
;;
esac
#DEBHELPER#
exit 0

View File

@ -1,9 +0,0 @@
Template: plinth/firstboot_wizard_secret
Type: note
#flag:translate!:3
_Description: FreedomBox first wizard secret - ${secret}
Please note down the above secret. You will be asked to enter this in the
first screen after you launch the FreedomBox web interface. In case you lose
it, you can retrieve it by running the following command:
.
$ sudo cat /var/lib/plinth/firstboot-wizard-secret

View File

@ -1,3 +1,2 @@
d /var/lib/plinth 0755 plinth plinth
d /var/lib/plinth/sessions 0755 plinth plinth
Z /var/lib/plinth/firstboot-wizard-secret 0400 plinth plinth

View File

@ -1 +0,0 @@
[type: gettext/rfc822deb] freedombox.templates

36
debian/po/ca.po vendored
View File

@ -1,36 +0,0 @@
# Catalan translation of plinth's debconf messages
# Copyright © 2024 Free Software Foundation, Inc.
# This file is distributed under the same license as the plinth package.
# poc senderi <pocsenderi@protonmail.com>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2024-11-05 22:18+0100\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: poc senderi <pocsenderi@protonmail.com>\n"
"Language-Team: Catalan <debian-l10n-catalan@lists.debian.org>\n"
"X-Generator: Poedit 2.4.2\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Secret per a l'engegada inicial del «wizard» de FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Anoteu el secret anterior. Us serà demanat a la primera pantalla després "
"d'engegar la interfície web del FreedomBox. En cas que el perdeu, el podeu "
"recuperar executant la següent ordre:"

37
debian/po/de.po vendored
View File

@ -1,37 +0,0 @@
# Translation of plinth debconf templates to German
# Copyright (C) 2019 FreedomBox packaging team <freedombox-pkg-team@lists.alioth.debian.org>
# This file is distributed under the same license as the plinth package.
# Helge Kreutzmann <debian@helgefjell.de>, 2018, 2019.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth 19.21\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2019-11-24 06:46+0100\n"
"Last-Translator: Helge Kreutzmann <debian@helgefjell.de>\n"
"Language-Team: german <debian-l10n-german@lists.debian.org>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Passphrase des Ersteinrichtungsprogramms der FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Bitte schreiben Sie diese geheime Zeichenkette auf. Sie werden auf dem "
"ersten Bildschirm nach dem Start der FreedomBox-Schnittstelle nach dieser "
"Zeichenkette gefragt werden. Falls Sie sie verlieren, können Sie sie durch "
"Ausführung des folgenden Befehls wiedererlangen:"

37
debian/po/es.po vendored
View File

@ -1,37 +0,0 @@
# Translation of plinth debconf templates to Spanish
# Copyright (C) 2019 FreedomBox packaging team <freedombox-pkg-team@lists.alioth.debian.org>
# This file is distributed under the same license as the plinth package.
# Fioddor Superconcentrado <fioddor@gmail.com>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: plinth 19.20\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-07-31 16:07+0000\n"
"PO-Revision-Date: 2022-08-01 15:13+0200\n"
"Last-Translator: Camaleón <noelamac@gmail.com>\n"
"Language-Team: Debian L10n Spanish <debian-l10n-spanish@lists.debian.org>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Secreto del asistente al primer arranque de FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Por favor, anote esta cadena de texto. Se le pedirá en la primera pantalla "
"al iniciar la interfaz web de FreedomBox. Si la pierde, podrá recuperarla "
"ejecutando la siguiente orden:"

42
debian/po/fr.po vendored
View File

@ -1,42 +0,0 @@
# Translation of plinth debconf templates to French
# Copyright (C) 2018 FreedomBox packaging team <freedombox-pkg-team@lists.alioth.debian.org>
# This file is distributed under the same license as the plinth package.
#
# Jean-Pierre Giraud <jean-pierregiraud@neuf.fr>, 2018, 2019.
msgid ""
msgstr ""
"Project-Id-Version: plinth\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2019-12-16 10:23+0100\n"
"Last-Translator: Jean-Pierre Giraud <jean-pierregiraud@neuf.fr>\n"
"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Lokalize 2.0\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Phrase secrète du premier assistant de FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
#| msgid ""
#| "Please save this string. You will be asked to enter this in the first "
#| "screen after you launch the FreedomBox interface. In case you lose it, "
#| "you can find it in the file /var/lib/plinth/firstboot-wizard-secret."
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Veuillez noter cette phrase secrète. Le premier écran après le chargement de "
"l'interface web de FreedomBox vous la demandera. Si vous l'avez oubliée, vous "
"pourrez la récupérer en exécutant la commande suivante :"

35
debian/po/it.po vendored
View File

@ -1,35 +0,0 @@
# freedombox po-debconf italian translation
# Copyright (C) 2022 freedombox's copyright holder
# This file is distributed under the same license as the freedombox package.
# Ceppo <ceppo@oziosi.org>, 2022.
#
msgid ""
msgstr ""
"Project-Id-Version: freedombox\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-18 16:09+0000\n"
"PO-Revision-Date: 2022-08-25 00:00+0000\n"
"Last-Translator: Ceppo <ceppo@oziosi.org>\n"
"Language-Team: Italian <debian-l10n-italian@lists.debian.org>\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Codice del primo wizard di FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Annotare il codice indicato sopra. Sarà richiesto di inserirlo nella prima "
"schermata dopo l'avvio dell'interfaccia web di FreedomBox. Qualora venisse "
"perso, sarebbe possibile recuperarlo eseguendo il comando seguente:"

39
debian/po/nl.po vendored
View File

@ -1,39 +0,0 @@
# Dutch translation of plinth debconf templates.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the plinth package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# Frans Spiesschaert <Frans.Spiesschaert@yucom.be>, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth_19.21\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2019-12-02 21:04+0100\n"
"Last-Translator: Frans Spiesschaert <Frans.Spiesschaert@yucom.be>\n"
"Language-Team: Debian Dutch l10n Team <debian-l10n-dutch@lists.debian.org>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2.1\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Geheime code voor de initiële wizard van FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Noteer bovenstaande geheime code. Er zal u gevraagd worden om ze in het "
"openingsscherm in te voeren wanneer u de FreedomBox-interface opstart. In "
"geval u ze kwijtraakt, kunt u ze terughalen door het volgende commando uit "
"te voeren:"

42
debian/po/pt.po vendored
View File

@ -1,42 +0,0 @@
# Translation of freedombox debconf messages to European Portuguese
# Copyright (C) 2019 FreedomBox packaging team <freedombox-pkg-team@lists.alioth.debian.org>
# This file is distributed under the same license as the freedombox package.
#
# Rui Branco - DebianPT <ruipb@debianpt.org>, 2018.
# Américo Monteiro <a_monteiro@gmx.com>, 2025.
msgid ""
msgstr ""
"Project-Id-Version: freedombox 25.9.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-07 15:09+0000\n"
"PO-Revision-Date: 2025-06-07 20:00+0100\n"
"Last-Translator: Américo Monteiro <a_monteiro@gmx.com>\n"
"Language-Team: Portuguese <>\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Lokalize 22.12.3\n"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Primeiro segredo de feiticeiro FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../freedombox.templates:1001
#| msgid ""
#| "Please save this string. You will be asked to enter this in the first "
#| "screen after you launch the FreedomBox interface. In case you lose it, "
#| "you can find it in the file /var/lib/plinth/firstboot-wizard-secret."
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Por favor anote o segredo em cima. Irá ser-lhe pedido o introduzir no "
"primeiro ecrã após lançar a interface web do FreedomBox. No caso de o "
"perder, consegue o obter ao correr o seguinte comando:"

36
debian/po/pt_BR.po vendored
View File

@ -1,36 +0,0 @@
# Debconf translations for plinth.
# Copyright (C) 2020 THE plinth'S COPYRIGHT HOLDER
# This file is distributed under the same license as the plinth package.
# Adriano Rafael Gomes <adrianorg@debian.org>, 2020.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth 20.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-24 18:00+0000\n"
"PO-Revision-Date: 2020-06-24 20:14-0300\n"
"Last-Translator: Adriano Rafael Gomes <adrianorg@debian.org>\n"
"Language-Team: Brazilian Portuguese <debian-l10n-portuguese@lists.debian."
"org>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Segredo do primeiro assistente do FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Por favor, anote o segredo acima. Você deverá informá-lo na primeira tela "
"depois de iniciar a interface web do FreedomBox. Caso você o perca, você "
"poderá recuperá-lo executando o seguinte comando:"

38
debian/po/ru.po vendored
View File

@ -1,38 +0,0 @@
# Russian translation of plinth debconf template.
# Copyright (C) 2019 FreedomBox packaging team <freedombox-pkg-team@lists.alioth.debian.org>
# This file is distributed under the same license as the plinth package.
# Lev Lamberov <dogsleg@debian.org>, 2020.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2020-02-10 10:17+0500\n"
"Last-Translator: Lev Lamberov <dogsleg@debian.org>\n"
"Language-Team: Debian L10n Russian <debian-l10n-russian@lists.debian.org>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.4\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Секретная строка мастера настройки FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Запишите эту секретную строку. Вам будет необходимо ввести её на самом "
"первом экране после запуска веб-интерфейса FreedomBox. Если вы потеряете эту "
"строку, то вы сможете получить её, выполнив следующую команду:"

37
debian/po/sq.po vendored
View File

@ -1,37 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the plinth package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: plinth\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: 2021-04-14 11:43+0300\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Last-Translator: Besnik Bleta <besnik@programeshqip.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: sq\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "E fshehtë për skenën e parë të ndihmësit FreedomBox - ${secret}"
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Ju lutemi, mbajeni shënim të fshehtën më sipër. Do tju kërkohet ta jepni "
"këtë në skenën e parë pasi të vini në punë ndërfaqen web të FreedomBox-it. "
"Po e humbët, mund ta rimerrni duke xhiruar urdhrin vijues:"

35
debian/po/sv.po vendored
View File

@ -1,35 +0,0 @@
# Translation of freedombox 23.13 debconf to Swedish.
# Copyright (C) 2011-2023 FreedomBox Authors
# This file is distributed under the same license as the freedombox package.
# Peter Kvillegård <quat@sdfeu.org>, 2023
#
msgid ""
msgstr ""
"Project-Id-Version: freedombox 23.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-21 16:31+0000\n"
"PO-Revision-Date: 2023-07-22 15:55+0200\n"
"Last-Translator: Peter Kvillegård <quat@sdfeu.org>\n"
"Language-Team: Swedish <debian-l10n-swedish@lists.debian.org>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr "Hemlighet för FreedomBox första guidade installerare - ${secret}"
#. Type: note
#. Description
#: ../freedombox.templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""
"Skriv ner ovanstående hemlighet. Du kommer att bli ombedd att ange den i "
"den första skärmen efter att du startat FreedomBox webbgränssnitt. Om du "
"tappar bort den kan den hämtas igen genom att köra följande kommando:"

View File

@ -1,33 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the plinth package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: plinth\n"
"Report-Msgid-Bugs-To: plinth@packages.debian.org\n"
"POT-Creation-Date: 2019-11-18 18:11-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. Type: note
#. Description
#: ../templates:1001
msgid "FreedomBox first wizard secret - ${secret}"
msgstr ""
#. Type: note
#. Description
#: ../templates:1001
msgid ""
"Please note down the above secret. You will be asked to enter this in the "
"first screen after you launch the FreedomBox web interface. In case you lose "
"it, you can retrieve it by running the following command:"
msgstr ""

View File

@ -5,11 +5,16 @@ FreedomBox app for first boot wizard.
import operator
import os
import pathlib
import secrets
import string
import sys
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from plinth import action_utils
from plinth import app as app_module
from plinth import cfg
from plinth.signals import post_setup
@ -39,7 +44,7 @@ class FirstBootApp(app_module.App):
super().__init__()
info = app_module.Info(app_id=self.app_id, version=self._version,
is_essential=True)
is_essential=True, name=_('First Boot'))
self.add(info)
def post_init(self):
@ -50,6 +55,8 @@ class FirstBootApp(app_module.App):
"""Install and configure the app."""
super().setup(old_version)
_firstboot_wizard_secret_create()
if not old_version:
self._show_next_steps_notification()
@ -180,3 +187,28 @@ def firstboot_wizard_secret_exists():
"""Return whether a firstboot wizard secret exists."""
secret_file = get_secret_file_path()
return os.path.exists(secret_file) and os.path.getsize(secret_file) > 0
def _generate_secret_key():
"""Generate a new random secret key for firstboot wizard."""
chars = string.ascii_letters + string.digits
return ''.join(secrets.choice(chars) for _ in range(16))
def _firstboot_wizard_secret_create():
"""Create a file with firstboot wizard secret if not in a disk image."""
if action_utils.is_disk_image():
return # On a disk image, first wizard secret is not asked.
path = pathlib.Path(get_secret_file_path())
if path.exists():
return # Secret already exists, don't change it.
secret = _generate_secret_key()
def opener(path, flags):
"""Create and open a file with restricted permissions."""
return os.open(path, flags, 0o400)
with open(path, mode='w', opener=opener) as file_handle:
file_handle.write(secret + '\n')

View File

@ -11,8 +11,8 @@ class FirstbootWizardSecretForm(forms.Form):
"""Form to collect and validate the first boot wizard secret."""
secret = forms.CharField(
label='', help_text=_(
'Enter the secret generated during FreedomBox installation. '
'This secret can also be obtained by running the command "sudo '
'Enter the secret generated during {box_name} installation. '
'This secret can be obtained by running the command "sudo '
'cat /var/lib/plinth/firstboot-wizard-secret" on your {box_name}'.
format(box_name=_(cfg.box_name))), required=False,
widget=forms.PasswordInput(