From b5591cb0088da9ba48fbaa541c7de2bd2b80a245 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 13 Nov 2013 20:05:44 -0500 Subject: [PATCH 01/12] Fix typo in base template. --- templates/base.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.tmpl b/templates/base.tmpl index 8a162888f..5ec88d4c4 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -184,7 +184,7 @@ - + From 1127ff4f996c81c4bba4a66b5ffd7d4aba882d6c Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 13 Nov 2013 20:38:39 -0500 Subject: [PATCH 02/12] Prepend server_dir to menu items. --- menu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.py b/menu.py index 90b0af896..477ea4ab1 100644 --- a/menu.py +++ b/menu.py @@ -42,7 +42,7 @@ class Menu(): If BASEHREF is true and url start with a slash, prepend the cfg.base_href to it""" if basehref and url.startswith("/"): - url = cfg.base_href + url + url = cfg.server_dir + cfg.base_href + url item = Menu(label=label, icon=icon, url=url, order=order) self.items.append(item) From d48ecb6722e3578cdcb6a087e12f1dd256f1b328 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 13 Nov 2013 20:47:33 -0500 Subject: [PATCH 03/12] Use server_dir as replacement for base_href. --- cfg.py | 1 - menu.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cfg.py b/cfg.py index 013a5bdff..e45f56807 100644 --- a/cfg.py +++ b/cfg.py @@ -35,7 +35,6 @@ port = int(get_item(parser, 'Network', 'port')) html_root = None main_menu = Menu() -base_href = "" if store_file.endswith(".sqlite3"): store_file = os.path.splitext(store_file)[0] diff --git a/menu.py b/menu.py index 477ea4ab1..93860dcdb 100644 --- a/menu.py +++ b/menu.py @@ -39,10 +39,10 @@ class Menu(): """This method creates a menu item with the parameters, adds that menu item to this menu, and returns the item. - If BASEHREF is true and url start with a slash, prepend the cfg.base_href to it""" + If BASEHREF is true and url start with a slash, prepend the cfg.server_dir to it""" if basehref and url.startswith("/"): - url = cfg.server_dir + cfg.base_href + url + url = cfg.server_dir + url item = Menu(label=label, icon=icon, url=url, order=order) self.items.append(item) From 3f36781fdf6b3935486adef4cfaf4adaa89afbb6 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 13 Nov 2013 23:45:40 -0500 Subject: [PATCH 04/12] If creating a new user db, make sure it's permission is 640. --- plinth.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plinth.py b/plinth.py index 7b3407c84..0e82b2027 100755 --- a/plinth.py +++ b/plinth.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import os, sys, argparse +import os, stat, sys, argparse from gettext import gettext as _ import cfg if not os.path.join(cfg.file_root, "vendor") in sys.path: @@ -135,7 +135,19 @@ def setup(): cfg.log = Logger() load_modules() cfg.html_root = Root() + + # check if we are creating a new user db + userdb_fname = '{}.sqlite3'.format(cfg.user_db) + try: + with open(userdb_fname): + userdb_exists = True + except IOError: + userdb_exists = False cfg.users = plugin_mount.UserStoreModule.get_plugins()[0] + # if we created a new user db, make sure it can't be read by everyone + if not userdb_exists: + os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) + cfg.page_plugins = plugin_mount.PagePlugin.get_plugins() cfg.log("Loaded %d page plugins" % len(cfg.page_plugins)) cfg.forms = plugin_mount.FormPlugin.get_plugins() From a7decf383ef67a1850d6d3b8a66f981392b6ae00 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 14 Nov 2013 18:28:47 -0500 Subject: [PATCH 05/12] Check user db permissions when we redirect to firstboot, instead of trying to check if the file exists. --- plinth.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/plinth.py b/plinth.py index 0e82b2027..3ccfdc867 100755 --- a/plinth.py +++ b/plinth.py @@ -57,6 +57,9 @@ class Root(plugin_mount.PagePlugin): ## TODO: firstboot hijacking root should probably be in the firstboot module with a hook in plinth.py with sqlite_db(cfg.store_file, table="firstboot") as db: if not 'state' in db: + # if we created a new user db, make sure it can't be read by everyone + userdb_fname = '{}.sqlite3'.format(cfg.user_db) + os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) raise cherrypy.InternalRedirect('firstboot') elif db['state'] < 5: cfg.log("First Boot state = %d" % db['state']) @@ -136,18 +139,7 @@ def setup(): load_modules() cfg.html_root = Root() - # check if we are creating a new user db - userdb_fname = '{}.sqlite3'.format(cfg.user_db) - try: - with open(userdb_fname): - userdb_exists = True - except IOError: - userdb_exists = False cfg.users = plugin_mount.UserStoreModule.get_plugins()[0] - # if we created a new user db, make sure it can't be read by everyone - if not userdb_exists: - os.chmod(userdb_fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) - cfg.page_plugins = plugin_mount.PagePlugin.get_plugins() cfg.log("Loaded %d page plugins" % len(cfg.page_plugins)) cfg.forms = plugin_mount.FormPlugin.get_plugins() From 63508b6bbacf7b42a61935f28b1d8d7168f0c0fe Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 14 Nov 2013 19:15:45 -0500 Subject: [PATCH 06/12] Fix some bugs in xmpp module. --- modules/installed/services/xmpp.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/installed/services/xmpp.py b/modules/installed/services/xmpp.py index 8881a2bd0..7e1cb749f 100644 --- a/modules/installed/services/xmpp.py +++ b/modules/installed/services/xmpp.py @@ -53,9 +53,7 @@ class xmpp(PagePlugin): form.submit(_("Update setup")) main += form.render() - sidebar_right = """ -Register XMPP Account -""" + sidebar_right = 'Register XMPP Account' return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_right=sidebar_right) class register(FormPlugin, PagePlugin): @@ -88,7 +86,7 @@ class register(FormPlugin, PagePlugin): if "successfully registered" in output: msg.add = _("Registered account for %s." % username) else: - msg.add = _("Failed to register account for %s: %o" % (username, output)) + msg.add = _("Failed to register account for %s: %s" % (username, output)) cfg.log(msg.text) main = self.main(username, msg=msg.text) From 4111fca8ebf8ce85921604d3666e7fea61bcddea Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Thu, 14 Nov 2013 22:21:17 -0500 Subject: [PATCH 07/12] Move owncloud into its own module. --- modules/installed/apps/apps.py | 45 ---------------------- modules/installed/apps/owncloud.py | 60 ++++++++++++++++++++++++++++++ modules/owncloud.py | 1 + 3 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 modules/installed/apps/owncloud.py create mode 120000 modules/owncloud.py diff --git a/modules/installed/apps/apps.py b/modules/installed/apps/apps.py index 2706110ce..efb99ea1a 100644 --- a/modules/installed/apps/apps.py +++ b/modules/installed/apps/apps.py @@ -3,7 +3,6 @@ from gettext import gettext as _ from modules.auth import require from plugin_mount import PagePlugin from forms import Form -from privilegedactions import privilegedaction_run import cfg class Apps(PagePlugin): @@ -12,7 +11,6 @@ class Apps(PagePlugin): self.register_page("apps") self.menu = cfg.main_menu.add_item("Apps", "icon-download-alt", "/apps", 80) self.menu.add_item("Photo Gallery", "icon-picture", "/apps/photos", 35) - self.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35) @cherrypy.expose def index(self): @@ -38,46 +36,3 @@ photos local, backed up, easily accessed and free from the whims of some other websites business model.

""") - @cherrypy.expose - @require() - def owncloud(self, submitted=False, **kwargs): - checkedinfo = { - 'enable' : False, - } - - if submitted: - opts = [] - for k in kwargs.keys(): - if 'on' == kwargs[k]: - shortk = k.split("owncloud_").pop() - checkedinfo[shortk] = True - - for key in checkedinfo.keys(): - if checkedinfo[key]: - opts.append(key) - else: - opts.append('no'+key) - privilegedaction_run("owncloud-setup", opts) - - output, error = privilegedaction_run("owncloud-setup", ['status']) - if error: - raise Exception("something is wrong: " + error) - for option in output.split(): - checkedinfo[option] = True - - main=""" -""" - form = Form(title="Configuration", - action=cfg.server_dir + "/apps/owncloud", - name="configure_owncloud", - message='') - form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable']) - form.hidden(name="submitted", value="True") - form.html(_("

When enabled, the owncloud installation will be available from /owncloud/ on the web server.

")) - form.submit(_("Update setup")) - main += form.render() - sidebar_right=""" -Owncloud

gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn't need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins. -

-""" - return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right) diff --git a/modules/installed/apps/owncloud.py b/modules/installed/apps/owncloud.py new file mode 100644 index 000000000..a7a0ffe8a --- /dev/null +++ b/modules/installed/apps/owncloud.py @@ -0,0 +1,60 @@ +import cherrypy +from gettext import gettext as _ +from modules.auth import require +from plugin_mount import PagePlugin +from forms import Form +from privilegedactions import privilegedaction_run +import cfg + +class Owncloud(PagePlugin): + order = 90 + + def __init__(self, *args, **kwargs): + PagePlugin.__init__(self, *args, **kwargs) + self.register_page("apps.owncloud") + cfg.html_root.apps.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35) + + @cherrypy.expose + @require() + def index(self, submitted=False, **kwargs): + checkedinfo = { + 'enable' : False, + } + + if submitted: + opts = [] + for k in kwargs.keys(): + if 'on' == kwargs[k]: + shortk = k.split("owncloud_").pop() + checkedinfo[shortk] = True + + for key in checkedinfo.keys(): + if checkedinfo[key]: + opts.append(key) + else: + opts.append('no'+key) + privilegedaction_run("owncloud-setup", opts) + + output, error = privilegedaction_run("owncloud-setup", ['status']) + if error: + raise Exception("something is wrong: " + error) + for option in output.split(): + checkedinfo[option] = True + + main=""" +""" + form = Form(title="Configuration", + action=cfg.server_dir + "/apps/owncloud", + name="configure_owncloud", + message='') + form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable']) + form.hidden(name="submitted", value="True") + form.html(_("

When enabled, the owncloud installation will be available from /owncloud/ on the web server.

")) + form.submit(_("Update setup")) + main += form.render() + sidebar_right=""" +Owncloud

gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn't need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins. +

+""" + return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right) + diff --git a/modules/owncloud.py b/modules/owncloud.py new file mode 120000 index 000000000..4ae17c8be --- /dev/null +++ b/modules/owncloud.py @@ -0,0 +1 @@ +installed/apps/owncloud.py \ No newline at end of file From 579ae89477d08199a772b03ce53cc15193f212fd Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Fri, 15 Nov 2013 23:36:45 -0500 Subject: [PATCH 08/12] Change XMPP server config form to use FormPlugin methods. This works with POST form method. --- modules/installed/services/xmpp.py | 68 +++++++++++++++++------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/modules/installed/services/xmpp.py b/modules/installed/services/xmpp.py index 7e1cb749f..6ccc469cf 100644 --- a/modules/installed/services/xmpp.py +++ b/modules/installed/services/xmpp.py @@ -11,50 +11,60 @@ class xmpp(PagePlugin): def __init__(self, *args, **kwargs): PagePlugin.__init__(self, *args, **kwargs) self.register_page("services.xmpp") + self.register_page("services.xmpp.configure") self.register_page("services.xmpp.register") cfg.html_root.services.menu.add_item("XMPP", "icon-comment", "/services/xmpp", 40) @cherrypy.expose @require() - def index(self, submitted=False, **kwargs): - checkedinfo = { - 'inband_enable' : False, - } + def index(self, **kwargs): + main = "

XMPP Server Accounts and Configuration

" + sidebar_right = 'Configure XMPP Server
' + sidebar_right = sidebar_right + 'Register XMPP Account' + return self.fill_template(title="XMPP Server", main=main, sidebar_right=sidebar_right) - if submitted: - opts = [] - for k in kwargs.keys(): - if 'on' == kwargs[k]: - shortk = k.split("xmpp_").pop() - checkedinfo[shortk] = True +class configure(FormPlugin, PagePlugin): + url = ["/services/xmpp/configure"] - for key in checkedinfo.keys(): - if checkedinfo[key]: - opts.append(key) - else: - opts.append('no'+key) - privilegedaction_run("xmpp-setup", opts) + sidebar_left = '' + sidebar_right = _("Configure XMPP Server") - output, error = privilegedaction_run("xmpp-setup", ['status']) + def main(self, inband_enable=False, message=None, *args, **kwargs): + output, error = privilegedaction_run("xmpp-setup", 'status') if error: raise Exception("something is wrong: " + error) - for option in output.split(): - checkedinfo[option] = True + if "inband_enable" in output.split(): + inband_enable = True - main = "

XMPP Server Configuration

" - form = Form(title="Configuration", - action=cfg.server_dir + "/services/xmpp", - name="configure_xmpp", - message='') - form.checkbox(_("Allow In-Band Registration"), name="xmpp_inband_enable", - id="xmpp_inband_enable", checked=checkedinfo['inband_enable']) + form = Form(title="Configure XMPP Server", + action=cfg.server_dir + "/services/xmpp/configure/index", + name="configure_xmpp_form", + message=message) + form.checkbox(_("Allow In-Band Registration"), name="inband_enable", + id="inband_enable", checked=inband_enable) + # hidden field is needed because checkbox doesn't post if not checked form.hidden(name="submitted", value="True") form.html(_("

When enabled, anyone who can reach this server will be allowed to register an account through an XMPP client.

")) form.submit(_("Update setup")) - main += form.render() + return form.render() - sidebar_right = 'Register XMPP Account' - return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_right=sidebar_right) + def process_form(self, inband_enable=None, **kwargs): + msg = Message() + + if inband_enable == u'on': + output, error = privilegedaction_run("xmpp-setup", "inband_enable") + if error: + raise Exception("something is wrong: " + error) + msg.add = _("Enabled in-band registration.") + else: + output, error = privilegedaction_run("xmpp-setup", "noinband_enable") + if error: + raise Exception("something is wrong: " + error) + msg.add = _("Disabled in-band registration.") + + cfg.log(msg.text) + main = self.main(inband_enable, msg=msg.text) + return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right) class register(FormPlugin, PagePlugin): url = ["/services/xmpp/register"] From 6c157284264d10f61d4ff11502bbfe2e00c709c5 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 16 Nov 2013 00:10:06 -0500 Subject: [PATCH 09/12] Change Owncloud config form to use FormPlugin methods. --- modules/installed/apps/owncloud.py | 88 +++++++++++++++++------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/modules/installed/apps/owncloud.py b/modules/installed/apps/owncloud.py index a7a0ffe8a..b8c300fa9 100644 --- a/modules/installed/apps/owncloud.py +++ b/modules/installed/apps/owncloud.py @@ -1,10 +1,11 @@ import cherrypy from gettext import gettext as _ from modules.auth import require -from plugin_mount import PagePlugin +from plugin_mount import PagePlugin, FormPlugin from forms import Form from privilegedactions import privilegedaction_run import cfg +from util import Message class Owncloud(PagePlugin): order = 90 @@ -12,49 +13,58 @@ class Owncloud(PagePlugin): def __init__(self, *args, **kwargs): PagePlugin.__init__(self, *args, **kwargs) self.register_page("apps.owncloud") + self.register_page("apps.owncloud.configure") cfg.html_root.apps.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35) @cherrypy.expose @require() - def index(self, submitted=False, **kwargs): - checkedinfo = { - 'enable' : False, - } - - if submitted: - opts = [] - for k in kwargs.keys(): - if 'on' == kwargs[k]: - shortk = k.split("owncloud_").pop() - checkedinfo[shortk] = True - - for key in checkedinfo.keys(): - if checkedinfo[key]: - opts.append(key) - else: - opts.append('no'+key) - privilegedaction_run("owncloud-setup", opts) - - output, error = privilegedaction_run("owncloud-setup", ['status']) - if error: - raise Exception("something is wrong: " + error) - for option in output.split(): - checkedinfo[option] = True - - main=""" -""" - form = Form(title="Configuration", - action=cfg.server_dir + "/apps/owncloud", - name="configure_owncloud", - message='') - form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable']) - form.hidden(name="submitted", value="True") - form.html(_("

When enabled, the owncloud installation will be available from /owncloud/ on the web server.

")) - form.submit(_("Update setup")) - main += form.render() + def index(self, **kwargs): sidebar_right=""" Owncloud

gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn't need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins.

""" - return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right) - + sidebar_right = sidebar_right + 'Configure Owncloud' + return self.fill_template(title="Owncloud", main='', sidebar_right=sidebar_right) + +class configure(FormPlugin, PagePlugin): + url = ["/apps/owncloud/configure"] + + sidebar_left = '' + sidebar_right = _("Configure Owncloud") + + def main(self, owncloud_enable=False, message=None, *args, **kwargs): + output, error = privilegedaction_run("owncloud-setup", 'status') + if error: + raise Exception("something is wrong: " + error) + if "enable" in output.split(): + owncloud_enable = True + + form = Form(title="Configuration", + action=cfg.server_dir + "/apps/owncloud/configure/index", + name="configure_owncloud", + message=message) + 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(_("

When enabled, the owncloud installation will be available from /owncloud/ on the web server.

")) + form.submit(_("Update setup")) + return form.render() + + def process_form(self, owncloud_enable=None, **kwargs): + msg = Message() + + if owncloud_enable == u'on': + output, error = privilegedaction_run("owncloud-setup", "enable") + if error: + raise Exception("something is wrong: " + error) + msg.add = _("Enabled Owncloud.") + else: + output, error = privilegedaction_run("owncloud-setup", "noenable") + if error: + raise Exception("something is wrong: " + error) + msg.add = _("Disabled Owncloud.") + + cfg.log(msg.text) + main = self.main(owncloud_enable, msg=msg.text) + return self.fill_template(title="Owncloud Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right) + From ea0f5b8102fdc42260869a61d603b77c8ccbd1de Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 16 Nov 2013 07:05:27 -0500 Subject: [PATCH 10/12] Earlier I removed some flexibility from XMPP/Owncloud config forms to get things working. Restoring code that will make it easier to add new parameters in the future. --- modules/installed/apps/owncloud.py | 31 +++++++++++++----------- modules/installed/services/xmpp.py | 39 ++++++++++++++++-------------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/modules/installed/apps/owncloud.py b/modules/installed/apps/owncloud.py index b8c300fa9..e2b95c75f 100644 --- a/modules/installed/apps/owncloud.py +++ b/modules/installed/apps/owncloud.py @@ -50,21 +50,24 @@ class configure(FormPlugin, PagePlugin): form.submit(_("Update setup")) return form.render() - def process_form(self, owncloud_enable=None, **kwargs): - msg = Message() + def process_form(self, **kwargs): + checkedinfo = { + 'enable' : False, + } - if owncloud_enable == u'on': - output, error = privilegedaction_run("owncloud-setup", "enable") - if error: - raise Exception("something is wrong: " + error) - msg.add = _("Enabled Owncloud.") - else: - output, error = privilegedaction_run("owncloud-setup", "noenable") - if error: - raise Exception("something is wrong: " + error) - msg.add = _("Disabled Owncloud.") + opts = [] + for k in kwargs.keys(): + if 'on' == kwargs[k]: + shortk = k.split("owncloud_").pop() + checkedinfo[shortk] = True - cfg.log(msg.text) - main = self.main(owncloud_enable, msg=msg.text) + for key in checkedinfo.keys(): + if checkedinfo[key]: + opts.append(key) + else: + opts.append('no'+key) + privilegedaction_run("owncloud-setup", " ".join(opts)) + + main = self.main(checkedinfo['enable']) return self.fill_template(title="Owncloud Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right) diff --git a/modules/installed/services/xmpp.py b/modules/installed/services/xmpp.py index 6ccc469cf..2ed240c21 100644 --- a/modules/installed/services/xmpp.py +++ b/modules/installed/services/xmpp.py @@ -29,41 +29,44 @@ class configure(FormPlugin, PagePlugin): sidebar_left = '' sidebar_right = _("Configure XMPP Server") - def main(self, inband_enable=False, message=None, *args, **kwargs): + def main(self, xmpp_inband_enable=False, message=None, *args, **kwargs): output, error = privilegedaction_run("xmpp-setup", 'status') if error: raise Exception("something is wrong: " + error) if "inband_enable" in output.split(): - inband_enable = True + xmpp_inband_enable = True form = Form(title="Configure XMPP Server", action=cfg.server_dir + "/services/xmpp/configure/index", name="configure_xmpp_form", message=message) - form.checkbox(_("Allow In-Band Registration"), name="inband_enable", - id="inband_enable", checked=inband_enable) + form.checkbox(_("Allow In-Band Registration"), name="xmpp_inband_enable", + id="xmpp_inband_enable", checked=xmpp_inband_enable) # hidden field is needed because checkbox doesn't post if not checked form.hidden(name="submitted", value="True") form.html(_("

When enabled, anyone who can reach this server will be allowed to register an account through an XMPP client.

")) form.submit(_("Update setup")) return form.render() - def process_form(self, inband_enable=None, **kwargs): - msg = Message() + def process_form(self, **kwargs): + checkedinfo = { + 'inband_enable' : False, + } - if inband_enable == u'on': - output, error = privilegedaction_run("xmpp-setup", "inband_enable") - if error: - raise Exception("something is wrong: " + error) - msg.add = _("Enabled in-band registration.") - else: - output, error = privilegedaction_run("xmpp-setup", "noinband_enable") - if error: - raise Exception("something is wrong: " + error) - msg.add = _("Disabled in-band registration.") + opts = [] + for k in kwargs.keys(): + if 'on' == kwargs[k]: + shortk = k.split("xmpp_").pop() + checkedinfo[shortk] = True - cfg.log(msg.text) - main = self.main(inband_enable, msg=msg.text) + for key in checkedinfo.keys(): + if checkedinfo[key]: + opts.append(key) + else: + opts.append('no'+key) + privilegedaction_run("xmpp-setup", " ".join(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) class register(FormPlugin, PagePlugin): From 42ab4429303a6ad4cad3e8c481d8ead0e60855d4 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 16 Nov 2013 07:14:00 -0500 Subject: [PATCH 11/12] Cosmetic changes to owncloud page. --- modules/installed/apps/owncloud.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/installed/apps/owncloud.py b/modules/installed/apps/owncloud.py index e2b95c75f..83a79539c 100644 --- a/modules/installed/apps/owncloud.py +++ b/modules/installed/apps/owncloud.py @@ -19,12 +19,12 @@ class Owncloud(PagePlugin): @cherrypy.expose @require() def index(self, **kwargs): - sidebar_right=""" -Owncloud

gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn't need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins. + main=""" +

ownCloud gives you universal access to your files through a web interface or WebDAV. It also provides a platform to easily view & sync your contacts, calendars and bookmarks across all your devices and enables basic editing right on the web. Installation has minimal server requirements, doesn't need special permissions and is quick. ownCloud is extendable via a simple but powerful API for applications and plugins.

""" - sidebar_right = sidebar_right + 'Configure Owncloud' - return self.fill_template(title="Owncloud", main='', sidebar_right=sidebar_right) + sidebar_right = 'Configure Owncloud' + return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right) class configure(FormPlugin, PagePlugin): url = ["/apps/owncloud/configure"] From 880e9bd76a393c496b7d6b36348ebdfcc4f35555 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 16 Nov 2013 13:21:27 -0500 Subject: [PATCH 12/12] Set default paths in auth_page module to begin with server_dir. --- modules/installed/lib/auth_page.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/installed/lib/auth_page.py b/modules/installed/lib/auth_page.py index 3f3574c6a..49d7a8de4 100644 --- a/modules/installed/lib/auth_page.py +++ b/modules/installed/lib/auth_page.py @@ -16,7 +16,7 @@ class AuthController(PagePlugin): def on_logout(self, username): """Called on logout""" - def get_loginform(self, username, msg='', from_page="/"): + def get_loginform(self, username, msg='', from_page=cfg.server_dir+"/"): form = Form(title="Login", action=cfg.server_dir + "/auth/login", message=msg) form.text_input(name="from_page", value=from_page, type="hidden") form.text_input("Username", name="username", value=username) @@ -26,7 +26,7 @@ class AuthController(PagePlugin): return self.fill_template(main=form.render(), sidebar_right=" ") @cherrypy.expose - def login(self, username=None, passphrase=None, from_page="/", **kwargs): + def login(self, username=None, passphrase=None, from_page=cfg.server_dir+"/", **kwargs): if username is None or passphrase is None: return self.get_loginform("", from_page=from_page) @@ -39,7 +39,7 @@ class AuthController(PagePlugin): raise cherrypy.HTTPRedirect(from_page or (cfg.server_dir + "/")) @cherrypy.expose - def logout(self, from_page="/"): + def logout(self, from_page=cfg.server_dir+"/"): sess = cherrypy.session username = sess.get(cfg.session_key, None) sess[cfg.session_key] = None