From: Sam Hartman <hartmans@debian.org>
Date: Mon, 11 Sep 2023 14:00:42 -0600
Subject: _pam_include

Patch to implement an @include directive for use in pam.d config files.

Authors: Jan Christoph Nordholz <hesso@pool.math.tu-berlin.de>

Updated for pam 1.7.0 by Sam Hartman <hartmans@debian.org>

Upstream status: not yet submitted
---
 libpam/pam_handlers.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c
index 7fd6ce8..1df5e40 100644
--- a/libpam/pam_handlers.c
+++ b/libpam/pam_handlers.c
@@ -127,6 +127,10 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f
 		    module_type = PAM_T_ACCT;
 		} else if (!strcasecmp("password", tok)) {
 		    module_type = PAM_T_PASS;
+		} else if (!strcasecmp("@include", tok)) {
+		    pam_include = 1;
+		    module_type = requested_module_type;
+		    goto parsing_done;
 		} else {
 		    /* Illegal module type */
 		    D(("bad module type: %s", tok));
@@ -197,6 +201,7 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f
 		_pam_set_default_control(actions, _PAM_ACTION_BAD);
 	    }
 
+parsing_done:
 	    tok = _pam_tokenize(NULL, &nexttok);
 	    if (pam_include) {
 		if (substack) {
