From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id pYtKDAPyvmNmvgAAbAwnHQ (envelope-from ) for ; Wed, 11 Jan 2023 18:29:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id WH2KCQPyvmN0GgEAG6o9tA (envelope-from ) for ; Wed, 11 Jan 2023 18:29:39 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9DB981B48E for ; Wed, 11 Jan 2023 18:29:38 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFeuO-0007Hz-AO; Wed, 11 Jan 2023 12:29:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFeuM-0007Hi-Py for guix-patches@gnu.org; Wed, 11 Jan 2023 12:29:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFeuM-0001RX-Hz for guix-patches@gnu.org; Wed, 11 Jan 2023 12:29:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFeuM-0003ef-Dc for guix-patches@gnu.org; Wed, 11 Jan 2023 12:29:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60735] [PATCH 2/2] services: Add block-facebook-hosts-service-type. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 11 Jan 2023 17:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60735 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60735@debbugs.gnu.org Cc: Bruno Victal Received: via spool by 60735-submit@debbugs.gnu.org id=B60735.167345813014023 (code B ref 60735); Wed, 11 Jan 2023 17:29:02 +0000 Received: (at 60735) by debbugs.gnu.org; 11 Jan 2023 17:28:50 +0000 Received: from localhost ([127.0.0.1]:43732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFeuA-0003e6-5X for submit@debbugs.gnu.org; Wed, 11 Jan 2023 12:28:50 -0500 Received: from smtpm3.myservices.hosting ([185.26.105.234]:58560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFeu7-0003dx-Vl for 60735@debbugs.gnu.org; Wed, 11 Jan 2023 12:28:48 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 88AB721102 for <60735@debbugs.gnu.org>; Wed, 11 Jan 2023 18:28:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 4731C80096; Wed, 11 Jan 2023 18:28:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ePxDfwfySSWo; Wed, 11 Jan 2023 18:28:45 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-118-236.dsl.telepac.pt [85.242.118.236]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id ECE9280093; Wed, 11 Jan 2023 18:28:44 +0100 (CET) From: Bruno Victal Date: Wed, 11 Jan 2023 17:28:14 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673458178; a=rsa-sha256; cv=none; b=IO7KsVdSdH/GlaFddRCiWkj1q8dH9tPRhfXhyy+mIqHKl3Xp/zLkf7ZwVJ/uc2xmxCP2lh VqLVlBNJxJDhGEadQ+J+mDx8gADIPyqzbH0e2jUMQ3Cc6EaOeTVcINbwiqOhJwSgFEMgbd 4uGI0aHn44PwC+iUhsYXwv6NlegvkCVZfDEV6OyJpkrNgPyrzSHUYX+UrEjYqXrkaWJ5Ct 4X1xcF8bfSBogW+zoTkzcbA+DQLKKIWoK2XD4yOruR83QTL+miR0t3abLU98XGgTQAlKg0 KNm35sTPG+Mz27S+1ORRs1KVCM2vEM7JipmFbgl7UWRU906Ih30PreQ1Ot4euw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673458178; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=upSSIiICS1QZCFeph+gcJeJpcszIATm609Na66nw9vI=; b=nm4E/8KWyg1J1cTEuSnbuAqXvJdqA3LPbbypHbZdbmWCt2Rfnau0vjBMAgieOi+MFWrxq8 3Utl2/1SM51hdD/Ux7/NjaW9S/GdHnAccL4UxWREJBhgC1akc1S9LB9f09o2Vs0ICzy6EH 3adVto3X9dCVWV+5ZkZ0B518mwIP5qfQqvbIszXUc9TvJTFGXKGv9xw+O1wjT8GTgqbimY cN3DY1BXAwjMOtSpmfWQ6Di8iQIU028W1S+5m6UFiFql4z0bo7XLmQrBxNie1rJdPQJpe7 8lNSMZvR6qY6K1LqvwHB9Lh0lDo94IZ9300wDFgcdoxELN6cuV0yG6Y+HnEgJA== X-Migadu-Queue-Id: 9DB981B48E X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-Migadu-Spam-Score: -2.89 X-Spam-Score: -2.89 X-TUID: euU3qQ5QhNdY Deprecates %facebook-host-aliases in favour of using etc-hosts-service-type service extensions. * gnu/services/networking.scm (block-facebook-hosts-service-type): New variable. (%facebook-host-aliases): Deprecate variable. * doc/guix.texi: Document it. --- doc/guix.texi | 29 ++++-------------- gnu/services/networking.scm | 61 ++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 55 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a55634ba8c..703e0e6769 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20952,34 +20952,17 @@ Networking Services @end table @end deftp -@defvr {Scheme Variable} %facebook-host-aliases -This variable contains a string for use in @file{/etc/hosts} -(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each -line contains a entry that maps a known server name of the Facebook +@defvar block-facebook-hosts-service-type +This service type adds a list of known Facebook hosts to the +@file{/etc/hosts} file. +(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}) +Each line contains a entry that maps a known server name of the Facebook on-line service---e.g., @code{www.facebook.com}---to the local host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. -This variable is typically used in the @code{hosts-file} field of an -@code{operating-system} declaration (@pxref{operating-system Reference, -@file{/etc/hosts}}): - -@lisp -(use-modules (gnu) (guix)) - -(operating-system - (host-name "mymachine") - ;; ... - (hosts-file - ;; Create a /etc/hosts file with aliases for "localhost" - ;; and "mymachine", as well as for Facebook servers. - (plain-file "hosts" - (string-append (local-host-aliases host-name) - %facebook-host-aliases)))) -@end lisp - This mechanism can prevent programs running locally, such as Web browsers, from accessing Facebook. -@end defvr +@end defvar The @code{(gnu services avahi)} provides the following definition. diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 702404bc6c..9e5caed3c5 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -19,6 +19,7 @@ ;;; Copyright © 2021 Maxime Devos ;;; Copyright © 2021 Guillaume Le Vaillant ;;; Copyright © 2022 Andrew Tropin +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -79,7 +80,9 @@ (define-module (gnu services networking) #:use-module (json) #:re-export (static-networking-service static-networking-service-type) - #:export (%facebook-host-aliases + #:export (%facebook-host-aliases ;deprecated + block-facebook-hosts-service-type + dhcp-client-service-type dhcp-client-configuration dhcp-client-configuration? @@ -234,39 +237,33 @@ (define-module (gnu services networking) ;;; ;;; Code: -(define %facebook-host-aliases +(define facebook-host-aliases ;; This is the list of known Facebook hosts to be added to /etc/hosts if you ;; are to block it. - "\ -# Block Facebook IPv4. -127.0.0.1 www.facebook.com -127.0.0.1 facebook.com -127.0.0.1 login.facebook.com -127.0.0.1 www.login.facebook.com -127.0.0.1 fbcdn.net -127.0.0.1 www.fbcdn.net -127.0.0.1 fbcdn.com -127.0.0.1 www.fbcdn.com -127.0.0.1 static.ak.fbcdn.net -127.0.0.1 static.ak.connect.facebook.com -127.0.0.1 connect.facebook.net -127.0.0.1 www.connect.facebook.net -127.0.0.1 apps.facebook.com - -# Block Facebook IPv6. -fe80::1%lo0 facebook.com -fe80::1%lo0 login.facebook.com -fe80::1%lo0 www.login.facebook.com -fe80::1%lo0 fbcdn.net -fe80::1%lo0 www.fbcdn.net -fe80::1%lo0 fbcdn.com -fe80::1%lo0 www.fbcdn.com -fe80::1%lo0 static.ak.fbcdn.net -fe80::1%lo0 static.ak.connect.facebook.com -fe80::1%lo0 connect.facebook.net -fe80::1%lo0 www.connect.facebook.net -fe80::1%lo0 apps.facebook.com\n") - + (let ((domains '("facebook.com" "www.facebook.com" + "login.facebook.com" "www.login.facebook.com" + "fbcdn.net" "www.fbcdn.net" "fbcdn.com" "www.fbcdn.com" + "static.ak.fbcdn.net" "static.ak.connect.facebook.com" + "connect.facebook.net" "www.connect.facebook.net" + "apps.facebook.com"))) + (fold (lambda (x tail) + (cons* (string-join `("127.0.0.1" ,x) "\t") + (string-join `("::1" ,x) "\t") + tail)) + '() domains))) + +(define-deprecated %facebook-host-aliases + block-facebook-hosts-service-type + (string-join facebook-host-aliases "\n" 'suffix)) + +(define block-facebook-hosts-service-type + (service-type + (name 'block-facebook-hosts) + (extensions + (list (service-extension etc-hosts-service-type + (const facebook-host-aliases)))) + (default-value #f) + (description "Add a list of known Facebook hosts to @file{/etc/hosts}"))) (define-record-type* dhcp-client-configuration make-dhcp-client-configuration -- 2.38.1