Blame SOURCES/pam-1.3.1-pam-pwhistory-load-conf-from-file.patch

287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/Makefile.am.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/Makefile.am
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/Makefile.am.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.709355179 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/Makefile.am	2022-09-29 10:13:35.780355766 +0200
287c98
@@ -10,9 +10,10 @@ EXTRA_DIST = README $(MANS) $(XMLS) tst-
287c98
 
287c98
 TESTS = tst-pam_pwhistory
287c98
 
287c98
-man_MANS = pam_pwhistory.8 pwhistory_helper.8
287c98
+man_MANS = pam_pwhistory.8 pwhistory_helper.8 pwhistory.conf.5
287c98
 
287c98
-XMLS = README.xml pam_pwhistory.8.xml pwhistory_helper.8.xml
287c98
+XMLS = README.xml pam_pwhistory.8.xml pwhistory_helper.8.xml \
287c98
+  pwhistory.conf.5.xml
287c98
 
287c98
 securelibdir = $(SECUREDIR)
287c98
 secureconfdir = $(SCONFIGDIR)
287c98
@@ -25,12 +26,14 @@ if HAVE_VERSIONING
287c98
   pam_pwhistory_la_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map
287c98
 endif
287c98
 
287c98
-noinst_HEADERS = opasswd.h
287c98
+noinst_HEADERS = opasswd.h pwhistory_config.h
287c98
+
287c98
+dist_secureconf_DATA = pwhistory.conf
287c98
 
287c98
 securelib_LTLIBRARIES = pam_pwhistory.la
287c98
 pam_pwhistory_la_CFLAGS = $(AM_CFLAGS)
287c98
 pam_pwhistory_la_LIBADD = $(top_builddir)/libpam/libpam.la @LIBCRYPT@ @LIBSELINUX@
287c98
-pam_pwhistory_la_SOURCES = pam_pwhistory.c opasswd.c
287c98
+pam_pwhistory_la_SOURCES = pam_pwhistory.c opasswd.c pwhistory_config.c
287c98
 
287c98
 sbin_PROGRAMS = pwhistory_helper
287c98
 pwhistory_helper_CFLAGS = $(AM_CFLAGS) -DHELPER_COMPILE=\"pwhistory_helper\" @PIE_CFLAGS@
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.8.xml.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.8.xml
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.8.xml.pam-pwhistory-load-conf-from-file	2017-02-10 11:10:15.000000000 +0100
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.8.xml	2022-09-29 10:13:35.780355766 +0200
287c98
@@ -36,6 +36,9 @@
287c98
       <arg choice="opt">
287c98
         authtok_type=<replaceable>STRING</replaceable>
287c98
       </arg>
287c98
+      <arg choice="opt">
287c98
+	      conf=<replaceable>/path/to/config-file</replaceable>
287c98
+      </arg>
287c98
 
287c98
     </cmdsynopsis>
287c98
   </refsynopsisdiv>
287c98
@@ -104,7 +107,7 @@
287c98
         <listitem>
287c98
           <para>
287c98
             The last <replaceable>N</replaceable> passwords for each
287c98
-            user are saved in <filename>/etc/security/opasswd</filename>.
287c98
+            user are saved.
287c98
             The default is <emphasis>10</emphasis>. Value of
287c98
             <emphasis>0</emphasis> makes the module to keep the existing
287c98
             contents of the <filename>opasswd</filename> file unchanged.
287c98
@@ -137,7 +140,26 @@
287c98
           </listitem>
287c98
         </varlistentry>
287c98
 
287c98
+        <varlistentry>
287c98
+          <term>
287c98
+            <option>conf=<replaceable>/path/to/config-file</replaceable></option>
287c98
+          </term>
287c98
+          <listitem>
287c98
+            <para>
287c98
+              Use another configuration file instead of the default
287c98
+              <filename>/etc/security/pwhistory.conf</filename>.
287c98
+            </para>
287c98
+          </listitem>
287c98
+        </varlistentry>
287c98
+
287c98
     </variablelist>
287c98
+    <para>
287c98
+      The options for configuring the module behavior are described in the
287c98
+      <citerefentry><refentrytitle>pwhistory.conf</refentrytitle>
287c98
+      <manvolnum>5</manvolnum></citerefentry> manual page. The options
287c98
+      specified on the module command line override the values from the
287c98
+      configuration file.
287c98
+    </para>
287c98
   </refsect1>
287c98
 
287c98
   <refsect1 id="pam_pwhistory-types">
287c98
@@ -223,6 +245,9 @@ password     required       pam_unix.so
287c98
     <title>SEE ALSO</title>
287c98
     <para>
287c98
       <citerefentry>
287c98
+	<refentrytitle>pwhistory.conf</refentrytitle><manvolnum>5</manvolnum>
287c98
+      </citerefentry>,
287c98
+      <citerefentry>
287c98
 	<refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum>
287c98
       </citerefentry>,
287c98
       <citerefentry>
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.c.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.c
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.c.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.711355195 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pam_pwhistory.c	2022-09-29 10:13:35.780355766 +0200
287c98
@@ -62,18 +62,11 @@
287c98
 #include <security/_pam_macros.h>
287c98
 
287c98
 #include "opasswd.h"
287c98
+#include "pwhistory_config.h"
287c98
 
287c98
 #define DEFAULT_BUFLEN 2048
287c98
 #define MAX_FD_NO 20000
287c98
 
287c98
-struct options_t {
287c98
-  int debug;
287c98
-  int enforce_for_root;
287c98
-  int remember;
287c98
-  int tries;
287c98
-};
287c98
-typedef struct options_t options_t;
287c98
-
287c98
 
287c98
 static void
287c98
 parse_option (pam_handle_t *pamh, const char *argv, options_t *options)
287c98
@@ -304,6 +297,8 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
287c98
   options.remember = 10;
287c98
   options.tries = 1;
287c98
 
287c98
+  parse_config_file(pamh, argc, argv, &options);
287c98
+
287c98
   /* Parse parameters for module */
287c98
   for ( ; argc-- > 0; argv++)
287c98
     parse_option (pamh, *argv, &options);
287c98
@@ -311,7 +306,6 @@ pam_sm_chauthtok (pam_handle_t *pamh, in
287c98
   if (options.debug)
287c98
     pam_syslog (pamh, LOG_DEBUG, "pam_sm_chauthtok entered");
287c98
 
287c98
-
287c98
   if (options.remember == 0)
287c98
     return PAM_IGNORE;
287c98
 
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.5.xml.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.5.xml
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.5.xml.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.780355766 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.5.xml	2022-09-29 10:13:35.780355766 +0200
287c98
@@ -0,0 +1,155 @@
287c98
+
287c98
+
287c98
+	"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
287c98
+
287c98
+<refentry id="pwhistory.conf">
287c98
+
287c98
+  <refmeta>
287c98
+    <refentrytitle>pwhistory.conf</refentrytitle>
287c98
+    <manvolnum>5</manvolnum>
287c98
+    <refmiscinfo class="sectdesc">Linux-PAM Manual</refmiscinfo>
287c98
+  </refmeta>
287c98
+
287c98
+  <refnamediv id="pwhistory.conf-name">
287c98
+    <refname>pwhistory.conf</refname>
287c98
+    <refpurpose>pam_pwhistory configuration file</refpurpose>
287c98
+  </refnamediv>
287c98
+
287c98
+  <refsect1 id="pwhistory.conf-description">
287c98
+
287c98
+    <title>DESCRIPTION</title>
287c98
+    <para>
287c98
+       <emphasis remap='B'>pwhistory.conf</emphasis> provides a way to configure the
287c98
+       default settings for saving the last passwords for each user.
287c98
+       This file is read by the <emphasis>pam_pwhistory</emphasis> module and is the
287c98
+       preferred method over configuring <emphasis>pam_pwhistory</emphasis> directly.
287c98
+    </para>
287c98
+    <para>
287c98
+       The file has a very simple <emphasis>name = value</emphasis> format with possible comments
287c98
+       starting with <emphasis>#</emphasis> character. The whitespace at the beginning of line, end
287c98
+       of line, and around the <emphasis>=</emphasis> sign is ignored.
287c98
+    </para>
287c98
+  </refsect1>
287c98
+
287c98
+  <refsect1 id="pwhistory.conf-options">
287c98
+
287c98
+    <title>OPTIONS</title>
287c98
+         <variablelist>
287c98
+            <varlistentry>
287c98
+              <term>
287c98
+                <option>debug</option>
287c98
+              </term>
287c98
+              <listitem>
287c98
+                <para>
287c98
+                  Turns on debugging via
287c98
+                  <citerefentry>
287c98
+                    <refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum>
287c98
+                  </citerefentry>.
287c98
+                </para>
287c98
+              </listitem>
287c98
+            </varlistentry>
287c98
+            <varlistentry>
287c98
+              <term>
287c98
+                <option>enforce_for_root</option>
287c98
+              </term>
287c98
+              <listitem>
287c98
+                <para>
287c98
+                  If this option is set, the check is enforced for root, too.
287c98
+                </para>
287c98
+              </listitem>
287c98
+            </varlistentry>
287c98
+            <varlistentry>
287c98
+              <term>
287c98
+                <option>remember=<replaceable>N</replaceable></option>
287c98
+              </term>
287c98
+              <listitem>
287c98
+                <para>
287c98
+                  The last <replaceable>N</replaceable> passwords for each
287c98
+                  user are saved.
287c98
+                  The default is <emphasis>10</emphasis>. Value of
287c98
+                  <emphasis>0</emphasis> makes the module to keep the existing
287c98
+                  contents of the <filename>opasswd</filename> file unchanged.
287c98
+                </para>
287c98
+              </listitem>
287c98
+            </varlistentry>
287c98
+            <varlistentry>
287c98
+              <term>
287c98
+                <option>retry=<replaceable>N</replaceable></option>
287c98
+              </term>
287c98
+              <listitem>
287c98
+                <para>
287c98
+                  Prompt user at most <replaceable>N</replaceable> times
287c98
+                  before returning with error. The default is 1.
287c98
+                </para>
287c98
+              </listitem>
287c98
+            </varlistentry>
287c98
+            <varlistentry>
287c98
+              <term>
287c98
+                <option>file=<replaceable>/path/filename</replaceable></option>
287c98
+              </term>
287c98
+              <listitem>
287c98
+                <para>
287c98
+                  Store password history in file
287c98
+                  <replaceable>/path/filename</replaceable> rather than the default
287c98
+                  location. The default location is
287c98
+	                <filename>/etc/security/opasswd</filename>.
287c98
+                </para>
287c98
+              </listitem>
287c98
+            </varlistentry>
287c98
+        </variablelist>
287c98
+  </refsect1>
287c98
+
287c98
+  <refsect1 id='pwhistory.conf-examples'>
287c98
+    <title>EXAMPLES</title>
287c98
+    <para>
287c98
+      /etc/security/pwhistory.conf file example:
287c98
+    </para>
287c98
+    <programlisting>
287c98
+debug
287c98
+remember=5
287c98
+file=/tmp/opasswd
287c98
+    </programlisting>
287c98
+  </refsect1>
287c98
+
287c98
+  <refsect1 id="pwhistory.conf-files">
287c98
+    <title>FILES</title>
287c98
+    <variablelist>
287c98
+      <varlistentry>
287c98
+        <term><filename>/etc/security/pwhistory.conf</filename></term>
287c98
+        <listitem>
287c98
+          <para>the config file for custom options</para>
287c98
+        </listitem>
287c98
+      </varlistentry>
287c98
+    </variablelist>
287c98
+  </refsect1>
287c98
+
287c98
+  <refsect1 id='pwhistory.conf-see_also'>
287c98
+    <title>SEE ALSO</title>
287c98
+    <para>
287c98
+      <citerefentry>
287c98
+        <refentrytitle>pwhistory</refentrytitle><manvolnum>8</manvolnum>
287c98
+      </citerefentry>,
287c98
+      <citerefentry>
287c98
+        <refentrytitle>pam_pwhistory</refentrytitle><manvolnum>8</manvolnum>
287c98
+      </citerefentry>,
287c98
+      <citerefentry>
287c98
+        <refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum>
287c98
+      </citerefentry>,
287c98
+      <citerefentry>
287c98
+        <refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum>
287c98
+      </citerefentry>,
287c98
+      <citerefentry>
287c98
+        <refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum>
287c98
+      </citerefentry>
287c98
+    </para>
287c98
+  </refsect1>
287c98
+
287c98
+  <refsect1 id='pwhistory.conf-author'>
287c98
+    <title>AUTHOR</title>
287c98
+      <para>
287c98
+        pam_pwhistory was written by Thorsten Kukuk. The support for
287c98
+        pwhistory.conf was written by Iker Pedrosa.
287c98
+      </para>
287c98
+  </refsect1>
287c98
+
287c98
+</refentry>
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.c.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.c
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.c.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.781355775 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.c	2022-09-29 10:14:33.377832622 +0200
287c98
@@ -0,0 +1,195 @@
287c98
+/*
287c98
+ * Copyright (c) 2022 Iker Pedrosa <ipedrosa@redhat.com>
287c98
+ *
287c98
+ * Redistribution and use in source and binary forms, with or without
287c98
+ * modification, are permitted provided that the following conditions
287c98
+ * are met:
287c98
+ * 1. Redistributions of source code must retain the above copyright
287c98
+ *    notice, and the entire permission notice in its entirety,
287c98
+ *    including the disclaimer of warranties.
287c98
+ * 2. Redistributions in binary form must reproduce the above copyright
287c98
+ *    notice, this list of conditions and the following disclaimer in the
287c98
+ *    documentation and/or other materials provided with the distribution.
287c98
+ * 3. The name of the author may not be used to endorse or promote
287c98
+ *    products derived from this software without specific prior
287c98
+ *    written permission.
287c98
+ *
287c98
+ * ALTERNATIVELY, this product may be distributed under the terms of
287c98
+ * the GNU Public License, in which case the provisions of the GPL are
287c98
+ * required INSTEAD OF the above restrictions.  (This clause is
287c98
+ * necessary due to a potential bad interaction between the GPL and
287c98
+ * the restrictions contained in a BSD-style copyright.)
287c98
+ *
287c98
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
287c98
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
287c98
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
287c98
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
287c98
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
287c98
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
287c98
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
287c98
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
287c98
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
287c98
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
287c98
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
287c98
+ */
287c98
+
287c98
+#include "config.h"
287c98
+
287c98
+#include <stdio.h>
287c98
+#include <stdlib.h>
287c98
+#include <string.h>
287c98
+#include <syslog.h>
287c98
+#include <ctype.h>
287c98
+
287c98
+#include <security/pam_modutil.h>
287c98
+
287c98
+#include "pam_inline.h"
287c98
+#include "pwhistory_config.h"
287c98
+
287c98
+#define PWHISTORY_DEFAULT_CONF "/etc/security/pwhistory.conf"
287c98
+
287c98
+/* lookup a value for key in login.defs file or similar key value format */
287c98
+static char *
287c98
+pwhistory_search_key(pam_handle_t *pamh UNUSED,
287c98
+		       const char *file_name,
287c98
+		       const char *key)
287c98
+{
287c98
+	FILE *fp;
287c98
+	char *buf = NULL;
287c98
+	size_t buflen = 0;
287c98
+	char *retval = NULL;
287c98
+
287c98
+#ifdef USE_ECONF
287c98
+	if (strcmp (file_name, LOGIN_DEFS) == 0)
287c98
+		return econf_search_key ("login", ".defs", key);
287c98
+#endif
287c98
+
287c98
+	fp = fopen(file_name, "r");
287c98
+	if (NULL == fp)
287c98
+		return NULL;
287c98
+
287c98
+	while (!feof(fp)) {
287c98
+		char *tmp, *cp;
287c98
+#if defined(HAVE_GETLINE)
287c98
+		ssize_t n = getline(&buf, &buflen, fp);
287c98
+#elif defined (HAVE_GETDELIM)
287c98
+		ssize_t n = getdelim(&buf, &buflen, '\n', fp);
287c98
+#else
287c98
+		ssize_t n;
287c98
+
287c98
+		if (buf == NULL) {
287c98
+			buflen = BUF_SIZE;
287c98
+			buf = malloc(buflen);
287c98
+			if (buf == NULL) {
287c98
+				fclose(fp);
287c98
+				return NULL;
287c98
+			}
287c98
+		}
287c98
+		buf[0] = '\0';
287c98
+		if (fgets(buf, buflen - 1, fp) == NULL)
287c98
+			break;
287c98
+		else if (buf != NULL)
287c98
+			n = strlen(buf);
287c98
+		else
287c98
+			n = 0;
287c98
+#endif /* HAVE_GETLINE / HAVE_GETDELIM */
287c98
+		cp = buf;
287c98
+
287c98
+		if (n < 1)
287c98
+			break;
287c98
+		if (cp[n - 1] == '\n')
287c98
+			cp[n - 1] = '\0';
287c98
+
287c98
+		tmp = strchr(cp, '#');  /* remove comments */
287c98
+		if (tmp)
287c98
+			*tmp = '\0';
287c98
+		while (isspace((int)*cp))    /* remove spaces and tabs */
287c98
+			++cp;
287c98
+		if (*cp == '\0')        /* ignore empty lines */
287c98
+			continue;
287c98
+
287c98
+		tmp = strsep (&cp, " \t=");
287c98
+		if (cp != NULL)
287c98
+			while (isspace((int)*cp) || *cp == '=')
287c98
+				++cp;
287c98
+		else
287c98
+			cp = buf + n;   /* empty string */
287c98
+
287c98
+		if (strcasecmp(tmp, key) == 0) {
287c98
+			retval = strdup(cp);
287c98
+			break;
287c98
+		}
287c98
+	}
287c98
+	fclose(fp);
287c98
+
287c98
+	free(buf);
287c98
+
287c98
+	return retval;
287c98
+}
287c98
+
287c98
+void
287c98
+parse_config_file(pam_handle_t *pamh, int argc, const char **argv,
287c98
+                  struct options_t *options)
287c98
+{
287c98
+    const char *fname = NULL;
287c98
+    int i;
287c98
+    char *val;
287c98
+
287c98
+    for (i = 0; i < argc; ++i) {
287c98
+        const char *str = pam_str_skip_prefix(argv[i], "conf=");
287c98
+
287c98
+        if (str != NULL) {
287c98
+            fname = str;
287c98
+        }
287c98
+    }
287c98
+
287c98
+    if (fname == NULL) {
287c98
+        fname = PWHISTORY_DEFAULT_CONF;
287c98
+    }
287c98
+
287c98
+    val = pwhistory_search_key (pamh, fname, "debug");
287c98
+    if (val != NULL) {
287c98
+        options->debug = 1;
287c98
+        free(val);
287c98
+    }
287c98
+
287c98
+    val = pwhistory_search_key (pamh, fname, "enforce_for_root");
287c98
+    if (val != NULL) {
287c98
+        options->enforce_for_root = 1;
287c98
+        free(val);
287c98
+    }
287c98
+
287c98
+    val = pwhistory_search_key (pamh, fname, "remember");
287c98
+    if (val != NULL) {
287c98
+        unsigned int temp;
287c98
+        if (sscanf(val, "%u", &temp) != 1) {
287c98
+            pam_syslog(pamh, LOG_ERR,
287c98
+                "Bad number supplied for remember argument");
287c98
+        } else {
287c98
+            options->remember = temp;
287c98
+        }
287c98
+        free(val);
287c98
+    }
287c98
+
287c98
+    val = pwhistory_search_key (pamh, fname, "retry");
287c98
+    if (val != NULL) {
287c98
+        unsigned int temp;
287c98
+        if (sscanf(val, "%u", &temp) != 1) {
287c98
+            pam_syslog(pamh, LOG_ERR,
287c98
+                "Bad number supplied for retry argument");
287c98
+        } else {
287c98
+            options->tries = temp;
287c98
+        }
287c98
+        free(val);
287c98
+    }
287c98
+
287c98
+    val = pwhistory_search_key (pamh, fname, "file");
287c98
+    if (val != NULL) {
287c98
+        if (*val != '/') {
287c98
+            pam_syslog (pamh, LOG_ERR,
287c98
+                "File path should be absolute: %s", val);
287c98
+        } else {
287c98
+            options->filename = val;
287c98
+        }
287c98
+    }
287c98
+}
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.h.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.h
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.h.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.781355775 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory_config.h	2022-09-29 10:13:35.781355775 +0200
287c98
@@ -0,0 +1,54 @@
287c98
+/*
287c98
+ * Copyright (c) 2022 Iker Pedrosa <ipedrosa@redhat.com>
287c98
+ *
287c98
+ * Redistribution and use in source and binary forms, with or without
287c98
+ * modification, are permitted provided that the following conditions
287c98
+ * are met:
287c98
+ * 1. Redistributions of source code must retain the above copyright
287c98
+ *    notice, and the entire permission notice in its entirety,
287c98
+ *    including the disclaimer of warranties.
287c98
+ * 2. Redistributions in binary form must reproduce the above copyright
287c98
+ *    notice, this list of conditions and the following disclaimer in the
287c98
+ *    documentation and/or other materials provided with the distribution.
287c98
+ * 3. The name of the author may not be used to endorse or promote
287c98
+ *    products derived from this software without specific prior
287c98
+ *    written permission.
287c98
+ *
287c98
+ * ALTERNATIVELY, this product may be distributed under the terms of
287c98
+ * the GNU Public License, in which case the provisions of the GPL are
287c98
+ * required INSTEAD OF the above restrictions.  (This clause is
287c98
+ * necessary due to a potential bad interaction between the GPL and
287c98
+ * the restrictions contained in a BSD-style copyright.)
287c98
+ *
287c98
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
287c98
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
287c98
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
287c98
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
287c98
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
287c98
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
287c98
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
287c98
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
287c98
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
287c98
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
287c98
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
287c98
+ */
287c98
+
287c98
+#ifndef _PWHISTORY_CONFIG_H
287c98
+#define _PWHISTORY_CONFIG_H
287c98
+
287c98
+#include <security/pam_ext.h>
287c98
+
287c98
+struct options_t {
287c98
+    int debug;
287c98
+    int enforce_for_root;
287c98
+    int remember;
287c98
+    int tries;
287c98
+    const char *filename;
287c98
+};
287c98
+typedef struct options_t options_t;
287c98
+
287c98
+void
287c98
+parse_config_file(pam_handle_t *pamh, int argc, const char **argv,
287c98
+                  struct options_t *options);
287c98
+
287c98
+#endif /* _PWHISTORY_CONFIG_H */
287c98
diff -up Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.pam-pwhistory-load-conf-from-file Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf
287c98
--- Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf.pam-pwhistory-load-conf-from-file	2022-09-29 10:13:35.781355775 +0200
287c98
+++ Linux-PAM-1.3.1/modules/pam_pwhistory/pwhistory.conf	2022-09-29 10:13:35.781355775 +0200
287c98
@@ -0,0 +1,21 @@
287c98
+# Configuration for remembering the last passwords used by a user.
287c98
+#
287c98
+# Enable the debugging logs.
287c98
+# Enabled if option is present.
287c98
+# debug
287c98
+#
287c98
+# root account's passwords are also remembered.
287c98
+# Enabled if option is present.
287c98
+# enforce_for_root
287c98
+#
287c98
+# Number of passwords to remember.
287c98
+# The default is 10.
287c98
+# remember = 10
287c98
+#
287c98
+# Number of times to prompt for the password.
287c98
+# The default is 1.
287c98
+# retry = 1
287c98
+#
287c98
+# The directory where the last passwords are kept.
287c98
+# The default is /etc/security/opasswd.
287c98
+# file = /etc/security/opasswd