summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--interfaces-controller.lua6
-rw-r--r--password-controller.lua2
-rw-r--r--password-model.lua19
3 files changed, 23 insertions, 4 deletions
diff --git a/interfaces-controller.lua b/interfaces-controller.lua
index be07e02..ad4ba05 100644
--- a/interfaces-controller.lua
+++ b/interfaces-controller.lua
@@ -21,19 +21,19 @@ mvc.on_load = function(self, parent)
pvt.parent_on_exec = parent.worker.mvc.post_exec
- logit ("interfaces controller on_load has finished")
+ --logit ("interfaces controller on_load has finished")
end
mvc.pre_exec = function (self)
- logit ("interfaces-controller pre_exec activated")
+ --logit ("interfaces-controller pre_exec activated")
-- pvt.parent_on_exec ()
end
mvc.post_exec = function ( self )
- logit ("interfaces-controller post_exec activated")
+ --logit ("interfaces-controller post_exec activated")
return pvt.parent_on_exec()
end
diff --git a/password-controller.lua b/password-controller.lua
index bc5389e..727cf77 100644
--- a/password-controller.lua
+++ b/password-controller.lua
@@ -30,5 +30,5 @@ end
update = function (self)
- return ( {password = self.model:set(cfe({value=self.clientdata.password}))})
+ return ( {report = self.model:set() })
end
diff --git a/password-model.lua b/password-model.lua
index 33dffbd..90fa50d 100644
--- a/password-model.lua
+++ b/password-model.lua
@@ -1,6 +1,7 @@
-- password model methods
module (..., package.seeall)
strsplit = require "split"
+require "fs"
-- no initializer in model - use controller.init for that
@@ -17,3 +18,21 @@ get = function (self)
return (cfe{value=status, name="password"})
end
+--setup so that it will compare password input
+set = function (self, cmd1, cmd2)
+ if cmd1 ~= cmd2 then report = "Invalid or non matching password. Try again"
+ else
+ command = "/usr/bin/cryptpw" .. " " .. cmd1
+ f = io.popen(command)
+ c = f:read("*l")
+ f:close()
+ --this is hardcoded for root should be easy to change
+ newpass = "root:" .. c
+ t = fs.search_replace("/etc/shadow", "root:[!%w%$%/%.]+", newpass)
+ fs.write_file("/etc/shadow", fs.ipairs_string(t))
+ report = "Success. New password set."
+ end
+ return( cfe{value=report, name="report"})
+end
+
+