mirror of https://github.com/jrbrtsn/ban2fail
Fixed omission in DNS reporting
This commit is contained in:
parent
6bcf8f54e7
commit
115c92855a
|
@ -92,7 +92,7 @@ struct Global G= {
|
|||
.version= {
|
||||
.major= 0,
|
||||
.minor= 13,
|
||||
.patch= 6
|
||||
.patch= 7
|
||||
},
|
||||
|
||||
.bitTuples.flags= GlobalFlagBitTuples
|
||||
|
|
42
ez_es.c
42
ez_es.c
|
@ -16,7 +16,11 @@ int _ez_ES_registerFd (
|
|||
{
|
||||
int rtn= ES_registerFd(fd, events, callback_f, ctxt);
|
||||
if(-1 == rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_registerFd() failed.");
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_registerFd() failed.");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -35,7 +39,11 @@ int _ez_ES_registerSignal (
|
|||
{
|
||||
int rtn= ES_registerSignal(signum, callback_f, ctxt);
|
||||
if(-1 == rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_registerSignal() failed.");
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_registerSignal() failed.");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -54,7 +62,11 @@ int _ez_ES_registerVSignal (
|
|||
{
|
||||
int rtn= ES_registerVSignal(signum, callback_f, ctxt);
|
||||
if(-1 == rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_registerVSignal() failed.");
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_registerVSignal() failed.");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -71,7 +83,11 @@ int _ez_ES_VSignal (
|
|||
{
|
||||
int rtn= ES_VSignal(tid, signum);
|
||||
if(rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_VSignal() returned %d.", rtn);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_VSignal() returned %d.", rtn);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -90,7 +106,11 @@ int _ez_ES_registerTimer (
|
|||
{
|
||||
int rtn= ES_registerTimer(pause_ms, interval_ms, callback_f, ctxt);
|
||||
if(-1 == rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_registerTimer() failed.");
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_registerTimer() failed.");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -106,7 +126,11 @@ int _ez_ES_unregister (
|
|||
{
|
||||
int rtn= ES_unregister(key);
|
||||
if(-1 == rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_unregister() failed.");
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_unregister() failed.");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -121,7 +145,11 @@ int _ez_ES_run (
|
|||
{
|
||||
int rtn= ES_run();
|
||||
if(rtn) {
|
||||
_eprintf(fileName, lineNo, funcName, "ES_run() returned %d", rtn);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ES_run() returned %d", rtn);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
|
12
ez_libanl.c
12
ez_libanl.c
|
@ -43,7 +43,11 @@ int _ez_getaddrinfo_a(
|
|||
|
||||
/* _sys_eprintf() will pass errno to gai_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf(gai_strerror, fileName, lineNo, funcName, "getaddrinfo_a() failed");
|
||||
_sys_eprintf(gai_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getaddrinfo_a() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -69,6 +73,10 @@ int _ez_gai_suspend(
|
|||
|
||||
/* _sys_eprintf() will pass errno to gai_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf(gai_strerror, fileName, lineNo, funcName, "gai_suspend() failed");
|
||||
_sys_eprintf(gai_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "gai_suspend() failed");
|
||||
abort();
|
||||
}
|
||||
|
|
228
ez_libc.c
228
ez_libc.c
|
@ -35,7 +35,11 @@ int _ez_fputs (
|
|||
{
|
||||
int rtn= fputs (s, stream);
|
||||
if (EOF == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fputs() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fputs(\"%s\") failed", s);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -52,7 +56,11 @@ int _ez_fputc (
|
|||
{
|
||||
int rtn= fputc (c, stream);
|
||||
if (EOF == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fputc() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fputc('%c') failed", (unsigned char)c);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -76,7 +84,11 @@ int _ez_fprintf (
|
|||
va_end(args);
|
||||
|
||||
if (0 > rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "vfprintf() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "vfprintf() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -95,7 +107,11 @@ FILE* _ez_popen (
|
|||
errno= 0;
|
||||
FILE *rtn= popen (command, type);
|
||||
if (!rtn || errno) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "popen(\"%s\", \"%s\") failed", command, type);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "popen(\"%s\", \"%s\") failed", command, type);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -112,7 +128,11 @@ FILE* _ez_fopen (
|
|||
{
|
||||
FILE *rtn= fopen (pathname, mode);
|
||||
if (!rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fopen(\"%s\", \"%s\") failed", pathname, mode);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fopen(\"%s\", \"%s\") failed", pathname, mode);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -128,7 +148,11 @@ int _ez_fclose (
|
|||
{
|
||||
int rtn= fclose (stream);
|
||||
if (EOF == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fclose() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fclose() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -144,7 +168,11 @@ int _ez_fflush (
|
|||
{
|
||||
int rtn= fflush (stream);
|
||||
if (EOF == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fflush() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fflush() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -163,7 +191,11 @@ size_t _ez_fread (
|
|||
{
|
||||
size_t rtn= fread (ptr, size, nmemb, stream);
|
||||
if (ferror(stream)) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fread() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fread() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -182,7 +214,11 @@ size_t _ez_fwrite (
|
|||
{
|
||||
size_t rtn= fwrite (ptr, size, nmemb, stream);
|
||||
if (ferror(stream)) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fwrite() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fwrite() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -198,7 +234,11 @@ int _ez_pclose (
|
|||
{
|
||||
int rtn= pclose (stream);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "pclose() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "pclose() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -216,7 +256,11 @@ char* _ez_fgets (
|
|||
{
|
||||
char *rtn= fgets (s, size, stream);
|
||||
if (!rtn && !feof(stream)) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fgets() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fgets() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -232,7 +276,11 @@ int _ez_remove (
|
|||
{
|
||||
int rtn= remove (pathname);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "remove(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "remove(\"%s\") failed", pathname);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -249,7 +297,11 @@ int _ez_rename (
|
|||
{
|
||||
int rtn= rename (oldpath, newpath);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "rename(\"%s\", \"%s\") failed", oldpath, newpath);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "rename(\"%s\", \"%s\") failed", oldpath, newpath);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -265,7 +317,11 @@ DIR* _ez_opendir (
|
|||
{
|
||||
DIR *rtn= opendir (name);
|
||||
if (!rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "opendir(\"%s\") failed", name);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "opendir(\"%s\") failed", name);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -281,7 +337,11 @@ int _ez_closedir (
|
|||
{
|
||||
int rtn= closedir (dirp);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "closedir() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "closedir() failed");
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -301,7 +361,11 @@ struct dirent* _ez_readdir (
|
|||
struct dirent* rtn= readdir(dirp);
|
||||
|
||||
if (!rtn && errno) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "readdir() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "readdir() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -318,7 +382,11 @@ int _ez_close (
|
|||
{
|
||||
int rtn= close (fd);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "close(%d) failed", fd);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "close(%d) failed", fd);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -336,7 +404,11 @@ ssize_t _ez_write (
|
|||
{
|
||||
ssize_t rtn= write (fd, buf, count);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "write(fd= %d) failed", fd);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "write(fd= %d) failed", fd);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -353,7 +425,11 @@ int _ez_stat (
|
|||
{
|
||||
int rtn= stat (pathname, statbuf);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "stat(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "stat(\"%s\") failed", pathname);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -370,7 +446,11 @@ int _ez_mkdir (
|
|||
{
|
||||
int rtn= mkdir (pathname, mode);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "mkdir(\"%s\", %04x) failed", pathname, (unsigned)mode);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "mkdir(\"%s\", %04x) failed", pathname, (unsigned)mode);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -386,7 +466,11 @@ int _ez_rmdir (
|
|||
{
|
||||
int rtn= rmdir (pathname);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "rmdir(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "rmdir(\"%s\") failed", pathname);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -402,7 +486,11 @@ int _ez_unlink (
|
|||
{
|
||||
int rtn= unlink (pathname);
|
||||
if (-1 == rtn) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "unlink(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "unlink(\"%s\") failed", pathname);
|
||||
abort();
|
||||
}
|
||||
return rtn;
|
||||
|
@ -430,13 +518,21 @@ int _ez_getaddrinfo(
|
|||
return rtn;
|
||||
|
||||
case EAI_SYSTEM:
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "getaddrinfo(\"%s:%s\") failed", node, service);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getaddrinfo(\"%s:%s\") failed", node, service);
|
||||
abort();
|
||||
}
|
||||
|
||||
/* _sys_eprintf() will pass errno to gai_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf(gai_strerror, fileName, lineNo, funcName, "getaddrinfo(\"%s:%s\") failed", node, service);
|
||||
_sys_eprintf(gai_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getaddrinfo(\"%s:%s\") failed", node, service);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -464,13 +560,21 @@ int _ez_getnameinfo(
|
|||
return rtn;
|
||||
|
||||
case EAI_SYSTEM:
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "getnameinfo() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getnameinfo() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
/* _sys_eprintf() will pass errno to gai_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf(gai_strerror, fileName, lineNo, funcName, "getnameinfo() failed", rtn);
|
||||
_sys_eprintf(gai_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getnameinfo() failed", rtn);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -494,7 +598,11 @@ int _ez_flock (
|
|||
break;
|
||||
}
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "flock() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "flock() failed");
|
||||
abort();
|
||||
|
||||
}
|
||||
|
@ -520,7 +628,11 @@ int _ez_open(
|
|||
break;
|
||||
}
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "open(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "open(\"%s\") failed", pathname);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
@ -544,7 +656,11 @@ int _ez_access(
|
|||
break;
|
||||
}
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "access(\"%s\") failed", pathname);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "access(\"%s\") failed", pathname);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
@ -562,7 +678,11 @@ char *_ez_strptime(
|
|||
char *rtn= strptime (s, format, tm);
|
||||
if(rtn) return rtn;
|
||||
|
||||
_eprintf(fileName, lineNo, funcName, "strptime(\"%s\",\"%s\") failed", s, format);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"strptime(\"%s\", \"%s\") failed", s, format);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
@ -578,7 +698,11 @@ int _ez_seteuid(
|
|||
int rtn= seteuid (euid);
|
||||
if(0 == rtn) return 0;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "seteuid(%d) failed", (int)euid);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "seteuid(%d) failed", (int)euid);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -593,7 +717,11 @@ int _ez_setegid(
|
|||
int rtn= setegid (egid);
|
||||
if(0 == rtn) return 0;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "setegid(%d) failed", (int)egid);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "setegid(%d) failed", (int)egid);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -621,7 +749,11 @@ struct group* _ez_getgrnam(
|
|||
|
||||
}
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "getgrnam(\"%s\") failed", name);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "getgrnam(\"%s\") failed", name);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
@ -639,7 +771,11 @@ int _ez_chown(
|
|||
int rtn= chown (pathname, owner, group);
|
||||
if(0 == rtn) return rtn;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "chown(\"%s\", %d, %d) failed", pathname, (int)owner, (int)group);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "chown(\"%s\", %d, %d) failed", pathname, (int)owner, (int)group);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -656,7 +792,11 @@ int _ez_fchown(
|
|||
int rtn= fchown (fd, owner, group);
|
||||
if(0 == rtn) return rtn;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fchown() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fchown() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -672,7 +812,11 @@ int _ez_fchmod(
|
|||
int rtn= fchmod (fd, mode);
|
||||
if(0 == rtn) return rtn;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "fchmod() failed");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "fchmod() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -687,7 +831,11 @@ int _ez_setuid(
|
|||
int rtn= setuid (uid);
|
||||
if(0 == rtn) return 0;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "setuid(%d) failed", (int)uid);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "setuid(%d) failed", (int)uid);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -702,6 +850,10 @@ int _ez_setgid(
|
|||
int rtn= setgid (gid);
|
||||
if(0 == rtn) return 0;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "setgid(%d) failed", (int)gid);
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "setgid(%d) failed", (int)gid);
|
||||
abort();
|
||||
}
|
||||
|
|
43
ez_libdb.c
43
ez_libdb.c
|
@ -38,7 +38,11 @@ int _ez_db_create(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "db_create() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "db_create() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -56,14 +60,17 @@ int _ez_db_open(
|
|||
int mode
|
||||
)
|
||||
{
|
||||
//eprintf("Opening file (%p) \"%s\"", db, file);
|
||||
int rtn= db->open(db, txnid, file, database, type, flags, mode);
|
||||
|
||||
if(!rtn) return 0;
|
||||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->open(\"%s\") failed", database);
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->open(\"%s\") failed", database);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -85,7 +92,11 @@ int _ez_db_put(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->put() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->put() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -111,7 +122,11 @@ int _ez_db_get(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->get() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->get() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -132,7 +147,11 @@ int _ez_db_del(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->del() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->del() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -151,7 +170,11 @@ int _ez_db_close(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->close() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->close() failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -170,6 +193,10 @@ int _ez_db_fd(
|
|||
|
||||
/* _sys_eprintf() will pass errno to db_sterror */
|
||||
errno= rtn;
|
||||
_sys_eprintf((const char*(*)(int))db_strerror, fileName, lineNo, funcName, "DB->fd() failed");
|
||||
_sys_eprintf((const char*(*)(int))db_strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "DB->fd() failed");
|
||||
abort();
|
||||
}
|
||||
|
|
90
ez_libz.c
90
ez_libz.c
|
@ -34,7 +34,11 @@ gzFile _ez_gzopen(
|
|||
gzFile rtn= gzopen(path, mode);
|
||||
if(rtn) return rtn;
|
||||
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzopen()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzopen()");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -54,7 +58,11 @@ int _ez_gzclose(
|
|||
switch(err) {
|
||||
|
||||
case Z_ERRNO:
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzclose()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzclose()");
|
||||
abort();
|
||||
|
||||
case Z_STREAM_ERROR:
|
||||
|
@ -70,7 +78,11 @@ int _ez_gzclose(
|
|||
break;
|
||||
|
||||
}
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzclose() [ %s ]", msg);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzclose() [ %s ]", msg);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -90,9 +102,17 @@ int _ez_gzwrite(
|
|||
int err;
|
||||
const char *str= gzerror(file, &err);
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzwrite()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzwrite()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzwrite() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzwrite() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
@ -113,9 +133,17 @@ int _ez_gzread(
|
|||
int err;
|
||||
const char *str= gzerror(file, &err);
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzread()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzread()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzread() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzread() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
@ -134,9 +162,17 @@ int _ez_gzflush(
|
|||
|
||||
const char *str= gzerror(file, &err);
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzflush()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzflush()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzflush() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzflush() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
@ -157,9 +193,17 @@ z_off_t _ez_gzseek(
|
|||
int err;
|
||||
const char *str= gzerror(file, &err);
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzseek()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzseek()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzseek() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzseek() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
@ -181,9 +225,17 @@ char* _ez_gzgets (
|
|||
const char *str= gzerror(file, &err);
|
||||
if(Z_OK != err && Z_STREAM_END != err) {
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gzgets()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gzgets()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gzgets() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gzgets() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
@ -206,9 +258,17 @@ z_off_t _ez_gztell(
|
|||
int err;
|
||||
const char *str= gzerror(file, &err);
|
||||
if(Z_ERRNO == err) {
|
||||
_sys_eprintf((const char*(*)(int))strerror, fileName, lineNo, funcName, "ERROR: gztell()");
|
||||
_sys_eprintf((const char*(*)(int))strerror
|
||||
#ifdef DEBUG
|
||||
, fileName, lineNo, funcName
|
||||
#endif
|
||||
, "ERROR: gztell()");
|
||||
} else {
|
||||
_eprintf(fileName, lineNo, funcName, "ERROR: gztell() [ %s ]", str);
|
||||
_eprintf(
|
||||
#ifdef DEBUG
|
||||
fileName, lineNo, funcName,
|
||||
#endif
|
||||
"ERROR: gztell() [ %s ]", str);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ DST=$BINDIR/$B2F
|
|||
echo $0 $@
|
||||
env | grep INSTALL
|
||||
strip release/$B2F
|
||||
sudo cp release/$B2F $DST
|
||||
sudo /bin/cp -f release/$B2F $DST
|
||||
sudo chown .adm $DST
|
||||
sudo chmod 4750 $DST
|
||||
|
||||
|
|
|
@ -118,6 +118,12 @@ LOGTYPE_proto_constructor(LOGTYPE *self, const struct logProtoType *proto)
|
|||
{ /* Compute md5sum of all patterns put together */
|
||||
MD5_CTX md5ctx;
|
||||
MD5_Init(&md5ctx);
|
||||
|
||||
/* Get timestamp config */
|
||||
if(TS_is_prepared(&proto->ts))
|
||||
TS_MD5_update(&proto->ts, &md5ctx);
|
||||
|
||||
/* Now all targets */
|
||||
const Target *t;
|
||||
for(t= proto->targetArr; t->rxArr; ++t) {
|
||||
Target_MD5_update(t, &md5ctx);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef LOGTYPE_H
|
||||
#define LOGTYPE_H
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ban2fail.h"
|
||||
|
|
|
@ -225,6 +225,7 @@ OFFENTRY_list(OFFENTRY *self, FILE *fh, int flags, unsigned nAllowed)
|
|||
|
||||
const static struct bitTuple dns_flagsArr[]= {
|
||||
{.name= "~", .bit= PDNS_FWD_FAIL_FLG},
|
||||
{.name= "!", .bit= PDNS_FWD_MISMATCH_FLG},
|
||||
{.name= "!!", .bit= PDNS_FWD_NONE_FLG},
|
||||
{.name= "NXDOMAIN", .bit= PDNS_NXDOMAIN_FLG},
|
||||
{.name= "SERVFAIL", .bit= PDNS_SERVFAIL_FLG},
|
||||
|
|
110
pdns.c
110
pdns.c
|
@ -389,55 +389,7 @@ worker_check_inbox_f(void *vp_ndx, int signo)
|
|||
int64_t ms= clock_gettime_ms(CLOCK_REALTIME) - S.start_ms;
|
||||
|
||||
/* Check to see if we've finished the reverse DNS lookup */
|
||||
if(msg.e->dns.flags & PDNS_REV_DNS_FLG) {
|
||||
|
||||
const static struct addrinfo hints= {
|
||||
.ai_family= AF_UNSPEC, /* Allow IPv4 or IPv6 */
|
||||
.ai_socktype= SOCK_DGRAM,
|
||||
.ai_protocol= IPPROTO_UDP
|
||||
};
|
||||
|
||||
/* Get a populated addrinfo object */
|
||||
struct addrinfo *res= NULL;
|
||||
int rc= ez_getaddrinfo(msg.e->dns.name, NULL, &hints, &res);
|
||||
|
||||
#ifdef qqDEBUG
|
||||
if(!strcmp(msg.e->addr, "50.116.38.131")) {
|
||||
pthread_mutex_lock(&S.prt_mtx);
|
||||
ez_fprintf(stderr, "%s (%s) ----------------------------------\n", msg.e->addr, msg.e->dns.name);
|
||||
addrinfo_print(res, stderr);
|
||||
fflush(stderr);
|
||||
pthread_mutex_unlock(&S.prt_mtx);
|
||||
}
|
||||
#endif
|
||||
switch(rc) {
|
||||
case 0:
|
||||
if(!addrinfo_is_match(res, msg.e->addr))
|
||||
msg.e->dns.flags |= PDNS_FWD_MISMATCH_FLG;
|
||||
break;
|
||||
|
||||
case EAI_NONAME:
|
||||
msg.e->dns.flags |= PDNS_FWD_NONE_FLG;
|
||||
break;
|
||||
|
||||
case EAI_FAIL:
|
||||
case EAI_NODATA:
|
||||
case EAI_AGAIN:
|
||||
msg.e->dns.flags |= PDNS_FWD_FAIL_FLG;
|
||||
break;
|
||||
|
||||
default:
|
||||
eprintf("rc= %d", rc);
|
||||
assert(0);
|
||||
|
||||
}
|
||||
|
||||
/* In any case, we are done */
|
||||
msg.e->dns.flags |= PDNS_FWD_DNS_FLG;
|
||||
|
||||
if(res) freeaddrinfo(res);
|
||||
|
||||
} else { /* reverse lookup */
|
||||
if(!(msg.e->dns.flags & PDNS_REV_DNS_FLG)) {
|
||||
|
||||
const static struct addrinfo hints= {
|
||||
.ai_flags = AI_NUMERICHOST, /* doing reverse lookups */
|
||||
|
@ -458,9 +410,9 @@ if(!strcmp(msg.e->addr, "50.116.38.131")) {
|
|||
rc= ez_getnameinfo(res->ai_addr, res->ai_addrlen, hostBuf, sizeof(hostBuf)-1, NULL, 0, NI_NAMEREQD);
|
||||
|
||||
#ifdef qqDEBUG
|
||||
if(!strcmp(msg.e->addr, "50.116.38.131")) {
|
||||
if(!strcmp(msg.e->addr, "113.183.137.246")) {
|
||||
pthread_mutex_lock(&S.prt_mtx);
|
||||
ez_fprintf(stderr, "%s ----------------------------------\n", msg.e->addr);
|
||||
ez_fprintf(stderr, "rc= %d, %s ----------------------------------\n", rc, msg.e->addr);
|
||||
addrinfo_print(res, stderr);
|
||||
fflush(stderr);
|
||||
pthread_mutex_unlock(&S.prt_mtx);
|
||||
|
@ -487,6 +439,62 @@ if(!strcmp(msg.e->addr, "50.116.38.131")) {
|
|||
abort();
|
||||
}
|
||||
|
||||
|
||||
} else { /* reverse lookup */
|
||||
|
||||
|
||||
const static struct addrinfo hints= {
|
||||
.ai_family= AF_UNSPEC, /* Allow IPv4 or IPv6 */
|
||||
.ai_socktype= SOCK_DGRAM,
|
||||
.ai_protocol= IPPROTO_UDP
|
||||
};
|
||||
|
||||
/* Get a populated addrinfo object */
|
||||
struct addrinfo *res= NULL;
|
||||
int rc= ez_getaddrinfo(msg.e->dns.name, NULL, &hints, &res);
|
||||
|
||||
#ifdef qqDEBUG
|
||||
if(!strcmp(msg.e->addr, "113.183.137.246")) {
|
||||
pthread_mutex_lock(&S.prt_mtx);
|
||||
ez_fprintf(stderr, "rc= %d, %s (%s) ----------------------------------\n", rc, msg.e->addr, msg.e->dns.name);
|
||||
addrinfo_print(res, stderr);
|
||||
fflush(stderr);
|
||||
pthread_mutex_unlock(&S.prt_mtx);
|
||||
}
|
||||
#endif
|
||||
switch(rc) {
|
||||
case 0:
|
||||
if(!addrinfo_is_match(res, msg.e->addr))
|
||||
msg.e->dns.flags |= PDNS_FWD_MISMATCH_FLG;
|
||||
#ifdef qqDEBUG
|
||||
if(!strcmp(msg.e->addr, "113.183.137.246")) {
|
||||
eprintf( "113.183.137.246 %s"
|
||||
, msg.e->dns.flags & PDNS_FWD_MISMATCH_FLG ? "Mismatched" : "matched"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case EAI_NONAME:
|
||||
msg.e->dns.flags |= PDNS_FWD_NONE_FLG;
|
||||
break;
|
||||
|
||||
case EAI_FAIL:
|
||||
case EAI_NODATA:
|
||||
case EAI_AGAIN:
|
||||
msg.e->dns.flags |= PDNS_FWD_FAIL_FLG;
|
||||
break;
|
||||
|
||||
default:
|
||||
eprintf("rc= %d", rc);
|
||||
assert(0);
|
||||
|
||||
}
|
||||
|
||||
/* In any case, we are done */
|
||||
msg.e->dns.flags |= PDNS_FWD_DNS_FLG;
|
||||
|
||||
if(res) freeaddrinfo(res);
|
||||
}
|
||||
|
||||
/* Catch being bumped out of blocking call by signal */
|
||||
|
|
2
target.c
2
target.c
|
@ -132,6 +132,8 @@ Target_MD5_update(const Target *self, MD5_CTX *ctx)
|
|||
* For computing MD5 checksum of cumulative patterns.
|
||||
*/
|
||||
{
|
||||
MD5_Update(ctx, &self->severity, sizeof(self->severity));
|
||||
|
||||
for(unsigned i= 0; i < self->nRx; ++i) {
|
||||
const struct TargetRx *rx= self->rxArr+i;
|
||||
MD5_Update(ctx, rx->pattern, strlen(rx->pattern));
|
||||
|
|
15
timestamp.c
15
timestamp.c
|
@ -144,3 +144,18 @@ abort:
|
|||
return rtn;
|
||||
}
|
||||
|
||||
int
|
||||
TS_MD5_update(const TS *self, MD5_CTX *ctx)
|
||||
/********************************************************
|
||||
* For computing MD5 checksum of config data.
|
||||
*/
|
||||
{
|
||||
if(self->pattern)
|
||||
MD5_Update(ctx, self->pattern, strlen(self->pattern));
|
||||
|
||||
if(self->strptime_fmt)
|
||||
MD5_Update(ctx, self->strptime_fmt, strlen(self->strptime_fmt));
|
||||
|
||||
MD5_Update(ctx, &self->flags, sizeof(self->flags));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define TIMESTAMP_H
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <openssl/md5.h>
|
||||
#include <regex.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -57,6 +58,11 @@ TS_scan(const TS *self, time_t *rslt, const char *str, const struct tm *pTmRef);
|
|||
* Scan a string to obtain the timestamp.
|
||||
*/
|
||||
|
||||
int
|
||||
TS_MD5_update(const TS *self, MD5_CTX *ctx);
|
||||
/********************************************************
|
||||
* For computing MD5 checksum of config data.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
18
util.c
18
util.c
|
@ -926,7 +926,8 @@ addrinfo_is_match(const struct addrinfo *ai, const char *addr)
|
|||
{
|
||||
for(; ai; ai= ai->ai_next) {
|
||||
const char *this_addr= addrinfo_2_addr(ai);
|
||||
if(!strcmp(this_addr, addr)) return 1;
|
||||
if(!strcmp(this_addr, addr))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -944,22 +945,27 @@ addrinfo_2_addr(const struct addrinfo *ai)
|
|||
* address of the static buffer containing address in null terminated string form.
|
||||
*/
|
||||
{
|
||||
/* Rotating buffers so this can be used multiple times as arg to printf() */
|
||||
#define N_BUFS 5
|
||||
#define BUF_SZ 43
|
||||
const char *rtn= NULL;
|
||||
if(!ai->ai_addr) goto abort;
|
||||
|
||||
static _Thread_local char buf[BUF_SZ];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
static _Thread_local char bufArr[N_BUFS][BUF_SZ];
|
||||
static _Thread_local unsigned count;
|
||||
char *buf= bufArr[++count%N_BUFS];
|
||||
|
||||
memset(buf, 0, BUF_SZ);
|
||||
|
||||
switch(ai->ai_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in *sin= (struct sockaddr_in*)ai->ai_addr;
|
||||
rtn= inet_ntop(AF_INET, &sin->sin_addr, buf, sizeof(buf)-1);
|
||||
rtn= inet_ntop(AF_INET, &sin->sin_addr, buf, BUF_SZ-1);
|
||||
} break;
|
||||
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *sin6= (struct sockaddr_in6*)ai->ai_addr;
|
||||
rtn= inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf)-1);
|
||||
rtn= inet_ntop(AF_INET6, &sin6->sin6_addr, buf, BUF_SZ-1);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
@ -969,5 +975,7 @@ addrinfo_2_addr(const struct addrinfo *ai)
|
|||
|
||||
abort:
|
||||
return rtn;
|
||||
#undef BUF_SZ
|
||||
#undef N_BUFS
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue