Unverified Commit c461e933 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Ensure that cache dirs and files have appropriate permissions" (#25240)

parent 234855ca
...@@ -27,11 +27,9 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t ...@@ -27,11 +27,9 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t
case "$(uname -s)" in case "$(uname -s)" in
Darwin) Darwin)
DART_ZIP_NAME="dart-sdk-darwin-x64.zip" DART_ZIP_NAME="dart-sdk-darwin-x64.zip"
IS_USER_EXECUTABLE="-perm +100"
;; ;;
Linux) Linux)
DART_ZIP_NAME="dart-sdk-linux-x64.zip" DART_ZIP_NAME="dart-sdk-linux-x64.zip"
IS_USER_EXECUTABLE="-perm /u+x"
;; ;;
*) *)
echo "Unknown operating system. Cannot install Dart SDK." echo "Unknown operating system. Cannot install Dart SDK."
...@@ -50,7 +48,7 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t ...@@ -50,7 +48,7 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t
# install the new sdk # install the new sdk
rm -rf -- "$DART_SDK_PATH" rm -rf -- "$DART_SDK_PATH"
mkdir -m 755 -p -- "$DART_SDK_PATH" mkdir -p -- "$DART_SDK_PATH"
DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/$DART_ZIP_NAME" DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/$DART_ZIP_NAME"
curl --continue-at - --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 || { curl --continue-at - --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 || {
...@@ -72,8 +70,6 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t ...@@ -72,8 +70,6 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t
exit 1 exit 1
} }
rm -f -- "$DART_SDK_ZIP" rm -f -- "$DART_SDK_ZIP"
find "$DART_SDK_PATH" -type d -exec chmod 755 {} \;
find "$DART_SDK_PATH" -type f $IS_USER_EXECUTABLE -exec chmod a+x,a+r {} \;
echo "$ENGINE_VERSION" > "$ENGINE_STAMP" echo "$ENGINE_VERSION" > "$ENGINE_STAMP"
# delete any temporary sdk path # delete any temporary sdk path
......
...@@ -25,15 +25,7 @@ abstract class OperatingSystemUtils { ...@@ -25,15 +25,7 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils._private(); OperatingSystemUtils._private();
/// Make the given file executable. This may be a no-op on some platforms. /// Make the given file executable. This may be a no-op on some platforms.
void makeExecutable(File file); ProcessResult makeExecutable(File file);
/// Updates the specified file system [entity] to have the file mode
/// bits set to the value defined by [mode], which can be specified in octal
/// (e.g. `644`) or symbolically (e.g. `u+x`).
///
/// On operating systems that do not support file mode bits, this will be a
/// no-op.
void chmod(FileSystemEntity entity, String mode);
/// Return the path (with symlinks resolved) to the given executable, or null /// Return the path (with symlinks resolved) to the given executable, or null
/// if `which` was not able to locate the binary. /// if `which` was not able to locate the binary.
...@@ -86,13 +78,8 @@ class _PosixUtils extends OperatingSystemUtils { ...@@ -86,13 +78,8 @@ class _PosixUtils extends OperatingSystemUtils {
_PosixUtils() : super._private(); _PosixUtils() : super._private();
@override @override
void makeExecutable(File file) { ProcessResult makeExecutable(File file) {
chmod(file, 'a+x'); return processManager.runSync(<String>['chmod', 'a+x', file.path]);
}
@override
void chmod(FileSystemEntity entity, String mode) {
processManager.runSync(<String>['chmod', mode, entity.path]);
} }
@override @override
...@@ -165,11 +152,11 @@ class _PosixUtils extends OperatingSystemUtils { ...@@ -165,11 +152,11 @@ class _PosixUtils extends OperatingSystemUtils {
class _WindowsUtils extends OperatingSystemUtils { class _WindowsUtils extends OperatingSystemUtils {
_WindowsUtils() : super._private(); _WindowsUtils() : super._private();
// This is a no-op.
@override @override
void makeExecutable(File file) {} ProcessResult makeExecutable(File file) {
return ProcessResult(0, 0, null, null);
@override }
void chmod(FileSystemEntity entity, String mode) {}
@override @override
List<File> _which(String execName, {bool all = false}) { List<File> _which(String execName, {bool all = false}) {
......
...@@ -145,10 +145,8 @@ class Cache { ...@@ -145,10 +145,8 @@ class Cache {
/// Return a directory in the cache dir. For `pkg`, this will return `bin/cache/pkg`. /// Return a directory in the cache dir. For `pkg`, this will return `bin/cache/pkg`.
Directory getCacheDir(String name) { Directory getCacheDir(String name) {
final Directory dir = fs.directory(fs.path.join(getRoot().path, name)); final Directory dir = fs.directory(fs.path.join(getRoot().path, name));
if (!dir.existsSync()) { if (!dir.existsSync())
dir.createSync(recursive: true); dir.createSync(recursive: true);
os.chmod(dir, '755');
}
return dir; return dir;
} }
...@@ -196,10 +194,8 @@ class Cache { ...@@ -196,10 +194,8 @@ class Cache {
final Directory thirdPartyDir = getArtifactDirectory('third_party'); final Directory thirdPartyDir = getArtifactDirectory('third_party');
final Directory serviceDir = fs.directory(fs.path.join(thirdPartyDir.path, serviceName)); final Directory serviceDir = fs.directory(fs.path.join(thirdPartyDir.path, serviceName));
if (!serviceDir.existsSync()) { if (!serviceDir.existsSync())
serviceDir.createSync(recursive: true); serviceDir.createSync(recursive: true);
os.chmod(serviceDir, '755');
}
final File cachedFile = fs.file(fs.path.join(serviceDir.path, url.pathSegments.last)); final File cachedFile = fs.file(fs.path.join(serviceDir.path, url.pathSegments.last));
if (!cachedFile.existsSync()) { if (!cachedFile.existsSync()) {
...@@ -556,16 +552,13 @@ class FlutterEngine extends CachedArtifact { ...@@ -556,16 +552,13 @@ class FlutterEngine extends CachedArtifact {
return result; return result;
} }
void _makeFilesExecutable(Directory dir) { void _makeFilesExecutable(Directory dir) {
os.chmod(dir, 'a+r,a+x'); for (FileSystemEntity entity in dir.listSync()) {
for (FileSystemEntity entity in dir.listSync(recursive: true)) {
if (entity is File) { if (entity is File) {
final FileStat stat = entity.statSync(); final String name = fs.path.basename(entity.path);
final bool isUserExecutable = ((stat.mode >> 6) & 0x1) == 1; if (name == 'flutter_tester')
if (entity.basename == 'flutter_tester' || isUserExecutable) { os.makeExecutable(entity);
// Make the file readable and executable by all users.
os.chmod(entity, 'a+r,a+x');
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment