File pam_kwallet.patch of Package pam-config
2014-05-17 Herbert Graeber <herbert@graeber-clan.de>
* src/mod_pam_kwallet.c: New.
* src/supported-modules.h: Add pam_kwallet.
Index: pam-config-0.88/src/Makefile.am
===================================================================
--- pam-config-0.88.orig/src/Makefile.am
+++ pam-config-0.88/src/Makefile.am
@@ -31,7 +31,7 @@ pam_config_SOURCES = pam-config.c load_c
mod_pam_csync.c mod_pam_fp.c mod_pam_fprint.c mod_pam_pwhistory.c \
mod_pam_selinux.c mod_pam_gnome_keyring.c mod_pam_passwdqc.c \
mod_pam_exec.c mod_pam_sss.c mod_pam_fprintd.c mod_pam_systemd.c \
- mod_pam_ecryptfs.c mod_pam_access.c
+ mod_pam_ecryptfs.c mod_pam_access.c mod_pam_kwallet.c
noinst_HEADERS = pam-config.h pam-module.h
Index: pam-config-0.88/src/Makefile.in
===================================================================
--- pam-config-0.88.orig/src/Makefile.in
+++ pam-config-0.88/src/Makefile.in
@@ -128,7 +128,7 @@ am_pam_config_OBJECTS = pam-config.$(OBJ
mod_pam_passwdqc.$(OBJEXT) mod_pam_exec.$(OBJEXT) \
mod_pam_sss.$(OBJEXT) mod_pam_fprintd.$(OBJEXT) \
mod_pam_systemd.$(OBJEXT) mod_pam_ecryptfs.$(OBJEXT) \
- mod_pam_access.$(OBJEXT)
+ mod_pam_access.$(OBJEXT) mod_pam_kwallet.$(OBJEXT)
pam_config_OBJECTS = $(am_pam_config_OBJECTS)
pam_config_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
@@ -355,7 +355,7 @@ pam_config_SOURCES = pam-config.c load_c
mod_pam_csync.c mod_pam_fp.c mod_pam_fprint.c mod_pam_pwhistory.c \
mod_pam_selinux.c mod_pam_gnome_keyring.c mod_pam_passwdqc.c \
mod_pam_exec.c mod_pam_sss.c mod_pam_fprintd.c mod_pam_systemd.c \
- mod_pam_ecryptfs.c mod_pam_access.c
+ mod_pam_ecryptfs.c mod_pam_access.c mod_pam_kwallet.c
noinst_HEADERS = pam-config.h pam-module.h
all: all-am
@@ -464,6 +464,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_gnome_keyring.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_group.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_krb5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_kwallet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_lastlog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_ldap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_pam_limits.Po@am__quote@
Index: pam-config-0.88/src/mod_pam_kwallet.c
===================================================================
--- /dev/null
+++ pam-config-0.88/src/mod_pam_kwallet.c
@@ -0,0 +1,132 @@
+/* Copyright (C) 2008 Thorsten Kukuk
+ Copyright (C) 2014 Herbert Graeber
+ Author: Thorsten Kukuk <kukuk@thkukuk.de>
+ Herbert Graeber <herbert@graeber-clan.de>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2 as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "pam-config.h"
+#include "pam-module.h"
+
+static void
+write_config_internal (FILE *fp, option_set_t *opt_set, const char *service)
+{
+ fprintf (fp, "%s optional\tpam_kwallet.so\t", service);
+
+ WRITE_CONFIG_OPTIONS
+}
+
+static int
+write_config_kwallet (pam_module_t *this,
+ enum write_type op __attribute__((unused)),
+ FILE *unused __attribute__((unused)))
+{
+ option_set_t *opt_set = this->get_opt_set (this, SESSION);
+ int is_written_session = 0, is_written_auth = 0;
+ FILE *fp;
+ config_content_t *ptr;
+ int writeit = opt_set->is_enabled (opt_set, "is_enabled");
+
+ if (debug)
+ {
+ debug_write_call (this, AUTH);
+ debug_write_call (this, SESSION);
+ }
+
+ load_single_config (gl_service, &ptr);
+
+ fp = create_service_file (gl_service);
+ if(fp == NULL)
+ return 1;
+
+ while (ptr != NULL)
+ {
+ if (writeit)
+ {
+ if (!is_written_session)
+ {
+ if (strcasestr (ptr->line, "session") != NULL)
+ {
+ write_config_internal (fp, opt_set, "session");
+ is_written_session = 1;
+ }
+ }
+ if (!is_written_auth)
+ {
+ if (strcasestr (ptr->line, "auth") != NULL)
+ {
+ write_config_internal (fp, opt_set, "auth");
+ is_written_auth = 1;
+ }
+ }
+
+ /* don't write old pam_kwallet.so line */
+ if (strcasestr (ptr->line, "pam_kwallet.so") == NULL)
+ fprintf (fp, "%s", ptr->line);
+ }
+ else
+ {
+ if (strcasestr (ptr->line, "pam_kwallet.so") == NULL)
+ fprintf (fp, "%s", ptr->line);
+ else
+ {
+ is_written_auth = 1;
+ is_written_session = 1;
+ }
+ }
+
+ ptr = ptr->next;
+ }
+
+ /* make sure we really write it if we have to add it. */
+ if ((!is_written_auth || !is_written_session) && writeit)
+ {
+ write_config_internal (fp, opt_set, "auth");
+ write_config_internal (fp, opt_set, "session");
+ }
+
+ return close_service_file (fp, gl_service);
+}
+
+GETOPT_START_ALL
+GETOPT_END_ALL
+
+PRINT_ARGS("kwallet")
+PRINT_XMLHELP("kwallet")
+
+/* ---- contruct module object ---- */
+DECLARE_BOOL_OPTS_1(is_enabled);
+DECLARE_STRING_OPTS_3(kdehome, kwalletd, socketPath);
+DECLARE_OPT_SETS;
+
+static module_helptext_t helptext[] = {{NULL, NULL, NULL}};
+
+/* at last construct the complete module object */
+pam_module_t mod_pam_kwallet = { "pam_kwallet.so", opt_sets, helptext,
+ &def_parse_config,
+ &def_print_module,
+ &write_config_kwallet,
+ &get_opt_set,
+ &getopt,
+ &print_args,
+ &print_xmlhelp};
Index: pam-config-0.88/src/pam-config.8
===================================================================
--- pam-config-0.88.orig/src/pam-config.8
+++ pam-config-0.88/src/pam-config.8
@@ -1251,6 +1251,32 @@ Add
option to all pam_lastlog\&.so invocations\&.
.RE
.PP
+\fB\-\-kwallet\fR
+.RS 4
+Enable/Disable pam_kwallet\&.so
+.RE
+.PP
+\fB\-\-kwallet\-kdehome=\fR\fIvalue\fR
+.RS 4
+Add
+\fBkdehome\fR
+option to all pam_kwallet\&.so invocations\&.
+.RE
+.PP
+\fB\-\-kwallet\-kwalletd=\fR\fIvalue\fR
+.RS 4
+Add
+\fBkwalletd=\fR\fIvalue\fR
+option to pam_kwallet\&.so\&.
+.RE
+.PP
+\fB\-\-kwallet\-socketPath=\fR\fIvalue\fR
+.RS 4
+Add
+\fBsocketPath=\fR\fIvalue\fR
+option to pam_kwallet\&.so\&.
+.RE
+.PP
\fB\-\-loginuid\fR
.RS 4
Enable/Disable pam_loginuid\&.so
Index: pam-config-0.88/src/pam-config.8.xml
===================================================================
--- pam-config-0.88.orig/src/pam-config.8.xml
+++ pam-config-0.88/src/pam-config.8.xml
@@ -1459,6 +1459,38 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--kwallet</option></term>
+ <listitem>
+ <para>
+ Enable/Disable pam_kwallet.so
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--kwallet-kdehome=</option><replaceable>value</replaceable></term>
+ <listitem>
+ <para>
+ Add <option>kdehome=</option><replaceable>value</replaceable> option to pam_kwallet.so.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--kwallet-kwalletd=</option><replaceable>value</replaceable></term>
+ <listitem>
+ <para>
+ Add <option>kwalletd=</option><replaceable>value</replaceable> option to pam_kwallet.so.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--kwallet-socketPath=</option><replaceable>value</replaceable></term>
+ <listitem>
+ <para>
+ Add <option>socketPath=</option><replaceable>value</replaceable> option to pam_kwallet.so.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--lastlog</option></term>
<listitem>
<para>
Index: pam-config-0.88/src/supported-modules.h
===================================================================
--- pam-config-0.88.orig/src/supported-modules.h
+++ pam-config-0.88/src/supported-modules.h
@@ -39,6 +39,7 @@ extern pam_module_t mod_pam_winbind;
extern pam_module_t mod_pam_ck_connector;
extern pam_module_t mod_pam_cryptpass;
extern pam_module_t mod_pam_csync;
+extern pam_module_t mod_pam_kwallet;
extern pam_module_t mod_pam_loginuid;
extern pam_module_t mod_pam_mount;
extern pam_module_t mod_pam_systemd;
@@ -165,6 +166,7 @@ pam_module_t *service_module_list[] = {
&mod_pam_ck_connector,
&mod_pam_cryptpass,
&mod_pam_csync,
+ &mod_pam_kwallet,
&mod_pam_lastlog,
&mod_pam_loginuid,
&mod_pam_mount,