@dotrino/vaultd 0.106.0 → 0.106.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/package.json +1 -1
- package/src/vault.js +24 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.106.
|
|
3
|
+
"version": "0.106.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Certificador personal de Dotrino: daemon headless que custodia la clave maestra y delega capacidades a tus dispositivos por el proxy. Tu CA propia.",
|
|
6
6
|
"bin": {
|
package/src/vault.js
CHANGED
|
@@ -1330,7 +1330,30 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
|
|
|
1330
1330
|
sock.on('error', cerrar)
|
|
1331
1331
|
})
|
|
1332
1332
|
server.on('error', (e) => log('[vault] the local desk could not open (' + e.message + '): services will use the proxy'))
|
|
1333
|
-
|
|
1333
|
+
// EL DIRECTORIO ES EL CONTROL, no el modo del socket.
|
|
1334
|
+
//
|
|
1335
|
+
// `mkdir` con `mode` NO corrige un directorio que ya existe, y sin `XDG_RUNTIME_DIR`
|
|
1336
|
+
// —un servicio de sistema, un contenedor— esto cae en `/tmp`, donde cualquiera puede
|
|
1337
|
+
// haberlo creado antes con permiso de escritura para todos. Quien sea dueño del
|
|
1338
|
+
// directorio puede borrar el socket y poner el suyo: los servicios de esta máquina
|
|
1339
|
+
// acabarían hablando con él. No leería nada (la respuesta va firmada por una llave que
|
|
1340
|
+
// nombra el acta y el cliente la comprueba), pero los deja sin arrancar.
|
|
1341
|
+
//
|
|
1342
|
+
// Y el `chmod 0600` de abajo llega DESPUÉS de `listen`, así que por sí solo deja una
|
|
1343
|
+
// rendija. Lo que la cierra de verdad es que el directorio sea nuestro y solo nuestro.
|
|
1344
|
+
const dir = socketDir()
|
|
1345
|
+
try { fs.mkdirSync(dir, { recursive: true, mode: 0o700 }) } catch (_) {}
|
|
1346
|
+
try {
|
|
1347
|
+
const st = fs.statSync(dir)
|
|
1348
|
+
const ajeno = typeof process.getuid === 'function' && st.uid !== process.getuid()
|
|
1349
|
+
const abierto = (st.mode & 0o077) !== 0
|
|
1350
|
+
if (ajeno || abierto) {
|
|
1351
|
+
return log(`[vault] the local desk stays closed: ${dir} is ${ajeno ? 'owned by another user' : 'writable by others'} ` +
|
|
1352
|
+
'— services on this machine will use the proxy instead')
|
|
1353
|
+
}
|
|
1354
|
+
} catch (e) {
|
|
1355
|
+
return log('[vault] the local desk stays closed: could not check ' + dir + ' (' + e.message + ')')
|
|
1356
|
+
}
|
|
1334
1357
|
try { fs.rmSync(socketPath, { force: true }) } catch (_) {}
|
|
1335
1358
|
server.listen(socketPath, () => {
|
|
1336
1359
|
try { fs.chmodSync(socketPath, 0o600) } catch (_) {}
|