[monitoring-plugins] Use access() instead of stat() in parse_ini.c

Git Repository git at monitoring-plugins.org
Fri Jan 24 14:40:06 CET 2014


 Module: monitoring-plugins
 Branch: master
 Commit: c2c24bc5648d087b62b0bf54df3508c3bf433010
 Author: Thomas Guyot-Sionnest <dermoth at aei.ca>
   Date: Fri Jan 24 08:30:57 2014 -0500
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c2c24bc

Use access() instead of stat() in parse_ini.c

---

 lib/parse_ini.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index a1da503..05d6a02 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -49,7 +49,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts);
 static int add_option(FILE *f, np_arg_list **optlst);
 /* internal function to find default file */
 static char* default_file(void);
-/* internal function to stat() files */
+/* internal function to test files access */
 static int test_file(const char* env, int len, const char* file, char* temp_file);
 
 /* parse_locator decomposes a string of the form
@@ -350,7 +350,6 @@ static char* default_file(void){
  * existence. Returns 1 if found, 0 if not and -1 if test wasn't performed.
  */
 static int test_file(const char* env, int len, const char* file, char* temp_file){
-	struct stat sb;
 
 	/* test if len + filelen + '/' + '\0' fits in temp_file */
 	if((len+strlen(file)+2)>MAX_INPUT_BUFFER)	return -1;
@@ -360,7 +359,7 @@ static int test_file(const char* env, int len, const char* file, char* temp_file
 	strncat(temp_file,"/",len+1);
 	strncat(temp_file,file,len+strlen(file)+1);
 
-	if(stat(temp_file, &sb) != -1) return 1;
+	if(access(temp_file, F_OK) == 0) return 1;
 	return 0;
 }
 



More information about the Commits mailing list