[PATCH] Don't fail to create passwd and group files if /etc already exists

Sebastian Huber sebastian.huber at embedded-brains.de
Sun Feb 22 18:29:14 UTC 2015


On 21/02/15 21:34, Chris Johns wrote:
> On 20/02/2015 11:00 pm, Sebastian Huber wrote:
>>
>> On 20/02/15 12:18, Chris Johns wrote:
>>> On 20/02/2015 8:29 pm, Sebastian Huber wrote:
>>>>
>>>> On 20/02/15 10:06, Nick Withers wrote:
>>>>> On Fri, 2015-02-20 at 08:59 +0100, Sebastian Huber wrote:
>>>>>> >Hello Nick,
>>>>>> >
>>>>>> >thanks for the patch. I checked in a slightly different version 
>>>>>> which
>>>>>> >ignores the return status completely.
>>>>> Hi Sebastian,
>>>>>
>>>>> Your commit effectively reverts Joel's changes in
>>>>> https://git.rtems.org/rtems/commit/?id=3211e8e9c0565fae8b13ba0115e3a23ad3ae8ade 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Would chucking a (void) in front of the mkdir() shut Coverity up?
>>>>
>>>> Ok, I should have checked the commit history since I wondered why I
>>>> added this error check in the first place. Lets try a (void) cast.
>>>>
>>>
>>> What about doing a stat, create the directory if not present and then
>>> error on a mkdir failure ? There are other failures that could happen
>>> making a directory that we should correctly report.
>>
>> The stat approach is not thread safe.
>>
>> Its up to the users of the create files to do the error handling.
>>
>
> Maybe just check the error code for EEXIST and ignore it, plus the 
> call is protected by a posix init once variable so I am not sure I 
> follow this thread safe bit.
>
> Chris

The purpose of this function is to provide default passwd and group 
file. At this point it doesn't matter if this fails. Its up to the users 
of these files to decide what to do if they don't exist or have the 
wrong format. You can for example delete these files right after the 
pgdgrp_init() or unplug the network cable if you use NFS.

The stat() function is pretty worthless since after the check everything 
might have changed.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list