cat is used to display /etc/nologin and the MOTD, and its comment says it 
writes to standard output. It actually wrote to file descriptor 0, which is the 
caller's standard input.

Write to STDOUT_FILENO instead.

Signed-off-by: Bradley Morgan <[email protected]>
---
 utils/login.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/login.c b/utils/login.c
index d348c6db..bef1185f 100644
--- a/utils/login.c
+++ b/utils/login.c
@@ -140,7 +140,7 @@ cat (mach_port_t node, char *str)
          break;
        else
          {
-           ssize_t err2 = write (0, data, data_len);
+           ssize_t err2 = write (STDOUT_FILENO, data, data_len);
            assert_backtrace (err2 == data_len);
            if (data != buf)
              munmap (data, data_len);
-- 
2.53.0


Reply via email to