implemented RFC4478 (repeated authentication)
changed %V printf handler to take a time delta, %#V now takes two arguments
This commit is contained in:
@@ -544,7 +544,7 @@ static void list(const private_x509ac_t *this, FILE *out, bool utc)
|
||||
fprintf(out, " validity: not before %#T, ", &this->notBefore, utc);
|
||||
if (now < this->notBefore)
|
||||
{
|
||||
fprintf(out, "not valid yet (valid in %V)\n", &now, &this->notBefore);
|
||||
fprintf(out, "not valid yet (valid in %#V)\n", &now, &this->notBefore);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -554,14 +554,14 @@ static void list(const private_x509ac_t *this, FILE *out, bool utc)
|
||||
fprintf(out, " not after %#T, ", &this->notAfter, utc);
|
||||
if (now > this->notAfter)
|
||||
{
|
||||
fprintf(out, "expired (%V ago)\n", &now, &this->notAfter);
|
||||
fprintf(out, "expired (%#V ago)\n", &now, &this->notAfter);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out, "ok");
|
||||
if (now > this->notAfter - ACERT_WARNING_INTERVAL * 60 * 60 * 24)
|
||||
{
|
||||
fprintf(out, " (expires in %V)", &now, &this->notAfter);
|
||||
fprintf(out, " (expires in %#V)", &now, &this->notAfter);
|
||||
}
|
||||
fprintf(out, " \n");
|
||||
}
|
||||
|
||||
@@ -279,11 +279,11 @@ static void list_certinfos(private_ca_info_t *this, FILE *out, bool utc)
|
||||
fprintf(out, "%#T, until %#T, ", &thisUpdate, utc, &nextUpdate, utc);
|
||||
if (now > nextUpdate)
|
||||
{
|
||||
fprintf(out, "expired (%V ago)\n", &now, &nextUpdate);
|
||||
fprintf(out, "expired (%#V ago)\n", &now, &nextUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out, "ok (expires in %V)\n", &now, &nextUpdate);
|
||||
fprintf(out, "ok (expires in %#V)\n", &now, &nextUpdate);
|
||||
}
|
||||
fprintf(out, " serial: %#B, %N\n", &serial,
|
||||
cert_status_names, certinfo->get_status(certinfo));
|
||||
|
||||
@@ -463,11 +463,11 @@ static void list(private_crl_t *this, FILE* out, bool utc)
|
||||
}
|
||||
else if (now > this->nextUpdate)
|
||||
{
|
||||
fprintf(out, "expired (%V ago)\n", &now, &this->nextUpdate);
|
||||
fprintf(out, "expired (%#V ago)\n", &now, &this->nextUpdate);
|
||||
}
|
||||
else if (now > this->nextUpdate - CRL_WARNING_INTERVAL * 60 * 60 * 24)
|
||||
{
|
||||
fprintf(out, "ok (expires in %V)\n", &now, &this->nextUpdate);
|
||||
fprintf(out, "ok (expires in %#V)\n", &now, &this->nextUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1182,7 +1182,7 @@ static void list(private_x509_t *this, FILE *out, bool utc)
|
||||
fprintf(out, " validity: not before %#T, ", &this->notBefore, utc);
|
||||
if (now < this->notBefore)
|
||||
{
|
||||
fprintf(out, "not valid yet (valid in %V)\n", &now, &this->notBefore);
|
||||
fprintf(out, "not valid yet (valid in %#V)\n", &now, &this->notBefore);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1192,14 +1192,14 @@ static void list(private_x509_t *this, FILE *out, bool utc)
|
||||
fprintf(out, " not after %#T, ", &this->notAfter, utc);
|
||||
if (now > this->notAfter)
|
||||
{
|
||||
fprintf(out, "expired (%V ago)\n", &now, &this->notAfter);
|
||||
fprintf(out, "expired (%#V ago)\n", &now, &this->notAfter);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out, "ok");
|
||||
if (now > this->notAfter - CERT_WARNING_INTERVAL * 60 * 60 * 24)
|
||||
{
|
||||
fprintf(out, " (expires in %V)", &now, &this->notAfter);
|
||||
fprintf(out, " (expires in %#V)", &now, &this->notAfter);
|
||||
}
|
||||
fprintf(out, " \n");
|
||||
}
|
||||
|
||||
@@ -150,11 +150,20 @@ static int print_time(FILE *stream, const struct printf_info *info,
|
||||
static int print_time_delta(FILE *stream, const struct printf_info *info,
|
||||
const void *const *args)
|
||||
{
|
||||
time_t *start = *((time_t**)(args[0]));
|
||||
time_t *end = *((time_t**)(args[1]));
|
||||
u_int delta = abs(*end - *start);
|
||||
|
||||
char* unit = "second";
|
||||
time_t *arg1, *arg2;
|
||||
time_t delta;
|
||||
|
||||
arg1 = *((time_t**)(args[0]));
|
||||
if (info->alt)
|
||||
{
|
||||
arg2 = *((time_t**)(args[1]));
|
||||
delta = abs(*arg1 - *arg2);
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = *arg1;
|
||||
}
|
||||
|
||||
if (delta > 2 * 60 * 60 * 24)
|
||||
{
|
||||
@@ -180,5 +189,5 @@ static int print_time_delta(FILE *stream, const struct printf_info *info,
|
||||
static void __attribute__ ((constructor))print_register()
|
||||
{
|
||||
register_printf_function(PRINTF_TIME, print_time, arginfo_ptr_alt_ptr_int);
|
||||
register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_ptr_ptr);
|
||||
register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_ptr_alt_ptr_ptr);
|
||||
}
|
||||
|
||||
@@ -116,3 +116,26 @@ int arginfo_ptr_alt_ptr_int(const struct printf_info *info, size_t n, int *argty
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* special arginfo handler respecting alt flag
|
||||
*/
|
||||
int arginfo_ptr_alt_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
if (info->alt)
|
||||
{
|
||||
if (n > 1)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
argtypes[1] = PA_POINTER;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
argtypes[0] = PA_POINTER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#define PRINTF_TRAFFIC_SELECTOR 'R'
|
||||
/** 1 argument: time_t *time; with #-modifier 2 arguments: time_t *time, bool utc */
|
||||
#define PRINTF_TIME 'T'
|
||||
/** 2 arguments: time_t *begin, time_t *end */
|
||||
/** 1 argument: time_t *delta; with #-modifier 2 arguments: time_t *begin, time_t *end */
|
||||
#define PRINTF_TIME_DELTA 'V'
|
||||
|
||||
/**
|
||||
@@ -55,6 +55,7 @@ int arginfo_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes);
|
||||
int arginfo_ptr_int(const struct printf_info *info, size_t n, int *argtypes);
|
||||
int arginfo_int_int(const struct printf_info *info, size_t n, int *argtypes);
|
||||
int arginfo_ptr_alt_ptr_int(const struct printf_info *info, size_t n, int *argtypes);
|
||||
int arginfo_ptr_alt_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes);
|
||||
int arginfo_int_alt_int_int(const struct printf_info *info, size_t n, int *argtypes);
|
||||
|
||||
#endif /* PRINTF_HOOK_H_ */
|
||||
|
||||
Reference in New Issue
Block a user