Hi,

We are running Postfix on macOS and making use of `maillog_file = /dev/stdout` 
and `postfix start-fg` to send our logs to stdout. Not using Docker.

We would like to pipe the logs from stdout to another process to do some 
analysis and post-processing, like so:

        $ postfix start-fg | our-custom-log-analyzer…

However, in this configuration, Postfix fails to start and logs this error:

        fatal: open logfile ‘/dev/stdout’: file has 0 hard links

If we don’t pipe the output, it starts just fine. 

It looks like this check in `safe_open_exist` is to blame:

    } else if (fstat_st->st_nlink != 1) {
        vstring_sprintf(why, "file has %d hard links",
                        (int) fstat_st->st_nlink);
        errno = EPERM;

When we pipe the output, st_nlink is 0, causing this check to fail. Do you 
think it would be acceptable to relax this check to `if (fstat_st->st_nlink > 
1)`, as shown in the attached patch?

Thanks!
Jonathan Hammer
e3 Software
https://e3software.com

Attachment: 0001-Relax-hard-link-check-in-safe_open-so-that-mail-logs.patch
Description: Binary data

Reply via email to