@ai-ecoverse/slicc-kernel 1.173.0 → 1.173.1
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 +2 -2
- package/dist/kernel-worker.js +122 -8
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +122 -8
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/sudo.d.ts +6 -1
- package/package.json +1 -1
|
@@ -7513,7 +7513,7 @@ var init_version = __esm({
|
|
|
7513
7513
|
"src/version.ts"() {
|
|
7514
7514
|
"use strict";
|
|
7515
7515
|
init_captured_globals();
|
|
7516
|
-
KERNEL_VERSION = true ? "1.173.
|
|
7516
|
+
KERNEL_VERSION = true ? "1.173.1" : "0.0.0-dev";
|
|
7517
7517
|
OS_RELEASE = "6.0.0-slicc";
|
|
7518
7518
|
}
|
|
7519
7519
|
});
|
|
@@ -7512,7 +7512,7 @@ var init_version = __esm({
|
|
|
7512
7512
|
"src/version.ts"() {
|
|
7513
7513
|
"use strict";
|
|
7514
7514
|
init_captured_globals();
|
|
7515
|
-
KERNEL_VERSION = true ? "1.173.
|
|
7515
|
+
KERNEL_VERSION = true ? "1.173.1" : "0.0.0-dev";
|
|
7516
7516
|
OS_RELEASE = "6.0.0-slicc";
|
|
7517
7517
|
}
|
|
7518
7518
|
});
|
package/dist/node.js
CHANGED
|
@@ -3702,7 +3702,7 @@ function satisfies(version, range2) {
|
|
|
3702
3702
|
}
|
|
3703
3703
|
|
|
3704
3704
|
// src/version.ts
|
|
3705
|
-
var KERNEL_VERSION = true ? "1.173.
|
|
3705
|
+
var KERNEL_VERSION = true ? "1.173.1" : "0.0.0-dev";
|
|
3706
3706
|
var OS_RELEASE = "6.0.0-slicc";
|
|
3707
3707
|
function procVersion() {
|
|
3708
3708
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -30677,6 +30677,104 @@ function splitWords(text) {
|
|
|
30677
30677
|
function quoteWord(word) {
|
|
30678
30678
|
return PLAIN3.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
|
|
30679
30679
|
}
|
|
30680
|
+
function addPart(word, part) {
|
|
30681
|
+
const last = word.length - 1;
|
|
30682
|
+
if (part === null) {
|
|
30683
|
+
if (word[last] !== null) word.push(null);
|
|
30684
|
+
} else if (typeof word[last] === "string") word[last] += part;
|
|
30685
|
+
else word.push(part);
|
|
30686
|
+
}
|
|
30687
|
+
function addPlain(word, plain3) {
|
|
30688
|
+
for (const [i, part] of plain3.split("*").entries()) {
|
|
30689
|
+
if (i > 0) addPart(word, null);
|
|
30690
|
+
if (part !== "") addPart(word, part);
|
|
30691
|
+
}
|
|
30692
|
+
}
|
|
30693
|
+
function splitPatterns(text) {
|
|
30694
|
+
const piece = /'([^']*)'|"((?:[^"\\]|\\[\s\S])*)"|\\([\s\S])|([^\s'"\\]+)|(\s+)/y;
|
|
30695
|
+
const words2 = [];
|
|
30696
|
+
let word;
|
|
30697
|
+
while (piece.lastIndex < text.length) {
|
|
30698
|
+
const m = piece.exec(text);
|
|
30699
|
+
if (!m) return void 0;
|
|
30700
|
+
const [, single, double, escaped, plain3, space] = m;
|
|
30701
|
+
if (space !== void 0) {
|
|
30702
|
+
if (word !== void 0) words2.push(word);
|
|
30703
|
+
word = void 0;
|
|
30704
|
+
continue;
|
|
30705
|
+
}
|
|
30706
|
+
word ??= [];
|
|
30707
|
+
if (plain3 !== void 0) addPlain(word, plain3);
|
|
30708
|
+
else addPart(word, single ?? (double !== void 0 ? unescaped(double) : escaped));
|
|
30709
|
+
}
|
|
30710
|
+
if (word !== void 0) words2.push(word);
|
|
30711
|
+
return words2;
|
|
30712
|
+
}
|
|
30713
|
+
var literal2 = (pattern) => pattern.map((p) => p ?? "*").join("");
|
|
30714
|
+
var isAny = (pattern) => pattern?.length === 1 && pattern[0] === null;
|
|
30715
|
+
function literalWord(word) {
|
|
30716
|
+
if (!word.includes("*")) return quoteWord(word);
|
|
30717
|
+
const bare = word.replaceAll("*", "");
|
|
30718
|
+
return bare === "" || PLAIN3.test(bare) ? word.replaceAll("*", "\\*") : quoteWord(word);
|
|
30719
|
+
}
|
|
30720
|
+
function patternWord(pattern) {
|
|
30721
|
+
if (pattern.length === 1 && typeof pattern[0] === "string") return literalWord(pattern[0]);
|
|
30722
|
+
return pattern.map((p) => p === null ? "*" : literalWord(p)).join("");
|
|
30723
|
+
}
|
|
30724
|
+
function globMatch(items, subjects, star, one) {
|
|
30725
|
+
let i = 0;
|
|
30726
|
+
let j = 0;
|
|
30727
|
+
let back = -1;
|
|
30728
|
+
let from = 0;
|
|
30729
|
+
while (j < subjects) {
|
|
30730
|
+
if (i < items && star(i)) {
|
|
30731
|
+
back = i++;
|
|
30732
|
+
from = j;
|
|
30733
|
+
} else if (i < items && one(i, j)) {
|
|
30734
|
+
i++;
|
|
30735
|
+
j++;
|
|
30736
|
+
} else if (back >= 0) {
|
|
30737
|
+
i = back + 1;
|
|
30738
|
+
j = ++from;
|
|
30739
|
+
} else return false;
|
|
30740
|
+
}
|
|
30741
|
+
while (i < items && star(i)) i++;
|
|
30742
|
+
return i === items;
|
|
30743
|
+
}
|
|
30744
|
+
function wordMatch(pattern, arg) {
|
|
30745
|
+
if (pattern.every((p) => p !== null)) return literal2(pattern) === arg;
|
|
30746
|
+
const chars = pattern.flatMap((p) => p === null ? [null] : [...p]);
|
|
30747
|
+
const subject = [...arg];
|
|
30748
|
+
return globMatch(
|
|
30749
|
+
chars.length,
|
|
30750
|
+
subject.length,
|
|
30751
|
+
(i) => chars[i] === null,
|
|
30752
|
+
(i, j) => chars[i] === subject[j]
|
|
30753
|
+
);
|
|
30754
|
+
}
|
|
30755
|
+
function commandMatches(cmnd, argv) {
|
|
30756
|
+
if (cmnd === "*") return true;
|
|
30757
|
+
const [path, ...args] = argv;
|
|
30758
|
+
if (path !== cmnd.path) return false;
|
|
30759
|
+
const want = cmnd.args;
|
|
30760
|
+
if (want === void 0) return true;
|
|
30761
|
+
return globMatch(
|
|
30762
|
+
want.length,
|
|
30763
|
+
args.length,
|
|
30764
|
+
(i) => isAny(want[i]),
|
|
30765
|
+
(i, j) => wordMatch(want[i], args[j])
|
|
30766
|
+
);
|
|
30767
|
+
}
|
|
30768
|
+
function commandText(cmnd) {
|
|
30769
|
+
const path = quoteWord(cmnd.path);
|
|
30770
|
+
if (cmnd.args === void 0) return path;
|
|
30771
|
+
if (cmnd.args.length === 0) return `${path} ""`;
|
|
30772
|
+
return [path, ...cmnd.args.map(patternWord)].join(" ");
|
|
30773
|
+
}
|
|
30774
|
+
function recordedCommand(argv) {
|
|
30775
|
+
const [path = "", ...args] = argv;
|
|
30776
|
+
return commandText({ path, args: args.map((a) => [a]) });
|
|
30777
|
+
}
|
|
30680
30778
|
function validWho(who) {
|
|
30681
30779
|
if (who === "ALL") return true;
|
|
30682
30780
|
return NAME3.test(who.startsWith("%") ? who.slice(1) : who);
|
|
@@ -30697,9 +30795,23 @@ function parseRule(line) {
|
|
|
30697
30795
|
if (cwd === "") return void 0;
|
|
30698
30796
|
const rule = { nopasswd: !!nopasswd, who, target, ...cwd !== void 0 ? { cwd } : {} };
|
|
30699
30797
|
if (rest2.trim() === "*") return { ...rule, cmnd: "*" };
|
|
30700
|
-
const
|
|
30701
|
-
|
|
30702
|
-
|
|
30798
|
+
const words2 = splitPatterns(rest2);
|
|
30799
|
+
const [first, ...args] = words2 ?? [];
|
|
30800
|
+
const path = first ? literal2(first) : "";
|
|
30801
|
+
if (!path.startsWith("/")) return void 0;
|
|
30802
|
+
const only = args.length === 1 && args[0]?.length === 1 && args[0][0] === "";
|
|
30803
|
+
if (only && /\s""$/.test(rest2.trim())) return { ...rule, cmnd: { path, args: [] } };
|
|
30804
|
+
return { ...rule, cmnd: args.length === 0 ? { path } : { path, args } };
|
|
30805
|
+
}
|
|
30806
|
+
function recordedBare(line, file, rule) {
|
|
30807
|
+
if (rule.cmnd === "*" || rule.cmnd.args !== void 0 || !rule.nopasswd) return false;
|
|
30808
|
+
if (file !== `${SUDOERS_D}/${rule.who}` || !NAME3.test(rule.who) || !NAME3.test(rule.target)) {
|
|
30809
|
+
return false;
|
|
30810
|
+
}
|
|
30811
|
+
const head = `NOPASSWD ${rule.who} (${rule.target}) `;
|
|
30812
|
+
const cmnd = `Cmnd ${quoteWord(rule.cmnd.path)}`;
|
|
30813
|
+
const cwd = rule.cwd === void 0 ? "" : `Cwd ${quoteWord(rule.cwd)} `;
|
|
30814
|
+
return line === `${head}${cwd}${cmnd}`;
|
|
30703
30815
|
}
|
|
30704
30816
|
function flags(parsed2, arg, next3) {
|
|
30705
30817
|
for (let j = 1; j < arg.length; j++) {
|
|
@@ -30737,7 +30849,7 @@ function parseArgs(args) {
|
|
|
30737
30849
|
return parsed2;
|
|
30738
30850
|
}
|
|
30739
30851
|
function described(rule) {
|
|
30740
|
-
const cmnd = rule.cmnd === "*" ? "ALL" : rule.cmnd
|
|
30852
|
+
const cmnd = rule.cmnd === "*" ? "ALL" : commandText(rule.cmnd);
|
|
30741
30853
|
const cwd = rule.cwd === void 0 ? "" : `CWD=${quoteWord(rule.cwd)} `;
|
|
30742
30854
|
return ` (${rule.target}) ${cwd}${rule.nopasswd ? "NOPASSWD: " : ""}${cmnd}`;
|
|
30743
30855
|
}
|
|
@@ -30783,7 +30895,9 @@ var Sudo = class {
|
|
|
30783
30895
|
const rules = [];
|
|
30784
30896
|
for (const [n, line] of text.split("\n").entries()) {
|
|
30785
30897
|
const rule = parseRule(line);
|
|
30786
|
-
if (rule
|
|
30898
|
+
if (rule && recordedBare(line, path, rule) && rule.cmnd !== "*") {
|
|
30899
|
+
rules.push({ ...rule, cmnd: { path: rule.cmnd.path, args: [] } });
|
|
30900
|
+
} else if (rule) rules.push(rule);
|
|
30787
30901
|
else if (rule === void 0) this.warn(`sudo: ${path}:${n + 1}: bad line skipped: ${line}`);
|
|
30788
30902
|
}
|
|
30789
30903
|
return rules;
|
|
@@ -30879,7 +30993,7 @@ var Sudo = class {
|
|
|
30879
30993
|
if (untrusted2) return untrusted2;
|
|
30880
30994
|
const argv = [path, ...args];
|
|
30881
30995
|
const matching = rules.filter(
|
|
30882
|
-
(rule) => applies(rule) && (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && (rule.cmnd
|
|
30996
|
+
(rule) => applies(rule) && (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && commandMatches(rule.cmnd, argv)
|
|
30883
30997
|
);
|
|
30884
30998
|
const grant = () => this.grant(self, target, cred, parsed2.command, path, cwd, call.term);
|
|
30885
30999
|
if (root || matching.some((rule) => rule.nopasswd)) return grant();
|
|
@@ -30976,7 +31090,7 @@ ${lines2}
|
|
|
30976
31090
|
const st = await fs.lstat(path).catch(() => void 0);
|
|
30977
31091
|
if (st && !await this.trusted(path)) return false;
|
|
30978
31092
|
const old = st ? await fs.readFile(path) : "";
|
|
30979
|
-
const words2 = argv
|
|
31093
|
+
const words2 = recordedCommand(argv);
|
|
30980
31094
|
const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Cmnd ${words2}
|
|
30981
31095
|
`;
|
|
30982
31096
|
const text = old === "" || old.endsWith("\n") ? `${old}${line}` : `${old}
|