From patchwork Wed Feb 28 10:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1905654 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=duplnsJp; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Zl2YuItI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TlB5f12tBz23qN for ; Wed, 28 Feb 2024 21:52:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gvQm1PXYBhMpfpKixUWoB1b5RuCbc2TTjl8onSP0PGw=; b=duplnsJplU3KXn ZjkuNJacFOQ8HprLG0YfOVfEpKDs307zxPj4LS4wBrk48bC+BYz5arc1lIffm9IWa8Rn4C562DtTT T8tkv16gzy/R85Huy4hSv7RqQtQX9qKwf8i4T/kEnzvAP8fYUAILHMVnL8n8ymJF1LltjY/DwfiZh /c+bWBh7N1ErgoRcqD3WvERq9XFMnPoL6m5FHWF8nRYdaiI4rGSYXO7T3SH+KJFMyS3ArfNEcHdSN p0lEwatvcaWn6K3b901NbjzKI2t2bK8LGFCibvr5nk0QU4SNVoMlB9JijN/id39I66NGMMGQp1cjF Lq3vE3VvHgIGoN4R/Qjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfHWu-00000008slA-2Itp; Wed, 28 Feb 2024 10:51:16 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfHWp-00000008sjk-15Ae for openwrt-devel@lists.openwrt.org; Wed, 28 Feb 2024 10:51:12 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so749728666b.0 for ; Wed, 28 Feb 2024 02:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709117470; x=1709722270; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eSIR6eoxH9Bo4W2p2bUaXBoDeL5zMmh0W7yLlFNPmR0=; b=Zl2YuItIYTzy2hU/uTH9jSP64d32ImPwuiOKz/+AKEzr+G9/FVrZtFGLwAyjNx7lTq t3s4/98kekYFWI7lUFm10sSQTzHUeYML0QeGgeQoQ7YqbJaKalL+Nuv22JZkYr2gyOj3 s//1nDPblt0qDbWDDAuuBwu8ucV8uRPeIwddWuAzhnd5W8gYLG/p2h2nWjMk8Ecccy73 JkuB/EfIZxC8KYsbmIDvzySwxOU1X5DR6USPjEzqs26tB/hKc++mcZSzLDbGdbtafPJc wUYBFAVlyOiP7+srrSeej6j/8TXxgZSdgogqjxt9jGAA2s6vufcsCvnPGpSkAJOI7yGI sFyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709117470; x=1709722270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eSIR6eoxH9Bo4W2p2bUaXBoDeL5zMmh0W7yLlFNPmR0=; b=Y/AJOs/hrIdwlyXxwGbcp/C9Uc5llIFjiy4155IyU+Zhyr0SKJw26dkvkjVXuYD/L0 AvnIvneSj6fiUom12eh2tdZEyns+zwdI+BTbtICmS6Q7kywoKNKbjEWj4+htPFV9E3Q5 nQeK5T6Q6JH0KxoIk9dNaR7ah+ae6y1Artc22z7MatQ/EpbF+79a0cil+E7Q2l/yxuiS zaZpcDHbGhUlt6T1hz06nHiPhga454ag99Fw+bsqH6RFjDrSX9H0ZZLzvWAGIX8AoQpd DfBcDnS56Tid8b8PoCQUQ6KYd3Q8wiRut2rGVg6HcrpAyJxAsIMAb9fpzThVe7wMUMMJ +4UA== X-Gm-Message-State: AOJu0YypQqzKTT69hCUFpFPySIucRd+fZPshBLyqBEko7CutfsqYoxOB e0Yvd4q3gyEcG31XmbepqV7L0qn8K65tjnDNiRNXzBOljn3JvKN3OD4iSEuz X-Google-Smtp-Source: AGHT+IESBEAp4Fshf/I1nK7B8/KJ9gG4eeMTcHEcKWUZGL4C324cHkqWfqEmtLdbI4Y6RwujbLp+jQ== X-Received: by 2002:a17:906:e257:b0:a3d:1cbd:67f7 with SMTP id gq23-20020a170906e25700b00a3d1cbd67f7mr9144181ejb.0.1709117469866; Wed, 28 Feb 2024 02:51:09 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id a6-20020a1709063e8600b00a4138c3f054sm1702269ejj.32.2024.02.28.02.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:51:09 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: Jo-Philipp Wich , Luiz Angelo Daros de Luca , =?utf-8?b?UmFmYcWCIE1pxYJl?= =?utf-8?b?Y2tp?= , Christian Marangi , Jonas Gorski Subject: [PATCH V3 3/3] base-files: sysupgrade: add uci-defaults script disabling services #2 Date: Wed, 28 Feb 2024 11:51:02 +0100 Message-Id: <20240228105102.3399-3-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240228105102.3399-1-zajec5@gmail.com> References: <20240228105102.3399-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_025111_332179_26D26443 X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Rafa=C5=82_Mi=C5=82ecki_Disabl?= =?unknown-8bit?q?ed_services_should_be_kept_disabled?= =?unknown-8bit?q?_after_sysupgrade=2E_This_can_be_easily_handled_using_a_pro?= =?unknown-8bit?q?per_uci-defaults?= =?unknown-8bit?q?_script=2E_Extend_sysupgrade_to_check_for_disabled_services?= =?unknown-8bit?q?=2C_generate_uci-defaults?= =?unknown-8bit?q?_script_disabling_them_and_include_it_in_backup=2E_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo2MzMgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_ab?= =?unknown-8bit?q?used_enduser_mail_provider?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= =?unknown-8bit?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freem?= =?unknown-8bit?q?ail_username_ends_in?= =?unknown-8bit?q?_digit?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= =?unknown-8bit?q?_-0=2E0_T=5FSCC=5FBODY=5FTEXT=5FLINE___No_description_avail?= =?unknown-8bit?q?able=2E?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki Disabled services should be kept disabled after sysupgrade. This can be easily handled using a proper uci-defaults script. Extend sysupgrade to check for disabled services, generate uci-defaults script disabling them and include it in backup. Cc: Christian Marangi Cc: Jo-Philipp Wich Cc: Jonas Gorski Signed-off-by: Rafał Miłecki Acked-by: Jo-Philipp Wich --- package/base-files/files/sbin/sysupgrade | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index a11e17615c..78ec455067 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -236,6 +236,7 @@ include /lib/upgrade create_backup_archive() { local conf_tar="$1" + local disabled [ "$(rootfs_type)" = "tmpfs" ] && { echo "Cannot save config while running from ramdisk." >&2 @@ -250,6 +251,14 @@ create_backup_archive() { [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" sed -i -e 's,^/,,' "$CONFFILES" { + for service in /etc/init.d/*; do + if ! $service enabled; then + disabled="$disabled$service disable\n" + fi + done + disabled="$disabled\nexit 0" + tar_print_member "/etc/uci-defaults/10_disable_services" "$(echo -e $disabled)" + # Part of archive with installed packages info if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then # Format: pkg-name{rom,overlay,unknown}