diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-08-14 11:43:33 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-08-14 11:43:33 +0000 |
commit | b61b3fbde769c1bd36b478048b03e551b8cdafa3 (patch) | |
tree | 32e6b4fdbce6441eded39dd662e92c039bb5e308 | |
parent | 50844c9aa17d26a8da03abbef8f9ad6ebf6fdaa7 (diff) | |
download | acf-alpine-baselayout-b61b3fbde769c1bd36b478048b03e551b8cdafa3.tar.bz2 acf-alpine-baselayout-b61b3fbde769c1bd36b478048b03e551b8cdafa3.tar.xz |
Changed system password to use posix.crypt instead of io.popen(cryptpw)v0.5.3
-rw-r--r-- | password-model.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/password-model.lua b/password-model.lua index f66c74b..8555768 100644 --- a/password-model.lua +++ b/password-model.lua @@ -3,6 +3,7 @@ module (..., package.seeall) require ("fs") require ("format") +require ("posix") read_password = function() pw = {} @@ -26,9 +27,15 @@ update_password = function (pw) end if success then - local f = io.popen("/usr/bin/cryptpw '" .. string.gsub(pw.value.password.value, "'", "'\\''") .. "'") - local newpass = f:read("*l") - f:close() + math.randomseed(os.time()) + local randomchar = function() + local char = math.random(64)+string.byte('.') + if char > string.byte('9') then char = char + 7 end + if char > string.byte('Z') then char = char + 6 end + return string.char(char) + end + local seed = randomchar() .. randomchar() + newpass = posix.crypt(pw.value.password.value, seed) local new = string.gsub(filecontent, "(\n"..pw.value.user.value..":)[^:]*", "%1"..newpass) fs.write_file("/etc/shadow", string.sub(new, 2)) else |