dovecot-1.2: Print a help message about authentication at startu...

dovecot at dovecot.org dovecot at dovecot.org
Sun Oct 19 13:32:05 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/d46579bb7a3c
changeset: 8301:d46579bb7a3c
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Oct 19 13:32:01 2008 +0300
description:
Print a help message about authentication at startup until the first successful authentication.

diffstat:

3 files changed, 31 insertions(+)
src/master/auth-process.c |   12 ++++++++++++
src/master/common.h       |    3 +++
src/master/main.c         |   16 ++++++++++++++++

diffs (88 lines):

diff -r 9d963e3bbe65 -r d46579bb7a3c src/master/auth-process.c
--- a/src/master/auth-process.c	Sun Oct 19 02:07:34 2008 +0300
+++ b/src/master/auth-process.c	Sun Oct 19 13:32:01 2008 +0300
@@ -19,6 +19,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include <syslog.h>
 
@@ -123,6 +124,17 @@ auth_process_input_user(struct auth_proc
 		i_error("BUG: Auth process %s sent unrequested reply with ID "
 			"%u", dec2str(process->pid), id);
 		return FALSE;
+	}
+
+	if (!auth_success_written) {
+		int fd;
+
+		fd = creat(AUTH_SUCCESS_PATH, 0666);
+		if (fd == -1)
+			i_error("creat(%s) failed: %m", AUTH_SUCCESS_PATH);
+		else
+			(void)close(fd);
+		auth_success_written = TRUE;
 	}
 
 	auth_master_callback(list[1], list + 2, request);
diff -r 9d963e3bbe65 -r d46579bb7a3c src/master/common.h
--- a/src/master/common.h	Sun Oct 19 02:07:34 2008 +0300
+++ b/src/master/common.h	Sun Oct 19 13:32:01 2008 +0300
@@ -6,12 +6,15 @@ struct ip_addr;
 #include "lib.h"
 #include "master-settings.h"
 
+#define AUTH_SUCCESS_PATH PKG_STATEDIR"/auth-success"
+
 extern struct ioloop *ioloop;
 extern int null_fd, inetd_login_fd;
 extern uid_t master_uid;
 extern char program_path[];
 extern char ssl_manual_key_password[];
 extern const char *env_tz;
+extern bool auth_success_written;
 #ifdef DEBUG
 extern bool gdb;
 #endif
diff -r 9d963e3bbe65 -r d46579bb7a3c src/master/main.c
--- a/src/master/main.c	Sun Oct 19 02:07:34 2008 +0300
+++ b/src/master/main.c	Sun Oct 19 13:32:01 2008 +0300
@@ -42,6 +42,7 @@ char program_path[PATH_MAX];
 char program_path[PATH_MAX];
 char ssl_manual_key_password[100];
 const char *env_tz;
+bool auth_success_written;
 #ifdef DEBUG
 bool gdb;
 #endif
@@ -97,6 +98,19 @@ static void fatal_log_check(void)
 	close(fd);
 	if (unlink(path) < 0)
 		i_error("unlink(%s) failed: %m", path);
+}
+
+static void auth_warning_print(void)
+{
+	struct stat st;
+
+	auth_success_written = stat(AUTH_SUCCESS_PATH, &st) == 0;
+	if (!auth_success_written) {
+		i_info("If you have trouble with authentication failures,\n"
+		       "enable auth_debug setting. "
+		       "See http://wiki.dovecot.org/WhyDoesItNotWork");
+
+	}
 }
 
 static void set_logfile(struct settings *set)
@@ -559,6 +573,8 @@ int main(int argc, char *argv[])
 		open_fds();
 
 	fatal_log_check();
+	if (strcmp(settings_root->defaults->protocols, "none") != 0)
+		auth_warning_print();
 	if (!foreground)
 		daemonize(settings_root->defaults);
 


More information about the dovecot-cvs mailing list