/etc/motd is not displayed when a named pipe?

You're not missing anything obvious. I dug into the source of the pam_motd module to figure this one out.

The trick is that pam_motd does the following with /etc/motd:

  1. Check the size of the file.
  2. Allocate a buffer of that size.
  3. Read the entire file into the buffer.
  4. Output the buffer through whatever output method is in use. (PAM is modular, after all; can't assume it's a terminal.)

Since a pipe doesn't have a file size, this fails at step 1.

EDIT: Why is PAM concerned about the size in the first place? I imagine it's to prevent denials of service, either intentional or unintentional. When PAM checks the file size, it also refuses to output the motd if the file is larger than 64 kbytes. I imagine whoever tried to log into the system would be very sad if someone managed to pipe a DVD movie file into /etc/motd, for example -- not to mention how much memory that might take.


This link will walk you through all essential steps