25 RCSID(
"$Id: 14d77ebacbb50e0bd9f1deab397e21dc0822779d $")
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/rad_assert.h>
44 printf(
"Pair list: %s\n", pl->
name);
45 printf(
"** Check:\n");
51 printf(
"** Reply:\n");
72 #define FIND_MODE_NAME 0
73 #define FIND_MODE_WANT_REPLY 1
74 #define FIND_MODE_HAVE_REPLY 2
100 DEBUG2(
"reading pairlist file %s", file);
106 if ((fp = fopen(file,
"r")) == NULL) {
116 while (fgets(buffer,
sizeof(buffer), fp) != NULL) {
119 if (!feof(fp) && (strchr(buffer,
'\n') == NULL)) {
121 ERROR(
"%s[%d]: line too long", file, lineno);
131 while (isspace((
int) *ptr)) ptr++;
133 if (*ptr ==
'#' || *ptr ==
'\n' || !*ptr)
continue;
140 if (isspace((
int) buffer[0])) {
141 ERROR(
"%s[%d]: Entry does not begin with a user name",
151 getword(&ptr, entry,
sizeof(entry),
false);
152 entry_lineno = lineno;
159 while (isspace((
int) *ptr)) ptr++;
169 if (FR_DIR_IS_RELATIVE(ptr)) {
174 p = strrchr(newfile, FR_DIR_SEP);
176 p = newfile + strlen(newfile);
179 getword(&ptr, p + 1,
sizeof(newfile) - 1 - (p - newfile),
false);
181 getword(&ptr, newfile,
sizeof(newfile),
false);
188 ERROR(
"%s[%d]: Could not open included file %s: %s",
202 last = &((*last)->next);
214 ERROR(
"%s[%d]: Parse error (check) for entry %s: %s",
220 if (parsecode !=
T_EOL) {
222 talloc_free(check_tmp);
223 ERROR(
"%s[%d]: Invalid text after check attributes for entry %s",
224 file, lineno, entry);
240 talloc_free(check_tmp);
241 ERROR(
"%s[%d]: Cannot use regular expressions for non-string attributes in entry %s",
242 file, lineno, entry);
260 if (!isspace((
int) buffer[0]))
goto create_entry;
273 if (!isspace((
int) buffer[0])) {
276 talloc_free(check_tmp);
277 talloc_free(reply_tmp);
278 ERROR(
"%s[%d]: Invalid comma after the reply attributes. Please delete it.",
296 if (parsecode !=
T_EOL) {
298 talloc_free(check_tmp);
299 talloc_free(reply_tmp);
300 ERROR(
"%s[%d]: Parse error (reply) for entry %s: %s",
315 t->check = check_tmp;
316 t->reply = reply_tmp;
317 t->lineno = entry_lineno;
333 if (!isspace((
int) buffer[0]))
goto parse_again;
void pairlist_free(PAIR_LIST **pl)
void fr_pair_steal(TALLOC_CTX *ctx, VALUE_PAIR *vp)
Steal one VP.
VALUE_PAIR * fr_cursor_init(vp_cursor_t *cursor, VALUE_PAIR *const *node)
Setup a cursor to iterate over attribute pairs.
void fr_pair_fprint(FILE *, VALUE_PAIR const *vp)
Print one attribute and value to FP.
int pairlist_read(TALLOC_CTX *ctx, char const *file, PAIR_LIST **list, int complain)
Abstraction to allow iterating over different configurations of VALUE_PAIRs.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define FIND_MODE_WANT_REPLY
int getword(char const **ptr, char *buf, int buflen, bool unescape)
Stores an attribute, a value and various bits of other data.
#define FIND_MODE_HAVE_REPLY
FR_TOKEN op
Operator to use when moving or inserting valuepair into a list.
char const * fr_strerror(void)
Get the last library error.
int strcasecmp(char *s1, char *s2)
VALUE_PAIR * fr_cursor_next(vp_cursor_t *cursor)
Advanced the cursor to the next VALUE_PAIR.
size_t strlcpy(char *dst, char const *src, size_t siz)
fr_dict_attr_t const * da
Dictionary attribute defines the attribute.
String of printable characters.
FR_TOKEN fr_pair_list_afrom_str(TALLOC_CTX *ctx, char const *buffer, VALUE_PAIR **head)
Read one line of attribute/value pairs into a list.
char * talloc_typed_strdup(void const *t, char const *p)
Call talloc strdup, setting the type on the new chunk correctly.