summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-03-29 02:13:04 -0400
committerGreg Hudson <ghudson@mit.edu>2013-03-29 02:13:04 -0400
commite5a79ece676bdb8f9a3aef838ec8f5c5c848c368 (patch)
tree10f5db11cce00dc30c334ed636251e032c68aefe
parent61ab05d3b647971f2fc9481e7498176626a13707 (diff)
downloadkrb5-e5a79ece676bdb8f9a3aef838ec8f5c5c848c368.tar.gz
krb5-e5a79ece676bdb8f9a3aef838ec8f5c5c848c368.tar.xz
krb5-e5a79ece676bdb8f9a3aef838ec8f5c5c848c368.zip
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.
-rw-r--r--src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c21
1 files changed, 2 insertions, 19 deletions
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);