From 3744d4c0ac436a0ac3cc3661d29b956f50823d8a Mon Sep 17 00:00:00 2001 From: djalal Date: Sun, 31 Oct 2010 21:37:06 +0000 Subject: [PATCH] Small code cleaning. --- scripts/nfs-ls.nse | 17 +++++++++-------- scripts/nfs-statfs.nse | 17 ++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/nfs-ls.nse b/scripts/nfs-ls.nse index 9b0cf129f..0cbcc20d9 100644 --- a/scripts/nfs-ls.nse +++ b/scripts/nfs-ls.nse @@ -258,11 +258,11 @@ action = function(host, port) end if nfs_info.maxfiles > 0 then - local args, str = {}, "" + local args = {} args['name'] = 'Arguments:' - str = string.format("maxfiles: %d (file listing output limited) ", - nfs_info.maxfiles) - table.insert(args, str) + table.insert(args, + string.format("maxfiles: %d (file listing output limited)\n", + nfs_info.maxfiles)) table.insert(o, args) end @@ -272,16 +272,17 @@ action = function(host, port) end for _, v in ipairs(mounts) do - local results, access, str, err = {}, {}, "" + local results, access, err = {}, {} status, err = nfs_ls(nfs_info, v.name, results, access) if not status then + table.insert(o, string.format("NFS Export %s", v.name)) table.insert(o, string.format("ERROR: %s", err)) else - str = "\n NFS Export: " .. results[1].filename + table.insert(o, + string.format("NFS Export: %s", results[1].filename)) if #access ~= 0 then - str = str .. "\n NFS Access: " .. access[1] + table.insert(o, string.format("NFS Access: %s", access[1])) end - table.insert(o, str) table.insert(o, report(nfs_info, results)) end end diff --git a/scripts/nfs-statfs.nse b/scripts/nfs-statfs.nse index cc57835d0..86e617928 100644 --- a/scripts/nfs-statfs.nse +++ b/scripts/nfs-statfs.nse @@ -90,7 +90,7 @@ local function report(nfs, tables) tab_avail, tab_use, tab_bs) for _, t in ipairs(tables) do tab.nextrow(outtab) - tab.addrow(outtab, (" %s"):format(t.filesystem), t.size, + tab.addrow(outtab, " "..t.filesystem, t.size, t.used, t.available, t.use, t.bsize) end elseif nfs.version == 3 then @@ -100,9 +100,8 @@ local function report(nfs, tables) tab_avail, tab_use, tab_maxfs, tab_linkmax) for _, t in ipairs(tables) do tab.nextrow(outtab) - tab.addrow(outtab, (" %s"):format(t.filesystem), t.size, - t.used, t.available, t.use, t.maxfilesize, - t.linkmax) + tab.addrow(outtab, " "..t.filesystem, t.size, t.used, + t.available, t.use, t.maxfilesize, t.linkmax) end end @@ -183,7 +182,7 @@ local function nfs_filesystem_info(nfs, mount, filesystem) end action = function(host, port) - local o, fs_info, mounts, status = {}, {}, {}, {} + local fs_info, mounts, status = {}, {}, {} local nfs_info = { host = host, @@ -200,10 +199,10 @@ action = function(host, port) local err status, err = nfs_filesystem_info(nfs_info, v.name, fs_info) if (not(status)) then - return stdnse.format_output(false, err) + return stdnse.format_output(false, + string.format("%s: %s", v.name, err)) end end - table.insert(o, report(nfs_info, fs_info)) - - return stdnse.format_output(true, o) + + return stdnse.format_output(true, report(nfs_info, fs_info)) end