Skip to content

Commit 47364b6

Browse files
authored
feat: implement stat shadowing for container filesystem extraction (#303)
* fix: remove groups table references from database schema Remove all references to the non-existent groups table that was causing "no such table: main.groups" errors. This includes: - Removed group_id and group_ip columns from sandboxes table - Removed foreign key constraint to groups table - Updated database functions to remove group parameters - Updated Sandbox model to remove group fields BREAKING CHANGE: Existing databases will need to be recreated or manually updated to remove group columns from the sandboxes table. * fix: preserve file type bits in stat xattr during tar extraction Add get_full_mode() helper to combine file type bits (S_IFREG, S_IFDIR, etc.) with permission bits when storing stat information in xattrs. This ensures the full mode value is preserved for accurate file type identification. * feat: add debug script to compare actual vs override stats Add compare_stat_overrides.sh script that displays actual file stats (uid:gid:mode) alongside user.containers.override_stat xattr values. Supports depth limiting (-L) and hidden files (-a) options. * fix: add cross-platform compatibility for macOS and Linux - Cast libc file type constants (S_IFREG, S_IFDIR, etc.) to u32 to handle platform differences (u16 on macOS, u32 on Linux) - Add platform-specific setxattr implementations using cfg attributes - macOS requires 6 arguments (includes position parameter) - Linux requires 5 arguments
1 parent d110bf1 commit 47364b6

File tree

8 files changed

+497
-51
lines changed

8 files changed

+497
-51
lines changed

microsandbox-core/lib/management/db.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ pub(crate) async fn save_or_update_sandbox(
115115
supervisor_pid: u32,
116116
microvm_pid: u32,
117117
rootfs_paths: &str,
118-
group_id: Option<u32>,
119-
group_ip: Option<String>,
120118
) -> MicrosandboxResult<i64> {
121119
let sandbox = Sandbox {
122120
id: 0,
@@ -127,8 +125,6 @@ pub(crate) async fn save_or_update_sandbox(
127125
supervisor_pid,
128126
microvm_pid,
129127
rootfs_paths: rootfs_paths.to_string(),
130-
group_id,
131-
group_ip,
132128
created_at: Utc::now(),
133129
modified_at: Utc::now(),
134130
};
@@ -142,8 +138,6 @@ pub(crate) async fn save_or_update_sandbox(
142138
supervisor_pid = ?,
143139
microvm_pid = ?,
144140
rootfs_paths = ?,
145-
group_id = ?,
146-
group_ip = ?,
147141
modified_at = CURRENT_TIMESTAMP
148142
WHERE name = ? AND config_file = ?
149143
RETURNING id
@@ -154,8 +148,6 @@ pub(crate) async fn save_or_update_sandbox(
154148
.bind(&sandbox.supervisor_pid)
155149
.bind(&sandbox.microvm_pid)
156150
.bind(&sandbox.rootfs_paths)
157-
.bind(&sandbox.group_id)
158-
.bind(&sandbox.group_ip)
159151
.bind(&sandbox.name)
160152
.bind(&sandbox.config_file)
161153
.fetch_optional(pool)
@@ -171,10 +163,9 @@ pub(crate) async fn save_or_update_sandbox(
171163
r#"
172164
INSERT INTO sandboxes (
173165
name, config_file, config_last_modified,
174-
status, supervisor_pid, microvm_pid, rootfs_paths,
175-
group_id, group_ip
166+
status, supervisor_pid, microvm_pid, rootfs_paths
176167
)
177-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
168+
VALUES (?, ?, ?, ?, ?, ?, ?)
178169
RETURNING id
179170
"#,
180171
)
@@ -185,8 +176,6 @@ pub(crate) async fn save_or_update_sandbox(
185176
.bind(sandbox.supervisor_pid)
186177
.bind(sandbox.microvm_pid)
187178
.bind(sandbox.rootfs_paths)
188-
.bind(sandbox.group_id)
189-
.bind(sandbox.group_ip)
190179
.fetch_one(pool)
191180
.await?;
192181

@@ -203,7 +192,7 @@ pub(crate) async fn get_sandbox(
203192
r#"
204193
SELECT id, name, config_file, config_last_modified, status,
205194
supervisor_pid, microvm_pid, rootfs_paths,
206-
group_id, group_ip, created_at, modified_at
195+
created_at, modified_at
207196
FROM sandboxes
208197
WHERE name = ? AND config_file = ?
209198
"#,
@@ -225,8 +214,6 @@ pub(crate) async fn get_sandbox(
225214
supervisor_pid: row.get("supervisor_pid"),
226215
microvm_pid: row.get("microvm_pid"),
227216
rootfs_paths: row.get("rootfs_paths"),
228-
group_id: row.get("group_id"),
229-
group_ip: row.get("group_ip"),
230217
created_at: parse_sqlite_datetime(&row.get::<String, _>("created_at")),
231218
modified_at: parse_sqlite_datetime(&row.get::<String, _>("modified_at")),
232219
}))
@@ -265,7 +252,7 @@ pub(crate) async fn get_running_config_sandboxes(
265252
r#"
266253
SELECT id, name, config_file, config_last_modified, status,
267254
supervisor_pid, microvm_pid, rootfs_paths,
268-
group_id, group_ip, created_at, modified_at
255+
created_at, modified_at
269256
FROM sandboxes
270257
WHERE config_file = ? AND status = ?
271258
ORDER BY created_at DESC
@@ -290,8 +277,6 @@ pub(crate) async fn get_running_config_sandboxes(
290277
supervisor_pid: row.get("supervisor_pid"),
291278
microvm_pid: row.get("microvm_pid"),
292279
rootfs_paths: row.get("rootfs_paths"),
293-
group_id: row.get("group_id"),
294-
group_ip: row.get("group_ip"),
295280
created_at: parse_sqlite_datetime(&row.get::<String, _>("created_at")),
296281
modified_at: parse_sqlite_datetime(&row.get::<String, _>("modified_at")),
297282
})

0 commit comments

Comments
 (0)