Blame SOURCES/dovecot-2.2-gidcheck.patch

854985
From ca5b3ec5331545b46ec1f1c4ecfa1302ddb10653 Mon Sep 17 00:00:00 2001
854985
From: Timo Sirainen <timo.sirainen@dovecot.fi>
854985
Date: Wed, 29 Jun 2016 00:56:56 +0300
854985
Subject: [PATCH] auth: userdb passwd iteration now skips users not in
854985
 first/last_valid_gid range
854985
854985
Patch by Michal Hlavinka / Red Hat
854985
---
854985
 src/auth/auth-settings.c | 4 ++++
854985
 src/auth/auth-settings.h | 2 ++
854985
 src/auth/userdb-passwd.c | 4 ++++
854985
 3 files changed, 10 insertions(+)
854985
2f024d
diff -up dovecot-2.2.36/src/auth/auth-settings.c.gidcheck dovecot-2.2.36/src/auth/auth-settings.c
2f024d
--- dovecot-2.2.36/src/auth/auth-settings.c.gidcheck	2018-04-30 15:52:05.000000000 +0200
2f024d
+++ dovecot-2.2.36/src/auth/auth-settings.c	2018-09-17 12:17:13.132032699 +0200
2f024d
@@ -272,6 +272,8 @@ static const struct setting_define auth_
854985
 	DEF_NOPREFIX(SET_BOOL, verbose_proctitle),
854985
 	DEF_NOPREFIX(SET_UINT, first_valid_uid),
854985
 	DEF_NOPREFIX(SET_UINT, last_valid_uid),
854985
+	DEF_NOPREFIX(SET_UINT, first_valid_gid),
854985
+	DEF_NOPREFIX(SET_UINT, last_valid_gid),
854985
 
2f024d
 	DEF_NOPREFIX(SET_STR, ssl_client_ca_dir),
2f024d
 	DEF_NOPREFIX(SET_STR, ssl_client_ca_file),
2f024d
@@ -331,6 +333,8 @@ static const struct auth_settings auth_d
854985
 	.verbose_proctitle = FALSE,
854985
 	.first_valid_uid = 500,
854985
 	.last_valid_uid = 0,
854985
+	.first_valid_gid = 1,
854985
+	.last_valid_gid = 0,
854985
 };
854985
 
854985
 const struct setting_parser_info auth_setting_parser_info = {
2f024d
diff -up dovecot-2.2.36/src/auth/auth-settings.h.gidcheck dovecot-2.2.36/src/auth/auth-settings.h
2f024d
--- dovecot-2.2.36/src/auth/auth-settings.h.gidcheck	2018-04-30 15:52:05.000000000 +0200
2f024d
+++ dovecot-2.2.36/src/auth/auth-settings.h	2018-09-17 12:13:30.540159133 +0200
2f024d
@@ -88,6 +88,8 @@ struct auth_settings {
854985
 	bool verbose_proctitle;
854985
 	unsigned int first_valid_uid;
854985
 	unsigned int last_valid_uid;
854985
+	unsigned int first_valid_gid;
854985
+	unsigned int last_valid_gid;
854985
 
854985
 	/* generated: */
854985
 	char username_chars_map[256];
2f024d
diff -up dovecot-2.2.36/src/auth/userdb-passwd.c.gidcheck dovecot-2.2.36/src/auth/userdb-passwd.c
2f024d
--- dovecot-2.2.36/src/auth/userdb-passwd.c.gidcheck	2018-04-30 15:52:05.000000000 +0200
2f024d
+++ dovecot-2.2.36/src/auth/userdb-passwd.c	2018-09-17 12:13:30.540159133 +0200
2f024d
@@ -145,6 +145,10 @@ passwd_iterate_want_pw(struct passwd *pw
854985
 		return FALSE;
854985
 	if (pw->pw_uid > (uid_t)set->last_valid_uid && set->last_valid_uid != 0)
854985
 		return FALSE;
854985
+	if (pw->pw_gid < (gid_t)set->first_valid_gid)
854985
+		return FALSE;
854985
+	if (pw->pw_gid > (gid_t)set->last_valid_gid && set->last_valid_gid != 0)
854985
+		return FALSE;
854985
 	return TRUE;
854985
 }
854985