From e3c58bb2b6a58a8795300fd7f9a7404eff456923 Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Sun, 17 Jun 2018 15:34:33 -0600 Subject: [PATCH] customize: virtual packages for build configuration This is a loose collection of virtual packages which when built, tweak the final image. It's mostly a workaround to overlay's going away. Signed-off-by: Philip Prindeville --- admin/customize/Makefile | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 admin/customize/Makefile diff --git a/admin/customize/Makefile b/admin/customize/Makefile new file mode 100644 index 0000000000000..c4f1c4d8ca809 --- /dev/null +++ b/admin/customize/Makefile @@ -0,0 +1,97 @@ +# +# Copyright (C) 2018 Philip Prindeville +# +# This is free software, licensed under the GNU General Public License v3 or +# later. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=customize +PKG_VERSION:=1.0 +PKG_RELEASE:=1 +PKG_LICENSE:=GPLv3 + +PKG_MAINTAINER:=Philip Prindeville + +include $(INCLUDE_DIR)/package.mk + +define Package/customize/Default + SECTION:=admin + CATEGORY:=Administration +endef + +define Package/customize/description + Customize your target system. +endef + +define Package/customize/download +endef + +define Build/Prepare +endef + +define Build/Configure +endef + +define Build/Compile + +endef + +define Package/root-passwd +$(call Package/customize/Default) + TITLE:=Set default root password +endef + +define Package/root-passwd/description + Use this package to seed your images with a preset root password. +endef + +define Package/root-passwd/config + config TARGET_ROOT_PASSWD + string "Default root password (hashed, with dollars doubled up)" + help + Default root password. +endef + +define Package/root-passwd/install + # nothing to do +endef + +ROOT_PASSWD:=$(call qstrip,$(CONFIG_TARGET_ROOT_PASSWD)) + +define Package/root-passwd/postinst +#!/bin/sh +if [ -n "$$IPKG_INSTROOT" ] && [ -n "$(ROOT_PASSWD)" ]; then + $(SED) 's/^root::0:/root:$(ROOT_PASSWD)::/' $$IPKG_INSTROOT/etc/shadow +fi +exit 0 +endef + +define Package/disable-openssh-password-login +$(call Package/customize/Default) + TITLE:=Turn off password logins via openssh + DEPENDS+= @(PACKAGE_openssh-server||PACKAGE_openssh-server-pam) +endef + +define Package/disable-openssh-password-login/description + Change default openssh server setting to disallow password logins (and + thereby mitigate possible password attacks) +endef + +define Package/disable-openssh-password-login/install + # nothing to do +endef + +define Package/disable-openssh-password-login/postinst +#!/bin/sh +if [ -n "$$IPKG_INSTROOT" ]; then + $(SED) 's/#PasswordAuthentication yes$$/PasswordAuthentication no/' \ + $$IPKG_INSTROOT/etc/ssh/sshd_config +fi +exit 0 +endef + +$(eval $(call BuildPackage,root-passwd)) +$(eval $(call BuildPackage,disable-openssh-password-login)) +