gluon-luci-admin: support disabling password login again
This commit is contained in:
parent
e5999b3f44
commit
baebeee98f
@ -16,16 +16,14 @@ $Id$
|
|||||||
|
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
local m, s, pw1, pw2
|
local m = Map("system", "SSH-Keys")
|
||||||
|
|
||||||
m = Map("system", "Remotezugriff")
|
|
||||||
m.submit = "Speichern"
|
m.submit = "Speichern"
|
||||||
m.reset = "Zurücksetzen"
|
m.reset = "Zurücksetzen"
|
||||||
m.pageaction = false
|
m.pageaction = false
|
||||||
m.template = "admin/expertmode"
|
m.template = "admin/expertmode"
|
||||||
|
|
||||||
if fs.access("/etc/config/dropbear") then
|
if fs.access("/etc/config/dropbear") then
|
||||||
s = m:section(TypedSection, "_keys", nil,
|
local s = m:section(TypedSection, "_dummy1", nil,
|
||||||
"Hier hast du die Möglichkeit SSH-Keys (einen pro Zeile) zu hinterlegen:")
|
"Hier hast du die Möglichkeit SSH-Keys (einen pro Zeile) zu hinterlegen:")
|
||||||
|
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
@ -57,37 +55,52 @@ if fs.access("/etc/config/dropbear") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
s = m:section(TypedSection, "_pass", nil,
|
local m2 = Map("system", "Passwort")
|
||||||
"Alternativ kannst du auch ein Passwort setzen. Wähle bitte ein sicheres Passwort, das du nirgendswo anders verwendest.")
|
m2.submit = "Speichern"
|
||||||
|
m2.reset = false
|
||||||
|
m2.pageaction = false
|
||||||
|
m2.template = "admin/expertmode"
|
||||||
|
|
||||||
|
local s = m2:section(TypedSection, "_dummy2", nil,
|
||||||
|
[[Alternativ kannst du auch ein Passwort setzen. Wähle bitte ein sicheres Passwort, das du nirgendwo anders verwendest.<br /><br />
|
||||||
|
Beim Setzen eines leeren Passworts wird der Login per Passwort gesperrt (dies ist die Standard-Einstellung).]])
|
||||||
|
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
|
|
||||||
pw1 = s:option(Value, "pw1", "Passwort")
|
local pw1 = s:option(Value, "pw1", "Passwort")
|
||||||
pw1.password = true
|
pw1.password = true
|
||||||
|
|
||||||
pw2 = s:option(Value, "pw2", "Wiederholung")
|
local pw2 = s:option(Value, "pw2", "Wiederholung")
|
||||||
pw2.password = true
|
pw2.password = true
|
||||||
|
|
||||||
function s.cfgsections()
|
function s.cfgsections()
|
||||||
return { "_pass" }
|
return { "_pass" }
|
||||||
end
|
end
|
||||||
|
|
||||||
function m.on_commit(map)
|
function m2.on_commit(map)
|
||||||
local v1 = pw1:formvalue("_pass")
|
local v1 = pw1:formvalue("_pass")
|
||||||
local v2 = pw2:formvalue("_pass")
|
local v2 = pw2:formvalue("_pass")
|
||||||
|
|
||||||
if v1 and v2 and #v1 > 0 and #v2 > 0 then
|
if v1 and v2 then
|
||||||
if v1 == v2 then
|
if v1 == v2 then
|
||||||
|
if #v1 > 0 then
|
||||||
if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then
|
if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then
|
||||||
m.message = "Passwort geändert."
|
m2.message = "Passwort geändert."
|
||||||
else
|
else
|
||||||
m.errmessage = "Das Passwort konnte nicht geändert werden."
|
m2.errmessage = "Das Passwort konnte nicht geändert werden."
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
m.errmessage = "Die beiden Passwörter stimmen nicht überein."
|
-- We don't check the return code here as the error 'password for root is already locked' is normal...
|
||||||
|
os.execute('passwd -l root >/dev/null')
|
||||||
|
m2.message = "Passwort gelöscht."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
m2.errmessage = "Die beiden Passwörter stimmen nicht überein."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
local c = Compound(m, m2)
|
||||||
|
c.pageaction = false
|
||||||
|
return c
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
<%- if self.message then %>
|
|
||||||
<p class="message success"><%=self.message%></p>
|
|
||||||
<%- end %>
|
|
||||||
<%- if self.errmessage then %>
|
|
||||||
<p class="message error"><%=self.errmessage%></p>
|
|
||||||
<%- end %>
|
|
||||||
<% if not self.embedded then %>
|
<% if not self.embedded then %>
|
||||||
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
|
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
|
||||||
<div>
|
<div>
|
||||||
@ -13,6 +7,12 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<div class="cbi-map" id="cbi-<%=self.config%>">
|
<div class="cbi-map" id="cbi-<%=self.config%>">
|
||||||
<% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
|
<% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
|
||||||
|
<%- if self.message then %>
|
||||||
|
<p class="message success"><%=self.message%></p>
|
||||||
|
<%- end %>
|
||||||
|
<%- if self.errmessage then %>
|
||||||
|
<p class="message error"><%=self.errmessage%></p>
|
||||||
|
<%- end %>
|
||||||
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
|
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
|
||||||
<% self:render_children() %>
|
<% self:render_children() %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user