bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 0.17: open-with-O_CREAT needs third argument


From: Chuck Swiger
Subject: Re: 0.17: open-with-O_CREAT needs third argument
Date: Wed, 7 Nov 2007 09:07:58 -0800

On Nov 7, 2007, at 3:44 AM, Bruno Haible wrote:
-         fd = open (filename, O_WRONLY | O_CREAT);
+         fd = open (filename, O_WRONLY | O_CREAT, 0600);
          if (fd < 0)
            {
              const char *errno_description = strerror (errno);

0666 is more appropriate here, IMO: It's not a temporary file, but a file whose name the user has specified on the command line. And I also forgot
O_TRUNC.

If you're creating a file on behalf of the user, I would expect it to receive permissions which reflect whatever umask(2) has been set to. Creating a world-writable file should be something that is done with caution (or never, depending on local opinions/policy with regard to security).

Regards,
--
-Chuck





reply via email to

[Prev in Thread] Current Thread [Next in Thread]