mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
upgrades: Run status operations as non-root
Current check whether the package manager is busy and getting the unattended upgrades log requires root. This will not allow Plinth to run as non-root. Fix this by moving the operations to actions script.
This commit is contained in:
1 parent
afdea208ec
commit
7b68dd55f2
3 files changed
+26
-17
No files matched your search
@@ -36,9 +36,6 @@ subsubmenu = [{'url': reverse_lazy('upgrades:index'),
|
||||
{'url': reverse_lazy('upgrades:upgrade'),
|
||||
'text': ugettext_lazy('Upgrade Packages')}]
|
||||
|
||||
LOG_FILE = '/var/log/unattended-upgrades/unattended-upgrades.log'
|
||||
LOCK_FILE = '/var/log/dpkg/lock'
|
||||
|
||||
|
||||
class UpgradesConfigurationView(FormView):
|
||||
"""Serve configuration page."""
|
||||
@@ -91,19 +88,15 @@ class UpgradesConfigurationView(FormView):
|
||||
def is_package_manager_busy():
|
||||
"""Return whether a package manager is running."""
|
||||
try:
|
||||
subprocess.check_output(['lsof', '/var/lib/dpkg/lock'])
|
||||
actions.superuser_run('upgrades', ['is-package-manager-busy'])
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
except actions.ActionError:
|
||||
return False
|
||||
|
||||
|
||||
def get_log():
|
||||
"""Return the current log for unattended upgrades."""
|
||||
try:
|
||||
with open(LOG_FILE, 'r') as file_handle:
|
||||
return file_handle.read()
|
||||
except IOError:
|
||||
return None
|
||||
return actions.superuser_run('upgrades', ['get-log'])
|
||||
|
||||
|
||||
def upgrade(request):
|
||||
|
||||
Reference in new issue
Block a user