118 int res = 0, retries, maxdigits;
119 char passwd[256], *
prompt =
"agent-pass", *argcopy =
NULL;
147 maxdigits = atoi(arglist.maxdigits);
148 if ((maxdigits<1) || (maxdigits>
sizeof(passwd)-2))
149 maxdigits =
sizeof(passwd) - 2;
151 maxdigits =
sizeof(passwd) - 2;
155 prompt = arglist.prompt;
157 prompt =
"agent-pass";
161 for (retries = 0; retries < 3; retries++) {
167 if (arglist.password[0] !=
'/') {
169 if (!strcmp(passwd, arglist.password))
174 if (!
ast_db_get(arglist.password + 1, passwd, tmp,
sizeof(tmp))) {
183 char buf[256] =
"", md5passwd[33] =
"", *md5secret =
NULL;
185 if (!(f = fopen(arglist.password,
"r"))) {
196 if (!fgets(buf,
sizeof(buf), f)) {
203 len = strlen(buf) - 1;
204 if (buf[len] ==
'\n')
213 if (!strcmp(md5passwd, md5secret)) {
216 ast_channel_accountcode_set(chan, buf);
222 if (!strcmp(passwd, buf)) {
225 ast_channel_accountcode_set(chan, buf);
237 if (md5secret && !strcmp(md5passwd, md5secret))
240 if (!strcmp(passwd, buf))
245 prompt =
"auth-incorrect";
248 if ((retries < 3) && !res) {
251 ast_channel_accountcode_set(chan, passwd);
#define ast_channel_lock(chan)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
#define ast_test_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
ast_channel_state
ast_channel states
static struct ast_str * password
#define ast_strlen_zero(foo)
#define ast_strdupa(s)
duplicate a string in memory from the stack
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.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
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.
Structure used to handle boolean flags.
char * strsep(char **str, const char *delims)
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.
const char * ast_channel_language(const struct ast_channel *chan)
static struct ast_str * prompt
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
static const struct ast_app_option auth_app_options[128]