From: oetiker Date: Fri, 28 May 2010 04:55:14 +0000 (+0000) Subject: [rrd_client.c] RRD client should resolve all paths when talking to a unix socket... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3f68f744a7c357577215126fc5ca059cd6baafd3;p=rrdtool.git [rrd_client.c] RRD client should resolve all paths when talking to a unix socket. This allows realpath() to resolve symbolic links, "..", etc. reported by: Eduardo Bragatto -- kevin brintnall git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4/program@2083 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_client.c b/src/rrd_client.c index 308965e..18dd0dd 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 */ /* One must hold `lock' when calling `close_connection'. */