126{
127 int res = 0, retries, maxdigits;
128 char passwd[256], *
prompt =
"agent-pass", *argcopy =
NULL;
130
136 );
137
140 return -1;
141 }
142
145 return -1;
146 }
147
149
151
154
156 maxdigits = atoi(arglist.maxdigits);
157 if ((maxdigits<1) || (maxdigits>sizeof(passwd)-2))
158 maxdigits = sizeof(passwd) - 2;
159 } else {
160 maxdigits = sizeof(passwd) - 2;
161 }
162
165 } else {
167 }
168
169
170 for (retries = 0; retries < 3; retries++) {
172 break;
173
174 res = 0;
175
176 if (arglist.password[0] != '/') {
177
178 if (!strcmp(passwd, arglist.password))
179 break;
182
184
187 break;
188 }
189 } else {
190
191 FILE *f;
192 char buf[256] =
"", md5passwd[33] =
"", *md5secret =
NULL;
193
194 if (!(f = fopen(arglist.password, "r"))) {
196 continue;
197 }
198
199 for (;;) {
201
202 if (feof(f))
203 break;
204
205 if (!fgets(
buf,
sizeof(
buf), f)) {
206 continue;
207 }
208
210 continue;
211
215
219 if (!md5secret)
220 continue;
222 if (!strcmp(md5passwd, md5secret)) {
225 ast_channel_accountcode_set(chan,
buf);
227 }
228 break;
229 }
230 } else {
231 if (!strcmp(passwd,
buf)) {
234 ast_channel_accountcode_set(chan,
buf);
236 }
237 break;
238 }
239 }
240 }
241
242 fclose(f);
243
246 if (md5secret && !strcmp(md5passwd, md5secret))
247 break;
248 } else {
249 if (!strcmp(passwd,
buf))
250 break;
251 }
252 }
253 }
254 prompt =
"auth-incorrect";
255 }
256
257 if ((retries < 3) && !res) {
260 ast_channel_accountcode_set(chan, passwd);
262 }
265 } else {
268 res = -1;
269 }
270
271 return res;
272}
static const struct ast_app_option auth_app_options[128]
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
static struct ast_str * prompt
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_channel_lock(chan)
const char * ast_channel_language(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
#define ast_channel_unlock(chan)
ast_channel_state
ast_channel states
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_APP_ARG(name)
Define an application argument.
enum ast_getdata_result 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.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
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.
char * strsep(char **str, const char *delims)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Structure used to handle boolean flags.
#define ast_test_flag(p, flag)
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.