fix: pre-create xdebug.log with world-writable permissions#242
Merged
AaronFeledy merged 3 commits intomainfrom Mar 5, 2026
Merged
fix: pre-create xdebug.log with world-writable permissions#242AaronFeledy merged 3 commits intomainfrom
AaronFeledy merged 3 commits intomainfrom
Conversation
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.
✅ Deploy Preview for lando-php ready!
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.
There was a problem hiding this comment.
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.
- Moved the xdebug log file creation inside the
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'); |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Problem
When xdebug is enabled, the log file at
/tmp/xdebug.logcan be created asroot:rootduringbuild_as_rootorrun_as_rootsteps. Subsequent runs aswww-datathen fail because the file is owned by root and not writable.Fix
Pre-create the log file with
chmod 666during the samebuild_as_root_internalstep that enables xdebug. Since this runs as root, thetouch+chmodensures the file exists with world-writable permissions before any user-level process tries to write to it.Changes
builders/php.js: Addedtouch /tmp/xdebug.log && chmod 666 /tmp/xdebug.logto the xdebug enable build stepNote
Low Risk
Low risk, limited to service build-time steps and changelog updates. Main consideration is the intentionally permissive
chmod 666on/tmp/xdebug.log, which could have minor side effects inside the container.Overview
Prevents xdebug failures caused by
/tmp/xdebug.logbeing created asrootduringbuild_as_root/run_as_rootby adding a root build step thattouches the file and sets it tochmod 666.Updates the
CHANGELOG.mdUnreleased section to document the xdebug log ownership fix.Written by Cursor Bugbot for commit 9c7df60. This will update automatically on new commits. Configure here.