PERFORCE change 30314 for review

Dag-Erling Smorgrav des at FreeBSD.org
Thu May 1 09:20:53 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=30314

Change 30314 by des at des.at.des.thinksec.com on 2003/05/01 09:20:03

	If compiled with -DDEBUG, enable debugging right before calling a
	module which has the "debug" option, and disable it upon return.

Affected files ...

.. //depot/projects/openpam/lib/openpam_dispatch.c#19 edit

Differences ...

==== //depot/projects/openpam/lib/openpam_dispatch.c#19 (text+ko) ====

@@ -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 @@
 {
 	pam_chain_t *chain;
 	int err, fail, r;
+#ifdef DEBUG
+	int debug;
+#endif
 
 	ENTER();
 	if (pamh == NULL)
@@ -96,8 +99,6 @@
 
 	/* 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 @@
 		} 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)


More information about the p4-projects mailing list