From: William A. Rowe Jr Date: Sat, 14 Sep 2002 16:43:24 +0000 (+0000) Subject: Move another non-exists test into the non-existing tests block, and X-Git-Tag: 2.0.42~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5272c10e4f7727579ee52dc267af4c2d67c4a918;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/support/htpasswd.c b/support/htpasswd.c index e1917ef51ac..4e1d03b2c39 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);