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
case "$(uname -s)" in
Darwin)
DART_ZIP_NAME="dart-sdk-darwin-x64.zip"
IS_USER_EXECUTABLE="-perm +100"
;;
Linux)
DART_ZIP_NAME="dart-sdk-linux-x64.zip"
IS_USER_EXECUTABLE="-perm /u+x"
;;
*)
echo "Unknown operating system. Cannot install Dart SDK."
......@@ -50,7 +48,7 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t
# install the new sdk
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"
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
exit 1
}
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"
# delete any temporary sdk path
......
......@@ -25,15 +25,7 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils._private();
/// Make the given file executable. This may be a no-op on some platforms.
void 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);
ProcessResult makeExecutable(File file);
/// Return the path (with symlinks resolved) to the given executable, or null
/// if `which` was not able to locate the binary.
......@@ -86,13 +78,8 @@ class _PosixUtils extends OperatingSystemUtils {
_PosixUtils() : super._private();
@override
void makeExecutable(File file) {
chmod(file, 'a+x');
}
@override
void chmod(FileSystemEntity entity, String mode) {
processManager.runSync(<String>['chmod', mode, entity.path]);
ProcessResult makeExecutable(File file) {
return processManager.runSync(<String>['chmod', 'a+x', file.path]);
}
@override
......@@ -165,11 +152,11 @@ class _PosixUtils extends OperatingSystemUtils {
class _WindowsUtils extends OperatingSystemUtils {
_WindowsUtils() : super._private();
// This is a no-op.
@override
void makeExecutable(File file) {}
@override
void chmod(FileSystemEntity entity, String mode) {}
ProcessResult makeExecutable(File file) {
return ProcessResult(0, 0, null, null);
}
@override
List<File> _which(String execName, {bool all = false}) {
......
......@@ -145,10 +145,8 @@ class Cache {
/// Return a directory in the cache dir. For `pkg`, this will return `bin/cache/pkg`.
Directory getCacheDir(String name) {
final Directory dir = fs.directory(fs.path.join(getRoot().path, name));
if (!dir.existsSync()) {
if (!dir.existsSync())
dir.createSync(recursive: true);
os.chmod(dir, '755');
}
return dir;
}
......@@ -196,10 +194,8 @@ class Cache {
final Directory thirdPartyDir = getArtifactDirectory('third_party');
final Directory serviceDir = fs.directory(fs.path.join(thirdPartyDir.path, serviceName));
if (!serviceDir.existsSync()) {
if (!serviceDir.existsSync())
serviceDir.createSync(recursive: true);
os.chmod(serviceDir, '755');
}
final File cachedFile = fs.file(fs.path.join(serviceDir.path, url.pathSegments.last));
if (!cachedFile.existsSync()) {
......@@ -556,16 +552,13 @@ class FlutterEngine extends CachedArtifact {
return result;
}
void _makeFilesExecutable(Directory dir) {
os.chmod(dir, 'a+r,a+x');
for (FileSystemEntity entity in dir.listSync(recursive: true)) {
for (FileSystemEntity entity in dir.listSync()) {
if (entity is File) {
final FileStat stat = entity.statSync();
final bool isUserExecutable = ((stat.mode >> 6) & 0x1) == 1;
if (entity.basename == 'flutter_tester' || isUserExecutable) {
// Make the file readable and executable by all users.
os.chmod(entity, 'a+r,a+x');
}
final String name = fs.path.basename(entity.path);
if (name == 'flutter_tester')
os.makeExecutable(entity);
}
}
}
......
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