Blame SOURCES/dovecot-2.2-gidcheck.patch

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