Skip to content

fix: pre-create xdebug.log with world-writable permissions#242

Merged
AaronFeledy merged 3 commits intomainfrom
fix/xdebug-log-permissions
Mar 5, 2026
Merged

fix: pre-create xdebug.log with world-writable permissions#242
AaronFeledy merged 3 commits intomainfrom
fix/xdebug-log-permissions

Conversation

@AaronFeledy
Copy link
Member

@AaronFeledy AaronFeledy commented Mar 5, 2026

Problem

When xdebug is enabled, the log file at /tmp/xdebug.log can be created as root:root during build_as_root or run_as_root steps. Subsequent runs as www-data then fail because the file is owned by root and not writable.

Fix

Pre-create the log file with chmod 666 during the same build_as_root_internal step that enables xdebug. Since this runs as root, the touch + chmod ensures the file exists with world-writable permissions before any user-level process tries to write to it.

Changes

  • builders/php.js: Added touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log to the xdebug enable build step

Note

Low Risk
Low risk, limited to service build-time steps and changelog updates. Main consideration is the intentionally permissive chmod 666 on /tmp/xdebug.log, which could have minor side effects inside the container.

Overview
Prevents xdebug failures caused by /tmp/xdebug.log being created as root during build_as_root/run_as_root by adding a root build step that touches the file and sets it to chmod 666.

Updates the CHANGELOG.md Unreleased section to document the xdebug log ownership fix.

Written by Cursor Bugbot for commit 9c7df60. This will update automatically on new commits. Configure here.

When xdebug is enabled, the log file at /tmp/xdebug.log can be created
as root during build_as_root or run_as_root steps. Subsequent runs as
www-data then fail because the file is owned by root.

Pre-create the log file with 666 permissions during the same
build_as_root_internal step that enables xdebug, ensuring any user
can write to it regardless of which user triggers the first write.
@netlify
Copy link

netlify bot commented Mar 5, 2026

Deploy Preview for lando-php ready!

Name Link
🔨 Latest commit 9c7df60
🔍 Latest deploy log https://app.netlify.com/projects/lando-php/deploys/69a9f786455d400008de7485
😎 Deploy Preview https://deploy-preview-242--lando-php.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 83 (🔴 down 8 from production)
Accessibility: 98 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Move the touch/chmod of /tmp/xdebug.log outside the xdebug conditional
so it runs for all PHP services regardless of xdebug config. This is
defensive — ensures the file is always writable even if xdebug gets
enabled later or something else writes to that path.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Xdebug log created unconditionally even when xdebug disabled
    • Moved the xdebug log file creation inside the if (options.xdebug) conditional block so it only runs when xdebug is enabled.

Create PR

Or push these changes by commenting:

@cursor push faad34056b
Preview (faad34056b)
diff --git a/builders/php.js b/builders/php.js
--- a/builders/php.js
+++ b/builders/php.js
@@ -248,12 +248,11 @@
         options.composer_version = options.composer_version.toString();
       }
 
-      // Pre-create xdebug log with world-writable permissions so root-owned builds
-      // don't block www-data from writing to it later
-      addBuildStep(['touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log'], options._app, options.name, 'build_as_root_internal');
-
       // Add build step to enable xdebug
       if (options.xdebug) {
+        // Pre-create xdebug log with world-writable permissions so root-owned builds
+        // don't block www-data from writing to it later
+        addBuildStep(['touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log'], options._app, options.name, 'build_as_root_internal');
         addBuildStep(['docker-php-ext-enable xdebug'], options._app, options.name, 'build_as_root_internal');
       }


// Pre-create xdebug log with world-writable permissions so root-owned builds
// don't block www-data from writing to it later
addBuildStep(['touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log'], options._app, options.name, 'build_as_root_internal');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xdebug log created unconditionally even when xdebug disabled

Medium Severity

The touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log build step runs unconditionally for every PHP container, but the xdebug enable step on line 256 is gated behind if (options.xdebug). The log file pre-creation belongs inside that same conditional so it only runs when xdebug is actually enabled. Without this guard, every PHP build unnecessarily creates a world-writable file.

Fix in Cursor Fix in Web

@AaronFeledy AaronFeledy merged commit d3b1fdf into main Mar 5, 2026
90 of 91 checks passed
@AaronFeledy AaronFeledy deleted the fix/xdebug-log-permissions branch March 5, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant