36 #include "asterisk/lock.h"
60 static const char app[] =
"Authenticate";
120 int res = 0, retries, maxdigits;
121 char passwd[256], *
prompt =
"agent-pass", *argcopy = NULL;
149 maxdigits = atoi(arglist.maxdigits);
150 if ((maxdigits<1) || (maxdigits>
sizeof(passwd)-2))
151 maxdigits =
sizeof(passwd) - 2;
153 maxdigits =
sizeof(passwd) - 2;
157 prompt = arglist.prompt;
159 prompt =
"agent-pass";
163 for (retries = 0; retries < 3; retries++) {
169 if (arglist.password[0] !=
'/') {
171 if (!strcmp(passwd, arglist.password))
176 if (!
ast_db_get(arglist.password + 1, passwd, tmp,
sizeof(tmp))) {
185 char buf[256] =
"", md5passwd[33] =
"", *md5secret = NULL;
187 if (!(f = fopen(arglist.password,
"r"))) {
198 if (!fgets(buf,
sizeof(buf), f)) {
205 len = strlen(buf) - 1;
206 if (buf[len] ==
'\n')
215 if (!strcmp(md5passwd, md5secret)) {
224 if (!strcmp(passwd, buf)) {
239 if (md5secret && !strcmp(md5passwd, md5secret))
242 if (!strcmp(passwd, buf))
247 prompt =
"auth-incorrect";
250 if ((retries < 3) && !res) {
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
char * strsep(char **str, const char *delims)
int ast_db_get(const char *family, const char *key, char *out, int outlen)
Get key value specified by family/key.
#define ast_test_flag(p, flag)
static struct ast_app_option auth_app_options[128]
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
static int auth_exec(struct ast_channel *chan, const char *data)
General Asterisk PBX channel definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Core PBX routines and definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
static int unload_module(void)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ast_channel_unlock(chan)
static int load_module(void)
Structure used to handle boolean flags.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_APP_ARG(name)
Define an application argument.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static struct ast_str * prompt
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistant data storage (akin to *doze registry)
const ast_string_field language
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.