view src/auth/userinfo.c @ 100:867ec80dbf42 HEAD

Custom flags are now shown in FLAGS and PERMANENTFLAGS lists after SELECT. It also warns if there's for some reason a duplicate index number in custom flags file.
author Timo Sirainen <tss@iki.fi>
date Thu, 29 Aug 2002 22:21:51 +0300
parents 3b1985cbc908
children fa2d1a1d025e
line wrap: on
line source

/* Copyright (C) 2002 Timo Sirainen */

#include "common.h"
#include "userinfo.h"

#include <stdlib.h>

UserInfoModule *userinfo;

void userinfo_init(void)
{
	const char *name, *args;

	userinfo = NULL;

	name = getenv("USERINFO");
	if (name == NULL)
		i_fatal("USERINFO environment is unset");

#ifdef USERINFO_PASSWD
	if (strcasecmp(name, "passwd") == 0)
		userinfo = &userinfo_passwd;
#endif
#ifdef USERINFO_SHADOW
	if (strcasecmp(name, "shadow") == 0)
		userinfo = &userinfo_shadow;
#endif
#ifdef USERINFO_PAM
	if (strcasecmp(name, "pam") == 0)
		userinfo = &userinfo_pam;
#endif
#ifdef USERINFO_PASSWD_FILE
	if (strcasecmp(name, "passwd-file") == 0)
		userinfo = &userinfo_passwd_file;
#endif

	if (userinfo == NULL)
		i_fatal("Unknown userinfo type '%s'", name);

	/* initialize */
	if (userinfo->init != NULL) {
		args = getenv("USERINFO_ARGS");
		if (args == NULL) args = "";

		userinfo->init(args);
	}

	if ((auth_methods & AUTH_METHOD_PLAIN) &&
	    userinfo->verify_plain == NULL)
		i_fatal("Userinfo %s doesn't support PLAIN method", name);
	if ((auth_methods & AUTH_METHOD_DIGEST_MD5) &&
	    userinfo->lookup_digest_md5 == NULL)
		i_fatal("Userinfo %s doesn't support DIGEST-MD5 method", name);
}

void userinfo_deinit(void)
{
	if (userinfo != NULL && userinfo->deinit != NULL)
		userinfo->deinit();
}