From bf6d43a490ce791ece8df83554e46f9d1faabd99 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Fri, 11 May 2012 09:53:06 -0400 Subject: Properly handle file permissions for ini_parse_ut startup_test() --- ini/ini_parse_ut.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c index 6cab9d4..826cce0 100644 --- a/ini/ini_parse_ut.c +++ b/ini/ini_parse_ut.c @@ -634,7 +634,6 @@ int merge_section_test(void) int startup_test(void) { int error = EOK; - int error2 = EOK; struct ini_cfgfile *file_ctx = NULL; struct ini_cfgobj *ini_config = NULL; char **error_list = NULL; @@ -642,6 +641,9 @@ int startup_test(void) memcpy(filename, FOO_CONF, sizeof(FOO_CONF)); + /* Ensure that we start with the correct file mode */ + chmod(filename, 0664); + INIOUT(printf("<==== Startup test ====>\n")); /* Open config file */ @@ -685,22 +687,9 @@ int startup_test(void) 0); if (error) { - /* In case the repo is created by root the permission is different */ - error2 = ini_config_access_check( - file_ctx, - INI_ACCESS_CHECK_MODE, /* add uid & gui flags - * in real case - */ - 0, /* <- will be real uid in real case */ - 0, /* <- will be real gid in real case */ - 0644, /* Checkling for rw-r-r-- */ - 0); - if(error2) { - printf("Access check failed twice: %d %d!\n", error, error2); - ini_config_file_destroy(file_ctx); - return EACCES; - } - /* If this check passed we are OK! */ + printf("Access check failed: %d!\n", error); + ini_config_file_destroy(file_ctx); + return EACCES; } /* Create config object */ -- cgit