The meaning of non-file permission umask bits is implementation defined.
On Bionic libc, attempting to set them triggers a FORTIFY runtime check.

* src/nohup.c: (main) Avoid setting non-permission bits in umask, just
clear the bits we need to use.
---
On Android:

    $ nohup true
    FORTIFY: umask: called with invalid mask -601
    Aborted                    nohup true

See
https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r29-release/libc/bionic/fortify.cpp#400

 src/nohup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/nohup.c b/src/nohup.c
index d58fcc53f..933bd02ba 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -141,7 +141,8 @@ main (int argc, char **argv)
       char const *file = "nohup.out";
       int flags = O_CREAT | O_WRONLY | O_APPEND;
       mode_t mode = S_IRUSR | S_IWUSR;
-      mode_t umask_value = umask (~mode);
+      mode_t umask_value = umask (0);
+      umask (umask_value & ~mode);
       out_fd = (redirecting_stdout
                 ? fd_reopen (STDOUT_FILENO, file, flags, mode)
                 : open (file, flags, mode));
-- 
2.51.0


Reply via email to