@threadedstack/wmd-web 0.1.14 → 0.1.15

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/RELEASE.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wmd-web",
3
3
  "version": "0.3.2",
4
- "commit": "1fe3dd6c164b913eecd21d64097b285c51fc1401",
4
+ "commit": "b591b664091fb3105d0cd0f341c56fe04131ff2c",
5
5
  "previous": "wmd-web-v0.1.0",
6
6
  "decisions": [
7
7
  "D-486",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadedstack/wmd-web",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/threadedstack/wmd-releases",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
11
11
  "wmd": {
12
- "tag": "v0.1.14",
13
- "commit": "1fe3dd6c164b913eecd21d64097b285c51fc1401",
12
+ "tag": "v0.1.15",
13
+ "commit": "b591b664091fb3105d0cd0f341c56fe04131ff2c",
14
14
  "web": "0.3.2"
15
15
  },
16
16
  "type": "module",
package/relay/logfile.ts CHANGED
@@ -26,14 +26,22 @@ export function createLogFile(o: LogFileOptions) {
26
26
  const retainMs = (o.retainDays ?? 14) * 24 * 3600_000
27
27
  const maxDir = o.maxLogDirBytes ?? 2 ** 30
28
28
  const warn = o.warn ?? ((m: string) => void process.stderr.write(`${m}\n`))
29
- const append = o.append ?? ((p: string, t: string) => appendFileSync(p, t, { mode: 0o600 }))
30
- // the directory holds connection metadata: owner only, also when it already existed with a looser mode
31
- mkdirSync(o.dir, { recursive: true, mode: 0o700 })
29
+ // The directory holds connection metadata: never open to others. Its group bits are the operator's: on Linux they
30
+ // are the ACL mask, and a chmod to 0700 would switch off a reader granted with setfacl. New files are group-readable
31
+ // only when the directory is, so such a reader can read them too.
32
+ const lockDown = () => {
33
+ mkdirSync(o.dir, { recursive: true, mode: 0o700 })
34
+ const m = statSync(o.dir).mode & 0o777
35
+ if (m & 0o007) chmodSync(o.dir, m & 0o770)
36
+ return m & 0o040 ? 0o640 : 0o600
37
+ }
38
+ let fileMode: number
32
39
  try {
33
- chmodSync(o.dir, 0o700)
40
+ fileMode = lockDown()
34
41
  } catch (e: any) {
35
- throw new Error(`the log directory ${o.dir} must be owner-only (0700) and cannot be made so: ${e?.message ?? e}`)
42
+ throw new Error(`the log directory ${o.dir} must be closed to others and cannot be made so: ${e?.message ?? e}`)
36
43
  }
44
+ const append = o.append ?? ((p: string, t: string) => appendFileSync(p, t, { mode: fileMode }))
37
45
  const live = join(o.dir, LIVE)
38
46
  let size = existsSync(live) ? statSync(live).size : 0
39
47
  let born = existsSync(live) ? statSync(live).birthtimeMs || statSync(live).mtimeMs : now()
@@ -93,8 +101,7 @@ export function createLogFile(o: LogFileOptions) {
93
101
  append(live, text)
94
102
  } catch (e: any) {
95
103
  if (e?.code !== 'ENOENT') throw e
96
- mkdirSync(o.dir, { recursive: true, mode: 0o700 }) // the directory was removed: make it again and try once more
97
- chmodSync(o.dir, 0o700)
104
+ fileMode = lockDown() // the directory was removed: make it again and try once more
98
105
  size = 0
99
106
  append(live, text)
100
107
  }