/[radius]/radius/radiusd/files.c
ViewVC logotype

Diff of /radius/radiusd/files.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.68 by gray, Tue Apr 29 13:57:59 2003 UTC revision 1.69 by gray, Wed Apr 30 08:38:30 2003 UTC
# Line 94  int user_find_db(char *name, RADIUS_REQ Line 94  int user_find_db(char *name, RADIUS_REQ
94  static MATCHING_RULE *file_read(int cf_file, char *name);  static MATCHING_RULE *file_read(int cf_file, char *name);
95    
96  int  int
97  comp_op(op, result)  comp_op(int op, int result)
         int op;  
         int result;  
98  {  {
99          switch (op) {          switch (op) {
100          default:          default:
# Line 141  comp_op(op, result) Line 139  comp_op(op, result)
139   * parser   * parser
140   */   */
141  int  int
142  add_user_entry(symtab, filename, line, name, check, reply)  add_user_entry(Symtab *symtab, char *filename, int line,
143          Symtab *symtab;                 char *name, VALUE_PAIR *check, VALUE_PAIR *reply)
         char *filename;  
         int line;  
         char *name;  
         VALUE_PAIR *check, *reply;  
144  {  {
145          User_symbol *sym;          User_symbol *sym;
146    
# Line 179  add_user_entry(symtab, filename, line, n Line 173  add_user_entry(symtab, filename, line, n
173  }  }
174    
175  static int  static int
176  free_user_entry(sym)  free_user_entry(User_symbol *sym)
         User_symbol *sym;  
177  {  {
178          avl_free(sym->check);          avl_free(sym->check);
179          avl_free(sym->reply);          avl_free(sym->reply);
# Line 194  struct temp_list { Line 187  struct temp_list {
187  };  };
188    
189  int  int
190  add_pairlist(closure, filename, line, name, lhs, rhs)  add_pairlist(struct temp_list *closure, char *filename, int line,
191          struct temp_list *closure;               char *name, VALUE_PAIR *lhs, VALUE_PAIR *rhs)
         char *filename;  
         int line;  
         char *name;  
         VALUE_PAIR *lhs, *rhs;  
192  {  {
193          MATCHING_RULE *pl;          MATCHING_RULE *pl;
194                    
# Line 229  add_pairlist(closure, filename, line, na Line 218  add_pairlist(closure, filename, line, na
218  }  }
219    
220  int  int
221  read_users(name)  read_users(char *name)
         char *name;  
222  {  {
223          if (!user_tab)          if (!user_tab)
224                  user_tab = symtab_create(sizeof(User_symbol), free_user_entry);                  user_tab = symtab_create(sizeof(User_symbol), free_user_entry);
# Line 238  read_users(name) Line 226  read_users(name)
226  }  }
227    
228  MATCHING_RULE *  MATCHING_RULE *
229  file_read(cf_file, name)  file_read(int cf_file, char *name)
         int cf_file;  
         char *name;  
230  {  {
231          struct temp_list tmp;          struct temp_list tmp;
232    
# Line 270  static User_symbol * user_next(USER_LOOK Line 256  static User_symbol * user_next(USER_LOOK
256   * Hash lookup   * Hash lookup
257   */   */
258  User_symbol *  User_symbol *
259  user_lookup(name, lptr)  user_lookup(char *name, USER_LOOKUP *lptr)
         char *name;  
         USER_LOOKUP *lptr;  
260  {  {
261          lptr->name = name;          lptr->name = name;
262          lptr->state = LU_begin;          lptr->state = LU_begin;
# Line 281  user_lookup(name, lptr) Line 265  user_lookup(name, lptr)
265  }  }
266    
267  User_symbol *  User_symbol *
268  user_next(lptr)  user_next(USER_LOOKUP *lptr)
         USER_LOOKUP *lptr;  
269  {  {
270          if (lptr->sym && (lptr->sym = sym_next((Symbol*)lptr->sym)))          if (lptr->sym && (lptr->sym = sym_next((Symbol*)lptr->sym)))
271                  return lptr->sym;                  return lptr->sym;
# Line 314  static int match_user(User_symbol *sym, Line 297  static int match_user(User_symbol *sym,
297   * Find matching profile in the hash table   * Find matching profile in the hash table
298   */   */
299  int  int
300  user_find_sym(name, req, check_pairs, reply_pairs)  user_find_sym(char *name, RADIUS_REQ *req,
301          char       *name;                VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs)
         RADIUS_REQ *req;  
         VALUE_PAIR **check_pairs;  
         VALUE_PAIR **reply_pairs;  
302  {  {
303          int found = 0;          int found = 0;
304          User_symbol *sym;          User_symbol *sym;
# Line 339  user_find_sym(name, req, check_pairs, re Line 319  user_find_sym(name, req, check_pairs, re
319  }  }
320    
321  int  int
322  match_user(sym, req, check_pairs, reply_pairs)  match_user(User_symbol *sym, RADIUS_REQ *req,
323          User_symbol *sym;             VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs)
         RADIUS_REQ *req;  
         VALUE_PAIR **check_pairs;  
         VALUE_PAIR **reply_pairs;  
324  {  {
325          VALUE_PAIR *p;          VALUE_PAIR *p;
326          VALUE_PAIR *check_tmp;          VALUE_PAIR *check_tmp;
# Line 412  match_user(sym, req, check_pairs, reply_ Line 389  match_user(sym, req, check_pairs, reply_
389   * is done by the caller. user_find() only compares attributes.   * is done by the caller. user_find() only compares attributes.
390   */   */
391  int  int
392  user_find(name, req, check_pairs, reply_pairs)  user_find(char *name, RADIUS_REQ *req,
393          char       *name;            VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs)
         RADIUS_REQ *req;  
         VALUE_PAIR **check_pairs;  
         VALUE_PAIR **reply_pairs;  
394  {  {
395          int             found = 0;          int found = 0;
396    
397          /*          /*
398           *      Check for valid input, zero length names not permitted           *      Check for valid input, zero length names not permitted
# Line 470  user_find(name, req, check_pairs, reply_ Line 444  user_find(name, req, check_pairs, reply_
444  /*  /*
445   * Obtain next token from the input string   * Obtain next token from the input string
446   */   */
 static int nextkn(char **sptr, char *token, int toksize);  
447    
448  int  static int
449  nextkn(sptr, token, toksize)  nextkn(char **sptr, char *token, int toksize)
         char **sptr;  
         char *token;  
         int toksize;  
450  {  {
451          char *start;          char *start;
452                    
# Line 539  nextkn(sptr, token, toksize) Line 509  nextkn(sptr, token, toksize)
509   * in errmsg.   * in errmsg.
510   */   */
511  int  int
512  userparse(buffer, first_pair, errmsg)  userparse(char *buffer, VALUE_PAIR **first_pair, char **errmsg)
         char *buffer;  
         VALUE_PAIR **first_pair;  
         char **errmsg;  
513  {  {
514          int             state;          int             state;
515          int             x;          int             x;
# Line 621  userparse(buffer, first_pair, errmsg) Line 588  userparse(buffer, first_pair, errmsg)
588   *      based on the pattern of the username.   *      based on the pattern of the username.
589   */   */
590  int  int
591  hints_setup(req)  hints_setup(RADIUS_REQ *req)
         RADIUS_REQ *req;  
592  {  {
593          VALUE_PAIR      *request_pairs = req->request;          VALUE_PAIR      *request_pairs = req->request;
594          char            newname[AUTH_STRING_LEN];          char            newname[AUTH_STRING_LEN];
# Line 753  hints_setup(req) Line 719  hints_setup(req)
719   * See if the huntgroup matches.   * See if the huntgroup matches.
720   */   */
721  int  int
722  huntgroup_match(req, huntgroup)  huntgroup_match(RADIUS_REQ *req, char *huntgroup)
         RADIUS_REQ *req;  
         char       *huntgroup;  
723  {  {
724          MATCHING_RULE *pl;          MATCHING_RULE *pl;
725                    
# Line 780  huntgroup_match(req, huntgroup) Line 744  huntgroup_match(req, huntgroup)
744   *         -1 on error.   *         -1 on error.
745   */   */
746  int  int
747  huntgroup_access(radreq)  huntgroup_access(RADIUS_REQ *radreq)
         RADIUS_REQ *radreq;  
748  {  {
749          VALUE_PAIR      *pair;          VALUE_PAIR      *pair;
750          MATCHING_RULE   *pl;          MATCHING_RULE   *pl;
# Line 818  huntgroup_access(radreq) Line 781  huntgroup_access(radreq)
781  }  }
782    
783  int  int
784  read_naslist_file(file)  read_naslist_file(char *file)
         char *file;  
785  {  {
786          int rc;          int rc;
787  #ifdef USE_SNMP  #ifdef USE_SNMP
# Line 982  read_nastypes_file(char *file) Line 944  read_nastypes_file(char *file)
944  }  }
945    
946  RADCK_TYPE *  RADCK_TYPE *
947  find_radck_type(name)  find_radck_type(char *name)
         char *name;  
948  {  {
949          RADCK_TYPE *tp;          RADCK_TYPE *tp;
950                    
# Line 1003  find_radck_type(name) Line 964  find_radck_type(name)
964   * parser   * parser
965   */   */
966  void  void
967  add_deny(user)  add_deny(char *user)
          char *user;  
968  {  {
969          sym_install(deny_tab, user);          sym_install(deny_tab, user);
970  }  }
971    
972  /*ARGSUSED*/  /*ARGSUSED*/
973  int  int
974  read_denylist_entry(denycnt, fc, fv, file, lineno)  read_denylist_entry(int *denycnt, int fc, char **fv, char *file, int lineno)
         int *denycnt;  
         int fc;  
         char **fv;  
         char *file;  
         int lineno;  
975  {  {
976          if (fc != 1) {          if (fc != 1) {
977                  radlog(L_ERR,                  radlog(L_ERR,
# Line 1061  read_deny_file() Line 1016  read_deny_file()
1016   * Return 1 if the given user should be denied access   * Return 1 if the given user should be denied access
1017   */   */
1018  int  int
1019  get_deny(user)  get_deny(char *user)
         char *user;  
1020  {  {
1021          return sym_lookup(deny_tab, user) != NULL;          return sym_lookup(deny_tab, user) != NULL;
1022  }  }
# Line 1076  get_deny(user) Line 1030  get_deny(user)
1030   *      See if a VALUE_PAIR list contains Fall-Through = Yes   *      See if a VALUE_PAIR list contains Fall-Through = Yes
1031   */   */
1032  int  int
1033  fallthrough(vp)  fallthrough(VALUE_PAIR *vp)
         VALUE_PAIR *vp;  
1034  {  {
1035          VALUE_PAIR *tmp;          VALUE_PAIR *tmp;
1036    
# Line 1088  fallthrough(vp) Line 1041  fallthrough(vp)
1041   *      Compare a portno with a range.   *      Compare a portno with a range.
1042   */   */
1043  int  int
1044  portcmp(check, request)  portcmp(VALUE_PAIR *check, VALUE_PAIR *request)
         VALUE_PAIR *check;  
         VALUE_PAIR *request;  
1045  {  {
1046          char buf[AUTH_STRING_LEN];          char buf[AUTH_STRING_LEN];
1047          char *s, *p, *save;          char *s, *p, *save;
# Line 1117  portcmp(check, request) Line 1068  portcmp(check, request)
1068    
1069    
1070  int  int
1071  uidcmp(check, username)  uidcmp(VALUE_PAIR *check, char *username)
         VALUE_PAIR *check;  
         char *username;  
1072  {  {
1073          struct passwd pw, *pwd;          struct passwd pw, *pwd;
1074          char buffer[512];          char buffer[512];
# Line 1135  uidcmp(check, username) Line 1084  uidcmp(check, username)
1084   *      We also handle additional groups.   *      We also handle additional groups.
1085   */   */
1086  int  int
1087  groupcmp(req, groupname, username)  groupcmp(RADIUS_REQ *req, char *groupname, char *username)
         RADIUS_REQ *req;  
         char *groupname;  
         char *username;  
1088  {  {
1089          struct passwd pw, *pwd;          struct passwd pw, *pwd;
1090          struct group gr, *grp;          struct group gr, *grp;
# Line 1172  groupcmp(req, groupname, username) Line 1118  groupcmp(req, groupname, username)
1118   *      Compare prefix/suffix.   *      Compare prefix/suffix.
1119   */   */
1120  int  int
1121  presufcmp(check, name, rest)  presufcmp(VALUE_PAIR *check, char *name, char *rest)
         VALUE_PAIR *check;  
         char *name;  
         char *rest;  
1122  {  {
1123          int len, namelen;          int len, namelen;
1124          int ret = -1;          int ret = -1;
# Line 1237  static int server_check_items[] = { Line 1180  static int server_check_items[] = {
1180  };  };
1181    
1182  int  int
1183  server_attr(attr)  server_attr(int attr)
         int attr;  
1184  {  {
1185          int i;          int i;
1186    
# Line 1253  server_attr(attr) Line 1195  server_attr(attr)
1195   * Return 0 on match.   * Return 0 on match.
1196   */   */
1197  int  int
1198  paircmp(request, check)  paircmp(RADIUS_REQ *request, VALUE_PAIR *check)
         RADIUS_REQ *request;  
         VALUE_PAIR *check;  
1199  {  {
1200          VALUE_PAIR *check_item = check;          VALUE_PAIR *check_item = check;
1201          VALUE_PAIR *auth_item;          VALUE_PAIR *auth_item;
# Line 1389  paircmp(request, check) Line 1329  paircmp(request, check)
1329   * Free a MATCHING_RULE   * Free a MATCHING_RULE
1330   */   */
1331  void  void
1332  matchrule_free(pl)  matchrule_free(MATCHING_RULE **pl)
         MATCHING_RULE **pl;  
1333  {  {
1334          MATCHING_RULE *p, *next;          MATCHING_RULE *p, *next;
1335    
# Line 1408  matchrule_free(pl) Line 1347  matchrule_free(pl)
1347  }  }
1348    
1349  int  int
1350  hints_pairmatch(pl, req, name, ret_name)  hints_pairmatch(MATCHING_RULE *pl, RADIUS_REQ *req, char *name, char *ret_name)
         MATCHING_RULE *pl;  
         RADIUS_REQ *req;  
         char *name;  
         char *ret_name;  
1351  {  {
1352          VALUE_PAIR *pair;          VALUE_PAIR *pair;
1353          char username[AUTH_STRING_LEN];          char username[AUTH_STRING_LEN];
# Line 1448  hints_pairmatch(pl, req, name, ret_name) Line 1383  hints_pairmatch(pl, req, name, ret_name)
1383   * a *very* restricted version  of wildmat   * a *very* restricted version  of wildmat
1384   */   */
1385  char *  char *
1386  wild_start(str)  wild_start(char *str)
         char *str;  
1387  {  {
1388          char *p;          char *p;
1389    
# Line 1472  wild_start(str) Line 1406  wild_start(str)
1406  }  }
1407    
1408  int  int
1409  match_any_chars(expr, name)  match_any_chars(char **expr, char **name)
         char **expr;  
         char **name;  
1410  {  {
1411          char *exprp, *expr_start, *p, *namep;          char *exprp, *expr_start, *p, *namep;
1412          int length;          int length;
# Line 1511  match_any_chars(expr, name) Line 1443  match_any_chars(expr, name)
1443  }  }
1444    
1445  int  int
1446  wild_match(expr, name, return_name)  wild_match(char *expr, char *name, char *return_name)
         char *expr;  
         char *name;  
         char *return_name;  
1447  {  {
1448          char *curp;          char *curp;
1449          char *start_pos, *end_pos;          char *start_pos, *end_pos;
# Line 1576  wild_match(expr, name, return_name) Line 1505  wild_match(expr, name, return_name)
1505   * Match a username with a wildcard expression.   * Match a username with a wildcard expression.
1506   */   */
1507  int  int
1508  matches(req, name, pl, matchpart)  matches(RADIUS_REQ *req, char *name, MATCHING_RULE *pl, char *matchpart)
         RADIUS_REQ *req;  
         char *name;  
         MATCHING_RULE *pl;  
         char *matchpart;  
1509  {  {
1510          if (strncmp(pl->name, "DEFAULT", 7) == 0 ||          if (strncmp(pl->name, "DEFAULT", 7) == 0 ||
1511              wild_match(pl->name, name, matchpart) == 0)              wild_match(pl->name, name, matchpart) == 0)
# Line 1596  matches(req, name, pl, matchpart) Line 1521  matches(req, name, pl, matchpart)
1521  /*  /*
1522   *      See if a potential DBM file is present.   *      See if a potential DBM file is present.
1523   */   */
1524  static int checkdbm(char *users, char *ext);  static int
1525    checkdbm(char *users, char *ext)
 int  
 checkdbm(users, ext)  
         char *users;  
         char *ext;  
1526  {  {
1527          char *buffer;          char *buffer;
1528          struct stat st;          struct stat st;
# Line 1618  checkdbm(users, ext) Line 1539  checkdbm(users, ext)
1539  static int reload_data(enum reload_what what, int *do_radck);  static int reload_data(enum reload_what what, int *do_radck);
1540    
1541  static int  static int
1542  realm_set_secret(srv)  realm_set_secret(RADIUS_SERVER *srv)
         RADIUS_SERVER *srv;  
1543  {  {
1544          CLIENT *client;          CLIENT *client;
1545    
# Line 1630  realm_set_secret(srv) Line 1550  realm_set_secret(srv)
1550  }  }
1551    
1552  int  int
1553  reload_data(what, do_radck)  reload_data(enum reload_what what, int *do_radck)
         enum reload_what what;  
         int *do_radck;  
1554  {  {
1555          char *path;          char *path;
1556          int   rc = 0;          int   rc = 0;
# Line 1770  reload_data(what, do_radck) Line 1688  reload_data(what, do_radck)
1688  }  }
1689    
1690  int  int
1691  reload_config_file(what)  reload_config_file(enum reload_what what)
         enum reload_what what;  
1692  {  {
1693          int do_radck;          int do_radck;
1694          int rc;          int rc;
# Line 1785  reload_config_file(what) Line 1702  reload_config_file(what)
1702  /* ****************************************************************************  /* ****************************************************************************
1703   * Debugging functions   * Debugging functions
1704   */   */
1705  static void dump_pair_list(FILE *fp, char *header, MATCHING_RULE *pl);  static void
1706    dump_pairs(FILE *fp, VALUE_PAIR *pair)
 void  
 dump_pairs(fp, pair)  
         FILE       *fp;  
         VALUE_PAIR *pair;  
1707  {  {
1708          int etype;          int etype;
1709                    
# Line 1848  dump_pairs(fp, pair) Line 1761  dump_pairs(fp, pair)
1761  }  }
1762    
1763  void  void
1764  dump_pair_list(fp, header, pl)  dump_pair_list(FILE *fp, char *header, MATCHING_RULE *pl)
         FILE      *fp;  
         char      *header;  
         MATCHING_RULE *pl;  
1765  {  {
1766          fprintf(fp, "%s {\n", header);          fprintf(fp, "%s {\n", header);
1767          for ( ; pl; pl = pl->next) {          for ( ; pl; pl = pl->next) {
# Line 1868  dump_pair_list(fp, header, pl) Line 1778  dump_pair_list(fp, header, pl)
1778  }  }
1779    
1780  int  int
1781  dump_user(fp, sym)  dump_user(FILE *fp, User_symbol *sym)
         FILE *fp;  
         User_symbol *sym;  
1782  {  {
1783          fprintf(fp, "\t%s:\n", sym->name);          fprintf(fp, "\t%s:\n", sym->name);
1784          fprintf(fp, "\tlhs {\n");          fprintf(fp, "\tlhs {\n");
# Line 1921  dump_users_db() Line 1829  dump_users_db()
1829   * Not 100% safe, since we don't compare attributes.   * Not 100% safe, since we don't compare attributes.
1830   */   */
1831  void  void
1832  presuf_setup(request_pairs)  presuf_setup(VALUE_PAIR *request_pairs)
         VALUE_PAIR *request_pairs;  
1833  {  {
1834          User_symbol *sym;          User_symbol *sym;
1835          USER_LOOKUP lu;          USER_LOOKUP lu;
# Line 1955  presuf_setup(request_pairs) Line 1862  presuf_setup(request_pairs)
1862  }  }
1863    
1864  void  void
1865  strip_username(do_strip, name, check_item, stripped_name)  strip_username(int do_strip, char *name, VALUE_PAIR *check_item,
1866          int         do_strip;                 char *stripped_name)
         char        *name;  
         VALUE_PAIR  *check_item;  
         char        *stripped_name;  
1867  {  {
1868          char tmpname[AUTH_STRING_LEN];          char tmpname[AUTH_STRING_LEN];
1869          char *source_ptr = name;          char *source_ptr = name;

Legend:
Removed from v.1.68  
changed lines
  Added in v.1.69

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26