]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Simplify krb5_ldap_readpassword
authorGreg Hudson <ghudson@mit.edu>
Fri, 29 Mar 2013 06:13:04 +0000 (02:13 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 29 Mar 2013 06:13:04 +0000 (02:13 -0400)
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.

src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c

index 9985a1b91c46f92dc8f7bbdb840ad585fda37cc9..9e32c2590bd850ddbd961538f7d1d1ad311ddb14 100644 (file)
@@ -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);