Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override umask value using a preload file loaded by Playground #560

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Sep 25, 2024

Related to p1727269932269989-slack-C04GESRBWKW and #555.

Proposed Changes

Testing Instructions

Ensure umask value is overriden

  • Run the app with the command npm start.
  • Create a new site or select one already created.
  • Create the file test.php, at the root level on the site, with the following content:
<?php
// Create file with default umask
$filename = "example-default-umask.txt";
$current_umask = umask();
    echo sprintf("Current umask: %04o<br>", $current_umask);
    $content = 'This is the content of the file.';
if (file_exists($filename)) {
    unlink($filename);
}
if (file_put_contents($filename, $content) !== false) {
    echo "File '$filename' created successfully.<br>";
} else {
    echo "Error creating file '$filename'.<br>";
}
chmod($filename, 0777 - umask());
  • Start the site.
  • Navigate to the PHP file: http://localhost:<PORT>/test.php.
  • Observe the umask value shown on the page is 0022.
  • Navigate to the site folder.
  • Observe that the permissions of the file are rwxr-xr-x (Full access to owner, and only READ and EXECUTE permissions to group and others).

Start a site created with a backup succeeds

  • Run the app with the command npm start.
  • Click on Add site.
  • Drop a backup file.
  • Create the site.
  • Observe the import process succeeds.
  • Start the site.
  • Navigate to the homepage.
  • Observe the site loads successfully.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fluiddot fluiddot added [Type] Bug Something isn't working [Status] Needs Review labels Sep 25, 2024
@fluiddot fluiddot requested a review from a team September 25, 2024 13:55
@fluiddot fluiddot self-assigned this Sep 25, 2024
@wojtekn
Copy link
Contributor

wojtekn commented Sep 26, 2024

Thanks for the fix @fluiddot . It's great that Playground provides a way to add multiple files for preload.

It works well. The output:

Current umask: 0022
File 'example-default-umask.txt' created successfully.

And file permissions:

-rw-r--r--@   1 cyphelf  staff    462 Sep 26 12:43 test.php

I've also tried installing Sage Vite theme, and it worked fine.

@fluiddot fluiddot merged commit bc5d68a into trunk Sep 26, 2024
12 of 13 checks passed
@fluiddot fluiddot deleted the fix/avoid-overriding-php-auto-prepend-file branch September 26, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants