*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
- * Copyright 2000 The FreeRADIUS server project
+ * Copyright 2000,2006 The FreeRADIUS server project
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "autoconf.h"
-#include "radiusd.h"
-#include "modules.h"
+#include <freeradius-devel/ident.h>
+RCSID("$Id$")
+#include <freeradius-devel/radiusd.h>
+#include <freeradius-devel/modules.h>
struct mypasswd {
struct mypasswd *next;
static void release_hash_table(struct hashtable * ht){
int i;
- if (!ht) return;
- for (i=0; i<ht->tablesize; i++)
+ if (ht == NULL) return;
+ for (i = 0; i < ht->tablesize; i++)
if (ht->table[i])
destroy_password(ht->table[i]);
- if (ht->table) free(ht->table);
- if (ht->fp) fclose(ht->fp);
+ if (ht->table) {
+ free(ht->table);
+ ht->table = NULL;
+ }
+ if (ht->fp) {
+ fclose(ht->fp);
+ ht->fp = NULL;
+ }
+ ht->tablesize = 0;
}
static void release_ht(struct hashtable * ht){
if(*buffer && *buffer!='\n' && (!ignorenis || (*buffer != '+' && *buffer != '-')) ){
if(!(hashentry = mypasswd_malloc(buffer, nfields, &len))){
release_hash_table(ht);
- ht->tablesize = 0;
return ht;
}
len = string_to_entry(buffer, nfields, ht->delimiter, hashentry, len);
else nextlist = 0;
if(!(hashentry1 = mypasswd_malloc("", nfields, &len))){
release_hash_table(ht);
- ht->tablesize = 0;
return ht;
}
for (i=0; i<nfields; i++) hashentry1->field[i] = hashentry->field[i];
struct mypasswd *pwdfmt;
char *filename;
char *format;
- char *authtype;
char * delimiter;
int allowmultiple;
int ignorenislike;
};
static const CONF_PARSER module_config[] = {
- { "filename", PW_TYPE_STRING_PTR,
+ { "filename", PW_TYPE_FILENAME,
offsetof(struct passwd_instance, filename), NULL, NULL },
{ "format", PW_TYPE_STRING_PTR,
offsetof(struct passwd_instance, format), NULL, NULL },
- { "authtype", PW_TYPE_STRING_PTR,
- offsetof(struct passwd_instance, authtype), NULL, NULL },
{ "delimiter", PW_TYPE_STRING_PTR,
offsetof(struct passwd_instance, delimiter), NULL, ":" },
{ "ignorenislike", PW_TYPE_BOOLEAN,
static int passwd_detach (void *instance) {
#define inst ((struct passwd_instance *)instance)
if(inst->ht) release_ht(inst->ht);
- if (inst->filename != NULL) free(inst->filename);
- if (inst->format != NULL) free(inst->format);
- if (inst->authtype != NULL ) free(inst->authtype);
- if (inst->delimiter != NULL) free(inst->delimiter);
free(instance);
return 0;
#undef inst
name = buffer;
break;
default:
- name = key->strvalue;
+ name = key->vp_strvalue;
}
if (! (pw = get_pw_nam(name, inst->ht)) ) {
continue;
if(!found) {
return RLM_MODULE_NOTFOUND;
}
- if (inst->authtype &&
- (key = pairmake ("Auth-Type", inst->authtype, T_OP_EQ))) {
- DEBUG("rlm_passwd: Adding \"Auth-Type = %s\"",
- inst->authtype);
- /*
- * Don't call pairadd. pairmove doesn't
- * over-write existing attributes.
- */
- pairmove(&request->config_items, &key);
- pairfree(&key); /* pairmove may have NOT moved it */
- }
return RLM_MODULE_OK;
#undef inst
}
module_t rlm_passwd = {
+ RLM_MODULE_INIT,
"passwd",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialize */
passwd_instantiate, /* instantiation */
+ passwd_detach, /* detach */
{
NULL, /* authentication */
passwd_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- passwd_detach, /* detach */
- NULL /* destroy */
};
#endif /* TEST */