@vm0/runner 3.18.5 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +18 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1888,7 +1888,7 @@ function encode(type, seq, payload = Buffer.alloc(0)) {
|
|
|
1888
1888
|
header.writeUInt32BE(body.length, 0);
|
|
1889
1889
|
return Buffer.concat([header, body]);
|
|
1890
1890
|
}
|
|
1891
|
-
function encodeExecPayload(command, timeoutMs, env) {
|
|
1891
|
+
function encodeExecPayload(command, timeoutMs, env, sudo = false) {
|
|
1892
1892
|
const cmdBuf = Buffer.from(command, "utf-8");
|
|
1893
1893
|
const envEntries = env ? Object.entries(env) : [];
|
|
1894
1894
|
let envSize = 0;
|
|
@@ -1902,12 +1902,13 @@ function encodeExecPayload(command, timeoutMs, env) {
|
|
|
1902
1902
|
encodedEntries.push([keyBuf, valBuf]);
|
|
1903
1903
|
}
|
|
1904
1904
|
}
|
|
1905
|
-
const payload = Buffer.alloc(
|
|
1905
|
+
const payload = Buffer.alloc(9 + cmdBuf.length + envSize);
|
|
1906
1906
|
payload.writeUInt32BE(timeoutMs, 0);
|
|
1907
|
-
payload.
|
|
1908
|
-
cmdBuf.
|
|
1907
|
+
payload.writeUInt8(sudo ? FLAG_SUDO : 0, 4);
|
|
1908
|
+
payload.writeUInt32BE(cmdBuf.length, 5);
|
|
1909
|
+
cmdBuf.copy(payload, 9);
|
|
1909
1910
|
if (encodedEntries.length > 0) {
|
|
1910
|
-
let offset =
|
|
1911
|
+
let offset = 9 + cmdBuf.length;
|
|
1911
1912
|
payload.writeUInt32BE(encodedEntries.length, offset);
|
|
1912
1913
|
offset += 4;
|
|
1913
1914
|
for (const [keyBuf, valBuf] of encodedEntries) {
|
|
@@ -2118,10 +2119,10 @@ var VsockClient = class {
|
|
|
2118
2119
|
/**
|
|
2119
2120
|
* Execute a command on the remote VM
|
|
2120
2121
|
*/
|
|
2121
|
-
async exec(command, timeoutMs, env) {
|
|
2122
|
+
async exec(command, timeoutMs, env, sudo = false) {
|
|
2122
2123
|
const actualTimeout = timeoutMs ?? DEFAULT_EXEC_TIMEOUT_MS;
|
|
2123
2124
|
try {
|
|
2124
|
-
const payload = encodeExecPayload(command, actualTimeout, env);
|
|
2125
|
+
const payload = encodeExecPayload(command, actualTimeout, env, sudo);
|
|
2125
2126
|
const response = await this.request(
|
|
2126
2127
|
MSG_EXEC,
|
|
2127
2128
|
payload,
|
|
@@ -2144,6 +2145,12 @@ var VsockClient = class {
|
|
|
2144
2145
|
};
|
|
2145
2146
|
}
|
|
2146
2147
|
}
|
|
2148
|
+
/**
|
|
2149
|
+
* Execute a command as root via the sudo protocol flag.
|
|
2150
|
+
*/
|
|
2151
|
+
async execAsRoot(command, timeoutMs) {
|
|
2152
|
+
return this.exec(command, timeoutMs, void 0, true);
|
|
2153
|
+
}
|
|
2147
2154
|
/**
|
|
2148
2155
|
* Execute a command and throw on non-zero exit
|
|
2149
2156
|
*/
|
|
@@ -2352,8 +2359,8 @@ var VsockClient = class {
|
|
|
2352
2359
|
* Returns immediately with the PID. Use waitForExit() to wait for completion.
|
|
2353
2360
|
* When the process exits, the agent sends an unsolicited notification.
|
|
2354
2361
|
*/
|
|
2355
|
-
async spawnAndWatch(command, timeoutMs = 0, env) {
|
|
2356
|
-
const payload = encodeExecPayload(command, timeoutMs, env);
|
|
2362
|
+
async spawnAndWatch(command, timeoutMs = 0, env, sudo = false) {
|
|
2363
|
+
const payload = encodeExecPayload(command, timeoutMs, env, sudo);
|
|
2357
2364
|
const response = await this.request(
|
|
2358
2365
|
MSG_SPAWN_WATCH,
|
|
2359
2366
|
payload,
|
|
@@ -3120,7 +3127,7 @@ async function executeJob(context, config, options = {}) {
|
|
|
3120
3127
|
logger9.log(`Guest client ready`);
|
|
3121
3128
|
if (config.firecracker.snapshot) {
|
|
3122
3129
|
const timestamp = (Date.now() / 1e3).toFixed(3);
|
|
3123
|
-
await guest.
|
|
3130
|
+
await guest.execAsRoot(`date -s "@${timestamp}"`);
|
|
3124
3131
|
}
|
|
3125
3132
|
if (context.storageManifest) {
|
|
3126
3133
|
await withSandboxTiming(
|
|
@@ -4674,7 +4681,7 @@ var snapshotCommand = new Command5("snapshot").description("Generate a Firecrack
|
|
|
4674
4681
|
);
|
|
4675
4682
|
|
|
4676
4683
|
// src/index.ts
|
|
4677
|
-
var version = true ? "3.
|
|
4684
|
+
var version = true ? "3.19.0" : "0.1.0";
|
|
4678
4685
|
program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
|
|
4679
4686
|
program.addCommand(startCommand);
|
|
4680
4687
|
program.addCommand(doctorCommand);
|