(dir, stat, currentUid)
| 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. |
| 153 | function 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 |
no outgoing calls
no test coverage detected