From 9bad51196bd3b1cb65c3beda39da231c4f172029 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Thu, 28 Jan 2021 21:32:59 -0800 Subject: [PATCH] Fixed selfupdate for Alpine --- agents/meshcore.js | 29 +++++++++++++++++++++++++---- agents/recoverycore.js | 23 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index c554f3f1..50f40117 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -3841,16 +3841,37 @@ function closeDescriptors(libc, descriptors) } } } -function linux_execv(name, agentfilename, sessionid) { +function linux_execv(name, agentfilename, sessionid) +{ var libs = require('monitor-info').getLibInfo('libc'); var libc = null; - while (libs.length > 0) { - try { + if ((libs.length == 0 || libs.length == null) && require('MeshAgent').ARCHID == 33) + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("ls /lib/libc.* | tr '\\n' '`' | awk -F'`' '{ " + ' printf "["; DEL=""; for(i=1;i 0) + { + try + { libc = require('_GenericMarshal').CreateNativeProxy(libs.pop().path); break; } - catch (e) { + catch (e) + { libc = null; continue; } diff --git a/agents/recoverycore.js b/agents/recoverycore.js index 9462fcf9..e8c2a7bd 100644 --- a/agents/recoverycore.js +++ b/agents/recoverycore.js @@ -174,11 +174,30 @@ function closeDescriptors(libc, descriptors) } } -function linux_execv(name, agentfilename, sessionid) { +function linux_execv(name, agentfilename, sessionid) +{ var libs = require('monitor-info').getLibInfo('libc'); var libc = null; - while (libs.length > 0) { + if ((libs.length == 0 || libs.length == null) && require('MeshAgent').ARCHID == 33) + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write("ls /lib/libc.* | tr '\\n' '`' | awk -F'`' '{ " + ' printf "["; DEL=""; for(i=1;i 0) + { try { libc = require('_GenericMarshal').CreateNativeProxy(libs.pop().path); break;