Blame SOURCES/dovecot-2.2-gidcheck.patch

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