From patchwork Wed Jul 29 16:57:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3285 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4BH08y4hpRz3xTX for ; Wed, 29 Jul 2020 16:57:54 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4BH08x5GpQz1gb; Wed, 29 Jul 2020 16:57:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BH08x4Dwqz306q; Wed, 29 Jul 2020 16:57:53 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4BH08x0FPTz2xGC for ; Wed, 29 Jul 2020 16:57:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 4BH08w0GK4z12s; Wed, 29 Jul 2020 16:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1596041872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=faS0nNRBFcK4me12iLgrvvAhNUnTSBU5gnTqZruwYW8=; b=K8X5890GuM1AVapoxGFZZKmT2RfV/WFyIvtRFeOWks9u8vjoWqK4j/HT3qELH8O6zUw/IT 9Vziwu0VHVNSFXibZH//xlrhGSlJCrWwnU9su6Pu3dMNuXyTaMe43qvf1JqdWiK+t/IpnN mCvK+/fEzRv7qhNaGUbbewgiFqLtAqUIk3QLvDp+U5ymMpJouwgjMsUlyE8NaoTMqan+3j cyUR1BlyrBEsfOo38ZvOilbhXfKalbGLrde/gSz1bnf77AnkdJh3LOij+PzU8I3TtysiVc xnd2ioOLkKEWg08cl1c0obnAOZe3m1AJn/37L03Jf6orIVPjvae4yligt0C38A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1596041872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=faS0nNRBFcK4me12iLgrvvAhNUnTSBU5gnTqZruwYW8=; b=NH0oV2/MX6JO6h9WTwaG2pDpC38hIm6Jxl9eksJHjWmcUmKhCzG2e44hYH1aot1cVJ8y6F 461a3jhe7rIRePAA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] libloc: Only update database once a week Date: Wed, 29 Jul 2020 18:57:43 +0200 Message-Id: <20200729165743.2680-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Ensure to download and update the database only once a week, even the script will be called by cron each hour. Fixes #12462. Signed-off-by: Stefan Schantl --- lfs/libloc | 1 + ...c-0.9.3-location-provide-return-code.patch | 22 +++++++++++++++++++ src/scripts/update-location-database | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/patches/libloc-0.9.3-location-provide-return-code.patch diff --git a/lfs/libloc b/lfs/libloc index a71a9ac5b..12bc52ca4 100644 --- a/lfs/libloc +++ b/lfs/libloc @@ -80,6 +80,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) # Apply upstream patches cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.3-country-terminate-buffer-when-reading-from-database.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.3-location-provide-return-code.patch # Add patch for i586 to disable strong stack protector. ifeq "$(BUILD_ARCH)" "i586" diff --git a/src/patches/libloc-0.9.3-location-provide-return-code.patch b/src/patches/libloc-0.9.3-location-provide-return-code.patch new file mode 100644 index 000000000..2382145c3 --- /dev/null +++ b/src/patches/libloc-0.9.3-location-provide-return-code.patch @@ -0,0 +1,22 @@ +commit 1be0681cc4bcc006369e69d90dc4439eaa6f58d5 +Author: Stefan Schantl +Date: Wed Jul 29 18:50:20 2020 +0200 + + location: Provide a return code if the database does not need to be + updated. + + Signed-off-by: Stefan Schantl + +diff --git a/src/python/location.in b/src/python/location.in +index 5211b28..8cdd140 100644 +--- a/src/python/location.in ++++ b/src/python/location.in +@@ -416,7 +416,7 @@ class CLI(object): + _("The datase has recently be updated recently (%s)") % \ + format_timedelta(now - t), + ) +- return ++ return 3 + + # Fetch the timestamp we need from DNS + t = location.discover_latest_version() diff --git a/src/scripts/update-location-database b/src/scripts/update-location-database index d830286ce..06b22d101 100644 --- a/src/scripts/update-location-database +++ b/src/scripts/update-location-database @@ -21,6 +21,8 @@ eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings) +UPDATE_INTERVAL="weekly" + # Proxy settings. # Check if a proxy should be used. if [[ $UPSTREAM_PROXY ]]; then @@ -39,7 +41,7 @@ if [[ $UPSTREAM_PROXY ]]; then fi # Get the latest location database from server. -if /usr/bin/location update; then +if /usr/bin/location update --cron=$UPDATE_INTERVAL; then # Call location and export all countries in xt_geoip compatible format. if /usr/bin/location export --directory=/usr/share/xt_geoip --family=ipv4 --format=xt_geoip; then