2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 struct authmech *mechs = NULL;
32 static int authless_inithandle(struct authhandle *auth, char *username)
37 static void authless_release(struct authhandle *auth)
41 static int authless_authenticate(struct authhandle *auth, char *data)
46 static int authless_succeed_1param(struct authhandle *auth)
51 static struct authmech authless =
54 .inithandle = authless_inithandle,
55 .release = authless_release,
56 .authenticate = authless_authenticate,
57 .renewcred = authless_succeed_1param,
58 .opensess = authless_succeed_1param,
59 .closesess = authless_succeed_1param
62 static struct authhandle *newhandle(void)
64 struct authhandle *auth;
66 auth = smalloc(sizeof(*auth));
70 auth->mechdata = NULL;
74 void authgethandle(struct authhandle *auth)
79 void authputhandle(struct authhandle *auth)
83 if(auth->text != NULL)
85 if(auth->mechdata != NULL)
86 auth->mech->release(auth);
90 struct authhandle *initauth(wchar_t *mechname, char *username)
92 struct authmech *mech;
93 struct authhandle *auth;
95 for(mech = mechs; mech != NULL; mech = mech->next)
97 if(mech->enabled && !wcscmp(mechname, mech->name))
107 if(mech->inithandle(auth, username))
115 int authenticate(struct authhandle *handle, char *data)
117 if(handle->mech == NULL)
119 return(handle->mech->authenticate(handle, data));
122 int authrenewcred(struct authhandle *handle)
124 if((handle->mech == NULL) || (handle->mech->renewcred == NULL))
125 return(AUTH_SUCCESS);
126 return(handle->mech->renewcred(handle));
129 int authopensess(struct authhandle *handle)
131 if((handle->mech == NULL) || (handle->mech->opensess == NULL))
132 return(AUTH_SUCCESS);
133 return(handle->mech->opensess(handle));
136 int authclosesess(struct authhandle *handle)
138 if((handle->mech == NULL) || (handle->mech->closesess == NULL))
139 return(AUTH_SUCCESS);
140 return(handle->mech->closesess(handle));
143 void regmech(struct authmech *mech)
149 static void preinit(int hup)
151 extern struct authmech authmech_pam;
156 regmech(&authmech_pam);
159 static int init(int hup)
161 authless.enabled = confgetint("auth", "authless");
165 static struct configvar myvars[] =
167 {CONF_VAR_STRING, "pamserv", {.str = L"doldacond"}},
168 {CONF_VAR_BOOL, "authless", {.num = 1}},
172 static struct module me =