]> granicus.if.org Git - apache/commitdiff
* support/htpasswd.c (main): Only check for readability if running in
authorJoe Orton <jorton@apache.org>
Fri, 20 Oct 2017 15:40:37 +0000 (15:40 +0000)
committerJoe Orton <jorton@apache.org>
Fri, 20 Oct 2017 15:40:37 +0000 (15:40 +0000)
  verify (-v) mode.

PR: 61631

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1812756 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/htpasswd.c

diff --git a/CHANGES b/CHANGES
index 3294bfc75e3a92ce7a0aa0284201f9a41981871b..704d38d587e6d19ec73d3a4127cb7ddf738a1576 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) htpasswd: Don't fail in -v mode if password file is unwritable.
+     PR 61631.  [Joe Orton]
+
   *) core: A signal received while stopping could have crashed the main
      process.  PR 61558.  [Yann Ylavic]
 
index 65a0b9c3bba90028e631c1cd27f8307cfabf448f..660a27c79275701c04770d25e2b4ebfd53191d98 100644 (file)
@@ -329,7 +329,7 @@ int main(int argc, const char * const argv[])
      */
     if (!(mask & APHTP_NOFILE)) {
         existing_file = exists(pwfilename, pool);
-        if (existing_file) {
+        if (existing_file && (mask & APHTP_VERIFY) == 0) {
             /*
              * Check that this existing file is readable and writable.
              */
@@ -339,6 +339,16 @@ int main(int argc, const char * const argv[])
                 exit(ERR_FILEPERM);
             }
         }
+        else if (existing_file && (mask & APHTP_VERIFY) != 0) {
+            /*
+             * Check that this existing file is readable.
+             */
+            if (!accessible(pool, pwfilename, APR_FOPEN_READ)) {
+                apr_file_printf(errfile, "%s: cannot open file %s for "
+                                "read access" NL, argv[0], pwfilename);
+                exit(ERR_FILEPERM);
+            }
+        }
         else {
             /*
              * Error out if -c was omitted for this non-existant file.