mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Cleaned up missed references to privilegedactions.
This commit is contained in:
parent
e23650232b
commit
16c994b787
19
actions.py
19
actions.py
@ -79,15 +79,31 @@ import pipes, shlex, subprocess
|
||||
contract.checkmod(__name__)
|
||||
|
||||
def run(action, options = None, async = False):
|
||||
"""Safely run a specific action as the current user.
|
||||
|
||||
See actions._run for more information.
|
||||
|
||||
"""
|
||||
return _run(action, options, async, False)
|
||||
|
||||
def superuser_run(action, options = None, async = False):
|
||||
"""Safely run a specific action as root.
|
||||
|
||||
See actions._run for more information.
|
||||
|
||||
"""
|
||||
return _run(action, options, async, True)
|
||||
|
||||
def _run(action, options = None, async = False, run_as_root = False):
|
||||
"""Safely run a specific action as root.
|
||||
"""Safely run a specific action as a normal user or root.
|
||||
|
||||
actions are pulled from the actions directory.
|
||||
|
||||
options are added to the action command.
|
||||
|
||||
async: run asynchronously or wait for the command to complete.
|
||||
|
||||
run_as_root: execute the command through sudo.
|
||||
|
||||
pre:
|
||||
os.sep not in action
|
||||
@ -96,6 +112,7 @@ def _run(action, options = None, async = False, run_as_root = False):
|
||||
|
||||
"""
|
||||
DIRECTORY = "actions"
|
||||
|
||||
if options == None:
|
||||
options = []
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ from gettext import gettext as _
|
||||
from modules.auth import require
|
||||
from plugin_mount import PagePlugin, FormPlugin
|
||||
from forms import Form
|
||||
from privilegedactions import privilegedaction_run
|
||||
import actions
|
||||
import cfg
|
||||
from util import Message
|
||||
|
||||
@ -33,7 +33,7 @@ class configure(FormPlugin, PagePlugin):
|
||||
sidebar_right = _("<strong>Configure Owncloud</strong>")
|
||||
|
||||
def main(self, owncloud_enable=False, message=None, *args, **kwargs):
|
||||
output, error = privilegedaction_run("owncloud-setup", 'status')
|
||||
output, error = actions.run("owncloud-setup", 'status')
|
||||
if error:
|
||||
raise Exception("something is wrong: " + error)
|
||||
if "enable" in output.split():
|
||||
@ -46,7 +46,7 @@ class configure(FormPlugin, PagePlugin):
|
||||
form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=owncloud_enable)
|
||||
# hidden field is needed because checkbox doesn't post if not checked
|
||||
form.hidden(name="submitted", value="True")
|
||||
form.html(_("<p>When enabled, the owncloud installation will be available from /owncloud/ on the web server.</p>"))
|
||||
form.html(_("""<p>When enabled, the owncloud installation will be available from <a href="/owncloud">owncloud</a> on the web server.</p>"""))
|
||||
form.submit(_("Update setup"))
|
||||
return form.render()
|
||||
|
||||
@ -66,7 +66,7 @@ class configure(FormPlugin, PagePlugin):
|
||||
opts.append(key)
|
||||
else:
|
||||
opts.append('no'+key)
|
||||
privilegedaction_run("owncloud-setup", " ".join(opts))
|
||||
actions.superuser_run("owncloud-setup", opts, async=True)
|
||||
|
||||
main = self.main(checkedinfo['enable'])
|
||||
return self.fill_template(title="Owncloud Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||
|
||||
@ -4,7 +4,7 @@ from modules.auth import require
|
||||
from plugin_mount import PagePlugin, FormPlugin
|
||||
import cfg
|
||||
from forms import Form
|
||||
from actions import superuser_run
|
||||
import actions
|
||||
from util import Message
|
||||
|
||||
class xmpp(PagePlugin):
|
||||
@ -30,7 +30,7 @@ class configure(FormPlugin, PagePlugin):
|
||||
sidebar_right = _("<strong>Configure XMPP Server</strong>")
|
||||
|
||||
def main(self, xmpp_inband_enable=False, message=None, *args, **kwargs):
|
||||
output, error = superuser_run("xmpp-setup", 'status')
|
||||
output, error = actions.superuser_run("xmpp-setup", 'status')
|
||||
if error:
|
||||
raise Exception("something is wrong: " + error)
|
||||
if "inband_enable" in output.split():
|
||||
@ -64,7 +64,7 @@ class configure(FormPlugin, PagePlugin):
|
||||
opts.append(key)
|
||||
else:
|
||||
opts.append('no'+key)
|
||||
privilegedaction_run("xmpp-setup", " ".join(opts))
|
||||
actions.run("xmpp-setup", opts)
|
||||
|
||||
main = self.main(checkedinfo['inband_enable'])
|
||||
return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||
@ -92,7 +92,8 @@ class register(FormPlugin, PagePlugin):
|
||||
if not password: msg.add = _("Must specify a password!")
|
||||
|
||||
if username and password:
|
||||
output, error = superuser_run("xmpp-register", [username, password])
|
||||
output, error = actions.superuser_run(
|
||||
"xmpp-register", [username, password])
|
||||
if error:
|
||||
raise Exception("something is wrong: " + error)
|
||||
|
||||
@ -103,5 +104,8 @@ class register(FormPlugin, PagePlugin):
|
||||
|
||||
cfg.log(msg.text)
|
||||
main = self.main(username, msg=msg.text)
|
||||
return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||
|
||||
return self.fill_template(
|
||||
title="XMPP Server Configuration",
|
||||
main=main,
|
||||
sidebar_left=self.sidebar_left,
|
||||
sidebar_right=self.sidebar_right)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user