1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "apr_strings.h"
20 #include "apr_errno.h"
21 #include "apr_file_io.h"
22 #include "apr_general.h"
23 #include "apr_version.h"
24 #if !APR_VERSION_AT_LEAST(2,0,0)
25 #include "apu_version.h"
28 #define MAX_STRING_LEN 256
36 #define BCRYPT_DEFAULT_COST 5
38 #define ERR_FILEPERM 1
40 #define ERR_PWMISMATCH 3
41 #define ERR_INTERRUPTED 4
42 #define ERR_OVERFLOW 5
47 #define ERR_ALG_NOT_SUPP 10
49 #define NL APR_EOL_STR
51 #if defined(WIN32) || defined(NETWARE)
52 #define CRYPT_ALGO_SUPPORTED 0
53 #define PLAIN_ALGO_SUPPORTED 1
55 #define CRYPT_ALGO_SUPPORTED 1
56 #define PLAIN_ALGO_SUPPORTED 0
59 #if APR_VERSION_AT_LEAST(2,0,0) || \
60 (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 5)
61 #define BCRYPT_ALGO_SUPPORTED 1
63 #define BCRYPT_ALGO_SUPPORTED 0
67 * Must be initialized with apr_file_open_stderr() before using any of the
70 extern apr_file_t *errfile;
90 * To be used as apr_pool_abort_fn
92 int abort_on_oom(int rc);
95 * Write a line to the file. On error, print a message and exit
97 void putline(apr_file_t *f, const char *l);
100 * The following functions return zero on success; otherwise, one of
101 * the ERR_* codes is returned and an error message is stored in ctx->errstr.
105 * Parse the algorithm specific options.
107 int parse_common_options(struct passwd_ctx *ctx, char opt, const char *opt_arg);
110 * Ask for password with verification.
112 int get_password(struct passwd_ctx *ctx);
115 * Make a password record from the given information.
117 int mkhash(struct passwd_ctx *ctx);