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("root", 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!")
54 m2 = Map("dropbear", translate("SSH Access"),
55 translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server"))
57 s = m2:section(TypedSection, "dropbear", translate("Dropbear Instance"))
62 ni = s:option(Value, "Interface", translate("Interface"),
63 translate("Listen only on the given interface or, if unspecified, on all"))
65 ni.template = "cbi/network_netlist"
70 pt = s:option(Value, "Port", translate("Port"),
71 translate("Specifies the listening port of this <em>Dropbear</em> instance"))
77 pa = s:option(Flag, "PasswordAuth", translate("Password authentication"),
78 translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"))
82 pa.default = pa.enabled
86 ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"),
87 translate("Allow the <em>root</em> user to login with password"))
91 ra.default = ra.enabled
94 gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"),
95 translate("Allow remote hosts to connect to local SSH forwarded ports"))
99 gp.default = gp.disabled
102 s2 = m2:section(TypedSection, "_dummy", translate("SSH-Keys"),
103 translate("Here you can paste public SSH-Keys (one per line) for SSH public-key authentication."))
106 s2.template = "cbi/tblsection"
108 function s2.cfgsections()
112 keys = s2:option(TextValue, "_data", "")
117 function keys.cfgvalue()
118 return fs.readfile("/etc/dropbear/authorized_keys") or ""
121 function keys.write(self, section, value)
123 fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n"))