Commit e0d37cd
fix(settings): stop reporting success when a settings write fails
WriteSettingToFile() opened the settings file with @fopen($f, "c+") and never
checked the result. When the web user cannot write the file, the open returns
false and PHP 8 throws "TypeError: flock(): Argument #1 must be of type
resource, false given" -- but the API response is still HTTP 200, so the
browser's success handler runs and jGrowl reports "setting saved" for a value
that was never written. The setting then reverts on the next page load, with
nothing in the UI to say why.
The way in is a stray root write. Apache/PHP run as fpp, and FPP's own writers
put ownership back (PutFileContents -> SetFilePerms chowns to fpp; sed -i
preserves the owner), but anything running as root that replaces the file with
a fresh inode leaves it root:root. Boot re-runs "chown -R fpp:fpp" over the
media directory, so the broken state lasts only until the next reboot -- which
is exactly long enough to look like a bug in whichever setting was being saved.
- WriteSettingToFile() returns bool, checks both the open and the write, and
logs which setting was lost.
- On an unwritable file it re-asserts fpp ownership via sudo and retries once.
Boot already asserts that same ownership, so the correct owner is not a
guess, and one stray root write no longer disables saving for the rest of the
uptime.
- PutSetting() returns 500 with a JSON error instead of {"status":"OK"}, and
skips the apply/restart path so the running system cannot diverge from disk.
Existing callers ignore the new return value and are unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent b72ce98 commit e0d37cd
2 files changed
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
199 | 243 | | |
200 | 244 | | |
201 | 245 | | |
| |||
207 | 251 | | |
208 | 252 | | |
209 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
210 | 261 | | |
211 | 262 | | |
212 | 263 | | |
| |||
220 | 271 | | |
221 | 272 | | |
222 | 273 | | |
223 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
224 | 280 | | |
225 | 281 | | |
226 | 282 | | |
227 | 283 | | |
228 | 284 | | |
229 | 285 | | |
| 286 | + | |
230 | 287 | | |
231 | 288 | | |
232 | 289 | | |
| |||
0 commit comments