]> granicus.if.org Git - apache/commitdiff
Merge 1812756 from trunk:
authorRainer Jung <rjung@apache.org>
Thu, 15 Mar 2018 22:53:42 +0000 (22:53 +0000)
committerRainer Jung <rjung@apache.org>
Thu, 15 Mar 2018 22:53:42 +0000 (22:53 +0000)
htpasswd: Don't fail in -v mode if password file is unwritable.
PR 61631.

Submitted by: rjung
Reviewed by: rjung, ylavic, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1826887 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
support/htpasswd.c

diff --git a/CHANGES b/CHANGES
index 51bc9948bce4d67d68c6b2d63ef41112922802c2..020215dd233eef23a7d4a554d79e11cabf7454ac 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.33
 
+  *) htpasswd: Don't fail in -v mode if password file is unwritable.
+     PR 61631.  [Joe Orton]
+
   *) htpasswd: don't point to (unused) stack memory on output
      to make static analysers happy.  PR 60634.
      [Yann Ylavic, reported by shqking and Zhenwei Zou]
diff --git a/STATUS b/STATUS
index dc5786401160ea10b5da5525d2a8375ba49521ad..67c46203da89d8beb95819b71ea670fe7f14794c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -126,13 +126,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      2.4.x patch: svn merge -c 1826686 ^/httpd/httpd/trunk .
      +1: jailletc36, ylavic, covener
 
-  *) htpasswd: Don't fail in -v mode if password file is unwritable.
-     PR 61631.
-     This brings 2.4.x htpasswd in sync with trunk.
-     trunk patch: http://svn.apache.org/r1812756
-     2.4.x patch: svn merge -c 1812756 ^/httpd/httpd/trunk .
-     +1: rjung, ylavic, covener
-
   *) htpasswd/htdbm: report the right limit when get_password() overflows.
      This brings 2.4.x passwd_common.c in sync with trunk.
      trunk patch: http://svn.apache.org/r1781516
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.