Code

patches: Added bts619123_mkdir_endless_loop_fix.
[pkg-collectd.git] / debian / patches / bts619123_mkdir_endless_loop_fix.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## bts619123_mkdir_endless_loop_fix.dpatch by Jonathan Nieder
3 ## <jrnieder@gmail.com>
4 ##
5 ## DP: common: check_create_dir(): Support symlinks as well.
6 ## DP:
7 ## DP: Previously, the following situation would cause an endless loop (as
8 ## DP: reported by Michael Prokop in Debian bug #619123): the (CSV or RRD)
9 ## DP: datadir is a symlink pointing to a non-existent target.
10 ## DP:
11 ## DP: With this patch applied, check_create_dir() fails with "<file> exists
12 ## DP: but is not a directory".
14 @DPATCH@
16 diff a/src/common.c b/src/common.c
17 --- a/src/common.c
18 +++ b/src/common.c
19 @@ -542,7 +542,8 @@ int check_create_dir (const char *file_orig)
20                 }
21  
22                 while (42) {
23 -                       if (stat (dir, &statbuf) == -1)
24 +                       if ((stat (dir, &statbuf) == -1)
25 +                                       && (lstat (dir, &statbuf) == -1))
26                         {
27                                 if (errno == ENOENT)
28                                 {