diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-24 08:30:57 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-24 08:30:57 -0500 |
commit | c2c24bc5648d087b62b0bf54df3508c3bf433010 (patch) | |
tree | 59f3db2a96b725722943fcea35801e6de577a232 /lib | |
parent | f1e9ebd03738f21f69eb468968f7f8a5c0f2fcf7 (diff) | |
download | monitoring-plugins-c2c24bc5648d087b62b0bf54df3508c3bf433010.tar.gz |
Use access() instead of stat() in parse_ini.c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse_ini.c | 5 |
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); | |||
49 | static int add_option(FILE *f, np_arg_list **optlst); | 49 | static int add_option(FILE *f, np_arg_list **optlst); |
50 | /* internal function to find default file */ | 50 | /* internal function to find default file */ |
51 | static char* default_file(void); | 51 | static char* default_file(void); |
52 | /* internal function to stat() files */ | 52 | /* internal function to test files access */ |
53 | static int test_file(const char* env, int len, const char* file, char* temp_file); | 53 | static 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 | */ |
352 | static int test_file(const char* env, int len, const char* file, char* temp_file){ | 352 | static 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 | ||