h = h * 7907 + *username++;
}
return h%tablesize;
-}
+}
static void release_hash_table(struct hashtable * ht){
int i;
if (!ht) return;
- for (i=0; i<ht->tablesize; i++)
+ for (i=0; i<ht->tablesize; i++)
if (ht->table[i])
destroy_password(ht->table[i]);
if (ht->table) free(ht->table);
char *list;
char *nextlist=0;
int i;
-
+
ht = (struct hashtable *) rad_malloc(sizeof(struct hashtable));
if(!ht) {
return NULL;
free(hashentry);
continue;
}
-
+
if (islist) {
list = hashentry->field[keyfield];
for (nextlist = list; *nextlist && *nextlist!=','; nextlist++);
char buffer[1024];
int len;
char *list, *nextlist;
-
+
if (ht->tablesize > 0) {
/* get saved address of next item to check from buffer */
hashentry = ht->last_found;
if(!strcmp(list, name)) return passwd;
}
}
-
+
}
}
fclose(ht->fp);
{
int h;
struct mypasswd * hashentry;
-
+
if (!ht || !name || *name == '\0') return NULL;
ht->last_found = NULL;
if (ht->tablesize > 0) {
char *buffer;
struct mypasswd* pw;
int i;
-
+
ht = build_hash_table("/etc/group", 4, 3, 1, 100, 0, ":");
if(!ht) {
printf("Hash table not built\n");
static CONF_PARSER module_config[] = {
{ "filename", PW_TYPE_STRING_PTR,
- offsetof(struct passwd_instance, filename), NULL, NULL },
+ offsetof(struct passwd_instance, filename), NULL, NULL },
{ "format", PW_TYPE_STRING_PTR,
offsetof(struct passwd_instance, format), NULL, NULL },
{ "authtype", PW_TYPE_STRING_PTR,
#define inst ((struct passwd_instance *)*instance)
int nfields=0, keyfield=-1, listable=0;
char *s;
- char *lf=NULL; /* destination list flags temporary */
+ char *lf=NULL; /* destination list flags temporary */
int len;
int i;
DICT_ATTR * da;
-
+
*instance = rad_malloc(sizeof(struct passwd_instance));
if ( !*instance) {
radlog(L_ERR, "rlm_passwd: cann't alloc instance");
if(*(s+1) == ','){
listable = 1;
s++;
- }
+ }
if(*(s+1) == '='){
lf[nfields]=1;
s++;
radlog(L_ERR, "rlm_passwd: no field market as key in format: %s", inst->format);
return -1;
}
- if (! (inst->ht = build_hash_table (inst->filename, nfields, keyfield, listable, inst->hashsize, inst->ignorenislike, inst->delimiter)) ){
+ if (! (inst->ht = build_hash_table (inst->filename, nfields, keyfield, listable, inst->hashsize, inst->ignorenislike, inst->delimiter)) ){
radlog(L_ERR, "rlm_passwd: can't build hashtable from passwd file");
return -1;
}
release_ht(inst->ht);
return -1;
}
-
+
memcpy(inst->pwdfmt->listflag, lf, nfields);
free(lf);
inst->listable = listable;
radlog(L_INFO, "rlm_passwd: nfields: %d keyfield %d(%s) listable: %s", nfields, keyfield, inst->pwdfmt->field[keyfield], listable?"yes":"no");
return 0;
-
+
#undef inst
}
{
int i;
VALUE_PAIR *newpair;
-
+
for (i=0; i<inst->nfields; i++) {
if (inst->pwdfmt->field[i] && *inst->pwdfmt->field[i] && pw->field[i] && i != inst->keyfield && inst->pwdfmt->listflag[i] == when) {
if (! (newpair = pairmake (inst->pwdfmt->field[i], pw->field[i], T_OP_EQ))) {
VALUE_PAIR * key;
struct mypasswd * pw;
int found = 0;
-
+
if(!request || !request->packet ||!request->packet->vps)
return RLM_MODULE_INVALID;
for (key = request->packet->vps;
pairadd (&request->config_items, key);
}
return RLM_MODULE_OK;
-
+
#undef inst
}