[PHP-WEBMASTER] [web-downloads] main: Fix directory permissions

Author: Shivam Mathur (shivammathur)
Date: 2025-02-14T08:49:37+05:30

Commit: Fix directory permissions · php/web-downloads@deb3f6f · GitHub
Raw diff: https://github.com/php/web-downloads/commit/deb3f6f87210f187fe1c74330af8a23ac73587d4.diff

Fix directory permissions

Changed paths:
  M src/Actions/GetArtifacts.php
  M src/Http/Controllers/PeclController.php
  M src/Http/Controllers/PhpController.php

Diff:

diff --git a/src/Actions/GetArtifacts.php b/src/Actions/GetArtifacts.php
index 3eb92cb..f1009b4 100644
--- a/src/Actions/GetArtifacts.php
+++ b/src/Actions/GetArtifacts.php
@@ -37,7 +37,8 @@ public function handle($workflow_run_id, $token): void
             if (is_dir($workflowRunDirectory)) {
                 (new Helpers)->rmdirr($workflowRunDirectory);
             }
- mkdir($workflowRunDirectory, 0755, true);
+ umask(0);
+ mkdir($workflowRunDirectory, 0777, true);
             foreach ($artifacts['artifacts'] as $artifact) {
                 $filepath = $workflowRunDirectory . "/" . $artifact['name'] . ".zip";
                 (new FetchArtifact)->handle($artifact['archive_download_url'], $filepath, $token);
diff --git a/src/Http/Controllers/PeclController.php b/src/Http/Controllers/PeclController.php
index 73fe86e..a487593 100644
--- a/src/Http/Controllers/PeclController.php
+++ b/src/Http/Controllers/PeclController.php
@@ -49,7 +49,8 @@ protected function fetchExtension(string $extension, string $ref, string $url, s
         $filepath = $directory . "/$extension-$ref-" . hash('sha256', $url) . strtotime('now') . ".zip";

         if(!is_dir($directory)) {
- mkdir($directory, 0755, true);
+ umask(0);
+ mkdir($directory, 0777, true);
         }

         (new FetchArtifact)->handle($url, $filepath, $token);
diff --git a/src/Http/Controllers/PhpController.php b/src/Http/Controllers/PhpController.php
index 2d0479b..5b2f85d 100644
--- a/src/Http/Controllers/PhpController.php
+++ b/src/Http/Controllers/PhpController.php
@@ -51,7 +51,8 @@ private function fetchPhpBuild(string $url, string $token): void
         $filepath = $directory . "/php-" . $hash . ".zip";

         if(!is_dir($directory)) {
- mkdir($directory, 0755, true);
+ umask(0);
+ mkdir($directory, 0777, true);
         }

         (new FetchArtifact)->handle($url, $filepath, $token);