/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
staticvoid htdbm_usage(void)
{
fprintf(stderr, "htdbm -- program for manipulating DBM password databases.\n\n" "Usage: htdbm [-cimBdpstvx] [-C cost] [-TDBTYPE] database username\n" " -b[cmBdptsv] [-C cost] [-TDBTYPE] database username password\n" " -n[imBdpst] [-C cost] username\n" " -nb[mBdpst] [-C cost] username password\n" " -v[imBdps] [-C cost] [-TDBTYPE] database username\n" " -vb[mBdps] [-C cost] [-TDBTYPE] database username password\n" " -x [-TDBTYPE] database username\n" " -l [-TDBTYPE] database\n" "Options:\n" " -c Create a new database.\n" " -n Don't update database; display results on stdout.\n" " -b Use the password from the command line rather than prompting for it.\n" " -i Read password from stdin without verification (for script usage).\n" " -m Force MD5 hashing of the password (default).\n" " -B Force BCRYPT hashing of the password (very secure).\n" " -C Set the computing time used for the bcrypt algorithm\n" " (higher is more secure but slower, default: %d, valid: 4 to 31).\n" " -d Force CRYPT hashing of the password (8 chars max, insecure).\n" " -s Force SHA hashing of the password (insecure).\n" " -p Do not hash the password (plaintext, insecure).\n" " -T DBM Type (SDBM|GDBM|DB|default).\n" " -l Display usernames from database on stdout.\n" " -v Verify the username/password.\n" " -x Remove the username record from database.\n" " -t The last param is username comment.\n" "The SHA algorithm does not use a salt and is less secure than the " "MD5 algorithm.\n",
BCRYPT_DEFAULT_COST); exit(ERR_SYNTAX);
}
int main(int argc, constchar * const argv[])
{
apr_pool_t *pool;
apr_status_t rv; char errbuf[MAX_STRING_LEN]; int need_file = 1; int need_user = 1; int need_pwd = 1; int need_cmnt = 0; int changed = 0; int cmd = HTDBM_MAKE; int i, ret, args_left = 2;
apr_getopt_t *state; char opt; constchar *opt_arg;
if (need_file) {
h->filename = apr_pstrdup(h->ctx.pool, argv[i++]); if ((rv = htdbm_open(h)) != APR_SUCCESS) {
fprintf(stderr, "Error opening database %s\n", h->filename);
apr_strerror(rv, errbuf, sizeof(errbuf));
fprintf(stderr,"%s\n",errbuf); exit(ERR_FILEPERM);
}
} if (need_user) {
h->username = apr_pstrdup(pool, argv[i++]); if (htdbm_valid_username(h) != APR_SUCCESS) exit(ERR_BADUSER);
} if (h->ctx.passwd_src == PW_ARG)
h->ctx.passwd = apr_pstrdup(pool, argv[i++]);
if (need_pwd) {
ret = get_password(&h->ctx); if (ret) {
fprintf(stderr, "Error: %s\n", h->ctx.errstr); exit(ret);
}
} if (need_cmnt)
h->comment = apr_pstrdup(pool, argv[i++]);
switch (cmd) { case HTDBM_VERIFY: if ((rv = htdbm_verify(h)) != APR_SUCCESS) { if (APR_STATUS_IS_ENOENT(rv)) {
fprintf(stderr, "The user '%s' could not be found in database\n", h->username); exit(ERR_BADUSER);
} else {
fprintf(stderr, "Password mismatch for user '%s'\n", h->username); exit(ERR_PWMISMATCH);
}
} else
fprintf(stderr, "Password validated for user '%s'\n", h->username); break; case HTDBM_DELETE: if (htdbm_del(h) != APR_SUCCESS) {
fprintf(stderr, "Cannot find user '%s' in database\n", h->username); exit(ERR_BADUSER);
}
h->username = NULL;
changed = 1; break; case HTDBM_LIST:
htdbm_list(h); break; default:
ret = htdbm_make(h); if (ret) exit(ret); break;
} if (need_file && !h->rdonly) { if ((rv = htdbm_save(h, &changed)) != APR_SUCCESS) {
apr_strerror(rv, errbuf, sizeof(errbuf)); exit(ERR_FILEPERM);
}
fprintf(stdout, "Database %s %s.\n", h->filename,
h->create ? "created" : (changed ? "modified" : "updated"));
} if (cmd == HTDBM_NOFILE) { if (!need_cmnt) {
fprintf(stderr, "%s:%s\n", h->username, h->ctx.passwd);
} else {
fprintf(stderr, "%s:%s:%s\n", h->username, h->ctx.passwd,
h->comment);
}
}
htdbm_terminate(h);
return0; /* Suppress compiler warning. */
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.12Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.