httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject cvs commit: httpd-2.0/support htdbm.c
Date Mon, 24 Dec 2001 07:05:19 GMT
ianh        01/12/23 23:05:19

  Modified:    .        CHANGES
               support  htdbm.c
  Log:
  allow htdbm to work with multiple DBM types by using a new option
  '-T'
  
  ps..
  why doesn't this program use apr_getopt??
  
  Revision  Changes    Path
  1.483     +1 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.482
  retrieving revision 1.483
  diff -u -r1.482 -r1.483
  --- CHANGES	2001/12/23 14:22:36	1.482
  +++ CHANGES	2001/12/24 07:05:18	1.483
  @@ -1,4 +1,5 @@
   Changes with Apache 2.0.30-dev
  +  *) Allow htdbm to work with multiple DBM types [Ian Holsman]
   
     *) Win32: Made change to apr_sendfile() to return APR_ENOTIMPL
        if oslevel < WINNT.  This should fix several problems reported
  
  
  
  1.4       +20 -10    httpd-2.0/support/htdbm.c
  
  Index: htdbm.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/htdbm.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- htdbm.c	2001/11/06 21:11:45	1.3
  +++ htdbm.c	2001/12/24 07:05:19	1.4
  @@ -133,6 +133,7 @@
       char                    *username;
       char                    *userpass;
       char                    *comment;
  +    char                    *type;
       int                     create;
       int                     rdonly;
       int                     alg;
  @@ -198,16 +199,17 @@
   
       /* Set MD5 as default */
       (*hdbm)->alg = ALG_APMD5;
  +    (*hdbm)->type = "default";
       return APR_SUCCESS;
   }
   
   static apr_status_t htdbm_open(htdbm_t *htdbm) 
   {
       if (htdbm->create)
  -        return apr_dbm_open(&htdbm->dbm, htdbm->filename, APR_DBM_RWCREATE, 
  +        return apr_dbm_open_ex(&htdbm->dbm, htdbm->type, htdbm->filename,
APR_DBM_RWCREATE, 
                               APR_OS_DEFAULT, htdbm->pool);
       else
  -        return apr_dbm_open(&htdbm->dbm, htdbm->filename, 
  +        return apr_dbm_open_ex(&htdbm->dbm, htdbm->type, htdbm->filename,

                               htdbm->rdonly ? APR_DBM_READONLY : APR_DBM_READWRITE, 
                               APR_OS_DEFAULT, htdbm->pool);
   }
  @@ -399,14 +401,14 @@
   #define CRYPT_OPTION ""
   #endif
       fprintf(stderr, "htdbm -- program for manipulating DBM password databases.\n\n");
  -    fprintf(stderr, "Usage: htdbm    [-cm"CRYPT_OPTION"pstvx] database username\n");
  -    fprintf(stderr, "                -b[cm"CRYPT_OPTION"ptsv] database username password\n");
  +    fprintf(stderr, "Usage: htdbm    [-cm"CRYPT_OPTION"pstvx] [-TDBTYPE] database username\n");
  +    fprintf(stderr, "                -b[cm"CRYPT_OPTION"ptsv] [-TDBTYPE] database username
password\n");
       fprintf(stderr, "                -n[m"CRYPT_OPTION"pst]   username\n");
       fprintf(stderr, "                -nb[m"CRYPT_OPTION"pst]  username password\n");
  -    fprintf(stderr, "                -v[m"CRYPT_OPTION"ps]    database username\n");
  -    fprintf(stderr, "                -vb[m"CRYPT_OPTION"ps]   database username password\n");
  -    fprintf(stderr, "                -x[m"CRYPT_OPTION"ps]    database username\n");
  -    fprintf(stderr, "                -l                       database\n");
  +    fprintf(stderr, "                -v[m"CRYPT_OPTION"ps]    [-TDBTYPE] database username\n");
  +    fprintf(stderr, "                -vb[m"CRYPT_OPTION"ps]   [-TDBTYPE] database username
password\n");
  +    fprintf(stderr, "                -x[m"CRYPT_OPTION"ps]    [-TDBTYPE] database username\n");
  +    fprintf(stderr, "                -l                       [-TDBTYPE] database\n");
       fprintf(stderr, "Options:\n");
       fprintf(stderr, "   -b   Use the password from the command line rather"
                       "than prompting for it.\n");
  @@ -418,6 +420,7 @@
   #endif
       fprintf(stderr, "   -p   Do not encrypt the password (plaintext).\n");
       fprintf(stderr, "   -s   Force SHA encryption of the password.\n");
  +    fprintf(stderr, "   -T   DBM Type (SDBM|GDBM|DB|default).\n");
       fprintf(stderr, "   -l   Display usernames from database on stdout.\n");
       fprintf(stderr, "   -t   The last param is username comment.\n");
       fprintf(stderr, "   -v   Verify the username/password.\n");
  @@ -493,6 +496,12 @@
                   need_cmnt = 1;
                   args_left++;
                   break;
  +            case 'T':
  +                h->type = apr_pstrdup(h->pool, ++arg);
  +                while (*arg !='\0')
  +                    *++arg;
  +                *--arg; /* so incrementing this in the loop with find a null */
  +                break;
               case 'v':
                   h->rdonly = 1;
                   cmd = HTDBM_VERIFY;
  @@ -533,9 +542,10 @@
           i--;
       else {
           h->filename = apr_pstrdup(h->pool, argv[i]);
  -        if ((rv = htdbm_open(h)) != APR_SUCCESS) {
  -            fprintf(stderr, "Error oppening database %s\n", argv[i]);
  +            if ((rv = htdbm_open(h)) != APR_SUCCESS) {
  +            fprintf(stderr, "Error opening database %s\n", argv[i]);
               apr_strerror(rv, errbuf, sizeof(errbuf));
  +            fprintf(stderr,"%s\n",errbuf);
               exit(ERR_FILEPERM);
           }
       }
  
  
  

Mime
View raw message