#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <ucontext.h>
-#include <security/pam_appl.h>
#include <errno.h>
#ifdef HAVE_CONFIG_H
#include "utils.h"
#include "conf.h"
#include "log.h"
+#include "module.h"
+
+#ifdef HAVE_PAM
+#include <ucontext.h>
+#include <security/pam_appl.h>
struct pamdata
{
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);
}
return(rc);
}
-struct authmech authmech_pam =
+static struct authmech authmech_pam =
{
.inithandle = inithandle,
.release = release,
.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 */