diff --git a/debian/freedombox.lintian-overrides b/debian/freedombox.lintian-overrides index 362a24015..b3b32a108 100644 --- a/debian/freedombox.lintian-overrides +++ b/debian/freedombox.lintian-overrides @@ -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 diff --git a/debian/freedombox.postinst b/debian/freedombox.postinst index ff6bc2a58..940bce4a9 100755 --- a/debian/freedombox.postinst +++ b/debian/freedombox.postinst @@ -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 diff --git a/debian/freedombox.templates b/debian/freedombox.templates deleted file mode 100644 index 8e56ca1cf..000000000 --- a/debian/freedombox.templates +++ /dev/null @@ -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 diff --git a/debian/freedombox.tmpfiles b/debian/freedombox.tmpfiles index 6a93eb87c..207715e35 100644 --- a/debian/freedombox.tmpfiles +++ b/debian/freedombox.tmpfiles @@ -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 diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in deleted file mode 100644 index 5282eba34..000000000 --- a/debian/po/POTFILES.in +++ /dev/null @@ -1 +0,0 @@ -[type: gettext/rfc822deb] freedombox.templates \ No newline at end of file diff --git a/debian/po/ca.po b/debian/po/ca.po deleted file mode 100644 index 7685425c6..000000000 --- a/debian/po/ca.po +++ /dev/null @@ -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 , 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 \n" -"Language-Team: Catalan \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:" diff --git a/debian/po/de.po b/debian/po/de.po deleted file mode 100644 index a80f10a4e..000000000 --- a/debian/po/de.po +++ /dev/null @@ -1,37 +0,0 @@ -# Translation of plinth debconf templates to German -# Copyright (C) 2019 FreedomBox packaging team -# This file is distributed under the same license as the plinth package. -# Helge Kreutzmann , 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 \n" -"Language-Team: german \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:" diff --git a/debian/po/es.po b/debian/po/es.po deleted file mode 100644 index d1f812f64..000000000 --- a/debian/po/es.po +++ /dev/null @@ -1,37 +0,0 @@ -# Translation of plinth debconf templates to Spanish -# Copyright (C) 2019 FreedomBox packaging team -# This file is distributed under the same license as the plinth package. -# Fioddor Superconcentrado , 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 \n" -"Language-Team: Debian L10n Spanish \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:" diff --git a/debian/po/fr.po b/debian/po/fr.po deleted file mode 100644 index b8f085bdb..000000000 --- a/debian/po/fr.po +++ /dev/null @@ -1,42 +0,0 @@ -# Translation of plinth debconf templates to French -# Copyright (C) 2018 FreedomBox packaging team -# This file is distributed under the same license as the plinth package. -# -# Jean-Pierre Giraud , 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 \n" -"Language-Team: French \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 :" - diff --git a/debian/po/it.po b/debian/po/it.po deleted file mode 100644 index 078ca7ee5..000000000 --- a/debian/po/it.po +++ /dev/null @@ -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 , 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 \n" -"Language-Team: Italian \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:" diff --git a/debian/po/nl.po b/debian/po/nl.po deleted file mode 100644 index 47498e3d8..000000000 --- a/debian/po/nl.po +++ /dev/null @@ -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 , YEAR. -# Frans Spiesschaert , 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 \n" -"Language-Team: Debian Dutch l10n Team \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:" diff --git a/debian/po/pt.po b/debian/po/pt.po deleted file mode 100644 index 5221e2521..000000000 --- a/debian/po/pt.po +++ /dev/null @@ -1,42 +0,0 @@ -# Translation of freedombox debconf messages to European Portuguese -# Copyright (C) 2019 FreedomBox packaging team -# This file is distributed under the same license as the freedombox package. -# -# Rui Branco - DebianPT , 2018. -# Américo Monteiro , 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 \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:" diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po deleted file mode 100644 index ed55366a6..000000000 --- a/debian/po/pt_BR.po +++ /dev/null @@ -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 , 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 \n" -"Language-Team: Brazilian Portuguese \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:" diff --git a/debian/po/ru.po b/debian/po/ru.po deleted file mode 100644 index 1ed226529..000000000 --- a/debian/po/ru.po +++ /dev/null @@ -1,38 +0,0 @@ -# Russian translation of plinth debconf template. -# Copyright (C) 2019 FreedomBox packaging team -# This file is distributed under the same license as the plinth package. -# Lev Lamberov , 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 \n" -"Language-Team: Debian L10n Russian \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. Если вы потеряете эту " -"строку, то вы сможете получить её, выполнив следующую команду:" diff --git a/debian/po/sq.po b/debian/po/sq.po deleted file mode 100644 index c36978d15..000000000 --- a/debian/po/sq.po +++ /dev/null @@ -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 , 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 \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 t’ju 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:" diff --git a/debian/po/sv.po b/debian/po/sv.po deleted file mode 100644 index fb9ae9dd3..000000000 --- a/debian/po/sv.po +++ /dev/null @@ -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 , 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 \n" -"Language-Team: Swedish \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:" diff --git a/debian/po/templates.pot b/debian/po/templates.pot deleted file mode 100644 index 5b8276cf2..000000000 --- a/debian/po/templates.pot +++ /dev/null @@ -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 , 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 \n" -"Language-Team: LANGUAGE \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 "" diff --git a/plinth/modules/first_boot/__init__.py b/plinth/modules/first_boot/__init__.py index ded007d11..146b9ff8e 100644 --- a/plinth/modules/first_boot/__init__.py +++ b/plinth/modules/first_boot/__init__.py @@ -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') diff --git a/plinth/modules/first_boot/forms.py b/plinth/modules/first_boot/forms.py index b4c51cd76..a2d9e557d 100644 --- a/plinth/modules/first_boot/forms.py +++ b/plinth/modules/first_boot/forms.py @@ -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(