Skip to content

Commit c5b8fb3

Browse files
committed
builder-main: Prevent deleting cwd or its parents with force-clean
Deleting the cwd leaves flatpak-builder in an inconsistent hung state by default as rofiles-fuse tries to recurse indefinitely when resolving paths: ``` statx(AT_FDCWD, "/home/bbhtt/test/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/cache/config", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=67, ...}) = 0 [...] ``` And generally this leads to unnecessary data loss when the cwd often contains manifest and other project files. Fixes #475
1 parent 15baba4 commit c5b8fb3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/builder-main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,14 @@ main (int argc,
862862
{
863863
if (opt_force_clean)
864864
{
865+
if (g_file_equal (app_dir, cwd_dir) ||
866+
g_file_has_prefix (cwd_dir, app_dir))
867+
{
868+
g_printerr ("Refusing to delete current working "
869+
"directory or its parents\n");
870+
return 1;
871+
}
872+
865873
g_print ("Emptying app dir '%s'\n", app_dir_path);
866874
if (!flatpak_rm_rf (app_dir, NULL, &error))
867875
{

0 commit comments

Comments
 (0)