--- htdbm.c 2011-09-23 14:41:11.000000000 +0000 +++ htdbm.c.new 2011-11-23 14:27:11.000000000 +0000 @@ -97,6 +97,11 @@ char *comment; char *type; int create; +#if 11 /*##++##*/ + int keep; + int allowcolon; + int writevalue; +#endif /*##++##*/ int rdonly; int alg; }; @@ -191,6 +196,9 @@ key.dptr = htdbm->username; key.dsize = strlen(htdbm->username); if (apr_dbm_exists(htdbm->dbm, key)) +#if 11 /*##++##*/ + if (htdbm->keep) return APR_EEXIST; else +#endif /*##++##*/ *changed = 1; val.dsize = strlen(htdbm->userpass); @@ -234,6 +242,9 @@ pwd = apr_pstrndup(htdbm->pool, rec, cmnt - rec); else pwd = apr_pstrdup(htdbm->pool, rec); +#if 11 /*##++##*/ + if (htdbm->writevalue) fwrite(val.dptr, 1, val.dsize, stdout); +#endif /*##++##*/ return apr_password_validate(htdbm->userpass, pwd); } @@ -331,6 +342,9 @@ fprintf(stderr, "Invalid username length\n"); return APR_EINVAL; } +#if 11 /*##++##*/ + if (!htdbm->allowcolon) +#endif /*##++##*/ if (strchr(htdbm->username, ':')) { fprintf(stderr, "Username contains invalid characters\n"); return APR_EINVAL; @@ -347,8 +361,13 @@ #define CRYPT_OPTION "" #endif fprintf(stderr, "htdbm -- program for manipulating DBM password databases.\n\n"); +#if 11 /*##++##*/ + fprintf(stderr, "Usage: htdbm [-ckam"CRYPT_OPTION"pstvwx] [-TDBTYPE] database username\n"); + fprintf(stderr, " -b[ckam"CRYPT_OPTION"ptsvw] [-TDBTYPE] database username password\n"); +#else /*##++##*/ fprintf(stderr, "Usage: htdbm [-cm"CRYPT_OPTION"pstvx] [-TDBTYPE] database username\n"); fprintf(stderr, " -b[cm"CRYPT_OPTION"ptsv] [-TDBTYPE] database username password\n"); +#endif /*##++##*/ 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] [-TDBTYPE] database username\n"); @@ -359,6 +378,11 @@ fprintf(stderr, " -b Use the password from the command line rather " "than prompting for it.\n"); fprintf(stderr, " -c Create a new database.\n"); +#if 11 /*##++##*/ + fprintf(stderr, " -w Write database value to stdout (when verifying).\n"); + fprintf(stderr, " -k Keep existing entries; only new entries may be added.\n"); + fprintf(stderr, " -a Allow colons in username.\n"); +#endif /*##++##*/ fprintf(stderr, " -n Don't update database; display results on stdout.\n"); fprintf(stderr, " -m Force MD5 encryption of the password (default).\n"); #if (!(defined(WIN32) || defined(TPF) || defined(NETWARE))) @@ -429,6 +453,17 @@ case 'c': h->create = 1; break; +#if 11 /*##++##*/ + case 'k': + h->keep = 1; + break; + case 'a': + h->allowcolon = 1; + break; + case 'w': + h->writevalue = 1; + break; +#endif /*##++##*/ case 'n': need_file = 0; cmd = HTDBM_NOFILE;