[hackers] [sbase][PATCH] nohup: Open nohup.out WRONLY

From: Arthur Williams <taaparthur_AT_gmail.com>
Date: Fri, 3 Sep 2021 19:08:21 -0500

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).
---
 nohup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
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:");
-- 
2.32.0
Received on Sat Sep 04 2021 - 02:08:21 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 04 2021 - 19:24:31 CEST