From c4db4cc4492f6becef2e41ce849975dcf8cbdec0 Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Fri, 23 Nov 2007 16:09:10 +0000 Subject: password model and controller updated git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@361 ab2d0c66-481e-0410-8bed-d214d4d58bed --- password-model.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'password-model.lua') 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 + + -- cgit v1.2.3