Commit 455af49
committed
system/nxpkg: address lifecycle review findings.
Fix real correctness/security gaps found during review, on top of the
network sync and CLI completion work:
- pkg_install(): commit the installed database before writing the
current/previous pointer files, and before advancing transaction
state past ACTIVATED. Those are recovery bookkeeping and convenience
mirrors respectively - once the installed database itself is
durably committed, a failure to refresh either one must not trigger
the failure-cleanup path, which could otherwise delete a payload the
database now legitimately points at. Also stop treating an existing
version directory as newly created when reinstalling an
already-installed version, so a failed reinstall can't delete a
working install.
- pkg_uninstall()/pkg_rollback(): acquire the per-package install lock
in addition to the installed-db lock, drop the entry from the
authoritative database first, and only then remove payload files -
a crash between those two steps can leave orphaned files, which are
reclaimable, but never leaves the database pointing at a payload
that's already gone.
- pkg_sync(): stage each sync to a PID-qualified temp filename instead
of a single fixed name, so concurrent sync calls can no longer race
on the same staging file. Return real negative errno codes instead
of EXIT_SUCCESS/EXIT_FAILURE, matching the rest of this API; pkg_main.c
maps that back to a process exit code at the CLI boundary.
- pkg_metadata_parse_installed_entry(): validate that name/current/
previous/every entry in versions[] are safe path components, and that
current (and previous, if set) actually appear in versions[] - a
corrupted or tampered installed-packages database can no longer
reference a nonexistent version or smuggle a path-traversal sequence
through a field this code already trusted implicitly.
- pkg_store_write_all()/pkg_repo_sink(): treat a zero-byte write() as
-EIO instead of looping on it silently.
- Removed the malloc()-falls-back-to-kmm_malloc() logic in pkg_malloc/
pkg_zalloc/pkg_realloc/pkg_free entirely - it required tracking which
allocator owned a given pointer via kmm_heapmember(), which is
specific to this target's flat, single-heap memory model and not a
sound general application API. These are now plain wrappers around
malloc/calloc/realloc/free.
- Added pkg_metadata_load_manifest_path(), so a caller (e.g. the
nxstore GUI frontend, launching an installed package) can load the
manifest actually recorded for a specific installed version, instead
of combining a rollback-selected version with whatever the current
catalog happens to describe for that package name - those can
disagree after a rollback if the catalog has since moved on.
- Storage root default changed from /tmp/nxpkg to /var/lib/nxpkg,
following the conventional persistent application-data location
instead of a path whose own name suggests non-persistent storage. A
board without persistent storage mounted at /var, or that wants a
different location (e.g. an SD card), still overrides this via
CONFIG_SYSTEM_NXPKG_ROOT as before.
- Moved system/nxpkg/README.txt into the companion NuttX documentation
PR rather than shipping user-facing documentation as an in-tree
README.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>1 parent 81b8892 commit 455af49
9 files changed
Lines changed: 205 additions & 313 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
69 | 62 | | |
70 | 63 | | |
71 | 64 | | |
| |||
99 | 92 | | |
100 | 93 | | |
101 | 94 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 95 | + | |
110 | 96 | | |
111 | 97 | | |
112 | 98 | | |
113 | 99 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 100 | + | |
122 | 101 | | |
123 | 102 | | |
124 | 103 | | |
125 | 104 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 105 | | |
151 | 106 | | |
152 | 107 | | |
153 | 108 | | |
154 | 109 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 110 | + | |
168 | 111 | | |
169 | 112 | | |
170 | 113 | | |
| |||
241 | 184 | | |
242 | 185 | | |
243 | 186 | | |
| 187 | + | |
244 | 188 | | |
245 | 189 | | |
246 | 190 | | |
| |||
291 | 235 | | |
292 | 236 | | |
293 | 237 | | |
| 238 | + | |
| 239 | + | |
294 | 240 | | |
295 | 241 | | |
296 | 242 | | |
| |||
0 commit comments