summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/admin-core/luasrc/view/sysauth.htm43
-rw-r--r--modules/admin-full/luasrc/controller/admin/system.lua20
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua34
-rw-r--r--modules/admin-full/luasrc/view/admin_system/sshkeys.htm39
4 files changed, 61 insertions, 75 deletions
diff --git a/modules/admin-core/luasrc/view/sysauth.htm b/modules/admin-core/luasrc/view/sysauth.htm
index 236ec7e6a7..e48f414c56 100644
--- a/modules/admin-core/luasrc/view/sysauth.htm
+++ b/modules/admin-core/luasrc/view/sysauth.htm
@@ -14,27 +14,36 @@ $Id$
-%>
<%+header%>
<% luci.i18n.loadc("sysauth") %>
-<h1><%:sysauth_head%></h1>
-<p><%:sysauth_prompt%></p>
-<% if fuser then %>
-<div class="error"><%:sysauth_failed%></div>
-<br />
-<% end %>
+
<form method="post" action="<%=REQUEST_URI%>">
- <div class="cbi-section-node">
+ <div class="cbi-map">
+ <h1><%:sysauth_head%></h1>
+ <div class="cbi-map-descr">
+ <%:sysauth_prompt%>
+ <%- if fuser then %>
+ <div class="error"><%:sysauth_failed%></div>
+ <br />
+ <% end -%>
+ </div>
+ <fieldset class="cbi-section"><fieldset class="cbi-section-node">
<div class="cbi-value">
- <div class="cbi-value-title"><%:username%></div>
- <div class="cbi-value-field"><input class="cbi-input-user" type="text" name="username" value="<%=duser%>" /></div>
+ <label class="cbi-value-title"><%:username%></label>
+ <div class="cbi-value-field">
+ <input class="cbi-input-user" type="text" name="username" value="<%=duser%>" />
+ </div>
</div>
<div class="cbi-value">
- <div class="cbi-value-title"><%:password%></div>
- <div class="cbi-value-field"><input class="cbi-input-key" type="password" name="password" /></div>
+ <label class="cbi-value-title"><%:password%></label>
+ <div class="cbi-value-field">
+ <input class="cbi-input-key" type="password" name="password" />
+ </div>
</div>
- <br />
- <div>
- <input type="submit" class="cbi-button cbi-button-apply" value="<%:login%>" />
- <input type="reset" class="cbi-button cbi-button-reset" value="<%:reset%>" />
- </div>
- </div>
+ </fieldset></fieldset>
+ </div>
+
+ <div>
+ <input type="submit" value="<%:login%>" class="cbi-button cbi-button-apply" />
+ <input type="reset" value="<%:reset%>" class="cbi-button cbi-button-reset" />
+ </div>
</form>
<%+footer%> \ No newline at end of file
diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua
index fec6526991..cf39483cfb 100644
--- a/modules/admin-full/luasrc/controller/admin/system.lua
+++ b/modules/admin-full/luasrc/controller/admin/system.lua
@@ -21,7 +21,7 @@ function index()
entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10)
entry({"admin", "system", "packages", "ipkg"}, call("action_ipkg"), i18n("a_s_p_ipkg"))
entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 20)
- entry({"admin", "system", "sshkeys"}, call("action_sshkeys"), i18n("a_s_sshkeys"), 30)
+ entry({"admin", "system", "sshkeys"}, form("admin_system/sshkeys"), i18n("a_s_sshkeys"), 30)
entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 40)
entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
@@ -220,24 +220,6 @@ function action_reboot()
end
end
-function action_sshkeys()
- local file = "/etc/dropbear/authorized_keys"
- local data = luci.http.formvalue("data")
- local stat = nil
- local err = nil
-
- if data then
- stat, err = luci.fs.writefile(file, data)
- end
-
- local cnt = luci.fs.readfile(file)
- if cnt then
- cnt = luci.util.pcdata(cnt)
- end
-
- luci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err})
-end
-
function action_upgrade()
require("luci.model.uci")
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua b/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua
new file mode 100644
index 0000000000..a204d420fc
--- /dev/null
+++ b/modules/admin-full/luasrc/model/cbi/admin_system/sshkeys.lua
@@ -0,0 +1,34 @@
+--[[
+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("a_s_sshkeys"), translate("a_s_sshkeys1"))
+
+t = f:field(TextValue, "keys")
+t.rows = 10
+function t.cfgvalue()
+ return luci.fs.readfile(keyfile) or ""
+end
+
+function f.handle(self, state, data)
+ if state == FORM_VALID then
+ if (luci.fs.readfile(keyfile) or "") ~= data.keys then
+ luci.fs.writefile(keyfile, data.keys)
+ end
+ end
+ return true
+end
+
+return f \ No newline at end of file
diff --git a/modules/admin-full/luasrc/view/admin_system/sshkeys.htm b/modules/admin-full/luasrc/view/admin_system/sshkeys.htm
deleted file mode 100644
index 7b636090cd..0000000000
--- a/modules/admin-full/luasrc/view/admin_system/sshkeys.htm
+++ /dev/null
@@ -1,39 +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$
-
--%>
-
-<%+header%>
-
-<form method="post" action="<%=controller%>/admin/system/sshkeys">
- <div class="cbi-map">
- <h1><%:a_s_sshkeys%></h1>
- <div class="cbi-map-descr">
- <%:a_s_sshkeys1%>
- </div>
- <fieldset class="cbi-section">
- <legend><%:a_s_sshkeys%></legend>
- <textarea style="width: 100%" rows="10" name="data" wrap="off"><%=cnt%></textarea>
- <% if msg then -%>
- <div class="cbi-error"><%:error%>: <%=msg%></div>
- <% end %>
- </fieldset>
- </div>
-
- <div>
- <input type="submit" value="<%:save%>" class="cbi-button cbi-button-save" />
- <input type="reset" value="<%:reset%>" class="cbi-button cbi-button-reset" />
- </div>
-</form>
-
-<%+footer%>