aboutsummaryrefslogtreecommitdiff
path: root/libpam/include/security/_pam_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'libpam/include/security/_pam_macros.h')
-rw-r--r--libpam/include/security/_pam_macros.h84
1 files changed, 52 insertions, 32 deletions
diff --git a/libpam/include/security/_pam_macros.h b/libpam/include/security/_pam_macros.h
index b5129d2a..d01f51f5 100644
--- a/libpam/include/security/_pam_macros.h
+++ b/libpam/include/security/_pam_macros.h
@@ -21,21 +21,21 @@
* override the memory.
*/
-#define _pam_overwrite(x) \
-do { \
- PAM_DEPRECATED register char *__xx__; \
- if ((__xx__=(x))) \
- while (*__xx__) \
- *__xx__++ = '\0'; \
+#define _pam_overwrite(x) \
+do { \
+ PAM_DEPRECATED register char *xx_; \
+ if ((xx_=(x))) \
+ while (*xx_) \
+ *xx_++ = '\0'; \
} while (0)
-#define _pam_overwrite_n(x,n) \
-do { \
- PAM_DEPRECATED register char *__xx__; \
- register unsigned int __i__ = 0; \
- if ((__xx__=(x))) \
- for (;__i__<n; __i__++) \
- __xx__[__i__] = 0; \
+#define _pam_overwrite_n(x,n) \
+do { \
+ PAM_DEPRECATED register char *xx_; \
+ register unsigned int i_ = 0; \
+ if ((xx_=(x))) \
+ for (;i_<(n); i_++) \
+ xx_[i_] = 0; \
} while (0)
/*
@@ -44,28 +44,25 @@ do { \
#define _pam_drop(X) \
do { \
- if (X) { \
- free(X); \
- X=NULL; \
- } \
+ free(X); \
+ (X)=NULL; \
} while (0)
/*
- * WARNING: Do NOT use this macro, as it does not reliable override the memory.
+ * WARNING: Do NOT use this macro, as it does not reliably override the memory.
*/
#define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
-do { \
- PAM_DEPRECATED int reply_i; \
- \
- for (reply_i=0; reply_i<replies; ++reply_i) { \
- if (reply[reply_i].resp) { \
- _pam_overwrite(reply[reply_i].resp); \
- free(reply[reply_i].resp); \
- } \
- } \
- if (reply) \
- free(reply); \
+do { \
+ PAM_DEPRECATED int reply_i; \
+ \
+ for (reply_i=0; reply_i<(replies); ++reply_i) { \
+ if ((reply)[reply_i].resp) { \
+ _pam_overwrite((reply)[reply_i].resp); \
+ free((reply)[reply_i].resp); \
+ } \
+ } \
+ free(reply); \
} while (0)
/* some debugging code */
@@ -97,8 +94,25 @@ do { \
#define _PAM_LOGFILE "/var/run/pam-debug.log"
#endif
-static void _pam_output_debug_info(const char *file, const char *fn
- , const int line)
+#ifdef PAM_NO_HEADER_FUNCTIONS
+UNUSED
+extern void _pam_output_debug_info(const char *file, const char *fn
+ , const int line);
+UNUSED
+PAM_FORMAT((printf, 1, 2))
+extern void _pam_output_debug(const char *format, ...);
+#else
+#ifdef PAM_DEBUG_C
+#define PAM_DEBUG_SCOPE
+#else
+#define PAM_DEBUG_SCOPE static
+#endif
+
+#ifdef UNUSED
+UNUSED
+#endif
+PAM_DEBUG_SCOPE void _pam_output_debug_info(const char *file, const char *fn
+ , const int line)
{
FILE *logfile;
int must_close = 1, fd;
@@ -123,7 +137,11 @@ static void _pam_output_debug_info(const char *file, const char *fn
fclose(logfile);
}
-static void _pam_output_debug(const char *format, ...)
+#ifdef UNUSED
+UNUSED
+#endif
+PAM_FORMAT((printf, 1, 2))
+PAM_DEBUG_SCOPE void _pam_output_debug(const char *format, ...)
{
va_list args;
FILE *logfile;
@@ -153,6 +171,8 @@ static void _pam_output_debug(const char *format, ...)
va_end(args);
}
+#undef PAM_DEBUG_SCOPE
+#endif
#define D(x) do { \
_pam_output_debug_info(__FILE__, __FUNCTION__, __LINE__); \