Re: [systemd-devel] [PATCH] sysv-generator: only allow regular files in enumerate_sysv()

2015-01-28 Thread Lennart Poettering
On Thu, 22.01.15 07:31, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:

 On Wed, Jan 14, 2015 at 02:51:41AM -0300, Cristian Rodríguez wrote:
  Otherwise, if the directory contains other directories we fail
  at fopen in load_sysv() with EISDIR.
  ---
   src/sysv-generator/sysv-generator.c | 6 --
   1 file changed, 4 insertions(+), 2 deletions(-)
  
  diff --git a/src/sysv-generator/sysv-generator.c 
  b/src/sysv-generator/sysv-generator.c
  index 2f24ef2..e15a16b 100644
  --- a/src/sysv-generator/sysv-generator.c
  +++ b/src/sysv-generator/sysv-generator.c
  @@ -727,8 +727,10 @@ static int enumerate_sysv(LookupPaths lp, Hashmap 
  *all_services) {
   _cleanup_free_ char *fpath = NULL, *name = NULL;
   int r;
   
  -if (hidden_file(de-d_name))
  -continue;
  +dirent_ensure_type(d, de);
  +
  +if (!dirent_is_file(de))
  +continue;
   
 Applied.

I reverted pretty much all of this again. There already was an
explicit S_ISREG() check in the loop. There's really no point in
checking the type of the files we enumerate multiple times.

Lennart

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


Re: [systemd-devel] [PATCH] sysv-generator: only allow regular files in enumerate_sysv()

2015-01-21 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Jan 14, 2015 at 02:51:41AM -0300, Cristian Rodríguez wrote:
 Otherwise, if the directory contains other directories we fail
 at fopen in load_sysv() with EISDIR.
 ---
  src/sysv-generator/sysv-generator.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/src/sysv-generator/sysv-generator.c 
 b/src/sysv-generator/sysv-generator.c
 index 2f24ef2..e15a16b 100644
 --- a/src/sysv-generator/sysv-generator.c
 +++ b/src/sysv-generator/sysv-generator.c
 @@ -727,8 +727,10 @@ static int enumerate_sysv(LookupPaths lp, Hashmap 
 *all_services) {
  _cleanup_free_ char *fpath = NULL, *name = NULL;
  int r;
  
 -if (hidden_file(de-d_name))
 -continue;
 +dirent_ensure_type(d, de);
 +
 +if (!dirent_is_file(de))
 +continue;
  
Applied.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sysv-generator: only allow regular files in enumerate_sysv()

2015-01-14 Thread Cristian Rodríguez

El 14/01/15 a las 10:39, Colin Guthrie escribió:

Cristian Rodríguez wrote on 14/01/15 13:34:

El 14/01/15 a las 09:21, Colin Guthrie escribió:

If I read the dirent_ensure_type and dirent_is_file code properly, this
would mean that symlinks to valid sysvinit scripts are now skipped.


dirent_is_file() returns true for symlinks.


Jeez, I really failed at reading the code today sorry for the noise!

(that said, as a general question what happens in dirent_is_file() if
there is a symlink to a directory?)

Col



The other way around in this case is to ignore EISDIR like ENOENT is 
ignored in load_sysv()

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sysv-generator: only allow regular files in enumerate_sysv()

2015-01-14 Thread Colin Guthrie
Cristian Rodríguez wrote on 14/01/15 13:34:
 El 14/01/15 a las 09:21, Colin Guthrie escribió:
 If I read the dirent_ensure_type and dirent_is_file code properly, this
 would mean that symlinks to valid sysvinit scripts are now skipped.
 
 dirent_is_file() returns true for symlinks.

Jeez, I really failed at reading the code today sorry for the noise!

(that said, as a general question what happens in dirent_is_file() if
there is a symlink to a directory?)

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] sysv-generator: only allow regular files in enumerate_sysv()

2015-01-13 Thread Cristian Rodríguez
Otherwise, if the directory contains other directories we fail
at fopen in load_sysv() with EISDIR.
---
 src/sysv-generator/sysv-generator.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/sysv-generator/sysv-generator.c 
b/src/sysv-generator/sysv-generator.c
index 2f24ef2..e15a16b 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -727,8 +727,10 @@ static int enumerate_sysv(LookupPaths lp, Hashmap 
*all_services) {
 _cleanup_free_ char *fpath = NULL, *name = NULL;
 int r;
 
-if (hidden_file(de-d_name))
-continue;
+dirent_ensure_type(d, de);
+
+if (!dirent_is_file(de))
+continue;
 
 fpath = strjoin(*path, /, de-d_name, NULL);
 if (!fpath)
-- 
2.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel