passwd_common.h revision d6fc66efa723db8b3ee5e9fd32579bed884e4e58
/* 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 "apr.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_errno.h"
#include "apr_file_io.h"
#include "apr_general.h"
#include "apr_version.h"
#define MAX_STRING_LEN 256
#define ALG_PLAIN 0
#define ALG_CRYPT 1
#define ALG_APMD5 2
#define ALG_APSHA 3
#define ERR_FILEPERM 1
#define ERR_SYNTAX 2
#define ERR_PWMISMATCH 3
#define ERR_INTERRUPTED 4
#define ERR_OVERFLOW 5
#define ERR_BADUSER 6
#define ERR_INVALID 7
#define ERR_RANDOM 8
#define ERR_GENERAL 9
#define ERR_ALG_NOT_SUPP 10
#define NL APR_EOL_STR
#define CRYPT_ALGO_SUPPORTED 0
#define PLAIN_ALGO_SUPPORTED 1
#else
#define CRYPT_ALGO_SUPPORTED 1
#define PLAIN_ALGO_SUPPORTED 0
#endif
/*
* Must be initialized with apr_file_open_stderr() before using any of the
* below functions.
*/
extern apr_file_t *errfile;
struct passwd_ctx {
const char *errstr;
char *out;
char *passwd;
int alg;
enum {
PW_PROMPT = 0,
} passwd_src;
};
/*
* Write a line to the file. On error, print a message and exit
*/
void putline(apr_file_t *f, const char *l);
/*
* The following functions return zero on success; otherwise, one of
* the ERR_* codes is returned and an error message is stored in ctx->errstr.
*/
/*
* Parse the algorithm specific options.
*/
/*
* Ask for password with verification.
*/
/*
* Make a password record from the given information.
*/