Skip to content

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

Open
redwormik wants to merge 1 commit into
webdevops:masterfrom
redwormik:bugfix/syslog-ng-docker-stdout-permissions
Open

redwormik wants to merge 1 commit into
webdevops:masterfrom
redwormik:bugfix/syslog-ng-docker-stdout-permissions

Conversation

@redwormik

Copy link
Copy Markdown

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>
@sonarqubecloud

Copy link
Copy Markdown

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