MCPcopy Create free account
hub / github.com/chhoumann/quickadd / assertOwnedDir

Function assertOwnedDir

scripts/start-obsidian-e2e-instance.mjs:153–171  ·  view source on GitHub ↗
(dir, stat, currentUid)

Source from the content-addressed store, hash-verified

151// while it was loose may already have planted a `home` symlink that a parent
152// chmod would not undo, and a later recursive mkdir / keychain link would follow.
153function assertOwnedDir(dir, stat, currentUid) {
154 if (stat.isSymbolicLink() || !stat.isDirectory()) {
155 throw new Error(
156 `Refusing to use ${dir}: it is a symlink or not a regular directory.`,
157 );
158 }
159 if (currentUid !== null && stat.uid !== currentUid) {
160 throw new Error(
161 `Refusing to use ${dir}: owned by uid ${stat.uid}, not ${currentUid}.`,
162 );
163 }
164 if ((stat.mode & 0o077) !== 0) {
165 throw new Error(
166 `Refusing to use ${dir}: it is group/other-accessible (mode ${(
167 stat.mode & 0o777
168 ).toString(8)}); remove it and retry.`,
169 );
170 }
171}
172
173// Create (when absent) and validate a private profile directory we own. The
174// profile root defaults under world-writable /tmp; if a co-located actor

Callers 2

ensureSecureDirFunction · 0.85
assertSecureDirIfPresentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected