Simplify things for PAM.
authorNIIBE Yutaka <gniibe@fsij.org>
Mon, 14 Nov 2016 23:14:15 +0000 (08:14 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Mon, 14 Nov 2016 23:14:15 +0000 (08:14 +0900)
* src/pam/auth-support/pam-util.h: Remove.
* src/pam/auth-support/pam-util.c: Remove.  Merge into...
* src/pam/pam_poldi.c (retrieve_username_from_pam): ... here.
(send_username_to_pam): Likewise.
* src/pam/auth-method-localdb/auth-localdb.c: Clean up.
* src/pam/auth-method-x509/auth-x509.c: Likewise.
* src/pam/auth-support/Makefile.am: Remove pam-util.{c,h}.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
src/pam/auth-method-localdb/auth-localdb.c
src/pam/auth-method-x509/auth-x509.c
src/pam/auth-support/Makefile.am
src/pam/auth-support/pam-util.c [deleted file]
src/pam/auth-support/pam-util.h [deleted file]
src/pam/pam_poldi.c

index 0c65817..07dfe64 100644 (file)
@@ -35,7 +35,6 @@
 #include "util/support.h"
 #include "auth-support/ctx.h"
 #include "auth-support/wait-for-card.h"
-#include "auth-support/pam-util.h"
 
 #include "usersdb.h"
 #include "key-lookup.h"
index 4b391db..d71d988 100644 (file)
@@ -34,7 +34,6 @@
 #include "util/support.h"
 #include "auth-support/ctx.h"
 #include "auth-support/getpin-cb.h"
-#include "auth-support/pam-util.h"
 #include "auth-methods.h"
 #include "util/defs.h"
 #include "util/simplelog.h"
index 9ab48a0..9a47d73 100644 (file)
@@ -41,5 +41,4 @@ libpam_poldi_auth_support_a_SOURCES = \
  ctx.h \
  conv.c conv.h \
  getpin-cb.c getpin-cb.h \
- pam-util.c pam-util.h \
  wait-for-card.c wait-for-card.h
diff --git a/src/pam/auth-support/pam-util.c b/src/pam/auth-support/pam-util.c
deleted file mode 100644 (file)
index b133061..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* pam-util.c - PAM util functions for Poldi.
- * Copyright (C) 2007, 2008 g10 Code GmbH
- *
- * This file is part of Poldi.
- *
- * Poldi is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Poldi 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <gpg-error.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-\f
-
-/* Retrieve the username through the PAM handle contained in CTX and
-   store it in *USERNAME.  Returns proper error code.  */
-gpg_error_t
-retrieve_username_from_pam (pam_handle_t *handle, const char **username)
-{
-  const void *username_void;
-  gpg_error_t err;
-  int ret;
-
-  ret = pam_get_item (handle, PAM_USER, &username_void);
-  if (ret == PAM_SUCCESS)
-    {
-      err = 0;
-      *username = username_void;
-    }
-  else
-    err = gpg_error (GPG_ERR_INTERNAL);
-
-  return err;
-}
-
-/* Make USERNAME available to the application through the PAM handle
-   contained in CTX.  Returns proper error code.  */
-gpg_error_t
-send_username_to_pam (pam_handle_t *handle, const char *username)
-{
-  gpg_error_t err;
-  int ret;
-
-  ret = pam_set_item (handle, PAM_USER, username);
-  if (ret == PAM_SUCCESS)
-    err = 0;
-  else
-    err = gpg_error (GPG_ERR_INTERNAL);
-
-  return err;
-}
diff --git a/src/pam/auth-support/pam-util.h b/src/pam/auth-support/pam-util.h
deleted file mode 100644 (file)
index 4a03f3d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* pam-util.c - PAM util functions for Poldi.
- * Copyright (C) 2007, 2008 g10 Code GmbH
- *
- * This file is part of Poldi.
- *
- * Poldi is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Poldi 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef PAM_UTIL_H
-#define PAM_UTIL_H
-
-#include <gpg-error.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-/* Retrieve the username through the PAM handle contained in CTX and
-   store it in *USERNAME.  Returns proper error code.  */
-gpg_error_t retrieve_username_from_pam (pam_handle_t *handle, const char **username);
-
-/* Make USERNAME available to the application through the PAM handle
-   contained in CTX.  Returns proper error code.  */
-gpg_error_t send_username_to_pam (pam_handle_t *handle, const char *username);
-
-#endif
index a27a3e9..48dbb3c 100644 (file)
@@ -37,7 +37,6 @@
 #include "scd/scd.h"
 
 #include "auth-support/wait-for-card.h"
-#include "auth-support/pam-util.h"
 #include "auth-support/conv.h"
 #include "auth-support/getpin-cb.h"
 #include "auth-methods.h"
@@ -349,6 +348,43 @@ modify_environment (pam_handle_t *pam_handle, poldi_ctx_t ctx)
                             "PAM_POLDI_LANGUAGE", cardinfo->disp_lang);
 }
 
+/* Retrieve the username through the PAM handle contained in CTX and
+   store it in *USERNAME.  Returns proper error code.  */
+static gpg_error_t
+retrieve_username_from_pam (pam_handle_t *handle, const char **username)
+{
+  const void *username_void;
+  gpg_error_t err;
+  int ret;
+
+  ret = pam_get_item (handle, PAM_USER, &username_void);
+  if (ret == PAM_SUCCESS)
+    {
+      err = 0;
+      *username = username_void;
+    }
+  else
+    err = gpg_error (GPG_ERR_INTERNAL);
+
+  return err;
+}
+
+/* Make USERNAME available to the application through the PAM handle
+   contained in CTX.  Returns proper error code.  */
+static gpg_error_t
+send_username_to_pam (pam_handle_t *handle, const char *username)
+{
+  gpg_error_t err;
+  int ret;
+
+  ret = pam_set_item (handle, PAM_USER, username);
+  if (ret == PAM_SUCCESS)
+    err = 0;
+  else
+    err = gpg_error (GPG_ERR_INTERNAL);
+
+  return err;
+}
 \f
 
 /*