summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-24 08:30:57 -0500
committerThomas Guyot-Sionnest <dermoth@aei.ca>2014-01-24 08:30:57 -0500
commitc2c24bc5648d087b62b0bf54df3508c3bf433010 (patch)
tree59f3db2a96b725722943fcea35801e6de577a232
parentf1e9ebd03738f21f69eb468968f7f8a5c0f2fcf7 (diff)
downloadmonitoring-plugins-c2c24bc.tar.gz
Use access() instead of stat() in parse_ini.c
-rw-r--r--lib/parse_ini.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index a1da5038..05d6a023 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);
49static int add_option(FILE *f, np_arg_list **optlst); 49static int add_option(FILE *f, np_arg_list **optlst);
50/* internal function to find default file */ 50/* internal function to find default file */
51static char* default_file(void); 51static char* default_file(void);
52/* internal function to stat() files */ 52/* internal function to test files access */
53static int test_file(const char* env, int len, const char* file, char* temp_file); 53static int test_file(const char* env, int len, const char* file, char* temp_file);
54 54
55/* parse_locator decomposes a string of the form 55/* parse_locator decomposes a string of the form
@@ -350,7 +350,6 @@ static char* default_file(void){
350 * existence. Returns 1 if found, 0 if not and -1 if test wasn't performed. 350 * existence. Returns 1 if found, 0 if not and -1 if test wasn't performed.
351 */ 351 */
352static int test_file(const char* env, int len, const char* file, char* temp_file){ 352static int test_file(const char* env, int len, const char* file, char* temp_file){
353 struct stat sb;
354 353
355 /* test if len + filelen + '/' + '\0' fits in temp_file */ 354 /* test if len + filelen + '/' + '\0' fits in temp_file */
356 if((len+strlen(file)+2)>MAX_INPUT_BUFFER) return -1; 355 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
360 strncat(temp_file,"/",len+1); 359 strncat(temp_file,"/",len+1);
361 strncat(temp_file,file,len+strlen(file)+1); 360 strncat(temp_file,file,len+strlen(file)+1);
362 361
363 if(stat(temp_file, &sb) != -1) return 1; 362 if(access(temp_file, F_OK) == 0) return 1;
364 return 0; 363 return 0;
365} 364}
366 365