From c3d09dfaa3dc284602f6e1736a4b34be958af993 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Wed, 12 Apr 2023 20:19:10 +0200 Subject: [PATCH 1/3] tang: updated to version 12 This version enables standalone operation. Signed-off-by: Nikos Mavrogiannopoulos --- utils/tang/Makefile | 20 +++++++++----------- utils/tang/files/config | 4 ++++ utils/tang/files/tang.init | 24 ++++++++++++++++++++++++ utils/tang/files/tang.upgrade | 1 + utils/tang/files/tangdw | 4 ---- utils/tang/files/tangdx | 12 ------------ 6 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 utils/tang/files/config create mode 100644 utils/tang/files/tang.init create mode 100644 utils/tang/files/tang.upgrade delete mode 100755 utils/tang/files/tangdw delete mode 100644 utils/tang/files/tangdx diff --git a/utils/tang/Makefile b/utils/tang/Makefile index 6dff7c88c4..005fe4d50c 100644 --- a/utils/tang/Makefile +++ b/utils/tang/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=tang -PKG_VERSION:=11 -PKG_RELEASE:=3 +PKG_VERSION:=12 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://github.com/latchset/$(PKG_NAME)/releases/download/v$(PKG_VERSION)/ -PKG_HASH:=ef5d3ae56030f20c290594b9be89ad9ec469dd385676595e1c7a2bfdc3f45d8f +PKG_HASH:=892e0b26ee2db01f2c257b083fbb85aede7d3f59de7361c9c9528c0d5783e69c PKG_MAINTAINER:=Tibor Dudlák PKG_LICENSE:=GPL-3.0-or-later @@ -25,7 +25,7 @@ include $(INCLUDE_DIR)/meson.mk define Package/tang SECTION:=utils TITLE:=tang v$(PKG_VERSION) - daemon for binding data to the presence of a third party - DEPENDS:=+libhttp-parser +xinetd +jose +bash + DEPENDS:=+libhttp-parser +jose +bash URL:=https://github.com/latchset/tang endef @@ -34,18 +34,18 @@ define Package/tang/description endef define Package/tang/conffiles -/etc/xinetd.d/tangdx /usr/share/tang/db/ endef define Package/tang/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/libexec - $(INSTALL_DIR) $(1)/etc/xinetd.d/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/tang-show-keys $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/tangd* $(1)/usr/libexec/ - $(INSTALL_BIN) ./files/tangdw $(1)/usr/libexec/ - $(CP) ./files/tangdx $(1)/etc/xinetd.d/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/tang.init $(1)/etc/init.d/tang + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/config $(1)/etc/config/tang endef define Package/tang/postinst @@ -54,10 +54,8 @@ if [ -z "$${IPKG_INSTROOT}" ]; then mkdir -p /usr/share/tang/db KEYS=$(find /usr/share/tang/db/ -name "*.jw*" -maxdepth 1 | wc -l) if [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair - /usr/libexec/tangd-keygen /usr/share/tang/db/ + /usr/libexec/tangd-keygen /usr/share/tang/db fi - (cat /etc/services | grep -E "tangd.*8888\/tcp") > /dev/null \ - || echo -e "tangd\t\t8888/tcp" >> /etc/services fi endef diff --git a/utils/tang/files/config b/utils/tang/files/config new file mode 100644 index 0000000000..1b37d3deb4 --- /dev/null +++ b/utils/tang/files/config @@ -0,0 +1,4 @@ +config tang 'config' + option port '9090' + option enabled '0' + diff --git a/utils/tang/files/tang.init b/utils/tang/files/tang.init new file mode 100644 index 0000000000..9ce89c1586 --- /dev/null +++ b/utils/tang/files/tang.init @@ -0,0 +1,24 @@ +#!/bin/sh /etc/rc.common + +START=50 +USE_PROCD=1 + +start_service() { + KEYS=$(find /usr/share/tang/db -name "*.jw*" -maxdepth 1 | wc -l) + if [ -z "${KEYS}" ] || [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair + mkdir -p /usr/share/tang/db + /usr/libexec/tangd-keygen /usr/share/tang/db + fi + + config_load "tang" + config_get_bool enabled "config" "enabled" 0 + config_get port "config" "port" "9090" + + [ "${enabled}" = "1" ] || return + + procd_open_instance + procd_set_param command /usr/libexec/tangd -p "${port}" -l /usr/share/tang/db + procd_set_param respawn + procd_set_param user tang + procd_close_instance +} diff --git a/utils/tang/files/tang.upgrade b/utils/tang/files/tang.upgrade new file mode 100644 index 0000000000..82623f64e3 --- /dev/null +++ b/utils/tang/files/tang.upgrade @@ -0,0 +1 @@ +/usr/share/tang/db/*.jw* diff --git a/utils/tang/files/tangdw b/utils/tang/files/tangdw deleted file mode 100755 index 91c8a89650..0000000000 --- a/utils/tang/files/tangdw +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo "==================================" >> /var/log/tangd.log -echo `date`: >> /var/log/tangd.log -/usr/libexec/tangd $1 2>> /var/log/tangd.log diff --git a/utils/tang/files/tangdx b/utils/tang/files/tangdx deleted file mode 100644 index bd2134eae3..0000000000 --- a/utils/tang/files/tangdx +++ /dev/null @@ -1,12 +0,0 @@ -service tangd -{ - port = 8888 - socket_type = stream - wait = no - user = root - server = /usr/libexec/tangdw - server_args = /usr/share/tang/db - log_on_success += USERID - log_on_failure += USERID - disable = no -} From 17d759c7fd69cbccf59d436baa653b326259fc73 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 7 May 2023 13:35:14 +0200 Subject: [PATCH 2/3] tang: remove post-installation key generation The keys will be generated on startup. Signed-off-by: Nikos Mavrogiannopoulos --- utils/tang/Makefile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/utils/tang/Makefile b/utils/tang/Makefile index 005fe4d50c..994d13dc53 100644 --- a/utils/tang/Makefile +++ b/utils/tang/Makefile @@ -48,15 +48,4 @@ define Package/tang/install $(INSTALL_CONF) ./files/config $(1)/etc/config/tang endef -define Package/tang/postinst -#!/bin/sh -if [ -z "$${IPKG_INSTROOT}" ]; then - mkdir -p /usr/share/tang/db - KEYS=$(find /usr/share/tang/db/ -name "*.jw*" -maxdepth 1 | wc -l) - if [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair - /usr/libexec/tangd-keygen /usr/share/tang/db - fi -fi -endef - $(eval $(call BuildPackage,tang)) From 21937be8edd6193003aea430df46f7e98f7d18d8 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 26 Apr 2022 09:50:08 +0200 Subject: [PATCH 3/3] tang: use sbin instead of libexec Signed-off-by: Nikos Mavrogiannopoulos --- utils/tang/Makefile | 4 ++-- utils/tang/files/tang.init | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/tang/Makefile b/utils/tang/Makefile index 994d13dc53..c9b159a190 100644 --- a/utils/tang/Makefile +++ b/utils/tang/Makefile @@ -39,9 +39,9 @@ endef define Package/tang/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/tang-show-keys $(1)/usr/bin/ - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/tangd* $(1)/usr/libexec/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/tangd* $(1)/usr/sbin/ $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/tang.init $(1)/etc/init.d/tang $(INSTALL_DIR) $(1)/etc/config diff --git a/utils/tang/files/tang.init b/utils/tang/files/tang.init index 9ce89c1586..ea4045f2e1 100644 --- a/utils/tang/files/tang.init +++ b/utils/tang/files/tang.init @@ -7,7 +7,7 @@ start_service() { KEYS=$(find /usr/share/tang/db -name "*.jw*" -maxdepth 1 | wc -l) if [ -z "${KEYS}" ] || [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair mkdir -p /usr/share/tang/db - /usr/libexec/tangd-keygen /usr/share/tang/db + /usr/sbin/tangd-keygen /usr/share/tang/db fi config_load "tang" @@ -17,7 +17,7 @@ start_service() { [ "${enabled}" = "1" ] || return procd_open_instance - procd_set_param command /usr/libexec/tangd -p "${port}" -l /usr/share/tang/db + procd_set_param command /usr/sbin/tangd -p "${port}" -l /usr/share/tang/db procd_set_param respawn procd_set_param user tang procd_close_instance