diff --git a/files/usr/share/commotion/patches/admin.oldpasswd.patch b/files/usr/share/commotion/patches/admin.oldpasswd.patch index ea8867d..5a32284 100644 --- a/files/usr/share/commotion/patches/admin.oldpasswd.patch +++ b/files/usr/share/commotion/patches/admin.oldpasswd.patch @@ -1,13 +1,13 @@ diff --git a/admin.lua b/admin.lua -index 61f0141..0d0827f 100644 +index 61f0141..28f4b78 100644 --- a/admin.lua +++ b/admin.lua -@@ -15,13 +15,33 @@ $Id: admin.lua 8153 2012-01-06 16:42:02Z jow $ +@@ -14,14 +14,35 @@ $Id: admin.lua 8153 2012-01-06 16:42:02Z jow $ + ]]-- local fs = require "nixio.fs" - --m = Map("system", translate("Router Password"), -- translate("Changes the administrator password for accessing the device")) ++local formvalue = require "luci.http".formvalue ++ +m = Map("system", translate("System Access"), + translate("System functions related to system access")) +local v0 = true -- track password success across maps @@ -30,9 +30,11 @@ index 61f0141..0d0827f 100644 + end +end --s = m:section(TypedSection, "_dummy", "") +-m = Map("system", translate("Router Password"), +s = m:section(TypedSection, "_dummy", translate("Router Password"), -+ translate("Changes the administrator password for accessing the device")) + translate("Changes the administrator password for accessing the device")) +- +-s = m:section(TypedSection, "_dummy", "") s.addremove = false s.anonymous = true - @@ -40,26 +42,20 @@ index 61f0141..0d0827f 100644 pw1 = s:option(Value, "pw1", translate("Password")) pw1.password = true -@@ -32,24 +52,36 @@ function s.cfgsections() +@@ -32,23 +53,38 @@ function s.cfgsections() return { "_pass" } end -+function m.on_before_commit(map) -+ -- if existing password, make sure user has old password -+ if s0 then -+ v0 = luci.sys.user.checkpasswd("root", pw0:formvalue("_pass0")) -+ end -+ -+ if v0 == false then -+ m.message = translate("Incorrect password. Changes rejected!") -+ m.save=v0 -+ m2.save=v0 -+ end -+end -+ - function m.on_commit(map) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") +-function m.on_commit(map) +- local v1 = pw1:formvalue("_pass") +- local v2 = pw2:formvalue("_pass") ++function m.on_save(map) ++ -- Distinguish between page load and form submission ++ if next(formvalue()) then ++ -- if existing password, make sure user has old password ++ if s0 then ++ v0 = luci.sys.user.checkpasswd("root", pw0:formvalue("_pass0")) ++ end - if v1 and v2 and #v1 > 0 and #v2 > 0 then - if v1 == v2 then @@ -70,8 +66,18 @@ index 61f0141..0d0827f 100644 - end - else - m.message = translate("Given password confirmation did not match, password not changed!") -- end -- end ++ if v0 == false then ++ m.message = translate("Incorrect password. Changes rejected!") ++ m.save=v0 ++ m2.save=v0 + end + end + end + ++function m.on_commit(map) ++ local v1 = pw1:formvalue("_pass") ++ local v2 = pw2:formvalue("_pass") ++ + if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then + if v1 == v2 then + if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then @@ -83,9 +89,16 @@ index 61f0141..0d0827f 100644 + m.message = translate("Given password confirmation did not match, password not changed!") + end + end - end ++end -- if fs.access("/etc/config/dropbear") then - m2 = Map("dropbear", translate("SSH Access"), +@@ -120,7 +156,7 @@ function keys.cfgvalue() + end + + function keys.write(self, section, value) +- if value then ++ if value and m2.save == true then + fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) + end + end