[dovecot-cvs] dovecot/src/auth Makefile.am, 1.47, 1.48 userdb-passdb.c, 1.9, NONE userdb-prefetch.c, NONE, 1.1 userdb.c, 1.22, 1.23

cras at dovecot.org cras at dovecot.org
Wed Oct 19 16:38:38 EEST 2005


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv16124/src/auth

Modified Files:
	Makefile.am userdb.c 
Added Files:
	userdb-prefetch.c 
Removed Files:
	userdb-passdb.c 
Log Message:
Renamed userdb passdb to prefetch.



Index: Makefile.am
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/Makefile.am,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- Makefile.am	7 Aug 2005 11:41:19 -0000	1.47
+++ Makefile.am	19 Oct 2005 13:38:36 -0000	1.48
@@ -71,9 +71,9 @@
 	userdb.c \
 	userdb-blocking.c \
 	userdb-ldap.c \
-	userdb-passdb.c \
 	userdb-passwd.c \
 	userdb-passwd-file.c \
+	userdb-prefetch.c \
 	userdb-static.c \
 	userdb-vpopmail.c \
 	userdb-sql.c

--- userdb-passdb.c DELETED ---

--- NEW FILE: userdb-prefetch.c ---
/* Copyright (C) 2004 Timo Sirainen */

#include "common.h"

#ifdef USERDB_PREFETCH

#include "str.h"
#include "var-expand.h"
#include "userdb.h"

#include <stdlib.h>

static void prefetch_lookup(struct auth_request *auth_request,
			    userdb_callback_t *callback)
{
	const char *const *args;
	string_t *str;
	uid_t uid;
	gid_t gid;
	int uid_seen, gid_seen;

	if (auth_request->extra_fields == NULL) {
		auth_request_log_error(auth_request, "prefetch",
				       "passdb didn't return userdb entries");
		callback(NULL, auth_request);
		return;
	}

	t_push();

	uid = (uid_t)-1; gid = (gid_t)-1;
	uid_seen = gid_seen = FALSE;

	str = t_str_new(256);
	str_append(str, auth_request->user);

	/* export the request. keep all keys starting with userdb_ but strip
	   the userdb_ away. */
	args = t_strsplit(auth_stream_reply_export(auth_request->extra_fields),
		"\t");
	for (; *args != NULL; args++) {
		const char *arg = *args;

		if (strncmp(arg, "userdb_", 7) != 0)
			continue;
		arg += 7;

		str_append_c(str, '\t');
		if (strncmp(arg, "uid=", 4) == 0) {
			uid_seen = TRUE;
			uid = userdb_parse_uid(auth_request, arg+4);
			if (uid == (uid_t)-1)
				break;

			str_append(str, "uid=");
			str_append(str, dec2str(uid));
		} else if (strncmp(arg, "gid=", 4) == 0) {
			gid_seen = TRUE;
			gid = userdb_parse_gid(auth_request, arg+4);
			if (gid == (gid_t)-1)
				break;

			str_append(str, "gid=");
			str_append(str, dec2str(gid));
		} else {
			str_append(str, arg);
		}
	}

	if (!uid_seen) {
		auth_request_log_error(auth_request, "prefetch",
				       "userdb_uid not returned");
	}
	if (!gid_seen) {
		auth_request_log_error(auth_request, "prefetch",
				       "userdb_gid not returned");
	}

	if (uid == (uid_t)-1 || gid == (gid_t)-1)
		callback(NULL, auth_request);
	else {
		struct auth_stream_reply *reply;

		/* import the string into request. since the values were
		   exported they are already in escaped form in the string. */
		reply = auth_stream_reply_init(auth_request);
		auth_stream_reply_import(reply, str_c(str));
		callback(reply, auth_request);
	}
	t_pop();
}

struct userdb_module_interface userdb_prefetch = {
	"prefetch",

	NULL,
	NULL,
	NULL,

	prefetch_lookup
};

#endif

Index: userdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- userdb.c	16 Oct 2005 14:34:40 -0000	1.22
+++ userdb.c	19 Oct 2005 13:38:36 -0000	1.23
@@ -9,7 +9,7 @@
 #include <pwd.h>
 #include <grp.h>
 
-extern struct userdb_module_interface userdb_passdb;
+extern struct userdb_module_interface userdb_prefetch;
 extern struct userdb_module_interface userdb_static;
 extern struct userdb_module_interface userdb_passwd;
 extern struct userdb_module_interface userdb_passwd_file;
@@ -24,8 +24,8 @@
 #ifdef USERDB_PASSWD_FILE
 	&userdb_passwd_file,
 #endif
-#ifdef USERDB_PASSDB
-	&userdb_passdb,
+#ifdef USERDB_PREFETCH
+	&userdb_prefetch,
 #endif
 #ifdef USERDB_STATIC
 	&userdb_static,



More information about the dovecot-cvs mailing list