[PATCH] Make dbus-uuidgen atomic
halfline at gmail.com
Fri Sep 3 10:24:55 PDT 2010
On Fri, Sep 3, 2010 at 12:15 PM, Colin Walters <walters at verbum.org> wrote:
> On Fri, Sep 3, 2010 at 11:59 AM, Ray Strode <halfline at gmail.com> wrote:
>> I think you want this to be 0644 right?
> Oh man, how do I suck so much...thanks for the patch review =)
>> 1) fchmod explicitly after the open
> Hmm, why wouldn't we trust open()?
Because open() doesn't use the value you pass in, it uses the value
you pass in ANDed wth the complement of the configured system umask.
I've come across bugs on a several occasions before where admins set
their umasks to be very restrictive and files ended up not being
readable when they should be.
Bottom line is, if something needs to be world readable you should
explicitly set it as such.
>> 2) check the permissions on the file on start up and make sure they're
>> right (and either fix them if they're wrong or error out)
> Seems like overkill to me...
Well, dbus-uuidgen --ensure is already doing a lot of checks on the
machine-id file. It actually loads the file (if it already exists)
and makes sure its the right format. If the file isn't the right
format it sets an error. If it's going to go to the trouble to make
sure the file is the right format, why shouldn't it also make sure the
file is right permissions.
More information about the dbus