2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 local fs = require "nixio.fs"
18 m = Map("system", translate("Router Password"),
19 translate("Changes the administrator password for accessing the device"))
21 s = m:section(TypedSection, "_dummy", "")
25 pw1 = s:option(Value, "pw1", translate("Password"))
28 pw2 = s:option(Value, "pw2", translate("Confirmation"))
31 function s.cfgsections()
35 function m.on_commit(map)
36 local v1 = pw1:formvalue("_pass")
37 local v2 = pw2:formvalue("_pass")
39 if v1 and v2 and #v1 > 0 and #v2 > 0 then
41 if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then
42 m.message = translate("Password successfully changed!")
44 m.message = translate("Unknown Error, password not changed!")
47 m.message = translate("Given password confirmation did not match, password not changed!")
53 if fs.access("/etc/config/dropbear") then
55 m2 = Map("dropbear", translate("SSH Access"),
56 translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server"))
58 s = m2:section(TypedSection, "dropbear", translate("Dropbear Instance"))
63 ni = s:option(Value, "Interface", translate("Interface"),
64 translate("Listen only on the given interface or, if unspecified, on all"))
66 ni.template = "cbi/network_netlist"
71 pt = s:option(Value, "Port", translate("Port"),
72 translate("Specifies the listening port of this <em>Dropbear</em> instance"))
78 pa = s:option(Flag, "PasswordAuth", translate("Password authentication"),
79 translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"))
83 pa.default = pa.enabled
87 ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"),
88 translate("Allow the <em>root</em> user to login with password"))
92 ra.default = ra.enabled
95 gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"),
96 translate("Allow remote hosts to connect to local SSH forwarded ports"))
100 gp.default = gp.disabled
103 s2 = m2:section(TypedSection, "_dummy", translate("SSH-Keys"),
104 translate("Here you can paste public SSH-Keys (one per line) for SSH public-key authentication."))
107 s2.template = "cbi/tblsection"
109 function s2.cfgsections()
113 keys = s2:option(TextValue, "_data", "")
118 function keys.cfgvalue()
119 return fs.readfile("/etc/dropbear/authorized_keys") or ""
122 function keys.write(self, section, value)
124 fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n"))