X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fauth-pam.c;h=35b0a051350779ce119f57bcc53623a2b5dd820e;hb=4e564b59c7c565387c4907017dfacce2ef761f8a;hp=48dbcbddfdf6123b0cb19446c075624234b14741;hpb=d3372da97568d5e1f35fa19787c8ec8af93a0435;p=doldaconnect.git diff --git a/daemon/auth-pam.c b/daemon/auth-pam.c index 48dbcbd..35b0a05 100644 --- a/daemon/auth-pam.c +++ b/daemon/auth-pam.c @@ -1,6 +1,6 @@ /* * Dolda Connect - Modular multiuser Direct Connect-style client - * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) + * Copyright (C) 2004 Fredrik Tolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #ifdef HAVE_CONFIG_H @@ -45,6 +43,11 @@ #include "utils.h" #include "conf.h" #include "log.h" +#include "module.h" + +#ifdef HAVE_PAM +#include +#include struct pamdata { @@ -99,20 +102,22 @@ static int pamconv(int nmsg, const struct pam_message **msg, struct pam_response } if(data->converr) { - for(; i < nmsg; i++) - { - (*resp)[i].resp = sstrdup(""); - (*resp)[i].resp_retcode = PAM_SUCCESS; - } + for(i--; i >= 0; i--) + free((*resp)[i].resp); + free(*resp); + *resp = NULL; return(PAM_CONV_ERR); } + (*resp)[i].resp_retcode = PAM_SUCCESS; switch(msg[i]->msg_style) { case PAM_PROMPT_ECHO_OFF: case PAM_PROMPT_ECHO_ON: (*resp)[i].resp = sstrdup((char *)data->passdata); memset((void *)data->passdata, 0, strlen((char *)data->passdata)); - (*resp)[i].resp_retcode = PAM_SUCCESS; + break; + default: + (*resp)[i].resp = NULL; break; } } @@ -166,9 +171,9 @@ static int inithandle(struct authhandle *auth, char *username) data = newpamdata(); conv.conv = (int (*)(int, const struct pam_message **, struct pam_response **, void *))pamconv; conv.appdata_ptr = auth; - if((buf = icwcstombs(confgetstr("auth", "pamserv"), NULL)) == NULL) + if((buf = icwcstombs(confgetstr("auth-pam", "pamserv"), NULL)) == NULL) { - flog(LOG_ERR, "could not initialize pam since auth.pamserv cannot be translated into the current locale: %s", strerror(errno)); + flog(LOG_ERR, "could not initialize pam since auth-pam.pamserv cannot be translated into the current locale: %s", strerror(errno)); releasepam(data); return(1); } @@ -195,7 +200,7 @@ static void pamauththread(struct authhandle *auth) data->validctxt = 0; } -static int pamauth(struct authhandle *auth, char *passdata) +static int pamauth(struct authhandle *auth, struct socket *sk, char *passdata) { struct pamdata *data; @@ -319,7 +324,7 @@ static int closesess(struct authhandle *auth) return(rc); } -struct authmech authmech_pam = +static struct authmech authmech_pam = { .inithandle = inithandle, .release = release, @@ -330,3 +335,31 @@ struct authmech authmech_pam = .name = L"pam", .enabled = 1 }; + +static int init(int hup) +{ + if(!hup) + regmech(&authmech_pam); + return(0); +} + +static struct configvar myvars[] = +{ + /** The name of the PAM service file to use. */ + {CONF_VAR_STRING, "pamserv", {.str = L"doldacond"}}, + {CONF_VAR_END} +}; + +static struct module me = +{ + .conf = + { + .vars = myvars + }, + .init = init, + .name = "auth-pam" +}; + +MODULE(me); + +#endif /* HAVE_PAM */