certmanager updates

This commit is contained in:
Олег Бородин
2024-08-12 17:41:49 +02:00
parent 21d64fd482
commit 6a3290b9ac
19 changed files with 257 additions and 18 deletions

View File

@@ -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/

View File

@@ -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.

5
configure vendored
View File

@@ -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

View File

@@ -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

1
debian/README.Debian vendored Normal file
View File

@@ -0,0 +1 @@
certmanager for Debian

5
debian/changelog vendored Normal file
View File

@@ -0,0 +1,5 @@
certmanager (1.0.1-1) unstable; urgency=low
* Release.
-- Oleg Borodin <borodin@unix7.org> Sun, 29 Oct 2017 18:57:56 +0200

1
debian/compat vendored Normal file
View File

@@ -0,0 +1 @@
10

11
debian/control vendored Normal file
View File

@@ -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

1
debian/patches/series vendored Normal file
View File

@@ -0,0 +1 @@
# You must remove unused comment lines for the released package.

6
debian/postinst vendored Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh -e
if [ "$1" = "configure" ] ; then
# Initial installation
systemctl preset certmanagerd.service >/dev/null 2>&1 || :
fi

3
debian/postrm vendored Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh -e
systemctl daemon-reload >/dev/null 2>&1 || :

20
debian/preinst vendored Executable file
View File

@@ -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

7
debian/prerm vendored Executable file
View File

@@ -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

14
debian/rules vendored Executable file
View File

@@ -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

1
debian/source/format vendored Normal file
View File

@@ -0,0 +1 @@
3.0 (quilt)

0
debian/source/include-binaries vendored Normal file
View File

1
debian/watch vendored Normal file
View File

@@ -0,0 +1 @@
version=3

View File

@@ -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"
)

View File

@@ -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