httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject cvs commit: httpd-2.0/docs/man htpasswd.1
Date Wed, 14 May 2003 19:23:31 GMT
thommay     2003/05/14 12:23:30

  Modified:    .        CHANGES
               support  htpasswd.c
               docs/man htpasswd.1
  Log:
  Add a delete flag to htpasswd.
  
  Revision  Changes    Path
  1.1171    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1170
  retrieving revision 1.1171
  diff -u -r1.1170 -r1.1171
  --- CHANGES	14 May 2003 03:22:30 -0000	1.1170
  +++ CHANGES	14 May 2003 19:23:28 -0000	1.1171
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) Add a delete flag to htpasswd.
  +     [Thom May]
  +
     *) Ensure that ssl-std.conf is generated at configure time, and switch
        to using the expanded config variables to work the same as
        httpd-std.conf PR 19611
  
  
  
  1.70      +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.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- htpasswd.c	13 May 2003 03:40:29 -0000	1.69
  +++ htpasswd.c	14 May 2003 19:23:30 -0000	1.70
  @@ -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);
   
  
  
  
  1.11      +5 -2      httpd-2.0/docs/man/htpasswd.1
  
  Index: htpasswd.1
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/docs/man/htpasswd.1,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- htpasswd.1	13 May 2003 03:43:18 -0000	1.10
  +++ htpasswd.1	14 May 2003 19:23:30 -0000	1.11
  @@ -27,10 +27,10 @@
   .SH "SYNOPSIS"
    
   .PP
  -\fBhtpasswd\fR [ -\fBc\fR ] [ -\fBm\fR ] \fIpasswdfile\fR \fIusername\fR
  +\fBhtpasswd\fR [ -\fBc\fR ] [ -\fBm\fR ] [ -\fBD\fB ] \fIpasswdfile\fR \fIusername\fR
    
   .PP
  -\fBhtpasswd\fR -\fBb\fR [ -\fBc\fR ] [ -\fBm\fR | -\fBd\fR | -\fBp\fR | -\fBs\fR ] \fIpasswdfile\fR
\fIusername\fR \fIpassword\fR
  +\fBhtpasswd\fR -\fBb\fR [ -\fBc\fR ] [ -\fBm\fR | -\fBd\fR | -\fBp\fR | -\fBs\fR ] [ -\fBD\fB
] \fIpasswdfile\fR \fIusername\fR \fIpassword\fR
    
   .PP
   \fBhtpasswd\fR -\fBn\fR [ -\fBm\fR | -\fBd\fR | -\fBs\fR | -\fBp\fR ] \fIusername\fR
  @@ -79,6 +79,9 @@
   .TP
   -p
   Use plaintext passwords\&. Though htpasswd will support creation on all platforms,
the httpd daemon will only accept plain text passwords on Windows, Netware and TPF\&.
 
  +.TP
  +-D
  +Delete user\&. If the username exists in the specified htpasswd file, it will be deleted\&.
   .TP
   \fIpasswdfile\fR
   Name of the file to contain the user name and password\&. If -c is given, this file
is created if it does not already exist, or rewritten and truncated if it does exist\&.
 
  
  
  

Mime
View raw message