From d81ce7886c20e537161083279e9bc96cf6b74290 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 28 Nov 2007 18:15:49 +0000 Subject: Still have problems showing owner of a file in cleartext (instead of uid) git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@384 ab2d0c66-481e-0410-8bed-d214d4d58bed --- shorewall-model.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'shorewall-model.lua') diff --git a/shorewall-model.lua b/shorewall-model.lua index bf42891..ce436c4 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -1,20 +1,21 @@ -- shorewall model methods module (..., package.seeall) -local function XXXfile_info ( path ) - local file = io.popen("ls -lh " .. path ) - local file_info_result = file:read("*a") or "unknown" - file:close() - local size,lastmod = string.match(file_info_result, "^%S+%s+%S+%s+%S+%s+%S+%s+(%S+)%s+(%S+%s+%S+%s+%S+)" ) - return {lastmod=lastmod,size=size, longname=path} -end local function file_info ( path ) require("posix") - filedetails = posix.stat(path) - filedetails.longname = path + modfiledetails = {} + local filedetails = posix.stat(path) + filedetails["owner"]=rawget((posix.getgroup(filedetails["uid"])),"1") + filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name") + filedetails["atimelong"]=os.date("%c", filedetails["atime"]) + filedetails["mtimelong"]=os.date("%c", filedetails["mtime"]) + filedetails["longname"]=path + return filedetails end +-- ################################################################################ +-- PUBLIC FUNCTIONS function get_status () local f,error = io.popen("/sbin/shorewall status") -- cgit v1.2.3