From adb9c9339f6689f9d29e6d931812f7c99da52ad3 Mon Sep 17 00:00:00 2001 From: octo Date: Thu, 22 Dec 2005 17:09:20 +0000 Subject: [PATCH] Fixed documentation in `configfile.h': s/Module/Plugin/ Moved an error message in `common.c'.. Moved the call to `check_create_dir' so it's run less frequently. --- configure.in | 2 +- src/common.c | 23 +++++++++++++---------- src/configfile.h | 2 +- src/plugin.c | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/configure.in b/configure.in index 976f9329..1ae7ec2a 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(collectd, 3.6.alpha0) +AC_INIT(collectd, 3.6.alpha1) AC_CONFIG_SRCDIR(src/collectd.c) AC_CONFIG_HEADERS(src/config.h) AM_INIT_AUTOMAKE(dist-bzip2) diff --git a/src/common.c b/src/common.c index db8fce1a..4d93f4aa 100644 --- a/src/common.c +++ b/src/common.c @@ -221,12 +221,6 @@ int check_create_dir (const char *file_orig) */ for (i = 0; i < (fields_num - last_is_file); i++) { - /* - * Join the components together again - */ - if (strjoin (dir, dir_len, fields, i + 1, "/") < 0) - return (-1); - /* * Do not create directories that start with a dot. This * prevents `../../' attacks and other likely malicious @@ -234,10 +228,19 @@ int check_create_dir (const char *file_orig) */ if (fields[i][0] == '.') { - syslog (LOG_ERR, "Cowardly refusing to create a directory that begins with a `.' (dot): `%s'", dir); + syslog (LOG_ERR, "Cowardly refusing to create a directory that begins with a `.' (dot): `%s'", file_orig); return (-2); } + /* + * Join the components together again + */ + if (strjoin (dir, dir_len, fields, i + 1, "/") < 0) + { + syslog (LOG_ERR, "strjoin failed: `%s', component #%i", file_orig, i); + return (-1); + } + if (stat (dir, &statbuf) == -1) { if (errno == ENOENT) @@ -271,6 +274,9 @@ int rrd_create_file (char *filename, char **ds_def, int ds_num) int i, j; int status = 0; + if (check_create_dir (filename)) + return (-1); + argc = ds_num + rra_num + 4; if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL) @@ -316,9 +322,6 @@ int rrd_update_file (char *host, char *file, char *values, /* host == NULL => local mode */ if (host != NULL) { - if (check_create_dir (host)) - return (-1); - if (snprintf (full_file, 1024, "%s/%s", host, file) >= 1024) return (-1); } diff --git a/src/configfile.h b/src/configfile.h index 0458360c..4f82eef1 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -37,7 +37,7 @@ void cf_unregister (char *type); * DESCRIPTION * `cf_register' is called by plugins that wish to receive config keys. The * plugin will then receive all keys it registered for if they're found in a - * `' section. + * `' section. * * PARAMETERS * `type' Name of the plugin (must be the same as passed to diff --git a/src/plugin.c b/src/plugin.c index abc08e57..98add242 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -292,7 +292,7 @@ void plugin_register (char *type, #ifdef HAVE_LIBRRD if ((operating_mode == MODE_LOCAL) || (operating_mode == MODE_CLIENT)) #endif - if (read == NULL) + if ((init != NULL) && (read == NULL)) syslog (LOG_NOTICE, "Plugin `%s' doesn't provide a read function.", type); if ((p = (plugin_t *) malloc (sizeof (plugin_t))) == NULL) -- 2.30.2