statzone

DNS zone file analyzer targeted at TLD zones
Log | Files | Refs | README | LICENSE

commit 7281aeb016f3169e237bbc467849e27448e34c74
parent 3c6f559f00b7b39d06e19926dff8640fe91e6d28
Author: Frederic Cambus <fred@statdns.com>
Date:   Sun, 20 Jan 2019 10:18:36 +0100

StatZone now uses pledge(2) on systems supporting it.

Diffstat:
MCMakeLists.txt | 10+++++++++-
Mcompat/compat.h | 4++++
Acompat/pledge.c | 6++++++
Acompat/pledge.h | 1+
Msrc/statzone.c | 4++++
5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -4,7 +4,7 @@ # https://www.statdns.com # # Created: 2012-02-13 -# Last Updated: 2019-01-04 +# Last Updated: 2019-01-20 # # StatZone is released under the BSD 2-Clause license # See LICENSE file for details. @@ -17,6 +17,10 @@ project (statzone C) include(CheckFunctionExists) include(GNUInstallDirs) +# Check if system has pledge +list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_OPENBSD_SOURCE) +check_function_exists(pledge HAVE_PLEDGE) + # Additional include directories for compat functions include_directories("compat") @@ -26,6 +30,10 @@ include_directories(${UTHASH_INCLUDE_DIRS}) set(SRC src/statzone.c src/strtolower.c) +if(NOT HAVE_PLEDGE) + set (SRC ${SRC} compat/pledge.c) +endif() + add_definitions(-Wall -Wextra -std=c99 -pedantic) add_executable(statzone ${SRC}) diff --git a/compat/compat.h b/compat/compat.h @@ -1,6 +1,10 @@ #ifndef COMPAT_H #define COMPAT_H +#ifndef HAVE_PLEDGE +#include "pledge.h" +#endif + #ifndef timespecsub #define timespecsub(tsp, usp, vsp) \ do { \ diff --git a/compat/pledge.c b/compat/pledge.c @@ -0,0 +1,6 @@ +int +pledge(const char *promises, const char *execpromises) { + (void)promises; + (void)execpromises; + return 0; +} diff --git a/compat/pledge.h b/compat/pledge.h @@ -0,0 +1 @@ +int pledge(const char *, const char *); diff --git a/src/statzone.c b/src/statzone.c @@ -70,6 +70,10 @@ main(int argc, char *argv[]) { char *token = NULL; char *token_lc = NULL; + if (pledge("stdio rpath", NULL) == -1) { + err(1, "pledge"); + } + while ((getoptFlag = getopt(argc, argv, "hv")) != -1) { switch(getoptFlag) {