view src/auth/userdb-passwd.c @ 2942:c7d426f8cb58 HEAD

Added name variable for userdb_module and passdb_module and changed their initialization a bit.
author Timo Sirainen <tss@iki.fi>
date Mon, 06 Dec 2004 18:39:02 +0200
parents cc2e39912eb3
children 131151e25e4b
line wrap: on
line source

/* Copyright (C) 2002-2003 Timo Sirainen */

#include "config.h"
#undef HAVE_CONFIG_H

#ifdef USERDB_PASSWD

#include "common.h"
#include "userdb.h"

#include <pwd.h>

static void passwd_lookup(struct auth_request *auth_request,
			  userdb_callback_t *callback, void *context)
{
	struct user_data data;
	struct passwd *pw;

	pw = getpwnam(auth_request->user);
	if (pw == NULL) {
		if (verbose) {
			i_info("passwd(%s): unknown user",
			       get_log_prefix(auth_request));
		}
		callback(NULL, context);
		return;
	}

	memset(&data, 0, sizeof(data));
	data.uid = pw->pw_uid;
	data.gid = pw->pw_gid;

	data.virtual_user = data.system_user = pw->pw_name;
	data.home = pw->pw_dir;

	callback(&data, context);
}

struct userdb_module userdb_passwd = {
	"passwd",

	NULL, NULL, NULL,
	passwd_lookup
};

#endif