Fixed selfupdate for Alpine
Bryan Roe committed
Jan 28, 2021 at 21:32 UTC
9bad51196bd3b1cb65c3beda39da231c4f172029
2 files changed
+46
-6
agents/meshcore.js
+25
-4
@@ -3841,16 +3841,37 @@ function closeDescriptors(libc, descriptors)
3841
}
3842
}
3843
}
3844
-function linux_execv(name, agentfilename, sessionid) {
3844
+function linux_execv(name, agentfilename, sessionid)
3845
+{
3846
var libs = require('monitor-info').getLibInfo('libc');
3847
var libc = null;
3848
3848
- while (libs.length > 0) {
3849
- try {
3849
+ if ((libs.length == 0 || libs.length == null) && require('MeshAgent').ARCHID == 33)
3850
+ {
3851
+ var child = require('child_process').execFile('/bin/sh', ['sh']);
3852
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
3853
+ child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
3854
+ child.stdin.write("ls /lib/libc.* | tr '\\n' '`' | awk -F'`' '{ " + ' printf "["; DEL=""; for(i=1;i<NF;++i) { printf "%s{\\"path\\":\\"%s\\"}",DEL,$i; DEL=""; } printf "]"; }\'\nexit\n');
3855
+ child.waitExit();
3856
+
3857
+ try
3858
+ {
3859
+ libs = JSON.parse(child.stdout.str.trim());
3860
+ }
3861
+ catch(e)
3862
+ {
3863
+ }
3864
+ }
3865
+
3866
+ while (libs.length > 0)
3867
+ {
3868
+ try
3869
+ {
3870
libc = require('_GenericMarshal').CreateNativeProxy(libs.pop().path);
3871
break;
3872
}
3853
- catch (e) {
3873
+ catch (e)
3874
+ {
3875
libc = null;
3876
continue;
3877
}
agents/recoverycore.js
+21
-2
@@ -174,11 +174,30 @@ function closeDescriptors(libc, descriptors)
174
}
175
}
176
177
-function linux_execv(name, agentfilename, sessionid) {
177
+function linux_execv(name, agentfilename, sessionid)
178
+{
179
var libs = require('monitor-info').getLibInfo('libc');
180
var libc = null;
181
181
- while (libs.length > 0) {
182
+ if ((libs.length == 0 || libs.length == null) && require('MeshAgent').ARCHID == 33)
183
+ {
184
+ var child = require('child_process').execFile('/bin/sh', ['sh']);
185
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
186
+ child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
187
+ child.stdin.write("ls /lib/libc.* | tr '\\n' '`' | awk -F'`' '{ " + ' printf "["; DEL=""; for(i=1;i<NF;++i) { printf "%s{\\"path\\":\\"%s\\"}",DEL,$i; DEL=""; } printf "]"; }\'\nexit\n');
188
+ child.waitExit();
189
+
190
+ try
191
+ {
192
+ libs = JSON.parse(child.stdout.str.trim());
193
+ }
194
+ catch(e)
195
+ {
196
+ }
197
+ }
198
+
199
+ while (libs.length > 0)
200
+ {
201
try {
202
libc = require('_GenericMarshal').CreateNativeProxy(libs.pop().path);
203
break;