blob: 376c0e20f0619ba91b289cbc0e43d4240ebe8b95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-- 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
|