From 185f526ddfe72e19282ff141f194544d90cdcff7 Mon Sep 17 00:00:00 2001 From: LouiseHsu Date: Mon, 20 May 2024 14:41:52 -0700 Subject: [PATCH] Fixes incorrect read/write permissions on Flutter.framework and FlutterMacOS.framework (#148580) Fixes https://github.com/flutter/flutter/issues/148354 Fixes https://github.com/flutter/flutter/issues/147142 Closes https://github.com/flutter/flutter/pull/147144 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --- .../lib/src/build_system/targets/ios.dart | 1 + .../lib/src/build_system/targets/macos.dart | 1 + .../build_system/targets/ios_test.dart | 2 ++ .../build_system/targets/macos_test.dart | 2 ++ .../ios_content_validation_test.dart | 17 ++++++++++++++--- .../macos_content_validation_test.dart | 5 +++++ 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart index 1fd586e063..b91459f4b1 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart @@ -314,6 +314,7 @@ abstract class UnpackIOS extends Target { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', basePath, environment.outputDir.path, ]); diff --git a/packages/flutter_tools/lib/src/build_system/targets/macos.dart b/packages/flutter_tools/lib/src/build_system/targets/macos.dart index 2e018fe84c..1d0a0a7b68 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/macos.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/macos.dart @@ -60,6 +60,7 @@ abstract class UnpackMacOS extends Target { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', basePath, environment.outputDir.path, ]); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart index 25b7b5c44c..1da088afa1 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart @@ -541,6 +541,7 @@ void main() { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', 'Artifact.flutterFramework.TargetPlatform.ios.debug.EnvironmentType.physical', outputDir.path, ]); @@ -597,6 +598,7 @@ void main() { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', 'Artifact.flutterFramework.TargetPlatform.ios.debug.EnvironmentType.simulator', outputDir.path, ], diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart index 5c082d589f..e172b7b31e 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart @@ -73,6 +73,7 @@ void main() { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', 'Artifact.flutterMacOSFramework.debug', environment.outputDir.path, ], @@ -133,6 +134,7 @@ void main() { '--delete', '--filter', '- .DS_Store/', + '--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r', // source 'Artifact.flutterMacOSFramework.debug', // destination diff --git a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart index 2e0587524e..0f7befcac5 100644 --- a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart +++ b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart @@ -422,10 +422,16 @@ void main() { .whereType() .singleWhere((Directory directory) => fileSystem.path.extension(directory.path) == '.app'); + final Directory flutterFrameworkDir = fileSystem.directory( + fileSystem.path.join( + appBundle.path, + 'Frameworks', + 'Flutter.framework', + ), + ); + final String flutterFramework = fileSystem.path.join( - appBundle.path, - 'Frameworks', - 'Flutter.framework', + flutterFrameworkDir.path, 'Flutter', ); @@ -456,6 +462,11 @@ void main() { ], ); expect(appCodesign, const ProcessResultMatcher()); + + // Check read/write permissions are being correctly set + final String rawStatString = flutterFrameworkDir.statSync().modeString(); + final String statString = rawStatString.substring(rawStatString.length - 9); + expect(statString, 'rwxr-xr-x'); }); }, skip: !platform.isMacOS, // [intended] only makes sense for macos platform. timeout: const Timeout(Duration(minutes: 10)) diff --git a/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart b/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart index 5568ad2f9a..2ff219c764 100644 --- a/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart +++ b/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart @@ -164,6 +164,11 @@ void main() { ), ); + // Check read/write permissions are being correctly set + final String rawStatString = outputFlutterFramework.statSync().modeString(); + final String statString = rawStatString.substring(rawStatString.length - 9); + expect(statString, 'rwxr-xr-x'); + // Check complicated macOS framework symlink structure. final Link current = outputFlutterFramework.childDirectory('Versions').childLink('Current');