--- /dev/null
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+project(onak VERSION 0.5.0 LANGUAGES C)
+
+include(FindPkgConfig)
+include(GNUInstallDirs)
+include(TestBigEndian)
+# Fall back for earlier versions of CMake which lack RUNSTATEDIR
+if ("x${CMAKE_INSTALL_FULL_RUNSTATEDIR}" STREQUAL "x")
+ set(CMAKE_INSTALL_FULL_RUNSTATEDIR
+ ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run)
+endif()
+
+# Configuration options from the user
+set(DBTYPE "dynamic" CACHE STRING
+ "Configure the default database backend to use" )
+option(KEYD
+ "Enable the key daemon to handle communication with the key database"
+ ON)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+
+# Pick up a git based version number for development builds
+find_package(Git)
+if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
+ EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
+ OUTPUT_VARIABLE GIT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "onak-" "" VERSION ${GIT_VERSION})
+else()
+ set(VERSION ${PROJECT_VERSION})
+endif()
+
+# Core objects
+add_library(libonak STATIC armor.c charfuncs.c cleankey.c cleanup.c decodekey.c
+ getcgi.c hash.c keyarray.c keyid.c keyindex.c ll.c log.c marshal.c
+ mem.c merge.c onak-conf.c parsekey.c photoid.c sigcheck.c sendsync.c
+ sha1x.c wordlist.c)
+set(LIBONAK_LIBRARIES "")
+
+# Ideally use Nettle, fall back to our own md5/sha1 routines otherwise
+pkg_check_modules(NETTLE nettle)
+if (NETTLE_FOUND)
+ set(HAVE_NETTLE true)
+ target_include_directories(libonak SYSTEM PUBLIC ${NETTLE_INCLUDE_DIRS})
+ LIST(APPEND LIBONAK_LIBRARIES ${NETTLE_LIBRARIES})
+else()
+ target_sources(libonak PRIVATE md5.c sha1.c)
+endif()
+
+# Backends
+
+# These have no dependencies and can always be compiled
+set(BACKENDS "file" "fs" "stacked")
+
+# DB4 backend (add check for existence)
+LIST(APPEND BACKENDS db4)
+set(BACKEND_db4_LIBS db-5.3)
+
+# HKP backend - needs libcurl
+pkg_check_modules(CURL libcurl)
+if (CURL_FOUND)
+ LIST(APPEND BACKENDS hkp)
+ set(BACKEND_hkp_INC ${CURL_INCLUDE_DIRS})
+ set(BACKEND_hkp_LIBS ${CURL_LIBRARIES})
+endif()
+
+# PostgreSQL backend - needs libpq
+pkg_check_modules(POSTGRESQL libpq)
+if (POSTGRESQL_FOUND)
+ LIST(APPEND BACKENDS pg)
+ set(BACKEND_pg_INC ${POSTGRESQL_INCLUDE_DIRS})
+ set(BACKEND_pg_LIBS ${POSTGRESQL_LIBRARIES})
+endif()
+
+# keyd backend - can be disabled entirely
+if (KEYD STREQUAL "ON")
+ LIST(APPEND BACKENDS keyd)
+
+ add_executable(keyd keyd.c)
+ target_link_libraries(keyd libonak)
+ add_executable(keydctl keydctl.c onak-conf.c)
+ target_link_libraries(keydctl libonak)
+ target_compile_definitions(keydctl PRIVATE
+ CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
+
+ pkg_check_modules(SYSTEMD libsystemd)
+ if (SYSTEMD_FOUND)
+ set(HAVE_SYSTEMD true)
+ target_include_directories(keyd SYSTEM PUBLIC
+ ${SYSTEMD_INCLUDE_DIRS})
+ target_link_libraries(keyd ${SYSTEMD_LIBRARIES})
+ endif()
+
+ install(TARGETS keydctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(TARGETS keyd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
+ install(FILES keyd.8 keydctl.8
+ DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
+endif()
+
+
+# Now we have the DB type confirmed we can tidy up the libonak options
+
+if (DBTYPE STREQUAL "dynamic")
+ LIST(APPEND LIBONAK_LIBRARIES "dl")
+ foreach(BACKEND IN LISTS BACKENDS)
+ add_library(keydb_${BACKEND} SHARED keydb_${BACKEND}.c)
+ target_include_directories(keydb_${BACKEND} SYSTEM PUBLIC
+ ${BACKEND_${BACKEND}_INC})
+ target_link_libraries(keydb_${BACKEND} libonak
+ ${BACKEND_${BACKEND}_LIBS})
+ install(TARGETS keydb_${BACKEND} LIBRARY DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/onak/backends/)
+ endforeach(BACKEND)
+else()
+ list (FIND BACKENDS ${DBTYPE} _index)
+ if (${_index} LESS 0)
+ message(FATAL_ERROR "${DBTYPE} is not a supported DB backend.")
+ endif()
+
+ LIST(APPEND LIBONAK_LIBRARIES ${BACKEND_${DBTYPE}_LIBS})
+endif()
+
+# For onak-conf.o compilation
+target_compile_definitions(libonak PRIVATE
+ CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}"
+ DBINIT=keydb_${DBTYPE}_init)
+
+# DB Backend related options are known, so finish off libonak configuration
+target_sources(libonak PRIVATE keydb_${DBTYPE}.c)
+target_link_libraries(libonak ${LIBONAK_LIBRARIES})
+
+# Executables start here
+
+# Swiss Army tool
+add_executable(onak onak.c)
+target_link_libraries(onak libonak)
+
+# CGI
+add_executable(add add.c)
+target_link_libraries(add libonak)
+add_executable(gpgwww gpgwww.c stats.c)
+target_link_libraries(gpgwww libonak)
+add_executable(hashquery hashquery.c)
+target_link_libraries(hashquery libonak)
+add_executable(lookup lookup.c)
+target_link_libraries(lookup libonak)
+
+# Tools that operate on the key DB
+add_executable(maxpath maxpath.c stats.c)
+target_link_libraries(maxpath libonak)
+add_executable(sixdegrees sixdegrees.c stats.c)
+target_link_libraries(sixdegrees libonak)
+add_executable(wotsap wotsap.c)
+target_link_libraries(wotsap libonak)
+
+# Stand alone tools
+add_executable(splitkeys splitkeys.c)
+target_link_libraries(splitkeys libonak)
+add_executable(stripkey stripkey.c)
+target_link_libraries(stripkey libonak)
+
+install(TARGETS onak splitkeys RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(FILES onak.1 splitkeys.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
+
+# Build files that have substitutions in them
+include_directories(${CMAKE_BINARY_DIR})
+configure_file("${CMAKE_SOURCE_DIR}/build-config.h.in"
+ "${CMAKE_BINARY_DIR}/build-config.h" @ONLY)
+
+configure_file("${CMAKE_SOURCE_DIR}/onak.ini.in"
+ "${CMAKE_BINARY_DIR}/onak.ini" @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/onak.ini
+ DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
+
+configure_file("${CMAKE_SOURCE_DIR}/onak-mail.pl.in"
+ "${CMAKE_BINARY_DIR}/onak-mail.pl" @ONLY)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/onak-mail.pl
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/onak/)
+install(FILES onak-mail.pl.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
+
+# Basic unit tests
+enable_testing()
+add_test(NAME syntaxtest COMMAND perl -cw ${CMAKE_BINARY_DIR}/onak-mail.pl)
+add_test(NAME sanitytests COMMAND ${CMAKE_SOURCE_DIR}/runtests)
+++ /dev/null
-#
-# Makefile for onak.
-#
-
-CC = @CC@
-CFLAGS += @CFLAGS@ -Wall -pedantic -fPIC
-# Uncomment to enable profiling.
-LDFLAGS += @LDFLAGS@
-# Can be "pg" for Postgresql, "file" for flat files or "db4" for Berkeley DB.
-DBTYPE = @DBTYPE@
-#
-LIBS = @LIBS@ @NETTLE_LIBS@
-DB4LIBS = @DB4LIBS@
-CURLLIBS = @LIBCURL@
-#MAKEDEPEND = makedepend -f- --
-MAKEDEPEND = $(CC) -MM
-prefix ?= @prefix@
-exec_prefix ?= @exec_prefix@
-
-PROGS = add lookup hashquery gpgwww onak splitkeys onak-mail.pl stripkey \
- wotsap
-CORE_OBJS = armor.o charfuncs.o decodekey.o getcgi.o hash.o marshal.o \
- keyid.o keyindex.o ll.o mem.o onak-conf.o parsekey.o sigcheck.o \
- log.o photoid.o wordlist.o cleanup.o merge.o sendsync.o keyarray.o \
- sha1x.o cleankey.o
-ifeq (x@NETTLE_LIBS@, x)
-CORE_OBJS += md5.o sha1.o
-endif
-SRCS = armor.c parsekey.c merge.c keyid.c md5.c sha1.c main.c getcgi.c mem.c \
- keyindex.c stats.c lookup.c add.c keydb_$(DBTYPE).c ll.c hash.c \
- gpgwww.c onak-conf.c charfuncs.c sendsync.c log.c photoid.c sigcheck.c \
- wordlist.c cleankey.c cleanup.c keyarray.c hashquery.c marshal.c \
- sha1x.c \
- $(foreach be,@BACKENDS@,keydb_$(be).c)
-PROGS_LDFLAGS_EXTRA =
-
-ifeq (x@KEYD@, xyes)
-PROGS += keyd keydctl
-KEYDB_OBJ = keydb_keyd.o
-SRCS += keyd.c keydb_keyd.c keydctl.c
-else
-KEYDB_OBJ = keydb_$(DBTYPE).o
-endif
-
-ifeq (x@DBTYPE@, xdynamic)
-LIBS += -ldl
-BACKENDS = $(foreach be,@BACKENDS@,libkeydb_$(be).so)
-PROGS += keyd keydctl
-PROGS_LDFLAGS_EXTRA = -rdynamic
-SRCS += keyd.c keydctl.c
-endif
-
-ifeq (x@GOSSIP@, xyes)
-SRCS += gossip-server.c
-GOSSIP_OBJS = gossip-server.o
-else
-GOSSIP_OBJS =
-endif
-
-OBJS = stats.o $(CORE_OBJS) $(KEYDB_OBJ) $(GOSSIP_OBJS)
-
-all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.ini \
- wotsap $(BACKENDS)
-
-test: onak $(BACKENDS)
- perl -cw onak-mail.pl
- @./runtests
-
-install: $(PROGS) onak.ini $(BACKENDS)
- install -d $(DESTDIR)/@bindir@
- install -d $(DESTDIR)/@libdir@/onak/backends
- install -d $(DESTDIR)/@localstatedir@/lib/onak
- install -d $(DESTDIR)/@mandir@/man1
- install -d $(DESTDIR)/@mandir@/man8
- install -d $(DESTDIR)/@sysconfdir@
- install -m 755 onak-mail.pl $(DESTDIR)/@libdir@/onak
- install onak splitkeys $(DESTDIR)/@bindir@
- install onak.1 splitkeys.1 $(DESTDIR)/@mandir@/man1
- install keyd.8 keydctl.8 onak-mail.pl.8 $(DESTDIR)/@mandir@/man8
-ifeq (x@DBTYPE@, xdynamic)
- install $(BACKENDS) $(DESTDIR)/@libdir@/onak/backends
- install -d $(DESTDIR)/@sbindir@
- install keyd $(DESTDIR)/@sbindir@
- install keydctl $(DESTDIR)/@bindir@
-endif
-
-keyd: keyd.o $(CORE_OBJS) $(GOSSIP_OBJS) keydb_$(DBTYPE).o
- $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
- -o keyd keyd.o $(CORE_OBJS) $(GOSSIP_OBJS) keydb_$(DBTYPE).o \
- $(LIBS) @SYSTEMD_LIBS@
-
-keydctl: keydctl.o onak-conf.o ll.o log.o
- $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
- -o keydctl keydctl.o onak-conf.o ll.o log.o $(LIBS)
-
-libkeydb_db4.so: keydb_db4.o $(CORE_OBJS)
- $(CC) $(LDFLAGS) -shared -o libkeydb_db4.so keydb_db4.o $(DB4LIBS) $(CORE_OBJS)
-
-libkeydb_hkp.so: keydb_hkp.o $(CORE_OBJS)
- $(CC) $(LDFLAGS) -shared -o libkeydb_hkp.so keydb_hkp.o $(CURLLIBS) $(CORE_OBJS)
-
-libkeydb_pg.so: keydb_pg.o $(CORE_OBJS)
- $(CC) $(LDFLAGS) -shared -o libkeydb_pg.so keydb_pg.o $(PQLIBS) $(CORE_OBJS)
-
-libkeydb_%.so: keydb_%.o $(CORE_OBJS)
- $(CC) $(LDFLAGS) -shared -o $@ $< $(CORE_OBJS)
-
-splitkeys: splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ)
- $(CC) $(LDFLAGS) -o splitkeys splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) \
- $(LIBS) $(PROGS_LDFLAGS_EXTRA)
-
-testparse: main.o $(OBJS)
- $(CC) $(LDFLAGS) -o testparse main.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-maxpath: maxpath.o $(OBJS)
- $(CC) $(LDFLAGS) -o maxpath maxpath.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-sixdegrees: sixdegrees.o $(OBJS)
- $(CC) $(LDFLAGS) -o sixdegrees sixdegrees.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-wotsap: wotsap.o $(OBJS)
- $(CC) $(LDFLAGS) -o wotsap wotsap.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-stripkey: stripkey.o $(OBJS)
- $(CC) $(LDFLAGS) -o stripkey stripkey.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-gpgwww: gpgwww.o $(OBJS)
- $(CC) $(LDFLAGS) -o gpgwww gpgwww.o $(OBJS) $(LIBS) \
- $(PROGS_LDFLAGS_EXTRA)
-
-hashquery: hashquery.o $(CORE_OBJS) $(KEYDB_OBJ)
- $(CC) $(LDFLAGS) -o hashquery hashquery.o $(CORE_OBJS) \
- $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
-
-lookup: lookup.o $(CORE_OBJS) $(KEYDB_OBJ)
- $(CC) $(LDFLAGS) -o lookup lookup.o $(CORE_OBJS) \
- $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
-
-add: add.o $(CORE_OBJS) $(KEYDB_OBJ)
- $(CC) $(LDFLAGS) -o add add.o \
- $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
-
-onak: onak.o $(CORE_OBJS) $(KEYDB_OBJ)
- $(CC) $(LDFLAGS) -o onak onak.o \
- $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
-
-onak-conf.o: onak-conf.c onak-conf.h
- $(CC) $(CFLAGS) -DCONFIGDIR=\"@sysconfdir@\" \
- -DDBINIT=keydb_@DBTYPE@_init -c onak-conf.c
-
-# HACK: onak-conf.o needs to be able to see keydb_@DBTYPE@_funcs, but
-# keydctl doesn't want to link against the DB stuff. To be fixed more cleanly.
-keydctl.o: keydctl.c keyd.h
- $(CC) $(CFLAGS) -DDBINIT=keydb_@DBTYPE@_init -c keydctl.c
-
-%: %.in
- sed -e 's:@BINDIR@:@bindir@:g' \
- -e 's:@CONFIG@:@sysconfdir@/onak.ini:g' \
- -e 's:@CONFIGOLD@:@sysconfdir@/onak.conf:g' \
- -e 's:@LIBDIR@:@libdir@:g' \
- -e 's:@RUNDIR@:@runstatedir@:g' \
- -e 's:@SBINDIR@:@sbindir@:g' \
- -e 's:@STATEDIR@:@localstatedir@:g' \
- < $< > $@
-
-clean:
- $(RM) $(PROGS) $(OBJS) Makefile.bak testparse maxpath *.core core \
- gpgwww.o add.o lookup.o main.o maxpath.o onak.o sixdegrees \
- sixdegrees.o splitkeys.o stripkey.o onak.ini keyd.o \
- keydctl.o hashquery.o wotsap.o version.h \
- TAGS cscope.out cscope.files \
- $(foreach be,@BACKENDS@,keydb_$(be).o) *.so
-ifeq (x@KEYD@, xyes)
- $(RM) keyd.o keydb_$(DBTYPE).o
-endif
-
-distclean: clean
- $(RM) -f Makefile .depend config.log config.status config.h
- $(RM) -r autom4te.cache
-
-doxygen-docs: *.c *.h Doxyfile
- doxygen
-
-version.h: $(SRCS)
- @echo '#include "config.h"' > version.h
- @if [ -e .git ]; then \
- echo "#define ONAK_VERSION \"`git describe --tags --dirty | cut -d - -f 2-`\"" \
- >> version.h; \
- else \
- echo "#define ONAK_VERSION PACKAGE_VERSION" >> version.h; \
- fi
-
-.depend: $(SRCS) version.h
- rm -f .depend
- $(MAKEDEPEND) $(CFLAGS) $(SRCS) > .depend
-
-include .depend
-
-.PHONY: all clean
#include <stdlib.h>
+#include "build-config.h"
+
#include "armor.h"
#include "keystructs.h"
#include "parsekey.h"
-#include "version.h"
/**
* @brief Line length we'll use for armored output
--- /dev/null
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define ONAK_VERSION "@VERSION@"
+
+#cmakedefine HAVE_NETTLE 1
+#cmakedefine HAVE_SYSTEMD 1
+#cmakedefine WORDS_BIGENDIAN 1
+
+#endif /* __CONFIG_H__ */
+++ /dev/null
-AC_PREREQ(2.50)
-AC_INIT([onak],[0.5.0],[noodles-onak@earth.li])
-AC_CONFIG_SRCDIR(onak.c)
-AC_CONFIG_HEADER(config.h)
-
-AC_PROG_CC
-AC_PROG_CC_C99
-
-AC_C_BIGENDIAN
-
-m4_include([m4/ax_lib_nettle.m4])
-
-AX_LIB_NETTLE(auto)
-AC_CHECK_HEADER([systemd/sd-daemon.h], [
- AC_CHECK_LIB([systemd-daemon], [sd_listen_fds],
- [AC_DEFINE([HAVE_SYSTEMD], [1], [sd_listen_fds is available])
- AC_SUBST([SYSTEMD_LIBS], [-lsystemd-daemon])
- ],
- AC_CHECK_LIB([systemd], [sd_listen_fds],
- [AC_DEFINE([HAVE_SYSTEMD], [1], [sd_listen_fds is available])
- AC_SUBST([SYSTEMD_LIBS], [-lsystemd])
- ])
- )
-])
-
-dnl We should always have these backends available.
-backends="file fs keyd stacked"
-
-LIBCURL_CHECK_CONFIG(,,[have_libcurl="yes" backends="$backends hkp"],have_libcurl="no")
-
-AC_CHECK_LIB(pq, PQsetdbLogin,[have_libpq="yes" backends="$backends pg"],have_libpq="no")
-
-AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no")
-AC_MSG_CHECKING(for libdb version in db.h)
-printf "#include <db.h>\nDB_VERSION_MAJOR DB_VERSION_MINOR\n" >conftest.c
-set `eval $ac_cpp conftest.c | egrep '^ *[[0-9]] *'`; v="$1"; vv="$2"
-AC_MSG_RESULT($v.$vv)
-if test "$v" -ge 4; then
- for db in "db-$v.$vv" "db$v.$vv" "db-$v" "db$v" "db"; do
- AC_MSG_CHECKING(for db_create in lib$db)
- oldLIBS="$LIBS"
- LIBS="$LIBS -l$db"
- db4libs="-l$db"
- AC_TRY_LINK([#include <db.h>], db_create(0, 0, 0),
- have_libdb="yes", have_libdb="no")
- AC_MSG_RESULT($have_libdb)
- LIBS="$oldLIBS"
- if test "$have_libdb" != "no"; then break; fi
- done
-fi
-if test "$have_libdb" = "yes" -a "$have_db_h" = "yes"; then
- AC_DEFINE(HAVE_LIBDB4, 1, [libdb found])
- backends="$backends db4"
-fi
-
-AC_MSG_CHECKING(available backends)
-AC_MSG_RESULT($backends)
-
-AC_ARG_ENABLE(backend,AC_HELP_STRING([--enable-backend=<backend>],[Choose the backend database to use. Defaults to dynamic.]), [], [enable_backend="dynamic"])
-
-AC_ARG_ENABLE(keyd,AC_HELP_STRING([--enable-keyd],[Use keyd as the DB backend.]), [], [])
-
-AC_MSG_CHECKING([which key database backend to use])
-AC_MSG_RESULT([$enable_backend])
-AC_CHECK_FILE([$srcdir/keydb_$enable_backend.c], ,AC_MSG_ERROR([non existent key database backend $enable_backend]))
-
-if test "x$enable_backend" = "xdb4"
-then
- if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then
- AC_MSG_ERROR(libdb not found.)
- fi
- LIBS="$LIBS $db4libs"
-else if test "x$enable_backend" = "xpg"
-then
- if test "$have_libpq" = "no"; then
- AC_MSG_ERROR(libpq not found.)
- fi
- LIBS="$LIBS -lpq"
-fi
-fi
-
-dnl If we are explicitly told which backend to use, only build that one.
-if test "x$enable_backend" = "xdb4"
-then
- backend="$enable_backend"
-fi
-
-dnl Fallback for autoconf before 2.70
-if test "x$runstatedir" = x; then
- AC_SUBST([runstatedir], ["$localstatedir/run"])
-fi
-
-AC_SUBST(DBTYPE, $enable_backend)
-AC_SUBST(DB4LIBS, $db4libs)
-AC_SUBST(KEYD, $enable_keyd)
-AC_SUBST(BACKENDS, $backends)
-
-AC_CONFIG_FILES(Makefile)
-
-AC_OUTPUT
Section: net
Priority: optional
Maintainer: Jonathan McDowell <noodles@earth.li>
-Build-Depends: debhelper (>= 9), dh-autoreconf, dh-systemd, libdb-dev, nettle-dev, libcurl4-gnutls-dev | libcurl-dev, libsystemd-dev (>= 214) [linux-any] | libsystemd-daemon-dev [linux-any]
+Build-Depends: cmake,
+ debhelper (>= 9),
+ dh-systemd,
+ libcurl4-gnutls-dev | libcurl-dev,
+ libdb-dev,
+ libsystemd-dev (>= 214) [linux-any] | libsystemd-daemon-dev [linux-any],
+ nettle-dev
Standards-Version: 3.9.8.0
Homepage: https://www.earth.li/projectpurple/progs/onak.html
Vcs-Browser: https://the.earth.li/gitweb/?p=onak.git;a=summary
-onak.ini etc
-add lookup gpgwww hashquery usr/lib/cgi-bin/pks
+obj-*/onak.ini etc
+obj-*/add obj-*/lookup obj-*/gpgwww obj-*/hashquery usr/lib/cgi-bin/pks
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-DEB_CONFIGURE_EXTRA_FLAGS += --enable-backend=dynamic --runstatedir=/run
-
CFLAGS += -std=gnu99
%:
- dh "$@" --with autoreconf,systemd
+ dh "$@" --with systemd
override_dh_installinit:
dh_installinit --no-start
#include <stdlib.h>
#include <string.h>
+#include "build-config.h"
+
#include "armor.h"
#include "charfuncs.h"
#include "cleanup.h"
#include "onak-conf.h"
#include "parsekey.h"
#include "stats.h"
-#include "version.h"
#define OP_UNKNOWN 0
#define OP_GET 1
#include <time.h>
#include <unistd.h>
-#include "config.h"
+#include "build-config.h"
#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
#include "mem.h"
#include "onak-conf.h"
#include "parsekey.h"
-#include "version.h"
/* Maximum number of clients we're prepared to accept at once */
#define MAX_CLIENTS 16
#include <string.h>
#include <curl/curl.h>
+#include "build-config.h"
+
#include "armor.h"
#include "charfuncs.h"
#include "keydb.h"
#include "mem.h"
#include "onak-conf.h"
#include "parsekey.h"
-#include "version.h"
struct onak_hkp_dbctx {
struct onak_db_config *config; /* Our DB config info */
#include <sys/socket.h>
#include <sys/un.h>
+#include "build-config.h"
+
#include "keyd.h"
#include "onak-conf.h"
-#include "version.h"
-
-/* HACK: We need to stop onak-conf.o requiring this. */
-void *DBINIT = NULL;
static int keyd_fd = -1;
static int verbose = 0;
#include <sys/types.h>
#include <arpa/inet.h>
-#include "config.h"
+#include "build-config.h"
#include "keyid.h"
#include "keystructs.h"
#include "onak.h"
#include <string.h>
#include <unistd.h>
+#include "build-config.h"
+
#include "armor.h"
#include "charfuncs.h"
#include "cleankey.h"
#include "onak-conf.h"
#include "parsekey.h"
#include "photoid.h"
-#include "version.h"
#define OP_UNKNOWN 0
#define OP_GET 1
+++ /dev/null
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_lib_nettle.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_LIB_NETTLE([yes|no|auto])
-#
-# DESCRIPTION
-#
-# Searches for the 'nettle' library with the --with... option.
-#
-# If found, define HAVE_NETTLE and macro NETTLE_LIBS. Also defines
-# NETTLE_WITH_<algo> for the algorithms found available. Possible
-# algorithms: AES ARCTWO BLOWFISH CAST128 DES DES3 SERPENT TWOFISH MD2 MD4
-# MD5 SHA1 SHA256.
-#
-# The argument is used if no --with...-nettle option is set. Value "yes"
-# requires the configuration by default. Value "no" does not require it by
-# default. Value "auto" configures the library only if available.
-#
-# See also AX_LIB_BEECRYPT, AX_LIB_CRYPTO, and AX_LIB_GCRYPT.
-#
-# LICENSE
-#
-# Copyright (c) 2009 Fabien Coelho <autoconf.archive@coelho.net>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 7
-
-# AX_CHECK_NETTLE_ALGO([name],[function])
-AC_DEFUN([AX_CHECK_NETTLE_ALGO],[
- AC_CHECK_LIB([nettle], [nettle_$2],
- AC_DEFINE([NETTLE_WITH_$1],[1],[Algorithm $1 in nettle library]))
-])
-
-# AX_LIB_NETTLE([yes|no|auto])
-AC_DEFUN([AX_LIB_NETTLE],[
- AC_MSG_CHECKING([whether nettle is enabled])
- AC_ARG_WITH([nettle],[ --with-nettle require nettle library
- --without-nettle disable nettle library],[
- AC_MSG_RESULT([$withval])
- ax_with_nettle=$withval
- ],[
- AC_MSG_RESULT([$1])
- ax_with_nettle=$1
- ])
- if test "$ax_with_nettle" = "yes" -o "$ax_with_nettle" = "auto" ; then
- AC_CHECK_HEADERS([nettle/nettle-meta.h],[
- AC_CHECK_LIB([nettle],[nettle_base64_encode_final],[
- AC_DEFINE([HAVE_NETTLE],[1],[Nettle library is available])
- HAVE_NETTLE=1
- AC_SUBST([NETTLE_LIBS],[-lnettle])
- # ciphers
- AX_CHECK_NETTLE_ALGO([AES],[aes_encrypt])
- AX_CHECK_NETTLE_ALGO([ARCTWO],[arctwo_encrypt])
- AX_CHECK_NETTLE_ALGO([BLOWFISH],[blowfish_encrypt])
- AX_CHECK_NETTLE_ALGO([CAST128],[cast128_encrypt])
- AX_CHECK_NETTLE_ALGO([DES],[des_encrypt])
- AX_CHECK_NETTLE_ALGO([DES3],[des3_encrypt])
- AX_CHECK_NETTLE_ALGO([SERPENT],[serpent_encrypt])
- AX_CHECK_NETTLE_ALGO([TWOFISH],[twofish_encrypt])
- # digests
- AX_CHECK_NETTLE_ALGO([MD2],[md2_digest])
- AX_CHECK_NETTLE_ALGO([MD4],[md4_digest])
- AX_CHECK_NETTLE_ALGO([MD5],[md5_digest])
- AX_CHECK_NETTLE_ALGO([RIPEMD160],[ripemd160_digest])
- AX_CHECK_NETTLE_ALGO([SHA1],[sha1_digest])
- AX_CHECK_NETTLE_ALGO([SHA224],[sha224_digest])
- AX_CHECK_NETTLE_ALGO([SHA256],[sha256_digest])
- AX_CHECK_NETTLE_ALGO([SHA384],[sha384_digest])
- AX_CHECK_NETTLE_ALGO([SHA512],[sha512_digest])
- ])
- ])
- # complain only if explicitely required
- if test "$ax_with_nettle" = "yes" -a "x$HAVE_NETTLE" = "x" ; then
- AC_MSG_ERROR([cannot configure required nettle library])
- fi
- fi
-])
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
-#include "config.h"
+#include "build-config.h"
#include <sys/types.h>
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
-
-#include "config.h"
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include "build-config.h"
+
#include "cleankey.h"
#include "ll.h"
#include "log.h"
#include "onak-conf.h"
+#ifdef DBINIT
extern struct onak_dbctx *DBINIT(struct onak_db_config *dbcfg, bool readonly);
+#endif
/*
* config - Runtime configuration for onak.
.backends = NULL,
.backends_dir = NULL,
+#ifdef DBINIT
.dbinit = DBINIT,
+#else
+ .dbinit = NULL,
+#endif
.clean_policies = ONAK_CLEAN_CHECK_SIGHASH,
# upgrades.
#
sub readoldconfig {
- open(CONFIG, "@CONFIGOLD@") or
+ open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") or
die "Can't read config file: $!";
while (<CONFIG>) {
#
sub readconfig {
# Prefer the old style config if it exists.
- if (-e "@CONFIGOLD@") {
+ if (-e "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.conf") {
&readoldconfig;
return;
}
- open(CONFIG, "@CONFIG@") or
+ open(CONFIG, "@CMAKE_INSTALL_FULL_SYSCONFDIR@/onak.ini") or
die "Can't read config file: $!";
my $section = "";
#include <sys/stat.h>
#include <unistd.h>
+#include "build-config.h"
+
#include "armor.h"
#include "charfuncs.h"
#include "cleankey.h"
#include "onak-conf.h"
#include "parsekey.h"
#include "photoid.h"
-#include "version.h"
void find_keys(struct onak_dbctx *dbctx,
char *search, uint64_t keyid,
;
[main]
backend=defaultdb4
-backends_dir=@LIBDIR@/onak/backends
-logfile=@STATEDIR@/log/onak.log
+backends_dir=@CMAKE_INSTALL_FULL_LIBDIR@/onak/backends
+logfile=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/onak.log
; Loglevel : 0 is highest debug, default is 3, nothing is 7+
loglevel=3
; Should we use the keyd backend?
use_keyd=false
-sock_dir=@RUNDIR@
+sock_dir=@CMAKE_INSTALL_FULL_RUNSTATEDIR@
; Maximum number of keys to return in a reply to an index, verbose index or
; get. Setting it to -1 will allow any size of reply.
max_reply_keys=128
; Settings related to the email interface to onak.
[mail]
maintainer_email=PGP Key Server Administrator <pgp-keyserver-admin@the.earth.li>
-mail_dir=@STATEDIR@/spool/onak
+mail_dir=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/spool/onak
; Specify the envelope sender address as the -f argument to
; sendmail. This is the address which will receive any bounces.
; If you don't use sendmail, then change this to an equivalent command.
[backend:defaultdb4]
; The default DB4 backend. Recommended.
type=db4
-location=@STATEDIR@/lib/onak
+location=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/onak
[backend:examplehkp]
; An example HKP backend; all operations will be done against the
#define SHA1HANDSOFF
-#include "config.h"
+#include "build-config.h"
#include <string.h>
*
* Placed into the public domain.
*/
-
-#include "config.h"
-
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+#include "build-config.h"
+
#ifdef HAVE_NETTLE
#include <nettle/sha.h>
#else
#include <stdint.h>
-#include "config.h"
+#include "build-config.h"
#include "decodekey.h"
#include "keyid.h"
#include "keystructs.h"
#include <string.h>
#include <arpa/inet.h>
+#include "build-config.h"
+
#include "hash.h"
#include "log.h"
#include "onak-conf.h"
#include "stats.h"
-#include "version.h"
static struct ll *sortkeyll(struct ll *keys)
{