@profullstack/threatcrush 0.13.25 → 0.13.27
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/dist/daemon.js +20 -4
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +51 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31633,10 +31633,12 @@ var IpcServer = class {
|
|
|
31633
31633
|
}
|
|
31634
31634
|
const isRoot4 = process.platform === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
31635
31635
|
if (isRoot4) {
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31639
|
-
|
|
31636
|
+
const gid = admGid();
|
|
31637
|
+
if (gid !== null) {
|
|
31638
|
+
try {
|
|
31639
|
+
nodeFs.chownSync(PATHS.socket, 0, gid);
|
|
31640
|
+
} catch {
|
|
31641
|
+
}
|
|
31640
31642
|
}
|
|
31641
31643
|
}
|
|
31642
31644
|
resolve6();
|
|
@@ -31841,6 +31843,20 @@ var IpcServer = class {
|
|
|
31841
31843
|
}
|
|
31842
31844
|
}
|
|
31843
31845
|
};
|
|
31846
|
+
function admGid(readGroup = () => (0, import_node_fs24.readFileSync)("/etc/group", "utf-8"), statAuthLog = () => (0, import_node_fs24.statSync)("/var/log/auth.log")) {
|
|
31847
|
+
try {
|
|
31848
|
+
for (const line of readGroup().split("\n")) {
|
|
31849
|
+
const [name, , gid] = line.split(":");
|
|
31850
|
+
if (name === "adm" && gid !== void 0 && /^\d+$/.test(gid)) return Number(gid);
|
|
31851
|
+
}
|
|
31852
|
+
} catch {
|
|
31853
|
+
}
|
|
31854
|
+
try {
|
|
31855
|
+
return statAuthLog().gid;
|
|
31856
|
+
} catch {
|
|
31857
|
+
return null;
|
|
31858
|
+
}
|
|
31859
|
+
}
|
|
31844
31860
|
|
|
31845
31861
|
// src/daemon/module-host.ts
|
|
31846
31862
|
var import_node_fs28 = require("fs");
|
|
@@ -36059,6 +36075,7 @@ async function installServiceCommand() {
|
|
|
36059
36075
|
console.log(source_default.dim(" Installing with a system Node (/usr/bin/node or /usr/local/bin/node) avoids this."));
|
|
36060
36076
|
}
|
|
36061
36077
|
ensureSystemDirs(configDir);
|
|
36078
|
+
installLogrotate();
|
|
36062
36079
|
stopUserModeDaemon();
|
|
36063
36080
|
try {
|
|
36064
36081
|
(0, import_node_child_process13.execSync)("systemctl daemon-reload", { stdio: "inherit" });
|
|
@@ -36080,6 +36097,33 @@ async function installServiceCommand() {
|
|
|
36080
36097
|
}
|
|
36081
36098
|
console.log();
|
|
36082
36099
|
}
|
|
36100
|
+
var LOGROTATE_PATH = "/etc/logrotate.d/threatcrush";
|
|
36101
|
+
function renderLogrotate(logDir = "/var/log/threatcrush") {
|
|
36102
|
+
return [
|
|
36103
|
+
"# Installed by `threatcrush install-service`.",
|
|
36104
|
+
`${logDir}/*.log {`,
|
|
36105
|
+
" daily",
|
|
36106
|
+
" maxsize 200M",
|
|
36107
|
+
" rotate 7",
|
|
36108
|
+
" compress",
|
|
36109
|
+
" delaycompress",
|
|
36110
|
+
" missingok",
|
|
36111
|
+
" notifempty",
|
|
36112
|
+
" create 0644 root root",
|
|
36113
|
+
" su root root",
|
|
36114
|
+
"}",
|
|
36115
|
+
""
|
|
36116
|
+
].join("\n");
|
|
36117
|
+
}
|
|
36118
|
+
function installLogrotate() {
|
|
36119
|
+
if (!(0, import_node_fs37.existsSync)((0, import_node_path26.dirname)(LOGROTATE_PATH))) return;
|
|
36120
|
+
try {
|
|
36121
|
+
(0, import_node_fs37.writeFileSync)(LOGROTATE_PATH, renderLogrotate(), { mode: 420 });
|
|
36122
|
+
console.log(source_default.green(` \u2713 Log rotation: ${LOGROTATE_PATH} (daily or 200M, keeps 7)`));
|
|
36123
|
+
} catch (err) {
|
|
36124
|
+
console.log(source_default.yellow(` ! Could not install log rotation: ${err.message}`));
|
|
36125
|
+
}
|
|
36126
|
+
}
|
|
36083
36127
|
function ensureSystemDirs(configDir) {
|
|
36084
36128
|
const dirs = [
|
|
36085
36129
|
{ path: "/etc/threatcrush", groupWritable: true },
|
|
@@ -36094,9 +36138,9 @@ function ensureSystemDirs(configDir) {
|
|
|
36094
36138
|
// it here only lasts until the next reboot. The unit's RuntimeDirectory=
|
|
36095
36139
|
// recreates it on every start instead.
|
|
36096
36140
|
];
|
|
36097
|
-
let
|
|
36141
|
+
let admGid2 = null;
|
|
36098
36142
|
try {
|
|
36099
|
-
|
|
36143
|
+
admGid2 = (0, import_node_fs37.statSync)("/var/log/auth.log").gid;
|
|
36100
36144
|
} catch {
|
|
36101
36145
|
}
|
|
36102
36146
|
for (const { path, groupWritable, sticky } of dirs) {
|
|
@@ -36105,7 +36149,7 @@ function ensureSystemDirs(configDir) {
|
|
|
36105
36149
|
} catch {
|
|
36106
36150
|
}
|
|
36107
36151
|
try {
|
|
36108
|
-
if (groupWritable &&
|
|
36152
|
+
if (groupWritable && admGid2 !== null) {
|
|
36109
36153
|
(0, import_node_fs37.chmodSync)(path, sticky ? 1533 : 509);
|
|
36110
36154
|
(0, import_node_child_process13.execSync)(`chgrp adm ${path}`, { stdio: "ignore" });
|
|
36111
36155
|
} else {
|