httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/support htpasswd.c
Date Tue, 20 May 2003 23:38:52 GMT
nd          2003/05/20 16:38:52

  Modified:    .        Tag: APACHE_2_0_BRANCH CHANGES STATUS
               support  Tag: APACHE_2_0_BRANCH htpasswd.c
  Log:
  backport Thom May's htpasswd patch to add a delete option
  
  Reviewed by: Brian Pane, Sander Striker, /me
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.988.2.105 +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.988.2.104
  retrieving revision 1.988.2.105
  diff -u -r1.988.2.104 -r1.988.2.105
  --- CHANGES	19 May 2003 02:25:18 -0000	1.988.2.104
  +++ CHANGES	20 May 2003 23:38:48 -0000	1.988.2.105
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.46
   
  +  *) Add a delete flag to htpasswd.
  +     [Thom May]
  +
     *) Fix mod_rewrite's handling of absolute URIs. The escaping routines
        now work scheme dependent and the query string will only be
        appended if supported by the particular scheme.  [André Malo]
  
  
  
  1.751.2.304 +1 -6      httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.751.2.303
  retrieving revision 1.751.2.304
  diff -u -r1.751.2.303 -r1.751.2.304
  --- STATUS	20 May 2003 23:28:14 -0000	1.751.2.303
  +++ STATUS	20 May 2003 23:38:50 -0000	1.751.2.304
  @@ -201,11 +201,6 @@
         modules/metadata/mod_mime_magic.c: r1.61
         +1: jerenkrantz, nd
   
  -    * htpasswd: add a delete flag.
  -      support/htpasswd.c: r1.70
  -      docs/manual/programs/htpasswd.xml r1.3
  -      +1: thommay, nd, brianp, striker
  -
       * Assure that we block on the read BIO when we invoke the read BIO for both
         first-use cases (via ssl_io_input_add_filter) and when we are writing and
         need response from the client (via ssl_io_filter_output).  Both of these
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.67.2.3  +46 -17    httpd-2.0/support/htpasswd.c
  
  Index: htpasswd.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/htpasswd.c,v
  retrieving revision 1.67.2.2
  retrieving revision 1.67.2.3
  diff -u -r1.67.2.2 -r1.67.2.3
  --- htpasswd.c	13 May 2003 17:18:39 -0000	1.67.2.2
  +++ htpasswd.c	20 May 2003 23:38:52 -0000	1.67.2.3
  @@ -139,6 +139,7 @@
   #define APHTP_NEWFILE        1
   #define APHTP_NOFILE         2
   #define APHTP_NONINTERACTIVE 4
  +#define APHTP_DELUSER        8
   
   apr_file_t *errfile;
   apr_file_t *ftemp = NULL;
  @@ -245,8 +246,8 @@
   static void usage(void)
   {
       apr_file_printf(errfile, "Usage:\n");
  -    apr_file_printf(errfile, "\thtpasswd [-cmdps] passwordfile username\n");
  -    apr_file_printf(errfile, "\thtpasswd -b[cmdps] passwordfile username "
  +    apr_file_printf(errfile, "\thtpasswd [-cmdpsD] passwordfile username\n");
  +    apr_file_printf(errfile, "\thtpasswd -b[cmdpsD] passwordfile username "
                       "password\n\n");
       apr_file_printf(errfile, "\thtpasswd -n[mdps] username\n");
       apr_file_printf(errfile, "\thtpasswd -nb[mdps] username password\n");
  @@ -267,6 +268,7 @@
       apr_file_printf(errfile, " -s  Force SHA encryption of the password.\n");
       apr_file_printf(errfile, " -b  Use the password from the command line "
               "rather than prompting for it.\n");
  +    apr_file_printf(errfile, " -D  Delete the specified user.\n");
       apr_file_printf(errfile,
               "On Windows, NetWare and TPF systems the '-m' flag is used by "
               "default.\n");
  @@ -359,6 +361,9 @@
                   *mask |= APHTP_NONINTERACTIVE;
                   args_left++;
               }
  +            else if (*arg == 'D') {
  +                *mask |= APHTP_DELUSER;
  +            }
               else {
                   usage();
               }
  @@ -369,6 +374,14 @@
           apr_file_printf(errfile, "%s: -c and -n options conflict\n", argv[0]);
           exit(ERR_SYNTAX);
       }
  +    if ((*mask & APHTP_NEWFILE) && (*mask & APHTP_DELUSER)) {
  +        apr_file_printf(errfile, "%s: -c and -D options conflict\n", argv[0]);
  +        exit(ERR_SYNTAX);
  +    }
  +    if ((*mask & APHTP_NOFILE) && (*mask & APHTP_DELUSER)) {
  +        apr_file_printf(errfile, "%s: -n and -D options conflict\n", argv[0]);
  +        exit(ERR_SYNTAX);
  +    }
       /*
        * Make sure we still have exactly the right number of arguments left
        * (the filename, the username, and possibly the password if -b was
  @@ -532,15 +545,17 @@
        * Any error message text is returned in the record buffer, since
        * the mkrecord() routine doesn't have access to argv[].
        */
  -    i = mkrecord(user, record, sizeof(record) - 1,
  -                 password, alg);
  -    if (i != 0) {
  -        apr_file_printf(errfile, "%s: %s\n", argv[0], record);
  -        exit(i);
  -    }
  -    if (mask & APHTP_NOFILE) {
  -        printf("%s\n", record);
  -        exit(0);
  +    if (!(mask & APHTP_DELUSER)) {
  +        i = mkrecord(user, record, sizeof(record) - 1,
  +                     password, alg);
  +        if (i != 0) {
  +            apr_file_printf(errfile, "%s: %s\n", argv[0], record);
  +            exit(i);
  +        }
  +        if (mask & APHTP_NOFILE) {
  +            printf("%s\n", record);
  +            exit(0);
  +        }
       }
   
       /*
  @@ -597,18 +612,32 @@
                   continue;
               }
               else {
  -                /* We found the user we were looking for, add him to the file.
  -                 */
  -                apr_file_printf(errfile, "Updating ");
  -                putline(ftemp, record);
  -                found++;
  +                if (!(mask & APHTP_DELUSER)) {
  +                    /* We found the user we were looking for.
  +                     * Add him to the file.
  +                    */
  +                    apr_file_printf(errfile, "Updating ");
  +                    putline(ftemp, record);
  +                    found++;
  +                }
  +                else {
  +                    /* We found the user we were looking for.
  +                     * Delete them from the file.
  +                     */
  +                    apr_file_printf(errfile, "Deleting ");
  +                    found++;
  +                }
               }
           }
           apr_file_close(fpw);
       }
  -    if (!found) {
  +    if (!found && !(mask & APHTP_DELUSER)) {
           apr_file_printf(errfile, "Adding ");
           putline(ftemp, record);
  +    }
  +    else if (!found && (mask & APHTP_DELUSER)) {
  +        apr_file_printf(errfile, "User %s not found\n", user);
  +        exit(0);
       }
       apr_file_printf(errfile, "password for user %s\n", user);
   
  
  
  

Mime
View raw message