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

2011-03-03 Thread Marius Tolzmann


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:


it started with a missing utmp and i tracked it down to 
systemd-tempfiles not working at all on reiserfs..




in src/util.c:3905 DT_UNKNOWN is already included when checking file for
type DT_REG or DT_LNK.



Do not assume that everyone is having exactly the same sources as you
:) Either include exact commit number for reference, or better just
name function; they are mostly small enough.


oops.. sorry for that.. i thought i mentioned that i am using the 
systemd v19 sources from the official release..




since there seems to be no special handling for symlinks (e.g. checking the
type of the symlinks destionation) i just fixed scandir_filter to also
accept DT_UNKNOWN.

(other) places where DT_REG checks may fail on reiserfs or other fs that
don't support setting the correct type of file in d_type:

src/tty-ask-password-agent.c:510: if (de-d_type != DT_REG)
src/modules-load.c:45: if (d-d_type != DT_REG
src/tmpfiles.c:781: if (d-d_type != DT_REG

.. how is this supposed to be handled?


Care to provide a patch to include missing DT_UNKNOWN in all places? :)


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..

marius

--
Dipl.-Inf. Marius Tolzmann marius.tolzm...@molgen.mpg.de
--.--
MPI f. molekulare Genetik |
Ihnestrasse 63-73, D-14195 Berlin |   == MarIuX GNU/Linux ==
Phone: +49 (0)30 8413 1709|
--^--
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
   ..I will never die. by calvin from calvinhobbes ;)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-03-03 Thread Andrey Borzenkov
On Thu, Mar 3, 2011 at 5:48 PM, Marius Tolzmann tolzm...@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 :) )
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-03-03 Thread Lennart Poettering
On Thu, 03.03.11 13:05, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:

 
 hello..
 
 we are currently using reiserfs on our root-partition..

Urks, people still use that cruft?
 
 since reiserfs always sets d_type to DT_UNKNOWN in dirent entries
 some tools like systemd-tmpfiles do not work as expected.
 
 in src/util.c:3905 DT_UNKNOWN is already included when checking file
 for type DT_REG or DT_LNK.
 
 since there seems to be no special handling for symlinks (e.g.
 checking the type of the symlinks destionation) i just fixed
 scandir_filter to also accept DT_UNKNOWN.

Fixed this now the same way.

 (other) places where DT_REG checks may fail on reiserfs or other fs
 that don't support setting the correct type of file in d_type:
 
 src/tty-ask-password-agent.c:510: if (de-d_type != DT_REG)

Shouldn't be a problem since this directory is in /dev, which we require
to be tmpfs or devtmpfs, which supports d_type. I have now added a comment to
clarify this.

 src/modules-load.c:45: if (d-d_type != DT_REG 

Fixed this now, too.

 src/tmpfiles.c:781: if (d-d_type != DT_REG 

This is the spot you already mentioned above, right?

 .. how is this supposed to be handled? if the type of a symlinks
 destination isn't checked the whole check could be skipped at all?

The check is a good if we can do it cheaply, but if we cannot it should
be acceptable in all these case if we don't do it.

Please check current git (in particular 1a6f4df) if it covers all issues
you raised.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-03-03 Thread Marius Tolzmann

hi

On 03/03/11 16:30, Lennart Poettering wrote:

On Thu, 03.03.11 13:05, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:



hello..

we are currently using reiserfs on our root-partition..


Urks, people still use that cruft?


at least we do..


.. how is this supposed to be handled? if the type of a symlinks
destination isn't checked the whole check could be skipped at all?


The check is a good if we can do it cheaply, but if we cannot it should
be acceptable in all these case if we don't do it.

Please check current git (in particular 1a6f4df) if it covers all issues
you raised.


i will check this ASAP...

thx for your support..


marius..

--
Dipl.-Inf. Marius Tolzmann marius.tolzm...@molgen.mpg.de
--.--
MPI f. molekulare Genetik |
Ihnestrasse 63-73, D-14195 Berlin |   == MarIuX GNU/Linux ==
Phone: +49 (0)30 8413 1709|
--^--
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
   ..I will never die. by calvin from calvinhobbes ;)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel