summaryrefslogtreecommitdiffstats
path: root/contrib/openpam/lib
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-05-02 15:08:06 +0000
committerdes <des@FreeBSD.org>2003-05-02 15:08:06 +0000
commit1b2b5956a02e1d56168e372dc96807d70b3ca363 (patch)
tree9381d916c61bc9101bbefef7b4c7f547e277a611 /contrib/openpam/lib
parentf1f9c1228ba0058106dd6a76502b853f93ceba5d (diff)
downloadFreeBSD-src-1b2b5956a02e1d56168e372dc96807d70b3ca363.zip
FreeBSD-src-1b2b5956a02e1d56168e372dc96807d70b3ca363.tar.gz
Vendor import of OpenPAM Dianthus.
Diffstat (limited to 'contrib/openpam/lib')
-rw-r--r--contrib/openpam/lib/openpam_dispatch.c18
-rw-r--r--contrib/openpam/lib/openpam_impl.h4
-rw-r--r--contrib/openpam/lib/openpam_log.c16
-rw-r--r--contrib/openpam/lib/pam_getenv.c4
4 files changed, 27 insertions, 15 deletions
diff --git a/contrib/openpam/lib/openpam_dispatch.c b/contrib/openpam/lib/openpam_dispatch.c
index 0ff6865..29f9138 100644
--- a/contrib/openpam/lib/openpam_dispatch.c
+++ b/contrib/openpam/lib/openpam_dispatch.c
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/openpam_dispatch.c#18 $
+ * $P4: //depot/projects/openpam/lib/openpam_dispatch.c#19 $
*/
#include <sys/param.h>
@@ -59,6 +59,9 @@ openpam_dispatch(pam_handle_t *pamh,
{
pam_chain_t *chain;
int err, fail, r;
+#ifdef DEBUG
+ int debug;
+#endif
ENTER();
if (pamh == NULL)
@@ -96,8 +99,6 @@ openpam_dispatch(pam_handle_t *pamh,
/* execute */
for (err = fail = 0; chain != NULL; chain = chain->next) {
- openpam_log(PAM_LOG_DEBUG, "calling %s() in %s",
- _pam_sm_func_name[primitive], chain->module->path);
if (chain->module->func[primitive] == NULL) {
openpam_log(PAM_LOG_ERROR, "%s: no %s()",
chain->module->path, _pam_sm_func_name[primitive]);
@@ -105,12 +106,23 @@ openpam_dispatch(pam_handle_t *pamh,
} else {
pamh->primitive = primitive;
pamh->current = chain;
+#ifdef DEBUG
+ debug = (openpam_get_option(pamh, "debug") != NULL);
+ if (debug)
+ ++_openpam_debug;
+ openpam_log(PAM_LOG_DEBUG, "calling %s() in %s",
+ _pam_sm_func_name[primitive], chain->module->path);
+#endif
r = (chain->module->func[primitive])(pamh, flags,
chain->optc, (const char **)chain->optv);
pamh->current = NULL;
+#ifdef DEBUG
openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s",
chain->module->path, _pam_sm_func_name[primitive],
pam_strerror(pamh, r));
+ if (debug)
+ --_openpam_debug;
+#endif
}
if (r == PAM_IGNORE)
diff --git a/contrib/openpam/lib/openpam_impl.h b/contrib/openpam/lib/openpam_impl.h
index 0ab2811..8921cfa 100644
--- a/contrib/openpam/lib/openpam_impl.h
+++ b/contrib/openpam/lib/openpam_impl.h
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/openpam_impl.h#20 $
+ * $P4: //depot/projects/openpam/lib/openpam_impl.h#21 $
*/
#ifndef _OPENPAM_IMPL_H_INCLUDED
@@ -44,6 +44,8 @@ extern const char *_pam_sm_func_name[PAM_NUM_PRIMITIVES];
extern const char *_pam_err_name[PAM_NUM_ERRORS];
extern const char *_pam_item_name[PAM_NUM_ITEMS];
+extern int _openpam_debug;
+
/*
* Control flags
*/
diff --git a/contrib/openpam/lib/openpam_log.c b/contrib/openpam/lib/openpam_log.c
index 23a51d5..0758580 100644
--- a/contrib/openpam/lib/openpam_log.c
+++ b/contrib/openpam/lib/openpam_log.c
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/openpam_log.c#17 $
+ * $P4: //depot/projects/openpam/lib/openpam_log.c#18 $
*/
#include <ctype.h>
@@ -45,6 +45,8 @@
#include "openpam_impl.h"
+int _openpam_debug = 0;
+
#if defined(openpam_log)
/*
@@ -62,12 +64,10 @@ _openpam_log(int level, const char *func, const char *fmt, ...)
switch (level) {
case PAM_LOG_DEBUG:
-#ifndef DEBUG
- return;
-#else
+ if (!_openpam_debug)
+ return;
priority = LOG_DEBUG;
break;
-#endif
case PAM_LOG_VERBOSE:
priority = LOG_INFO;
break;
@@ -108,12 +108,10 @@ openpam_log(int level, const char *fmt, ...)
switch (level) {
case PAM_LOG_DEBUG:
-#ifndef DEBUG
- return;
-#else
+ if (!_openpam_debug)
+ return;
priority = LOG_DEBUG;
break;
-#endif
case PAM_LOG_VERBOSE:
priority = LOG_INFO;
break;
diff --git a/contrib/openpam/lib/pam_getenv.c b/contrib/openpam/lib/pam_getenv.c
index 58ad283..098e1ef 100644
--- a/contrib/openpam/lib/pam_getenv.c
+++ b/contrib/openpam/lib/pam_getenv.c
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/openpam/lib/pam_getenv.c#12 $
+ * $P4: //depot/projects/openpam/lib/pam_getenv.c#13 $
*/
#include <stdlib.h>
@@ -48,7 +48,7 @@
* Retrieve the value of a PAM environment variable
*/
-char *
+const char *
pam_getenv(pam_handle_t *pamh,
const char *name)
{
OpenPOWER on IntegriCloud