1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-29 02:49:01 +00:00

Centralize AFP timestamp conversion to string

This commit is contained in:
nnposter
2020-08-10 01:48:19 +00:00
parent a0e19f54e0
commit ca58ae9562

View File

@@ -350,6 +350,8 @@ local ERROR_MSG = {
[ERROR.FPCallNotSupported] = "Server does not support this command.",
}
local TIME_OFFSET = os.time{year=2000, month=1, day=1, hour=0} - os.time{year=1970, month=1, day=1, hour=0}
-- Check if all the bits in flag are set in bitmap.
local function flag_is_set(bitmap, flag)
return (bitmap & flag) == flag
@@ -1761,10 +1763,9 @@ Helper = {
local item = response.result.file or response.result.dir
local diff = os.time{year=2000, month=1, day=1, hour=0} - os.time{year=1970, month=1, day=1, hour=0}
local create = datetime.format_timestamp(item.CreationDate + diff)
local backup = datetime.format_timestamp(item.BackupDate )
local modify = datetime.format_timestamp(item.ModificationDate + diff )
local create = Util.time_to_string(item.CreationDate)
local backup = Util.time_to_string(item.BackupDate)
local modify = Util.time_to_string(item.ModificationDate)
return true, { create = create, backup = backup, modify = modify }
end,
@@ -1892,6 +1893,15 @@ Util =
end,
--- Converts AFP file timestamp to a standard text format
--
-- @param timestamp value returned by FPEnumerateExt2 or FPGetFileDirParms
-- @return string representing the timestamp
time_to_string = function (timestamp)
return timestamp and datetime.format_timestamp(timestamp + TIME_OFFSET) or nil
end,
--- Decodes the UnixPrivileges.ua_permissions value
--
-- @param privs number containing the UnixPrivileges.ua_permissions value