1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-10 13:23:41 +00:00

Changed order of operation for getLibInfo()

This commit is contained in:
Bryan Roe
2021-01-28 23:30:50 -08:00
parent a848bc6da8
commit 50bb5730c3
2 changed files with 18 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@@ -42,24 +42,7 @@ function getLibInfo(libname)
child.stdin.write("whereis ldconfig | awk '{ print $2 }'\nexit\n");
child.waitExit();
if (child.stdout.str.trim() == '')
{
// No ldconfig
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.on('data', function () { });
child.stdin.write('ls /lib/' + libname + '.*' + " | tr '\\n' '`' | awk -F'`' '{" + ' DEL=""; printf "["; for(i=1;i<NF;++i) { if($1~/((.so)(.[0-9]+)*)$/) { printf "%s{\\"path\\": \\"%s\\"}",DEL,$i; DEL=","; } } printf "]"; }\'\nexit\n');
child.waitExit();
try
{
return(JSON.parse(child.stdout.str.trim()));
}
catch(e)
{
return ([]);
}
}
else
if (child.stdout.str.trim() != '')
{
var ldconfig = child.stdout.str.trim();
child = require('child_process').execFile('/bin/sh', ['sh']);
@@ -71,13 +54,27 @@ function getLibInfo(libname)
try
{
var v = JSON.parse(child.stdout.str.trim());
return (v);
if (v.length != 0) { return (v); }
}
catch (e)
{
return ([]);
}
}
// No ldconfig, or no result returned;
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.on('data', function () { });
child.stdin.write('ls /lib/' + libname + '.*' + " | tr '\\n' '`' | awk -F'`' '{" + ' DEL=""; printf "["; for(i=1;i<NF;++i) { if($1~/((.so)(.[0-9]+)*)$/) { printf "%s{\\"path\\": \\"%s\\"}",DEL,$i; DEL=","; } } printf "]"; }\'\nexit\n');
child.waitExit();
try
{
return (JSON.parse(child.stdout.str.trim()));
}
catch (e)
{
return ([]);
}
}
function monitorinfo()