[rrd-developers] rrd_graph and flush behavior

Eduardo Bragatto eduardo at bragatto.com
Tue May 25 23:53:00 CEST 2010


On May 25, 2010, at 6:14 PM, Eduardo Bragatto wrote:

> On May 25, 2010, at 5:28 PM, kevin brintnall wrote:
>
>> The symbolic link should work.  Can you verify whether realpath(2)
>> on your system reports the correct path in the symlink case?  If
>> realpath(2) is right and the client is still not providing the right
>> file name, then there is definitely a problem.
>
> realpath(3) does work.
>
> I have used this little wrapper:
>
> http://yost.com/computers/compileAndGo/realpath.html
>
> And after compiling and running it, I do get the real path:
>
> # ./test_realpath /usr/local/rrd/stable-crm2/repository/manager.nbg/
> switches/whk2s1/10146.rrd
> /usr/local/rrd/stable-crm2/rrd/switches/whk2s1/10146.rrd
>
> However calling "rrd_graph" to read "/usr/local/rrd/stable-crm2/
> repository/manager.nbg/switches/whk2s1/10146.rrd" does not cause it to
> flush to disk.

Hi,

I have checked the code from rrd_client.c and indeed there was a  
problem there, starting on line #75 (rrdtool 1.4.3 stable):

   if (*path == '/') /* absolute path */
   {
     if (! is_unix)
     {
       rrd_set_error ("absolute path names not allowed when talking "
           "to a remote daemon");
       return (NULL);
     }
   }
   else /* relative path */
   {
     if (is_unix)
     {
       realpath (path, resolved_path);
       ret = resolved_path;
     }
     /* else: nothing to do */
   }
   return (ret);

As we can see there, realpath is only called if using relative paths.

realpath should also be called if it's an absolute path AND we are  
talking to a unix socket. Patching the code as follows has resolved  
the issue with symlinks:

   if (*path == '/') /* absolute path */
   {
     if (! is_unix)
     {
       rrd_set_error ("absolute path names not allowed when talking "
           "to a remote daemon");
       return (NULL);
     }
     /**** started adding here ***/
     else
     {
       realpath (path, resolved_path);
       ret = resolved_path;
     }
     /**** stopped adding here ***/
   }
   else /* relative path */
   {
     if (is_unix)
     {
       realpath (path, resolved_path);
       ret = resolved_path;
     }
     /* else: nothing to do */
   }

Thank you all for your assistance. I hope to see this fix in a future  
stable release.

- Eduardo Bragatto.



More information about the rrd-developers mailing list