changeset 11543:356afa6263d4 HEAD

lib-master: Post-login scripts can now exit to prevent user from logging in, without logging error.
author Timo Sirainen <tss@iki.fi>
date Mon, 14 Jun 2010 18:51:17 +0100
parents 05700fe85e22
children 1f006c9e5795
files src/lib-master/master-login.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-master/master-login.c	Mon Jun 14 16:15:57 2010 +0100
+++ b/src/lib-master/master-login.c	Mon Jun 14 18:51:17 2010 +0100
@@ -41,6 +41,7 @@
 	struct io *io;
 	struct timeout *to;
 	string_t *input;
+	char *username;
 };
 
 struct master_login {
@@ -222,6 +223,7 @@
 	if (close(pl->fd) < 0)
 		i_error("close(postlogin) failed: %m");
 	str_free(&pl->input);
+	i_free(pl->username);
 	i_free(pl);
 }
 
@@ -255,9 +257,12 @@
 
 			i_error("fd_read(%s) failed: %m",
 				login->postlogin_socket_path);
-		} else {
+		} else if (str_len(pl->input) > 0) {
 			i_error("fd_read(%s) failed: disconnected",
 				login->postlogin_socket_path);
+		} else {
+			i_info("Post-login script denied access to user %s",
+			       pl->username);
 		}
 		master_login_client_free(&pl->client);
 		master_login_postlogin_free(pl);
@@ -325,6 +330,7 @@
 
 	pl = i_new(struct master_login_postlogin, 1);
 	pl->client = client;
+	pl->username = i_strdup(auth_args[0]);
 	pl->fd = fd;
 	pl->io = io_add(fd, IO_READ, master_login_postlogin_input, pl);
 	pl->to = timeout_add(MASTER_LOGIN_POSTLOGIN_TIMEOUT_MSECS,