-- password model methods module (..., package.seeall) require "format" -- no initializer in model - use controller.init for that --setup so that it will compare password input set = function (self, userid, 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