tpm_extendpcr: Support platforms not having syslog()
This commit is contained in:
@@ -19,14 +19,18 @@
|
|||||||
#include <crypto/hashers/hasher.h>
|
#include <crypto/hashers/hasher.h>
|
||||||
#include <utils/debug.h>
|
#include <utils/debug.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#endif
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
/* logging */
|
/* logging */
|
||||||
static bool log_to_stderr = TRUE;
|
static bool log_to_stderr = TRUE;
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
static bool log_to_syslog = TRUE;
|
static bool log_to_syslog = TRUE;
|
||||||
|
#endif
|
||||||
static level_t default_loglevel = 1;
|
static level_t default_loglevel = 1;
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
@@ -39,8 +43,6 @@ chunk_t pcr_value;
|
|||||||
*/
|
*/
|
||||||
static void tpm_extendpcr_dbg(debug_t group, level_t level, char *fmt, ...)
|
static void tpm_extendpcr_dbg(debug_t group, level_t level, char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buffer[8192];
|
|
||||||
char *current = buffer, *next;
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (level <= default_loglevel)
|
if (level <= default_loglevel)
|
||||||
@@ -52,8 +54,12 @@ static void tpm_extendpcr_dbg(debug_t group, level_t level, char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
if (log_to_syslog)
|
if (log_to_syslog)
|
||||||
{
|
{
|
||||||
|
char buffer[8192];
|
||||||
|
char *current = buffer, *next;
|
||||||
|
|
||||||
/* write in memory buffer first */
|
/* write in memory buffer first */
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||||
@@ -71,6 +77,7 @@ static void tpm_extendpcr_dbg(debug_t group, level_t level, char *fmt, ...)
|
|||||||
current = next;
|
current = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,10 +92,12 @@ static void init_log(const char *program)
|
|||||||
{
|
{
|
||||||
setbuf(stderr, NULL);
|
setbuf(stderr, NULL);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
if (log_to_syslog)
|
if (log_to_syslog)
|
||||||
{
|
{
|
||||||
openlog(program, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
|
openlog(program, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user