@ai-ecoverse/slicc-kernel 1.192.0 → 1.193.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/README.md +17 -7
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +136 -14
- package/dist/cloudflare.js.map +3 -3
- package/dist/kernel-worker.js +136 -14
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.cjs +3 -2
- package/dist/node-process-worker.cjs.map +2 -2
- package/dist/node-process-worker.js +3 -2
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +136 -14
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +3 -2
- package/dist/process-worker.js.map +2 -2
- package/dist/types/sudo.d.ts +1 -0
- package/dist/types/sudoers.d.ts +7 -0
- package/package.json +2 -2
package/dist/cloudflare.js
CHANGED
|
@@ -4889,7 +4889,7 @@ function satisfies(version, range2) {
|
|
|
4889
4889
|
}
|
|
4890
4890
|
|
|
4891
4891
|
// src/version.ts
|
|
4892
|
-
var KERNEL_VERSION = true ? "1.
|
|
4892
|
+
var KERNEL_VERSION = true ? "1.193.0" : "0.0.0-dev";
|
|
4893
4893
|
var OS_RELEASE = "6.0.0-slicc";
|
|
4894
4894
|
function procVersion() {
|
|
4895
4895
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -18094,10 +18094,12 @@ function kernelLine(m, line, file) {
|
|
|
18094
18094
|
};
|
|
18095
18095
|
}
|
|
18096
18096
|
var DEFAULTS = /^Defaults(?=[:@>!\s]|$)/;
|
|
18097
|
-
var DEFAULTS_ONLY = `Defaults aren't supported, except timestamp_timeout and
|
|
18097
|
+
var DEFAULTS_ONLY = `Defaults aren't supported, except timestamp_timeout, timestamp_type and env_keep for everyone, a user or a %group: this line changes nothing`;
|
|
18098
|
+
var DEFAULTS_EXPECTED = 'expected timestamp_timeout=<minutes>, timestamp_type=<type> or env_keep+="<names>" after Defaults';
|
|
18098
18099
|
var PARAM = /^(!*)([A-Za-z_]+)(?:\s*([-+]?=)\s*(.*))?$/s;
|
|
18099
18100
|
var MINUTES = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
18100
18101
|
var TYPES = ["tty", "ppid", "global"];
|
|
18102
|
+
var KEEP_OPS = ["=", "+=", "-="];
|
|
18101
18103
|
function defaultsValue(raw2) {
|
|
18102
18104
|
const quoted = /^"(.*)"$/s.exec(raw2);
|
|
18103
18105
|
return quoted ? quoted[1] : raw2;
|
|
@@ -18116,10 +18118,33 @@ function typeParam({ text, negated, op, value: value2 }) {
|
|
|
18116
18118
|
if (value2 === "kernel") return "timestamp_type=kernel isn't supported: use tty, ppid or global";
|
|
18117
18119
|
return `timestamp_type takes =tty, =ppid or =global, not ${shown(text)}`;
|
|
18118
18120
|
}
|
|
18121
|
+
function keepValue(names2) {
|
|
18122
|
+
const text = names2.join(" ");
|
|
18123
|
+
return names2.length === 1 ? text : `"${text}"`;
|
|
18124
|
+
}
|
|
18125
|
+
function keepParam(param, bangs, op, raw2) {
|
|
18126
|
+
if (bangs === "!" && op === void 0) {
|
|
18127
|
+
return { settings: {}, keep: { op: "!", names: [] }, text: "!env_keep" };
|
|
18128
|
+
}
|
|
18129
|
+
const quoted = /^"(.*)"$/s.exec(raw2);
|
|
18130
|
+
const value2 = (quoted ? quoted[1] : raw2).trim();
|
|
18131
|
+
const names2 = value2 === "" ? [] : value2.split(/[ \t]+/);
|
|
18132
|
+
const named = names2.every((name2) => !/["\\]/.test(name2) && !hasControl(name2));
|
|
18133
|
+
const listed = quoted ? named : named && names2.length === 1;
|
|
18134
|
+
if (bangs !== "" || op === void 0 || !KEEP_OPS.includes(op) || !listed) {
|
|
18135
|
+
return `env_keep takes a double-quoted, space-separated list of names, or one name without quotes, after =, += or -= (!env_keep empties the list), not ${shown(param)}`;
|
|
18136
|
+
}
|
|
18137
|
+
return {
|
|
18138
|
+
settings: {},
|
|
18139
|
+
keep: { op, names: names2 },
|
|
18140
|
+
text: `env_keep${op}${keepValue(names2)}`
|
|
18141
|
+
};
|
|
18142
|
+
}
|
|
18119
18143
|
function defaultsParam(param) {
|
|
18120
18144
|
const m = PARAM.exec(param);
|
|
18121
18145
|
if (!m) return DEFAULTS_ONLY;
|
|
18122
18146
|
const [, bangs = "", name2, op, raw2 = ""] = m;
|
|
18147
|
+
if (name2 === "env_keep") return keepParam(param, bangs, op, raw2.trim());
|
|
18123
18148
|
const read = { text: param, negated: bangs !== "", op, value: defaultsValue(raw2.trim()) };
|
|
18124
18149
|
const settings = name2 === "timestamp_timeout" ? timeoutParam(read) : name2 === "timestamp_type" ? typeParam(read) : DEFAULTS_ONLY;
|
|
18125
18150
|
if (typeof settings === "string") return settings;
|
|
@@ -18136,24 +18161,98 @@ function defaultsWho(binding) {
|
|
|
18136
18161
|
}
|
|
18137
18162
|
return who;
|
|
18138
18163
|
}
|
|
18164
|
+
function splitParams(list) {
|
|
18165
|
+
const params = [];
|
|
18166
|
+
let from = 0;
|
|
18167
|
+
let quoted = false;
|
|
18168
|
+
for (let i = 0; i < list.length; i++) {
|
|
18169
|
+
if (list[i] === '"') quoted = !quoted;
|
|
18170
|
+
else if (list[i] === "," && !quoted) {
|
|
18171
|
+
params.push(list.slice(from, i));
|
|
18172
|
+
from = i + 1;
|
|
18173
|
+
}
|
|
18174
|
+
}
|
|
18175
|
+
params.push(list.slice(from));
|
|
18176
|
+
return params;
|
|
18177
|
+
}
|
|
18139
18178
|
function defaultsLine(text) {
|
|
18140
18179
|
const m = /^Defaults(\S*)(?:\s+(.*))?$/s.exec(text);
|
|
18141
18180
|
const who = defaultsWho(m?.[1] ?? "");
|
|
18142
18181
|
if (typeof who === "string") return { error: who };
|
|
18143
18182
|
const list = (m?.[2] ?? "").trim();
|
|
18144
|
-
if (list === "")
|
|
18145
|
-
return {
|
|
18146
|
-
error: "expected timestamp_timeout=<minutes> or timestamp_type=<type> after Defaults"
|
|
18147
|
-
};
|
|
18183
|
+
if (list === "") return { error: DEFAULTS_EXPECTED };
|
|
18148
18184
|
const settings = {};
|
|
18185
|
+
const keep2 = [];
|
|
18149
18186
|
const params = [];
|
|
18150
|
-
for (const param of list
|
|
18187
|
+
for (const param of splitParams(list)) {
|
|
18151
18188
|
const read = defaultsParam(param.trim());
|
|
18152
18189
|
if (typeof read === "string") return { error: read };
|
|
18153
18190
|
Object.assign(settings, read.settings);
|
|
18191
|
+
if (read.keep) keep2.push(read.keep);
|
|
18154
18192
|
params.push(read.text);
|
|
18155
18193
|
}
|
|
18156
|
-
return { defaults: { who, settings, params } };
|
|
18194
|
+
return { defaults: { who, settings, ...keep2.length > 0 ? { keep: keep2 } : {}, params } };
|
|
18195
|
+
}
|
|
18196
|
+
function keepList(entries) {
|
|
18197
|
+
let list = [];
|
|
18198
|
+
for (const { op, names: names2 } of entries.flatMap((e) => e.keep ?? [])) {
|
|
18199
|
+
if (op === "=" || op === "!") list = [];
|
|
18200
|
+
for (const name2 of names2) {
|
|
18201
|
+
const at = list.indexOf(name2);
|
|
18202
|
+
if (op !== "-=" && at < 0) list.push(name2);
|
|
18203
|
+
else if (op === "-=" && at >= 0) list.splice(at, 1);
|
|
18204
|
+
}
|
|
18205
|
+
}
|
|
18206
|
+
return list;
|
|
18207
|
+
}
|
|
18208
|
+
function seek(entry, from, ch, stop) {
|
|
18209
|
+
let at = from;
|
|
18210
|
+
while (at !== stop && at < entry.length && entry[at] !== ch) at++;
|
|
18211
|
+
return at;
|
|
18212
|
+
}
|
|
18213
|
+
function wildEnd(pattern, entry, star, sep) {
|
|
18214
|
+
let len = star;
|
|
18215
|
+
let sawSep = false;
|
|
18216
|
+
for (let at = star; at < pattern.length; at++, len++) {
|
|
18217
|
+
if (pattern[at] === "*") {
|
|
18218
|
+
while (pattern[at] === "*") at++;
|
|
18219
|
+
if (at === pattern.length) return len;
|
|
18220
|
+
sawSep ||= pattern[at] === "=";
|
|
18221
|
+
len = seek(entry, len, pattern[at], sawSep ? -1 : sep);
|
|
18222
|
+
}
|
|
18223
|
+
if (entry[len] !== pattern[at]) return void 0;
|
|
18224
|
+
}
|
|
18225
|
+
return len === sep || len === entry.length ? len : void 0;
|
|
18226
|
+
}
|
|
18227
|
+
function envPatternMatch(pattern, entry) {
|
|
18228
|
+
const eq = entry.indexOf("=");
|
|
18229
|
+
const sep = eq < 0 ? entry.length : eq;
|
|
18230
|
+
const star = pattern.indexOf("*");
|
|
18231
|
+
const prefix = star < 0 ? pattern.length : star;
|
|
18232
|
+
if (!entry.startsWith(pattern.slice(0, prefix))) return void 0;
|
|
18233
|
+
const whole = prefix === sep || prefix === entry.length ? prefix : void 0;
|
|
18234
|
+
const len = star < 0 ? whole : wildEnd(pattern, entry, star, sep);
|
|
18235
|
+
return len === void 0 ? void 0 : len > sep + 1;
|
|
18236
|
+
}
|
|
18237
|
+
function keptEnv(env, keep2) {
|
|
18238
|
+
const kept = {};
|
|
18239
|
+
const patterns = [...keep2].reverse();
|
|
18240
|
+
for (const [name2, value2] of Object.entries(env)) {
|
|
18241
|
+
const entries = name2 === "LOGNAME" || name2 === "USER" ? ["LOGNAME", "USER"] : [`${name2}=${value2}`];
|
|
18242
|
+
let full;
|
|
18243
|
+
for (const pattern of patterns) {
|
|
18244
|
+
for (const entry of entries) full ??= envPatternMatch(pattern, entry);
|
|
18245
|
+
if (full !== void 0) break;
|
|
18246
|
+
}
|
|
18247
|
+
if (full === void 0 || !full && value2.startsWith("() ")) continue;
|
|
18248
|
+
kept[name2] = value2;
|
|
18249
|
+
}
|
|
18250
|
+
const user = kept.LOGNAME ?? kept.USER;
|
|
18251
|
+
if (user !== void 0) {
|
|
18252
|
+
kept.LOGNAME ??= user;
|
|
18253
|
+
kept.USER ??= user;
|
|
18254
|
+
}
|
|
18255
|
+
return kept;
|
|
18157
18256
|
}
|
|
18158
18257
|
function resolveDefaults(entries, applies) {
|
|
18159
18258
|
const everyone = entries.filter((e) => e.who === null);
|
|
@@ -18163,13 +18262,15 @@ function resolveDefaults(entries, applies) {
|
|
|
18163
18262
|
return {
|
|
18164
18263
|
timestampTimeout: settings.timestampTimeout ?? TIMESTAMP_TIMEOUT,
|
|
18165
18264
|
timestampType: settings.timestampType ?? TIMESTAMP_TYPE,
|
|
18265
|
+
envKeep: keepList(matching),
|
|
18166
18266
|
matching
|
|
18167
18267
|
};
|
|
18168
18268
|
}
|
|
18169
18269
|
function defaultsText(entries) {
|
|
18170
18270
|
const all = resolveDefaults(entries, () => false);
|
|
18271
|
+
const keep2 = all.envKeep.length === 0 ? "" : `, env_keep="${all.envKeep.join(" ")}"`;
|
|
18171
18272
|
return [
|
|
18172
|
-
`Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}`,
|
|
18273
|
+
`Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}${keep2}`,
|
|
18173
18274
|
...entries.filter((e) => e.who !== null).map((e) => `Defaults:${e.who.join(",")} ${e.params.join(", ")}`)
|
|
18174
18275
|
];
|
|
18175
18276
|
}
|
|
@@ -19078,7 +19179,17 @@ var Sudo = class {
|
|
|
19078
19179
|
const rules = root ? [] : policy.rules;
|
|
19079
19180
|
const mine = rules.filter((rule) => applies(rule.who));
|
|
19080
19181
|
if (parsed3.list) return await this.listed(self, root, mine, settings.matching);
|
|
19081
|
-
const
|
|
19182
|
+
const kept = keptEnv(call.env ?? {}, settings.envKeep);
|
|
19183
|
+
const session = {
|
|
19184
|
+
caller,
|
|
19185
|
+
self,
|
|
19186
|
+
target,
|
|
19187
|
+
owner,
|
|
19188
|
+
policy: policyOf(settings),
|
|
19189
|
+
kept,
|
|
19190
|
+
parsed: parsed3,
|
|
19191
|
+
signal
|
|
19192
|
+
};
|
|
19082
19193
|
if (parsed3.validate) return this.validate(session, root, mine, call.cwd);
|
|
19083
19194
|
return this.command(session, root, mine, call);
|
|
19084
19195
|
}
|
|
@@ -19122,7 +19233,7 @@ var Sudo = class {
|
|
|
19122
19233
|
const now = await this.rootOnly(r.cwd, args);
|
|
19123
19234
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
19124
19235
|
if (flipped !== void 0) return failed2("EPERM", `sudo: ${flipped} is no longer root-only`);
|
|
19125
|
-
const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3);
|
|
19236
|
+
const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3, {});
|
|
19126
19237
|
(this.o.warn ?? console.warn)(
|
|
19127
19238
|
`sudo: ${self.name} : TTY=unknown ; PWD=${quoteWord(r.cwd)} ; USER=${target.name} ; REPLAY=${r.id} ; COMMAND=${argv.map(quoteWord).join(" ")}`
|
|
19128
19239
|
);
|
|
@@ -19155,7 +19266,7 @@ var Sudo = class {
|
|
|
19155
19266
|
const matching = mine.filter(
|
|
19156
19267
|
(rule) => (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && stdinMatches(rule, caller.stdin) && commandMatches(rule.cmnd, argv) && pinned(rule, bound3)
|
|
19157
19268
|
);
|
|
19158
|
-
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3);
|
|
19269
|
+
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept);
|
|
19159
19270
|
if (root || matching.some((rule) => rule.nopasswd)) return grant();
|
|
19160
19271
|
const quoted = argv.map(quoteWord).join(" ");
|
|
19161
19272
|
if (matching.length === 0) {
|
|
@@ -19328,11 +19439,13 @@ ${line}`;
|
|
|
19328
19439
|
return false;
|
|
19329
19440
|
}
|
|
19330
19441
|
}
|
|
19331
|
-
grant(self, target, cred, argv, file, cwd, term, files) {
|
|
19442
|
+
grant(self, target, cred, argv, file, cwd, term, files, kept) {
|
|
19443
|
+
const { TERM: _term, [TICKET_ENV]: _ticket, ...caller } = kept;
|
|
19332
19444
|
const env = {
|
|
19333
19445
|
...this.o.env(),
|
|
19334
19446
|
...userEnv(target, this.o.pnpmHome),
|
|
19335
19447
|
SHELL: target.shell,
|
|
19448
|
+
...caller,
|
|
19336
19449
|
PATH: SECURE_PATH,
|
|
19337
19450
|
PWD: cwd,
|
|
19338
19451
|
...term !== void 0 && TERM.test(term) ? { TERM: term } : {},
|
|
@@ -26483,6 +26596,14 @@ function words2(value2) {
|
|
|
26483
26596
|
}
|
|
26484
26597
|
return [...value2];
|
|
26485
26598
|
}
|
|
26599
|
+
function variables(value2) {
|
|
26600
|
+
if (typeof value2 !== "object" || value2 === null) return {};
|
|
26601
|
+
return Object.fromEntries(
|
|
26602
|
+
Object.entries(value2).filter(
|
|
26603
|
+
([name2, v]) => typeof v === "string" && /^[^=\0]+$/.test(name2) && !v.includes("\0")
|
|
26604
|
+
)
|
|
26605
|
+
);
|
|
26606
|
+
}
|
|
26486
26607
|
var ESCAPES = { " ": "\\t", "\n": "\\n", "\r": "\\r" };
|
|
26487
26608
|
function clipboardLine(text) {
|
|
26488
26609
|
let out = "";
|
|
@@ -28005,7 +28126,8 @@ var WasmProcess = class {
|
|
|
28005
28126
|
op: "proc-sudo",
|
|
28006
28127
|
args: words2(req.args),
|
|
28007
28128
|
cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
|
|
28008
|
-
...typeof req.term === "string" ? { term: req.term } : {}
|
|
28129
|
+
...typeof req.term === "string" ? { term: req.term } : {},
|
|
28130
|
+
env: variables(req.env)
|
|
28009
28131
|
};
|
|
28010
28132
|
const answer2 = await sudo(
|
|
28011
28133
|
call,
|