From patchwork Wed Aug 11 10:34:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "F. D. Ansel" X-Patchwork-Id: 1515753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: 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=2JuvksWD; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=B+hktzjz; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gl5qp0SwGz9sWc for ; Wed, 11 Aug 2021 20:37:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Mime-Version: Date:Message-ID:Subject:From:To:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=7q6vMKRZrnGF7ZEPQwZPwU/u6WDInk9m415HAv2GJPw=; b=2JuvksWD/JtZRIPEVC7bJafElM zV9bz9NLLPLFnh7gYl5ZolvKSq0sQBYk6G8UEriVFoUe3FIRKa/EYkanu3BEoZu/0LUQebedmdwk4 ycU5dT+TrhPJeqvFnCBoDrrgfuVHYjJxd5yN5SBpdJnAAKaWgBw39N9DZPCM5j7ythmNo9N0/d422 2AUK6G9fPbk3VPPypeV9/3tDUMOnhSpoOt5vuUxZUYzP8DP1ybpR5dBPSsC+7pJFr57jQ6Ksc6HYm 45bllf5C0Du8QtGIEtdBEbYXQPTjzqHzhT5A/Ogq9ZzdgqG1qromwyJvtxYmvxL5uNlrxS5jqMuL3 rJyNYkTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDlZK-006ehq-BU; Wed, 11 Aug 2021 10:34:42 +0000 Received: from forward101p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:101]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDlZB-006eeb-CV for openwrt-devel@lists.openwrt.org; Wed, 11 Aug 2021 10:34:37 +0000 Received: from sas1-1650ac5d911d.qloud-c.yandex.net (sas1-1650ac5d911d.qloud-c.yandex.net [IPv6:2a02:6b8:c08:d927:0:640:1650:ac5d]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 290CC328244B for ; Wed, 11 Aug 2021 13:34:29 +0300 (MSK) Received: from sas1-37da021029ee.qloud-c.yandex.net (sas1-37da021029ee.qloud-c.yandex.net [2a02:6b8:c08:1612:0:640:37da:210]) by sas1-1650ac5d911d.qloud-c.yandex.net (mxback/Yandex) with ESMTP id jY7zxBpJCy-YTH0PxEl; Wed, 11 Aug 2021 13:34:29 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1628678069; bh=uh5m/r0lQBFQAON786mL8oPWt75tD02IgVYacXDzk5c=; h=Date:Message-ID:Subject:From:To; b=B+hktzjzFjWmCw2zbiz80+eEFGj0LOWKiEFlD4GnQejuOmTPVkE0GRZdJdH0SKZSV mXpJN8aRaORNIlkIj/51qA/I03OSuPqm9Nbu9HBEOV8dTKgeYYQwc04tVziX2OyGlW 2kKmSXogbycTzs/hvCQ2QulhESPvjWkoK6ceohyM= Authentication-Results: sas1-1650ac5d911d.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by sas1-37da021029ee.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id cudJWtZzPz-YSEChkT2; Wed, 11 Aug 2021 13:34:28 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Received: from [62.201.164.138] (mail.co.uk [62.201.164.138]) by fda.mooo.com (Postfix) with ESMTPSA id 54F0B5409C8 for ; Wed, 11 Aug 2021 12:34:27 +0200 (CEST) To: openwrt-devel@lists.openwrt.org From: "F. D. Ansel" Subject: cgi-io: extend backup file name Message-ID: <947821e8-ba87-2ac4-8432-a9066e6519d1@yandex.ru> Date: Wed, 11 Aug 2021 12:34:27 +0200 Mime-Version: 1.0 Content-Language: de-DE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210811_033434_017589_56144F03 X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: it is now backup_HOST_rREV-HASH_YYYY-MM-DD_HHMM.tgz HOST is without domain now, if fqdn was set the extension changed form tar.gz to tgz REV+HASH added for easier get of version TIME added to allow mo [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [2a02:6b8:0:1472:2741:0:8b7:101 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [fdansel[at]yandex.ru] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 it is now backup_HOST_rREV-HASH_YYYY-MM-DD_HHMM.tgz HOST is without domain now, if fqdn was set the extension changed form tar.gz to tgz REV+HASH added for easier get of version TIME added to allow more than 1 backup per day added list of installed packages From 37e9917a3f784b8f0338546129d4a319deaba013 Mon Sep 17 00:00:00 2001 From: Fritz D. Ansel Date: Mon, 2 Aug 2021 21:16:16 +0200 Subject: [PATCH] extend backup file name it is now backup_HOST_rREV-HASH_YYYY-MM-DD_HHMM.tgz HOST is without domain now, if fqdn was set the extension changed form tar.gz to tgz REV+HASH added for easier get of version TIME added to allow more than 1 backup per day added list of installed packages Signed-off-by: Fritz D. Ansel --- main.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 95a62b8..c0aa15b 100644 --- a/main.c +++ b/main.c @@ -650,7 +650,7 @@ main_backup(int argc, char **argv) return failure(500, errno, "Failed chdir('/')"); execl("/sbin/sysupgrade", "/sbin/sysupgrade", - "--create-backup", "-", NULL); + "-k", "--create-backup", "-", NULL); return -1; @@ -658,15 +658,31 @@ main_backup(int argc, char **argv) close(fds[1]); now = time(NULL); - strftime(datestr, sizeof(datestr) - 1, "%Y-%m-%d", localtime(&now)); + strftime(datestr, sizeof(datestr) - 1, "%Y-%m-%d_%H%M", localtime(&now)); if (gethostname(hostname, sizeof(hostname) - 1)) sprintf(hostname, "OpenWrt"); + else { + for (int i=0; i<(int)strlen(hostname); i++) + if (hostname[i] == '.') { + hostname[i] = '\0'; + break; + } + } + + char version[32] = "UNKNOWN"; + FILE *fp; + if ((fp = fopen("/etc/openwrt_version", "r")) != NULL) { + if (fgets(version, sizeof(version), fp) == version) + if (version[strlen(version)-1] == '\n' ) + version[strlen(version)-1] = '\0'; + fclose(fp); + } printf("Status: 200 OK\r\n"); printf("Content-Type: application/x-targz\r\n"); printf("Content-Disposition: attachment; " - "filename=\"backup-%s-%s.tar.gz\"\r\n\r\n", hostname, datestr); + "filename=\"backup_%s_%s_%s.tgz\"\r\n\r\n", hostname, version, datestr); fflush(stdout);