/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "passwd_common.h"
#include "apr_strings.h"
#include "apr_errno.h"
#if APR_HAVE_STDIO_H
#include <stdio.h>
#endif
#include "apr_md5.h"
#include "apr_sha1.h"
#if APR_HAVE_TIME_H
#include <time.h>
#endif
#if APR_HAVE_CRYPT_H
#include <crypt.h>
#endif
#include <stdlib.h>
#endif
#include <string.h>
#endif
#include <unistd.h>
#endif
#if APR_HAVE_IO_H
#include <io.h>
#endif
#ifdef _MSC_VER
#endif
{
do {
break;
if (written > 0) {
}
abort();
/* NOTREACHED */
return 0;
}
{
static const char itoa64[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
apr_size_t n;
if (n > sizeof(rnd)) {
abort();
}
if (rv) {
&rv);
return ERR_RANDOM;
}
n = 0;
while (size > 0) {
if (bits < 6) {
bits += 8;
}
size--;
val >>= 6;
bits -= 6;
}
*s = '\0';
return 0;
}
{
if (f == NULL)
return;
rv = apr_file_puts(l, f);
if (rv != APR_SUCCESS) {
apr_file_close(f);
}
}
{
return ERR_GENERAL;
}
goto err_too_long;
}
}
}
goto err_too_long;
}
else {
goto err_too_long;
buf[0] = '\0';
return ERR_PWMISMATCH;
}
}
return 0;
return ERR_OVERFLOW;
}
/*
* Make a password record from the given information. A zero return
* indicates success; on failure, ctx->errstr points to the error message.
*/
{
char *pw;
int ret = 0;
char *cbuf;
#endif
"Warning: Ignoring -C argument for this algorithm." NL);
}
return ret;
}
case ALG_APSHA:
/* XXX out >= 28 + strlen(sha1) chars - fixed len SHA */
break;
case ALG_APMD5:
if (ret != 0)
break;
if (rv != APR_SUCCESS) {
"could not encode password: %pm", &rv);
ret = ERR_GENERAL;
}
break;
case ALG_PLAIN:
/* XXX this len limitation is not in sync with any HTTPd len. */
break;
case ALG_CRYPT:
if (ret != 0)
break;
break;
}
"characters by CRYPT algorithm." NL);
}
}
break;
#endif /* CRYPT_ALGO_SUPPORTED */
case ALG_BCRYPT:
if (rv != APR_SUCCESS) {
"bytes: %pm", &rv);
ret = ERR_RANDOM;
break;
}
if (rv != APR_SUCCESS) {
"bcrypt: %pm", &rv);
break;
}
break;
#endif /* BCRYPT_ALGO_SUPPORTED */
default:
abort();
}
return ret;
}
const char *opt_arg)
{
switch (opt) {
case 'b':
break;
case 'i':
break;
case 'm':
break;
case 's':
break;
case 'p':
#if !PLAIN_ALGO_SUPPORTED
/* Backward compatible behavior: Just print a warning */
"Warning: storing passwords as plain text might just "
"not work on this platform." NL);
#endif
break;
case 'd':
#else
/* Backward compatible behavior: Use MD5. OK since MD5 is more secure */
"Warning: CRYPT algorithm not supported on this "
"platform." NL
"Automatically using MD5 format." NL);
#endif
break;
case 'B':
#else
/* Don't fall back to something less secure */
return ERR_ALG_NOT_SUPP;
#endif
break;
case 'C': {
char *endptr;
return ERR_SYNTAX;
}
break;
}
default:
"parse_common_options(): BUG: invalid option %c",
opt);
abort();
}
return 0;
}