From 6a3290b9ac63ea6e2e0b3cacfe5f577e5ae3c021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=91=D0=BE=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Mon, 12 Aug 2024 17:41:49 +0200 Subject: [PATCH] certmanager updates --- Makefile.am | 92 ++++++++++++++++++++++++++++++++-- Makefile.in | 90 +++++++++++++++++++++++++++++++-- configure | 5 +- configure.ac | 3 +- debian/README.Debian | 1 + debian/changelog | 5 ++ debian/compat | 1 + debian/control | 11 ++++ debian/patches/series | 1 + debian/postinst | 6 +++ debian/postrm | 3 ++ debian/preinst | 20 ++++++++ debian/prerm | 7 +++ debian/rules | 14 ++++++ debian/source/format | 1 + debian/source/include-binaries | 0 debian/watch | 1 + internal/config/path.go | 9 ++-- internal/server/server.go | 5 +- 19 files changed, 257 insertions(+), 18 deletions(-) create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/patches/series create mode 100755 debian/postinst create mode 100755 debian/postrm create mode 100755 debian/preinst create mode 100755 debian/prerm create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/source/include-binaries create mode 100644 debian/watch diff --git a/Makefile.am b/Makefile.am index 01b9c16..b2b85dc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,9 +26,55 @@ certmanagerctl$(EXEEXT): $(certmanagerctl_SOURCES) $(EXTRA_certmanagerd_SOURCES) EXTRA_certmanagerd_SOURCES = \ + internal/config/config.go \ + internal/database/account.go \ + internal/database/database.go \ + internal/database/grant.go \ + internal/database/issuer.go \ + internal/database/service.go \ + internal/descriptor/descriptor.go \ + internal/grpc/handler/account.go \ + internal/grpc/handler/grant.go \ + internal/grpc/handler/handler.go \ + internal/grpc/handler/issuer.go \ + internal/grpc/handler/service.go \ + internal/grpc/handler/status.go \ + internal/grpc/service/service.go \ + internal/logic/account.go \ + internal/logic/database.go \ + internal/logic/grants.go \ + internal/logic/issuer.go \ + internal/logic/logic.go \ + internal/logic/service.go \ + internal/logic/status.go \ + internal/server/server.go \ + internal/test/database_test.go \ + internal/wrpc/handler/handler.go \ + internal/wrpc/handler/status.go \ + internal/wrpc/service/service.go \ + pkg/aux509/x509cert.go \ + pkg/aux509/x509cert_test.go \ + pkg/auxgin/corsmw.go \ + pkg/auxgin/logmw.go \ + pkg/auxgin/reqlog.go \ + pkg/auxgin/reslog.go \ + pkg/auxgrpc/error.go \ + pkg/auxhttp/genres.go \ + pkg/auxhttp/getbearer.go \ + pkg/auxhttp/parseauth.go \ + pkg/auxid/genid.go \ + pkg/client/auth.go \ + pkg/client/client.go \ + pkg/client/control.go \ + pkg/cm509/testchain_a00.crt \ + pkg/cm509/testchain_a01.crt \ + pkg/cm509/testchain_a02.crt \ + pkg/cm509/testchain_a03.crt \ + pkg/cm509/x509.go \ pkg/cmctl/cmctl_grpc.pb.go \ - pkg/cmctl/cmctl.pb.go - + pkg/cmctl/cmctl.pb.go \ + pkg/common/common.go \ + pkg/logger/logger.go EXTRA_DIST = $(EXTRA_certmanagerd_SOURCES) \ internal/test/auxfunction_test.go \ @@ -50,8 +96,21 @@ EXTRA_DIST = $(EXTRA_certmanagerd_SOURCES) \ proto/cmctl.proto \ go.mod \ go.sum \ - README.md - + README.md \ + internal/test/Makefile.in \ + debian/changelog \ + debian/compat \ + debian/control \ + debian/patches/series \ + debian/postinst \ + debian/postrm \ + debian/preinst \ + debian/prerm \ + debian/README.Debian \ + debian/rules \ + debian/source/format \ + debian/source/include-binaries \ + debian/watch GENDIR=pkg/cmctl grpc: @@ -95,13 +154,36 @@ run: test -z $(DESTDIR)$(SRV_DATADIR) || $(MKDIR_P) $(DESTDIR)$(SRV_DATADIR) env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/certmanagerd/... --daemon=false -distclean-local: clean + + +BUILD_DIR = $(shell pwd)/tmp + +$(DIST_ARCHIVES): dist +package: $(DIST_ARCHIVES) + mkdir -p $(BUILD_DIR) + mv $(DIST_ARCHIVES) $(BUILD_DIR) + cd $(BUILD_DIR) && $(AMTAR) -xf $(DIST_ARCHIVES) + cd $(BUILD_DIR)/$(distdir) && \ + ./configure --enable-devel-mode + cd $(BUILD_DIR)/$(distdir) && \ + $(MAKE) debian-package + +debian-package: + $(DBUILDPACKAGE) -us -uc -ui -i -b + +debian-package-clean: + $(DBUILDPACKAGE) --rules-target clean -us -uc -ui + +distclean-local: clean rm -rf autom4te.cache + + clean-local: rm -rf autom4te.cache rm -f cmd/certmanagerd/certmanagerd rm -f cmd/certmanagerctl/certmanagerctl rm -rf tmp/ + rm -f $(DIST_ARCHIVES) rm -rf autom4te.cache/ diff --git a/Makefile.in b/Makefile.in index 2b957b4..9032249 100644 --- a/Makefile.in +++ b/Makefile.in @@ -101,7 +101,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = internal/config/path.go \ - initrc/certmanagerd.service + initrc/certmanagerd.service initrc/certmanagerd CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) @@ -166,6 +166,7 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` AM_RECURSIVE_TARGETS = cscope am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/initrc/certmanagerd.in \ $(top_srcdir)/initrc/certmanagerd.service.in \ $(top_srcdir)/internal/config/path.go.in README.md \ config.guess config.sub install-sh missing @@ -304,8 +305,55 @@ certmanagerctl_SOURCES = cmd/certmanagerctl/main.go \ cmd/certmanagerctl/grant.go EXTRA_certmanagerd_SOURCES = \ + internal/config/config.go \ + internal/database/account.go \ + internal/database/database.go \ + internal/database/grant.go \ + internal/database/issuer.go \ + internal/database/service.go \ + internal/descriptor/descriptor.go \ + internal/grpc/handler/account.go \ + internal/grpc/handler/grant.go \ + internal/grpc/handler/handler.go \ + internal/grpc/handler/issuer.go \ + internal/grpc/handler/service.go \ + internal/grpc/handler/status.go \ + internal/grpc/service/service.go \ + internal/logic/account.go \ + internal/logic/database.go \ + internal/logic/grants.go \ + internal/logic/issuer.go \ + internal/logic/logic.go \ + internal/logic/service.go \ + internal/logic/status.go \ + internal/server/server.go \ + internal/test/database_test.go \ + internal/wrpc/handler/handler.go \ + internal/wrpc/handler/status.go \ + internal/wrpc/service/service.go \ + pkg/aux509/x509cert.go \ + pkg/aux509/x509cert_test.go \ + pkg/auxgin/corsmw.go \ + pkg/auxgin/logmw.go \ + pkg/auxgin/reqlog.go \ + pkg/auxgin/reslog.go \ + pkg/auxgrpc/error.go \ + pkg/auxhttp/genres.go \ + pkg/auxhttp/getbearer.go \ + pkg/auxhttp/parseauth.go \ + pkg/auxid/genid.go \ + pkg/client/auth.go \ + pkg/client/client.go \ + pkg/client/control.go \ + pkg/cm509/testchain_a00.crt \ + pkg/cm509/testchain_a01.crt \ + pkg/cm509/testchain_a02.crt \ + pkg/cm509/testchain_a03.crt \ + pkg/cm509/x509.go \ pkg/cmctl/cmctl_grpc.pb.go \ - pkg/cmctl/cmctl.pb.go + pkg/cmctl/cmctl.pb.go \ + pkg/common/common.go \ + pkg/logger/logger.go EXTRA_DIST = $(EXTRA_certmanagerd_SOURCES) \ internal/test/auxfunction_test.go \ @@ -327,13 +375,28 @@ EXTRA_DIST = $(EXTRA_certmanagerd_SOURCES) \ proto/cmctl.proto \ go.mod \ go.sum \ - README.md + README.md \ + internal/test/Makefile.in \ + debian/changelog \ + debian/compat \ + debian/control \ + debian/patches/series \ + debian/postinst \ + debian/postrm \ + debian/preinst \ + debian/prerm \ + debian/README.Debian \ + debian/rules \ + debian/source/format \ + debian/source/include-binaries \ + debian/watch GENDIR = pkg/cmctl SYSTEMD_LIBDIR = /lib/systemd/system FREEBSD_LOCALBASE = /usr/local FREEBSD_RCDIR = $(FREEBSD_LOCALBASE)/etc/rc.d LINUX_SYSTEMDDIR = /lib/systemd/system +BUILD_DIR = $(shell pwd)/tmp all: all-am .SUFFIXES: @@ -375,6 +438,8 @@ internal/config/path.go: $(top_builddir)/config.status $(top_srcdir)/internal/co cd $(top_builddir) && $(SHELL) ./config.status $@ initrc/certmanagerd.service: $(top_builddir)/config.status $(top_srcdir)/initrc/certmanagerd.service.in cd $(top_builddir) && $(SHELL) ./config.status $@ +initrc/certmanagerd: $(top_builddir)/config.status $(top_srcdir)/initrc/certmanagerd.in + cd $(top_builddir) && $(SHELL) ./config.status $@ install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ @@ -859,7 +924,23 @@ run: test -z $(DESTDIR)$(SRV_DATADIR) || $(MKDIR_P) $(DESTDIR)$(SRV_DATADIR) env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/certmanagerd/... --daemon=false -distclean-local: clean +$(DIST_ARCHIVES): dist +package: $(DIST_ARCHIVES) + mkdir -p $(BUILD_DIR) + mv $(DIST_ARCHIVES) $(BUILD_DIR) + cd $(BUILD_DIR) && $(AMTAR) -xf $(DIST_ARCHIVES) + cd $(BUILD_DIR)/$(distdir) && \ + ./configure --enable-devel-mode + cd $(BUILD_DIR)/$(distdir) && \ + $(MAKE) debian-package + +debian-package: + $(DBUILDPACKAGE) -us -uc -ui -i -b + +debian-package-clean: + $(DBUILDPACKAGE) --rules-target clean -us -uc -ui + +distclean-local: clean rm -rf autom4te.cache clean-local: @@ -867,6 +948,7 @@ clean-local: rm -f cmd/certmanagerd/certmanagerd rm -f cmd/certmanagerctl/certmanagerctl rm -rf tmp/ + rm -f $(DIST_ARCHIVES) rm -rf autom4te.cache/ # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/configure b/configure index 3e6ba7c..6073971 100755 --- a/configure +++ b/configure @@ -3174,7 +3174,7 @@ srv_sbindir="${prefix}/sbin" -ac_config_files="$ac_config_files Makefile internal/test/Makefile internal/config/path.go initrc/certmanagerd.service" +ac_config_files="$ac_config_files internal/test/Makefile Makefile internal/config/path.go initrc/certmanagerd.service initrc/certmanagerd" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3912,10 +3912,11 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "internal/test/Makefile") CONFIG_FILES="$CONFIG_FILES internal/test/Makefile" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "internal/config/path.go") CONFIG_FILES="$CONFIG_FILES internal/config/path.go" ;; "initrc/certmanagerd.service") CONFIG_FILES="$CONFIG_FILES initrc/certmanagerd.service" ;; + "initrc/certmanagerd") CONFIG_FILES="$CONFIG_FILES initrc/certmanagerd" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.ac b/configure.ac index 9a5931a..7fd1014 100644 --- a/configure.ac +++ b/configure.ac @@ -188,9 +188,10 @@ AC_SUBST(srv_sbindir, "${prefix}/sbin") AC_CONFIG_FILES([ -Makefile internal/test/Makefile +Makefile internal/config/path.go initrc/certmanagerd.service +initrc/certmanagerd ]) AC_OUTPUT diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..e240a3b --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1 @@ +certmanager for Debian diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..68fc4c1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +certmanager (1.0.1-1) unstable; urgency=low + + * Release. + + -- Oleg Borodin Sun, 29 Oct 2017 18:57:56 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..bc839fa --- /dev/null +++ b/debian/control @@ -0,0 +1,11 @@ +Source: certmanager +Section: utils +Priority: extra +Maintainer: borodin@unix7.org +Build-Depends: debhelper (>=10) +Standards-Version: 1.0.1 +Homepage: http://wiki.unix7.org + +Package: certmanager +Description: certmanager +Architecture: amd64 \ No newline at end of file diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..c2331c8 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,6 @@ +#!/bin/sh -e + +if [ "$1" = "configure" ] ; then + # Initial installation + systemctl preset certmanagerd.service >/dev/null 2>&1 || : +fi diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 0000000..c3c7ae1 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,3 @@ +#!/bin/sh -e + +systemctl daemon-reload >/dev/null 2>&1 || : diff --git a/debian/preinst b/debian/preinst new file mode 100755 index 0000000..1057534 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..503d273 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,7 @@ +#!/bin/sh -e + +if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then + # Package removal, not upgrade + systemctl --no-reload disable certmanagerd.service > /dev/null 2>&1 || : + systemctl stop certmanagerd.service > /dev/null 2>&1 || : +fi diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..f9a69a5 --- /dev/null +++ b/debian/rules @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +%: +# dh $@ --with autoreconf + dh $@ +# ./configure --prefix=/usr +# dh_build +# dh_install +# dh_auto_clean + +override_dh_auto_configure: + ./configure --prefix=/usr + +#EOF diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..46ebe02 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) \ No newline at end of file diff --git a/debian/source/include-binaries b/debian/source/include-binaries new file mode 100644 index 0000000..e69de29 diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..9e7c0da --- /dev/null +++ b/debian/watch @@ -0,0 +1 @@ +version=3 diff --git a/internal/config/path.go b/internal/config/path.go index df56554..d80b682 100644 --- a/internal/config/path.go +++ b/internal/config/path.go @@ -1,8 +1,9 @@ package config const ( - confdirPath = "/home/ziggi/Projects/certman/etc/certmanager" - rundirPath = "/home/ziggi/Projects/certman/tmp/run" - logdirPath = "/home/ziggi/Projects/certman/tmp/log" - datadirPath = "/home/ziggi/Projects/certman/tmp/data" + confdirPath = "/home/ziggi/Projects/certman/etc/certmanager" + rundirPath = "/home/ziggi/Projects/certman/tmp/run" + logdirPath = "/home/ziggi/Projects/certman/tmp/log" + datadirPath = "/home/ziggi/Projects/certman/tmp/data" ) + diff --git a/internal/server/server.go b/internal/server/server.go index fc09ecd..392aaab 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -158,14 +158,15 @@ func (srv *Server) Run() error { } srv.log.Infof("Running server as user %s", currUser.Username) + ctx, _ := context.WithTimeout(context.Background(), 1*time.Second) + // Initialize database - err = srv.db.InitDatabase() + err = srv.db.InitDatabase(ctx) if err != nil { return err } // Seed accounts - ctx, _ := context.WithTimeout(context.Background(), 1*time.Second) _, err = srv.lg.SeedAccount(ctx) if err != nil { return err