summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/admin-full/luasrc/controller/admin/services.lua13
-rw-r--r--modules/admin-full/luasrc/controller/admin/system.lua3
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_services/dropbear.lua28
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/admin.lua127
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua45
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua35
6 files changed, 132 insertions, 119 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/services.lua b/modules/admin-full/luasrc/controller/admin/services.lua
index b88e8ab57d..38e3448f0e 100644
--- a/modules/admin-full/luasrc/controller/admin/services.lua
+++ b/modules/admin-full/luasrc/controller/admin/services.lua
@@ -16,7 +16,7 @@ module("luci.controller.admin.services", package.seeall)
function index()
luci.i18n.loadc("base")
local i18n = luci.i18n.translate
-
+
local page = node("admin", "services", "crontab")
page.target = form("admin_services/crontab")
page.title = i18n("Scheduled Tasks")
@@ -24,10 +24,10 @@ function index()
local page = node("admin", "services")
page.target = template("admin_services/index")
- page.title = i18n("Services")
+ page.title = i18n("Services")
page.order = 40
page.index = true
-
+
if nixio.fs.access("/etc/config/lucittpd") then
local page = node("admin", "services", "lucittpd")
page.target = cbi("admin_services/lucittpd")
@@ -41,13 +41,8 @@ function index()
page.title = "Busybox HTTPd"
page.order = 11
end
-
- local page = node("admin", "services", "dropbear")
- page.target = cbi("admin_services/dropbear")
- page.title = "Dropbear SSHd"
- page.order = 20
- if nixio.fs.access("/etc/config/dhcp") then
+ if nixio.fs.access("/etc/config/dhcp") then
local page = node("admin", "services", "dnsmasq")
page.target = cbi("admin_services/dnsmasq")
page.title = "Dnsmasq"
diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua
index 95961f49db..da2ad95002 100644
--- a/modules/admin-full/luasrc/controller/admin/system.lua
+++ b/modules/admin-full/luasrc/controller/admin/system.lua
@@ -21,10 +21,9 @@ function index()
entry({"admin", "system"}, alias("admin", "system", "system"), i18n("System"), 30).index = true
entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("System"), 1)
+ entry({"admin", "system", "admin"}, form("admin_system/admin"), i18n("Administration"), 2)
entry({"admin", "system", "packages"}, call("action_packages"), i18n("Software"), 10)
entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg"))
- entry({"admin", "system", "passwd"}, form("admin_system/passwd"), i18n("Admin Password"), 20)
- entry({"admin", "system", "sshkeys"}, form("admin_system/sshkeys"), i18n("<abbr title=\"Secure Shell\">SSH</abbr>-Keys"), 30)
entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("Processes"), 45)
if nixio.fs.access("/etc/config/fstab") then
diff --git a/modules/admin-full/luasrc/model/cbi/admin_services/dropbear.lua b/modules/admin-full/luasrc/model/cbi/admin_services/dropbear.lua
deleted file mode 100644
index ce68360016..0000000000
--- a/modules/admin-full/luasrc/model/cbi/admin_services/dropbear.lua
+++ /dev/null
@@ -1,28 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-m = Map("dropbear", "Dropbear SSHd", translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server"))
-
-s = m:section(TypedSection, "dropbear", "")
-s.anonymous = true
-s.addremove = true
-
-port = s:option(Value, "Port", translate("Port"))
-port.isinteger = true
-
-pwauth = s:option(Flag, "PasswordAuth", translate("Password authentication"), translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"))
-pwauth.enabled = 'on'
-pwauth.disabled = 'off'
-pwauth.rmempty = false
-
-return m
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua b/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua
new file mode 100644
index 0000000000..94066e93c0
--- /dev/null
+++ b/modules/admin-full/luasrc/model/cbi/admin_system/admin.lua
@@ -0,0 +1,127 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local fs = require "nixio.fs"
+
+m = Map("system", translate("Router Password"),
+ translate("Changes the administrator password for accessing the device"))
+
+s = m:section(TypedSection, "_dummy", "")
+s.addremove = false
+s.anonymous = true
+
+pw1 = s:option(Value, "pw1", translate("Password"))
+pw1.password = true
+
+pw2 = s:option(Value, "pw2", translate("Confirmation"))
+pw2.password = true
+
+function s.cfgsections()
+ return { "_pass" }
+end
+
+function m.on_commit(map)
+ local v1 = pw1:formvalue("_pass")
+ local v2 = pw2:formvalue("_pass")
+
+ if v1 and v2 and #v1 > 0 and #v2 > 0 then
+ if v1 == v2 then
+ if luci.sys.user.setpasswd("root", v1) == 0 then
+ m.message = translate("Password successfully changed!")
+ else
+ m.message = translate("Unknown Error, password not changed!")
+ end
+ else
+ m.message = translate("Given password confirmation did not match, password not changed!")
+ end
+ end
+end
+
+
+
+m2 = Map("dropbear", translate("SSH Access"),
+ translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server"))
+
+s = m2:section(TypedSection, "dropbear", translate("Dropbear Instance"))
+s.anonymous = true
+s.addremove = true
+
+
+ni = s:option(Value, "Interface", translate("Interface"),
+ translate("Listen only on the given interface or, if unspecified, on all"))
+
+ni.template = "cbi/network_netlist"
+ni.nocreate = true
+ni.unspecified = true
+
+
+pt = s:option(Value, "Port", translate("Port"),
+ translate("Specifies the listening port of this <em>Dropbear</em> instance"))
+
+pt.datatype = "port"
+pt.default = 22
+
+
+pa = s:option(Flag, "PasswordAuth", translate("Password authentication"),
+ translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"))
+
+pa.enabled = "on"
+pa.disabled = "off"
+pa.default = pa.enabled
+pa.rmempty = false
+
+
+ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"),
+ translate("Allow the <em>root</em> user to login with password"))
+
+ra.enabled = "on"
+ra.disabled = "off"
+ra.default = ra.enabled
+
+
+gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"),
+ translate("Allow remote hosts to connect to local SSH forwarded ports"))
+
+gp.enabled = "on"
+gp.disabled = "off"
+gp.default = gp.disabled
+
+
+s2 = m2:section(TypedSection, "_dummy", translate("SSH-Keys"),
+ translate("Here you can paste public SSH-Keys (one per line) for SSH public-key authentication."))
+s2.addremove = false
+s2.anonymous = true
+s2.template = "cbi/tblsection"
+
+function s2.cfgsections()
+ return { "_keys" }
+end
+
+keys = s2:option(TextValue, "_data", "")
+keys.wrap = "off"
+keys.rows = 3
+keys.rmempty = false
+
+function keys.cfgvalue()
+ return fs.readfile("/etc/dropbear/authorized_keys") or ""
+end
+
+function keys.write(self, section, value)
+ if value then
+ fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n"))
+ end
+end
+
+return m, m2
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua b/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua
deleted file mode 100644
index 6f13bb0fc8..0000000000
--- a/modules/admin-full/luasrc/model/cbi/admin_system/passwd.lua
+++ /dev/null
@@ -1,45 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-f = SimpleForm("password", translate("Admin Password"), translate("Change the password of the system administrator (User <code>root</code>)"))
-
-pw1 = f:field(Value, "pw1", translate("Password"))
-pw1.password = true
-pw1.rmempty = false
-
-pw2 = f:field(Value, "pw2", translate("Confirmation"))
-pw2.password = true
-pw2.rmempty = false
-
-function pw2.validate(self, value, section)
- return pw1:formvalue(section) == value and value
-end
-
-function f.handle(self, state, data)
- if state == FORM_VALID then
- local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
-
- if stat then
- f.message = translate("Password successfully changed")
- else
- f.errmessage = translate("Unknown Error")
- end
-
- data.pw1 = nil
- data.pw2 = nil
- end
- return true
-end
-
-return f \ No newline at end of file
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua b/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua
deleted file mode 100644
index c18539c8e8..0000000000
--- a/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua
+++ /dev/null
@@ -1,35 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-local keyfile = "/etc/dropbear/authorized_keys"
-
-f = SimpleForm("sshkeys", translate("<abbr title=\"Secure Shell\">SSH</abbr>-Keys"), translate("Here you can paste public <abbr title=\"Secure Shell\">SSH</abbr>-Keys (one per line) for <abbr title=\"Secure Shell\">SSH</abbr> public-key authentication."))
-
-t = f:field(TextValue, "keys")
-t.rmempty = true
-t.rows = 10
-function t.cfgvalue()
- return nixio.fs.readfile(keyfile) or ""
-end
-
-function f.handle(self, state, data)
- if state == FORM_VALID then
- if data.keys then
- nixio.fs.writefile(keyfile, data.keys:gsub("\r\n", "\n"))
- end
- end
- return true
-end
-
-return f