[systemd-devel] how to handle filesystems that do not support d_type in readdirs dirent?

Andrey Borzenkov arvidjaar at mail.ru
Thu Mar 3 07:24:10 PST 2011


On Thu, Mar 3, 2011 at 5:48 PM, Marius Tolzmann <tolzmann at molgen.mpg.de> wrote:
>
> hi..
>
> On 03/03/11 13:52, Andrey Borzenkov wrote:
>>>
>>> since reiserfs always sets d_type to DT_UNKNOWN in dirent entries some
>>> tools
>>> like systemd-tmpfiles do not work as expected.
>>
>> Hmm .. this could be the reason for my problem with utmp:
>

Yep, it is fixed with my patch that follows. Thank you!

>
> the question is: how to fix?
>
> why check for regular file/symlink at all when the destination of the
> symlink is not checked again..
>
> so there are (at least) to options to (quick) fix this:
>  - remove the whole check..
>  - add DT_UNKNOWN and may be in addition check for regular file using
>    some stat() before reading the config in systemd-tmpfiles..
>

Yes, good question. This looks more like optimization that security,
so we do not try to open at least obviously wrong file types. But of
course rogue link to something like /proc/ioports could be quite
interesting :)

> so there are (at least) to options to (quick) fix this:
>  - remove the whole check..
>  - add DT_UNKNOWN and may be in addition check for regular file using
>    some stat() before reading the config in systemd-tmpfiles..
>

If we are going to check for regular file, we should do it for DT_LNK as well.
The patch sent as follow-up does exactly this. Could you please test
if it fixes your issues (Tested-By is always good :) )


More information about the systemd-devel mailing list