From: Greg Hudson Date: Fri, 29 Mar 2013 06:13:04 +0000 (-0400) Subject: Simplify krb5_ldap_readpassword X-Git-Tag: krb5-1.12-alpha1~239 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5a79ece676bdb8f9a3aef838ec8f5c5c848c368;p=thirdparty%2Fkrb5.git Simplify krb5_ldap_readpassword There's no need to check whether the file exists and is readable before opening it, and setting an extended error message which is just strerror_r() of the errno value isn't useful. --- diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c index 9985a1b91c..9e32c2590b 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c @@ -97,26 +97,9 @@ krb5_ldap_readpassword(krb5_context context, krb5_ldap_context *ldap_context, # define strerror_r(ERRNUM, BUF, SIZE) (strncpy(BUF, strerror(ERRNUM), SIZE), BUF[(SIZE)-1] = 0) #endif - /* check whether file exists */ - if (access(file, F_OK) < 0) { + fptr = fopen(file, "r"); + if (fptr == NULL) { st = errno; - strerror_r(errno, errbuf, sizeof(errbuf)); - krb5_set_error_message (context, st, "%s", errbuf); - goto rp_exit; - } - - /* check read access */ - if (access(file, R_OK) < 0) { - st = errno; - strerror_r(errno, errbuf, sizeof(errbuf)); - krb5_set_error_message (context, st, "%s", errbuf); - goto rp_exit; - } - - if ((fptr=fopen(file, "r")) == NULL) { - st = errno; - strerror_r(errno, errbuf, sizeof(errbuf)); - krb5_set_error_message (context, st, "%s", errbuf); goto rp_exit; } set_cloexec_file(fptr);