krb5 commit: Simplify krb5_ldap_readpassword

Greg Hudson ghudson at MIT.EDU
Fri Mar 29 11:41:35 EDT 2013


https://github.com/krb5/krb5/commit/e5a79ece676bdb8f9a3aef838ec8f5c5c848c368
commit e5a79ece676bdb8f9a3aef838ec8f5c5c848c368
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Mar 29 02:13:04 2013 -0400

    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.

 .../kdb/ldap/libkdb_ldap/ldap_service_stash.c      |   21 +------------------
 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 9985a1b..9e32c25 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);


More information about the cvs-krb5 mailing list