help: Show security notice when backports are in use

Closes #1611.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil@medhas.org: Fixed incorrect HTML nesting and inline styling]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2019-07-26 19:06:57 -04:00 committed by Sunil Mohan Adapa
parent 9d39225098
commit a0837be410
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 28 additions and 1 deletions

View File

@ -20,6 +20,7 @@ Help app for FreedomBox.
import mimetypes
import os
import subprocess
from apt.cache import Cache
from django.core.files.base import File
@ -83,7 +84,8 @@ def about(request):
'title': _('About {box_name}').format(box_name=_(cfg.box_name)),
'version': __version__,
'new_version': not freedombox.candidate.is_installed,
'os_release': get_os_release()
'os_release': get_os_release(),
'backports_in_use': get_backports_in_use(),
}
return TemplateResponse(request, 'help_about.html', context)
@ -143,3 +145,16 @@ def get_os_release():
line = line.split('=')
output = line[1]
return output
def get_backports_in_use():
"""Return whether backports packages are installed."""
# Only freedombox package is set to be installed from backports currently.
output = subprocess.check_output(['apt-cache', 'policy', 'freedombox'])
for line in output.decode().split('\n'):
if 'Installed:' in line:
version = line.strip().split(': ')[1]
if 'bpo' in version:
return True
return False

View File

@ -90,4 +90,16 @@
{% endif %}
</p>
{% if backports_in_use %}
<h3>{% trans "Security Notice" %}</h3>
<p>
{% blocktrans trimmed %}
You are using packages from Debian backports. Please note that these
packages do not have security support from Debian. However, they are
maintained on a best-effort basis by contributors in Debian and
FreedomBox community.
{% endblocktrans %}
</p>
{% endif %}
{% endblock %}