Commit c69a552
authored
🐛 fix(unix): use correct runtime dir path for OpenBSD (#440)
OpenBSD applications using platformdirs were unnecessarily falling back
to temporary directories because the default runtime path
`/var/run/user/{uid}` is not writable by regular users on OpenBSD. 🔒
This issue was reported by OpenBSD package maintainers who noticed the
mismatch with the platform's native XDG implementation.
OpenBSD now has native `XDG_RUNTIME_DIR` support in libc via the
`setxdgenv()` function in
[`lib/libc/gen/login_cap.c`](https://github.com/openbsd/src/blob/master/lib/libc/gen/login_cap.c),
which creates directories at `/tmp/run/user/{uid}` with proper ownership
and permissions. The fix splits the BSD platform detection to handle
OpenBSD separately from FreeBSD and NetBSD, which both continue using
`/var/run/user/{uid}`. ✨
This change aligns platformdirs with OpenBSD's official implementation
while preserving existing behavior for FreeBSD and NetBSD. Applications
on OpenBSD will now correctly use the runtime directory created by the
system during login instead of falling back to temporary directories.
## Documentation References
During investigation, the following official platform documentation was
reviewed:
- **OpenBSD**: [`setxdgenv()` in
login_cap.c](https://github.com/openbsd/src/blob/master/lib/libc/gen/login_cap.c)
- uses `/tmp/run/user/{uid}`
- **FreeBSD**: [`pam_xdg`
module](https://github.com/freebsd/freebsd-src/blob/main/lib/libpam/modules/pam_xdg/pam_xdg.c)
- uses `/var/run/xdg/{username}` (platformdirs fallback of
`/var/run/user/{uid}` is reasonable)
- **NetBSD**: No native XDG support found; [pkgsrc
patches](https://github.com/NetBSD/pkgsrc/blob/trunk/misc/py-platformdirs/patches/patch-tests_test__unix.py)
treat it same as FreeBSD
Fixes #4361 parent 03ccfd0 commit c69a552
2 files changed
Lines changed: 48 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
176 | 198 | | |
| 199 | + | |
| 200 | + | |
177 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
178 | 206 | | |
179 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
180 | 213 | | |
181 | | - | |
| 214 | + | |
| 215 | + | |
182 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
183 | 221 | | |
| 222 | + | |
184 | 223 | | |
185 | 224 | | |
186 | 225 | | |
| |||
0 commit comments