mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-11 08:23:49 +00:00
security: Move backports notice to security page
Move get_backports_in_use to upgrades. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
d042c3c60c
commit
f41cc116a1
@ -74,17 +74,4 @@
|
||||
{% endblocktrans %}
|
||||
{% 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 %}
|
||||
|
||||
@ -6,7 +6,6 @@ Help app for FreedomBox.
|
||||
import mimetypes
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
from apt.cache import Cache
|
||||
from django.core.files.base import File
|
||||
@ -52,7 +51,6 @@ def about(request):
|
||||
'version': __version__,
|
||||
'new_version': not freedombox.candidate.is_installed,
|
||||
'os_release': get_os_release(),
|
||||
'backports_in_use': get_backports_in_use(),
|
||||
}
|
||||
return TemplateResponse(request, 'help_about.html', context)
|
||||
|
||||
@ -134,16 +132,3 @@ 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
|
||||
|
||||
@ -7,6 +7,18 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block status %}
|
||||
{% 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 %}
|
||||
|
||||
<a class="btn btn-default" role="button" href="{% url 'security:report' %}"
|
||||
title="{% trans 'Show security report' %}">
|
||||
<span class="fa fa-line-chart" aria-hidden="true"></span>
|
||||
|
||||
@ -9,6 +9,7 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from plinth import action_utils, actions
|
||||
from plinth.modules import security
|
||||
from plinth.modules.upgrades import get_backports_in_use
|
||||
|
||||
from .forms import SecurityForm
|
||||
|
||||
@ -28,10 +29,12 @@ def index(request):
|
||||
else:
|
||||
form = SecurityForm(initial=status, prefix='security')
|
||||
|
||||
return TemplateResponse(request, 'security.html', {
|
||||
'app_info': security.app.info,
|
||||
'form': form,
|
||||
})
|
||||
return TemplateResponse(
|
||||
request, 'security.html', {
|
||||
'app_info': security.app.info,
|
||||
'form': form,
|
||||
'backports_in_use': get_backports_in_use(),
|
||||
})
|
||||
|
||||
|
||||
def get_status(request):
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
FreedomBox app for upgrades.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_noop
|
||||
|
||||
@ -131,3 +133,16 @@ def disable():
|
||||
def _setup_repositories(data):
|
||||
"""Setup apt backport repositories."""
|
||||
actions.superuser_run('upgrades', ['setup-repositories'])
|
||||
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user