[hackers] [sbase] nohup: Open nohup.out WRONLY || Arthur Williams

From: <git_AT_suckless.org>
Date: Sun, 24 Oct 2021 01:19:11 +0200 (CEST)

commit 2c2a7f54ab55a022a617e510b6e00c3e2736fabd
Author: Arthur Williams <taaparthur_AT_gmail.com>
AuthorDate: Fri Sep 3 19:08:21 2021 -0500
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Sat Oct 23 16:17:20 2021 -0700

    nohup: Open nohup.out WRONLY
    
    Open nohup.out write-only instead of not specifying the access permissions
    instead of getting undefined behavior (which probably results in stdout
    not being writable).

diff --git a/nohup.c b/nohup.c
index 2825c5d..5c1bf44 100644
--- a/nohup.c
+++ b/nohup.c
_AT_@ -31,7 +31,7 @@ main(int argc, char *argv[])
                 enprintf(127, "signal HUP:");
 
         if (isatty(STDOUT_FILENO)) {
- if ((fd = open("nohup.out", O_APPEND | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
+ if ((fd = open("nohup.out", O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
                         enprintf(127, "open nohup.out:");
                 if (dup2(fd, STDOUT_FILENO) < 0)
                         enprintf(127, "dup2:");
Received on Sun Oct 24 2021 - 01:19:11 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 24 2021 - 01:24:32 CEST