diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-03-31 19:49:32 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-14 12:15:54 -0400 |
commit | 693c44378b5a7b457b31f343730880dee8f271f3 (patch) | |
tree | 3c8c0d7d78f839f58531e73ce6794f6cae8ff4d9 /common | |
parent | 539881bc12a01e4307cd474a584c2e30c1c09d9c (diff) | |
download | sssd-693c44378b5a7b457b31f343730880dee8f271f3.tar.gz sssd-693c44378b5a7b457b31f343730880dee8f271f3.tar.bz2 sssd-693c44378b5a7b457b31f343730880dee8f271f3.zip |
Resolve paths for reporting purposes
Diffstat (limited to 'common')
-rw-r--r-- | common/ini/Makefile.am | 5 | ||||
-rw-r--r-- | common/ini/ini_config.c | 20 |
2 files changed, 21 insertions, 4 deletions
diff --git a/common/ini/Makefile.am b/common/ini/Makefile.am index 76205262..3d9115cd 100644 --- a/common/ini/Makefile.am +++ b/common/ini/Makefile.am @@ -39,14 +39,15 @@ libini_config_la_SOURCES = \ libini_config_la_LIBADD = \ -L$(topbuilddir)/collection \ - -lcollection + -lcollection \ + -lpath_utils libini_config_la_LDFLAGS = \ -version-info 2:0:0 # Build unit test check_PROGRAMS = ini_config_ut ini_config_ut_SOURCES = ini_config_ut.c -ini_config_ut_LDADD = libini_config.la -lcollection +ini_config_ut_LDADD = libini_config.la -lcollection -lpath_utils if HAVE_DOXYGEN docs: diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c index 76b456e6..66d2c03a 100644 --- a/common/ini/ini_config.c +++ b/common/ini/ini_config.c @@ -29,6 +29,7 @@ #include <locale.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include "config.h" /* For error text */ #include <libintl.h> @@ -39,6 +40,7 @@ #include "trace.h" #include "ini_config.h" #include "ini_metadata.h" +#include "path_utils.h" #define NAME_OVERHEAD 10 @@ -665,6 +667,8 @@ int config_from_fd_with_metadata(const char *application, int save_error = 0; int fd = -1; FILE *config_file = NULL; + int can_free = 0; + char abs_name[PATH_MAX + 1]; TRACE_FLOW_STRING("config_from_fd_with_metadata", "Entry"); @@ -716,13 +720,25 @@ int config_from_fd_with_metadata(const char *application, return file_error; } + /* Normalize path for reporting purposes */ + error = make_normalized_absolute_path(abs_name, + PATH_MAX, + config_filename); + if(error) { + TRACE_ERROR_NUMBER("Failed to resolve path", error); + fclose(config_file); + return error; + } + + /* Collect meta data before actually parsing the file */ error = collect_metadata(metaflags, metadata, config_file, - config_filename); + abs_name); if(error) { TRACE_ERROR_NUMBER("Failed to collect metadata", error); + fclose(config_file); return error; } @@ -730,7 +746,7 @@ int config_from_fd_with_metadata(const char *application, /* Parse data if needed */ error = config_with_metadata(application, config_file, - config_filename, + abs_name, ini_config, error_level, error_list, |