[rrd-developers] [PATCH] RRD client should resolve all paths when talking to a unix socket.

Tobias Oetiker tobi at oetiker.ch
Fri May 28 06:56:28 CEST 2010


Hi Kevin,

Yesterday kevin brintnall wrote:

> This allows realpath() to resolve symbolic links, "..", etc.
>
> Reported by: Eduardo Bragatto <eduardo at bragatto.com>

thanks, its in.

cheers
tobi

> ---
>  src/rrd_client.c |   26 ++++++++++++--------------
>  1 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/src/rrd_client.c b/src/rrd_client.c
> index b895237..b3294f4 100644
> --- a/src/rrd_client.c
> +++ b/src/rrd_client.c
> @@ -77,26 +77,24 @@ static const char *get_path (const char *path, char *resolved_path) /* {{{ */
>        || (strncmp ("unix:", sd_path, strlen ("unix:")) == 0))
>      is_unix = 1;
>
> -  if (*path == '/') /* absolute path */
> +  if (is_unix)
>    {
> -    if (! is_unix)
> -    {
> -      rrd_set_error ("absolute path names not allowed when talking "
> -          "to a remote daemon");
> -      return (NULL);
> -    }
> -    /* else: nothing to do */
> +    ret = realpath(path, resolved_path);
> +    if (ret == NULL)
> +      rrd_set_error("realpath(%s): %s", path, rrd_strerror(errno));
> +    return ret;
>    }
> -  else /* relative path */
> +  else
>    {
> -    if (is_unix)
> +    if (*path == '/') /* not absolute path */
>      {
> -      realpath (path, resolved_path);
> -      ret = resolved_path;
> +      rrd_set_error ("absolute path names not allowed when talking "
> +          "to a remote daemon");
> +      return NULL;
>      }
> -    /* else: nothing to do */
>    }
> -  return (ret);
> +
> +  return path;
>  } /* }}} char *get_path */
>
>  static size_t strsplit (char *string, char **fields, size_t size) /* {{{ */
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-developers mailing list