Skip to content

[BUGFIX] Keep syslog-ng from changing the owner and mode of /docker.stdout - #673

Merged
Kanti merged 3 commits into
webdevops:masterfrom
redwormik:bugfix/syslog-ng-docker-stdout-permissions
Nov 25, 2026
Merged

Kanti merged 3 commits into
webdevops:masterfrom
redwormik:bugfix/syslog-ng-docker-stdout-permissions

Conversation

@redwormik

Copy link
Copy Markdown
Contributor

Since #656, PHP-FPM opens its access log at /docker.stdout. On DigitalOcean App Platform it then does not start: the stdout of the container cannot be opened any more, and file --dereference /proc/1/fd/1 reports invalid mode 0640.

The pipe() and file() destinations of syslog-ng apply the global owner("root") group("adm") perm(0640) to what they open, unless it is a character or block device (file_opener_open_fd() in syslog-ng). /docker.stdout is the stdout of the container, so syslog-ng changed the owner and mode of the pipe of the container runtime. App Platform runs gVisor, and gVisor before release-20261005.0 drops the file type when fchmod() is called on an imported host file (gvisor/gvisor@3cf8bfde6). Nginx is not affected because it opens /docker.stdout before syslog-ng starts; PHP-FPM opens it afterwards.

The destination now has empty owner(), group() and perm(), so syslog-ng leaves its target as it is. 10-init.sh matches the destination without its options when it switches to file() in tty mode.

For users: a file that LOG_STDOUT names keeps the owner and mode it was created with, instead of syslog-ng changing it to root:adm 0640 on every start. The documentation does not mention that mode, so it stays as it is.

Verified:

  • The new image test testSyslogKeepsTheOwnerAndModeOfTheContainerStdout fails on the published webdevops/php:8.5-alpine (11a0 root:adm instead of 1180 root:root) and passes on that image with the regenerated syslog-ng files (make test-image IMAGE=webdevops/php:8.5-alpine REFERENCE=…). All other image tests pass on both.
  • strace in webdevops/php-nginx:8.5-alpine: syslog-ng makes no fchown/fchmod calls with stdout as a pipe (pipe()) or as a tty (file()), and logger messages still reach the container log.
  • DigitalOcean App Platform (gVisor): PHP-FPM starts, and /proc/1/fd/1 stays a FIFO.
  • make check passes, except composer audit, which reports advisories for twig/twig that are already on master.

…tdout

The pipe() and file() destinations of syslog-ng apply the global
owner("root") group("adm") perm(0640) to what they open, unless it is a
character or block device. /docker.stdout is the stdout of the container,
so syslog-ng changed the owner and mode of the pipe of the container
runtime. On gVisor before release-20261005.0, as on DigitalOcean App
Platform, fchmod() on such an imported host file drops its file type
(gvisor/gvisor@3cf8bfde6): no process can open /docker.stdout afterwards,
and PHP-FPM, which opens its access log there since webdevops#656, does not start.

The destination now has empty owner(), group() and perm(), so syslog-ng
leaves the target as it is. 10-init.sh matches the destination without its
options when it switches to file() in tty mode. A file that LOG_STDOUT
names keeps the owner and mode it was created with, instead of becoming
root:adm 0640 on every start.

The image test compares the stdout of the container with its stderr once
syslog-ng has written to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kanti
Kanti force-pushed the bugfix/syslog-ng-docker-stdout-permissions branch from b539453 to 5d599f7 Compare November 25, 2026 07:43
…40, test syslog-ng in webdevops/php only

With empty owner(), group() and perm(), the mode of a new LOG_STDOUT file
depended on the service that opened it first: 0600 root:root in php
(syslog-ng), 0644 root:root in php-nginx (Nginx), where master gave 0640
root:adm in both. The entrypoint now creates a missing file as root:adm 0640
before the services start; a file that exists keeps its owner and mode.

The tests of syslog-ng move to SyslogChecks, which only PhpTest uses: the
images built on webdevops/php share its syslog-ng configuration (AGENTS.md).
This also drops the skip for images without syslog-ng, which no image is any
more.
…644, and start when they cannot be created

0644 root:root is what Nginx and Apache create; LOG_STDERR was 0644 there
before. The entrypoint stops at any error (errexit), so a failing install,
e.g. in a read-only directory, stopped the container; it now logs a warning
and the container starts, as before the files were created in advance. Image
test: with LOG_STDOUT in /proc, the container starts and cron runs.
@sonarqubecloud

Copy link
Copy Markdown

@Kanti

Kanti commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot, @redwormik! Tracing this down to file_opener_open_fd() in syslog-ng and the fchmod() bug in gVisor was great work, and the fix is exactly as small as it should be.

I pushed one commit on top:

  • Log files keep a fixed mode: With the empty owner(), group() and perm(), a new file of LOG_STDOUT/LOG_STDERR got the mode of whichever service opened it first: 0600 root:root in php (syslog-ng), 0644 root:root in php-nginx (Nginx), where it used to be 0640 root:adm in both. The entrypoint now creates a missing file as root:adm 0640 before the services start; a file that already exists keeps its owner and mode, as you intended. Documented in docs/environment-variables.md, with a test.
  • Tests only in webdevops/php: Your test and the new one moved to SyslogChecks, which only the tests of webdevops/php use, since the images built on it share the syslog-ng configuration (see AGENTS.md). That also dropped the skip for images without syslog-ng, which no image is any more.

Thanks again for the fix and the very clear description!

@Kanti
Kanti merged commit 8139d77 into webdevops:master Nov 25, 2026
190 checks passed
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.

2 participants