summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2002-09-14 16:43:24 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2002-09-14 16:43:24 +0000
commit5272c10e4f7727579ee52dc267af4c2d67c4a918 (patch)
tree9a24d8009446cce32d5f9ad3354d5ce73c9f930c /support
parent807087a5e22338064b4f83f318563307a7d50088 (diff)
downloadhttpd-5272c10e4f7727579ee52dc267af4c2d67c4a918.tar.gz
Move another non-exists test into the non-existing tests block, and
clean up the comments a bit more. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96810 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support')
-rw-r--r--support/htpasswd.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/support/htpasswd.c b/support/htpasswd.c
index e1917ef51a..4e1d03b2c3 100644
--- a/support/htpasswd.c
+++ b/support/htpasswd.c
@@ -497,25 +497,16 @@ int main(int argc, const char * const argv[])
"might just not work on this platform.\n");
}
#endif
+
+ /*
+ * Only do the file checks if we're supposed to frob it.
+ */
if (!(mask & APHTP_NOFILE)) {
existing_file = exists(pwfilename, pool);
- /*
- * Only do the file checks if we're supposed to frob it.
- *
- * Verify that the file exists if -c was omitted. We give a special
- * message if it doesn't.
- */
- if (!(mask & APHTP_NEWFILE) && !existing_file) {
- apr_file_printf(errfile,
- "%s: cannot modify file %s; use '-c' to create it\n",
- argv[0], pwfilename);
- exit(ERR_FILEPERM);
- }
- /*
- * If the file exists, check that it's readable and writable.
- * If it doesn't exist, verify that we can create it.
- */
if (existing_file) {
+ /*
+ * Check that this existing file is readable and writable.
+ */
if (!accessible(pool, pwfilename, APR_READ | APR_APPEND)) {
apr_file_printf(errfile, "%s: cannot open file %s for "
"read/write access\n", argv[0], pwfilename);
@@ -523,6 +514,18 @@ int main(int argc, const char * const argv[])
}
}
else {
+ /*
+ * Error out if -c was omitted for this non-existant file.
+ */
+ if (!(mask & APHTP_NEWFILE)) {
+ apr_file_printf(errfile,
+ "%s: cannot modify file %s; use '-c' to create it\n",
+ argv[0], pwfilename);
+ exit(ERR_FILEPERM);
+ }
+ /*
+ * As it doesn't exist yet, verify that we can create it.
+ */
if (!accessible(pool, pwfilename, APR_CREATE | APR_WRITE)) {
apr_file_printf(errfile, "%s: cannot create file %s\n",
argv[0], pwfilename);