- Added pam_google_authenticator.patch: support google authentiator

[bnc#888149]

OBS-URL: https://build.opensuse.org/package/show/Linux-PAM/pam-config?expand=0&rev=72
This commit is contained in:
Thorsten Kukuk 2014-11-12 13:34:03 +00:00 committed by Git OBS Bridge
parent 00f28c6d83
commit 3756712a68
3 changed files with 164 additions and 0 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 12 14:33:26 CET 2014 - kukuk@suse.de
- Added pam_google_authenticator.patch: support google authentiator
[bnc#888149]
-------------------------------------------------------------------
Thu Sep 25 14:43:18 CEST 2014 - kukuk@suse.de

View File

@ -24,6 +24,7 @@ Version: 0.88
Release: 0
PreReq: pam >= 0.99
Source: %{name}-%{version}.tar.bz2
Patch: pam_google_authenticator.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -37,6 +38,7 @@ add/adjust/remove other PAM modules and their options.
%prep
%setup -q
%patch -p1
%build
%configure

View File

@ -0,0 +1,156 @@
diff -uNr pam-config-0.87/src/Makefile.am pam-config-0.87.gauth/src/Makefile.am
--- pam-config-0.87/src/Makefile.am 2014-04-02 08:45:02.000000000 -0400
+++ pam-config-0.87.gauth/src/Makefile.am 2014-07-17 07:57:50.000000000 -0400
@@ -31,7 +31,7 @@
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_google_authenticator.c
noinst_HEADERS = pam-config.h pam-module.h
diff -uNr pam-config-0.87/src/Makefile.in pam-config-0.87.gauth/src/Makefile.in
--- pam-config-0.87/src/Makefile.in 2014-04-02 09:11:21.000000000 -0400
+++ pam-config-0.87.gauth/src/Makefile.in 2014-07-17 07:57:50.000000000 -0400
@@ -128,7 +128,7 @@
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_google_authenticator.$(OBJEXT)
pam_config_OBJECTS = $(am_pam_config_OBJECTS)
pam_config_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
diff -uNr pam-config-0.87/src/mod_pam_google_authenticator.c pam-config-0.87.gauth/src/mod_pam_google_authenticator.c
--- pam-config-0.87/src/mod_pam_google_authenticator.c 1969-12-31 19:00:00.000000000 -0500
+++ pam-config-0.87.gauth/src/mod_pam_google_authenticator.c 2014-07-17 14:26:47.914409709 -0400
@@ -0,0 +1,110 @@
+/* Copyright (C) 2014 Darin Perusich
+ Author: Darin Perusich <darin@darins.net>
+
+ 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 <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "pam-config.h"
+#include "pam-module.h"
+
+static void
+write_config_internal (FILE *fp, option_set_t *opt_set)
+{
+ fprintf (fp, "auth\trequired\tpam_google_authenticator.so\t");
+
+ WRITE_CONFIG_OPTIONS
+}
+
+static int
+write_config_google_authenticator (pam_module_t *this,
+ enum write_type op __attribute__((unused)),
+ FILE *unused __attribute__((unused)))
+{
+ option_set_t *opt_set = this->get_opt_set (this, AUTH);
+ int is_written = 0;
+ FILE *fp;
+ config_content_t *ptr;
+ int writeit = opt_set->is_enabled (opt_set, "is_enabled");
+
+ if (debug)
+ debug_write_call (this, AUTH);
+
+ load_single_config (gl_service, &ptr);
+
+ fp = create_service_file (gl_service);
+ if( fp == NULL ) return 1;
+
+ while (ptr != NULL)
+ {
+ if (writeit)
+ {
+ /* don't write old pam_google_authenticator.so line */
+ if (strcasestr (ptr->line, "pam_google_authenticator.so") == NULL)
+ fprintf (fp, "%s", ptr->line);
+
+ if (!is_written)
+ {
+ if (strcasestr (ptr->line, "auth") != NULL)
+ {
+ write_config_internal (fp, opt_set);
+ is_written = 1;
+ }
+ }
+ }
+ else
+ {
+ if (strcasestr (ptr->line, "pam_google_authenticator.so") == NULL)
+ fprintf (fp, "%s", ptr->line);
+ else
+ is_written = 1;
+ }
+ ptr = ptr->next;
+ }
+
+ /* make sure we really write it if we have to add it. */
+ if (!is_written && writeit)
+ write_config_internal (fp, opt_set);
+
+ return close_service_file (fp, gl_service);
+}
+
+GETOPT_START_ALL
+GETOPT_END_ALL
+
+PRINT_ARGS("google_authenticator")
+PRINT_XMLHELP("google_authenticator")
+
+/* ---- contruct module object ---- */
+DECLARE_BOOL_OPTS_3 (is_enabled, noskewadj, nullok);
+DECLARE_STRING_OPTS_1 (secret);
+DECLARE_OPT_SETS;
+
+static module_helptext_t helptext[] = {{NULL, NULL, NULL}};
+
+/* at last construct the complete module object */
+pam_module_t mod_pam_google_authenticator = { "pam_google_authenticator.so", opt_sets, helptext,
+ &def_parse_config,
+ &def_print_module,
+ &write_config_google_authenticator,
+ &get_opt_set,
+ &getopt,
+ &print_args,
+ &print_xmlhelp};
diff -uNr pam-config-0.87/src/supported-modules.h pam-config-0.87.gauth/src/supported-modules.h
--- pam-config-0.87/src/supported-modules.h 2014-04-02 08:43:31.000000000 -0400
+++ pam-config-0.87.gauth/src/supported-modules.h 2014-07-17 07:57:50.000000000 -0400
@@ -42,6 +42,7 @@
extern pam_module_t mod_pam_loginuid;
extern pam_module_t mod_pam_mount;
extern pam_module_t mod_pam_systemd;
+extern pam_module_t mod_pam_google_authenticator;
pam_module_t *common_module_list[] = {
&mod_pam_access,
@@ -167,5 +168,6 @@
&mod_pam_lastlog,
&mod_pam_loginuid,
&mod_pam_mount,
+ &mod_pam_google_authenticator,
NULL
};