@profullstack/threatcrush 0.12.2 → 0.12.3

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/index.js CHANGED
@@ -11246,7 +11246,7 @@ function bansPanel(parent, state, theme, options) {
11246
11246
  if (fw.warning) {
11247
11247
  panel.text("NOT PRIVILEGED", { fg: severityColors.critical, bold: true });
11248
11248
  panel.label(fw.warning, { fg: severityColors.high });
11249
- panel.label("sudo threatcrush install-service", { fg: theme.muted });
11249
+ panel.label("threatcrush install-service", { fg: theme.muted });
11250
11250
  panel.spacer(1);
11251
11251
  }
11252
11252
  if (state.bans.length === 0) {
@@ -25433,7 +25433,7 @@ function explainBlockFailure(err, backend) {
25433
25433
  const denied = /not permitted|EACCES|EPERM|permission denied|must be root/i.test(raw);
25434
25434
  if (!denied) return `${raw} (backend: ${backend})`;
25435
25435
  const who = typeof process.getuid === "function" && process.getuid() === 0 ? "as root" : `as uid ${typeof process.getuid === "function" ? process.getuid() : "?"}`;
25436
- return `threatcrushd is running ${who} and cannot manage ${backend}. A ban is written by the daemon, not by whoever asked for it \u2014 run the daemon as root: sudo threatcrush install-service && sudo systemctl enable --now threatcrushd`;
25436
+ return `threatcrushd is running ${who} and cannot manage ${backend}. A ban is written by the daemon, not by whoever asked for it. Fix it with one command, which asks for root itself: threatcrush install-service`;
25437
25437
  }
25438
25438
  var RemediationManager = class {
25439
25439
  constructor(adapter, bus2, config) {
@@ -26070,14 +26070,31 @@ function resolveBinPath() {
26070
26070
  return "threatcrush";
26071
26071
  }
26072
26072
  }
26073
+ function stableNodePath(execPath) {
26074
+ const stable = execPath.replace(/(\/installs\/node\/)[^/]+\//, "$1latest/");
26075
+ if (stable === execPath) return execPath;
26076
+ return (0, import_node_fs30.existsSync)(stable) ? stable : execPath;
26077
+ }
26078
+ function looksLikeNodeScript(path) {
26079
+ try {
26080
+ const head = (0, import_node_fs30.readFileSync)(path, "utf-8").slice(0, 120);
26081
+ return /^#!.*\bnode\b/.test(head);
26082
+ } catch {
26083
+ return false;
26084
+ }
26085
+ }
26086
+ function execStartCommand(binPath, nodePath, isNodeScript) {
26087
+ return isNodeScript ? `${nodePath} ${binPath} daemon` : `${binPath} daemon`;
26088
+ }
26073
26089
  function isRoot2() {
26074
26090
  return typeof process.getuid === "function" && process.getuid() === 0;
26075
26091
  }
26076
26092
  function reexecWithSudo(args) {
26077
26093
  if ((0, import_node_child_process9.spawnSync)("sudo", ["--version"], { stdio: "pipe" }).status !== 0) return false;
26078
- console.log(source_default.dim(" This needs root. Re-running under sudo...\n"));
26094
+ console.log(source_default.dim(" This needs root \u2014 sudo will ask for your password.\n"));
26079
26095
  const bin = resolveBinPath();
26080
- const result = (0, import_node_child_process9.spawnSync)("sudo", [bin, ...args], { stdio: "inherit" });
26096
+ const argv = looksLikeNodeScript(bin) ? [stableNodePath(process.execPath), bin, ...args] : [bin, ...args];
26097
+ const result = (0, import_node_child_process9.spawnSync)("sudo", argv, { stdio: "inherit" });
26081
26098
  return result.status === 0;
26082
26099
  }
26083
26100
  function callerHome() {
@@ -26134,9 +26151,16 @@ async function installServiceCommand() {
26134
26151
  console.log(source_default.dim(" Run this as root: threatcrush install-service"));
26135
26152
  return;
26136
26153
  }
26137
- const unit = resolveTemplate().replace("{{BIN_PATH}}", resolveBinPath());
26154
+ const binPath = resolveBinPath();
26155
+ const exec = execStartCommand(
26156
+ binPath,
26157
+ stableNodePath(process.execPath),
26158
+ looksLikeNodeScript(binPath)
26159
+ );
26160
+ const unit = resolveTemplate().replace("{{BIN_PATH}} daemon", exec).replace("{{BIN_PATH}}", binPath);
26138
26161
  (0, import_node_fs30.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
26139
26162
  console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
26163
+ console.log(source_default.dim(` ExecStart=${exec}`));
26140
26164
  ensureSystemDirs();
26141
26165
  stopUserModeDaemon();
26142
26166
  try {