summaryrefslogtreecommitdiff
path: root/common/ini
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-04-10 13:39:06 -0400
committerSimo Sorce <ssorce@redhat.com>2009-04-10 17:01:54 -0400
commitb531c1872952c5f9a2a46d0a0dfe8dc63be470fd (patch)
tree648c6bddf432eeb156b4e211c161953adde97b6e /common/ini
parent24967bd826ad5437a11b1431c8289b1881b52a17 (diff)
downloadsssd-b531c1872952c5f9a2a46d0a0dfe8dc63be470fd.tar.gz
sssd-b531c1872952c5f9a2a46d0a0dfe8dc63be470fd.tar.bz2
sssd-b531c1872952c5f9a2a46d0a0dfe8dc63be470fd.zip
The lower level function now returns NOENT if file is not found.
Diffstat (limited to 'common/ini')
-rw-r--r--common/ini/ini_config.c8
-rw-r--r--common/ini/ini_config_ut.c6
2 files changed, 11 insertions, 3 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index 8d19b272..4112049f 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -145,7 +145,7 @@ static int ini_to_collection(const char *filename,
if (file == NULL) {
error = errno;
TRACE_ERROR_NUMBER("Failed to open file - but this is OK", error);
- return EOK;
+ return ENOENT;
}
/* Open the collection of errors */
@@ -416,7 +416,8 @@ int config_for_app(const char *application,
TRACE_INFO_STRING("Reading master file:", config_file);
error = ini_to_collection(config_file, *ini_config,
error_level, pass_common);
- if (error != EOK) {
+ /* ENOENT and EOK are Ok */
+ if (error && (error != ENOENT)) {
TRACE_ERROR_NUMBER("Failed to read master file", error);
/* In case of error when we created collection - delete it */
if(error && created) {
@@ -468,7 +469,8 @@ int config_for_app(const char *application,
error = ini_to_collection(file_name, *ini_config,
error_level, pass_specific);
free(file_name);
- if (error) {
+ /* ENOENT and EOK are Ok */
+ if (error && (error != ENOENT)) {
TRACE_ERROR_NUMBER("Failed to read specific application file", error);
/* In case of error when we created collection - delete it */
if (error && created) {
diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c
index 28560e54..6787c36c 100644
--- a/common/ini/ini_config_ut.c
+++ b/common/ini/ini_config_ut.c
@@ -61,6 +61,12 @@ int single_file()
struct collection_item *ini_config = (struct collection_item *)(NULL);
struct collection_item *error_set = (struct collection_item *)(NULL);
+ error = config_from_file("test", "./ini/not_exist_ini.conf", &ini_config,INI_STOP_ON_NONE,&error_set);
+ if(error) {
+ printf("Attempt to read configuration returned error: %d. EXPECTED.\n\n",error);
+ if(error != ENOENT) return error;
+ }
+
error = config_from_file("test", "./ini/ini.conf", &ini_config,INI_STOP_ON_NONE,&error_set);
if(error) {
printf("Attempt to read configuration returned error: %d\n",error);