changeset 13060:99da5f4f375d

master: Fail at startup if default_login_user or default_internal_user doesn't exist.
author Timo Sirainen <tss@iki.fi>
date Fri, 03 Jun 2011 17:37:25 +0300
parents d339aeb782ed
children 5b03ca65f4ed
files src/config/settings-get.pl src/master/master-settings.c
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/config/settings-get.pl	Fri Jun 03 17:22:09 2011 +0300
+++ b/src/config/settings-get.pl	Fri Jun 03 17:37:25 2011 +0300
@@ -3,6 +3,7 @@
 
 print '#include "lib.h"'."\n";
 print '#include "array.h"'."\n";
+print '#include "ipwd.h"'."\n";
 print '#include "var-expand.h"'."\n";
 print '#include "file-lock.h"'."\n";
 print '#include "fsync-mode.h"'."\n";
--- a/src/master/master-settings.c	Fri Jun 03 17:22:09 2011 +0300
+++ b/src/master/master-settings.c	Fri Jun 03 17:37:25 2011 +0300
@@ -6,6 +6,7 @@
 #include "istream.h"
 #include "network.h"
 #include "str.h"
+#include "ipwd.h"
 #include "mkdir-parents.h"
 #include "safe-mkdir.h"
 #include "settings-parser.h"
@@ -407,6 +408,7 @@
 	struct service_settings *const *services;
 	const char *const *strings;
 	ARRAY_TYPE(const_string) all_listeners;
+	struct passwd pw;
 	unsigned int i, j, count, len, client_limit, process_limit;
 	unsigned int max_auth_client_processes, max_anvil_client_processes;
 
@@ -427,6 +429,17 @@
 		return FALSE;
 	}
 
+	if (i_getpwnam(set->default_login_user, &pw) == 0) {
+		*error_r = t_strdup_printf("default_login_user doesn't exist: %s",
+					   set->default_login_user);
+		return FALSE;
+	}
+	if (i_getpwnam(set->default_internal_user, &pw) == 0) {
+		*error_r = t_strdup_printf("default_internal_user doesn't exist: %s",
+					   set->default_internal_user);
+		return FALSE;
+	}
+
 	/* check that we have at least one service. the actual service
 	   structure validity is checked later while creating them. */
 	if (!array_is_created(&set->services) ||