From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id uGgpAeWd32V6awAA62LTzQ:P1 (envelope-from ) for ; Wed, 28 Feb 2024 21:56:05 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id uGgpAeWd32V6awAA62LTzQ (envelope-from ) for ; Wed, 28 Feb 2024 21:56:05 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OIWxfZQR; 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=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1709153764; 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:dkim-signature; bh=1bXGvrXtYU6T5ck/vbZQpLiNIxMGd3nNBLe7Q4o9rVg=; b=JvO0gUt6vAM/KBSOXlfTtMU/I23zog0uUJI7lq54Te9KjXATtACqu+4sQ/n4F3ZvtmMkgP JJqO8ZBtHZl51CiOATQv2eysWidk6tEH8IAvk/AbZFoalcSAZYccvkMlbCuafjZ30Spc4C VaQwKw4iH5IBzY9zlUtwDtqID40kwXbOiWkRkutreE2WXqsmbWSs5XgOkD2Zcv/YVBNYb3 gr3x15bVIaiO4DP8P26A0eLqglKXbfiWaNhggKCuBCl/5NkhDQfKriCLrsQ/CqKu/lcv5K pGlKq8X+J0msjUHsm2if2ewZedxFMOeuhqXZCzuyp3/XcKPEUCZMQaXMIZvGMQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OIWxfZQR; 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=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1709153764; a=rsa-sha256; cv=none; b=tXXydTsBPShaywJ/hwFhJA/Hn5N+KfzYmSiveQNIrdxBxbAYZ1N/Y3zZ98hjE8FDG48tf1 FwBZGJWHWMbiM/I3zUBZvNCsVQB/8/Mx6C57DOZbMGxM3paDVYJNNGp454zzEWJCh1/kWz WfFO03wM+D1MrZHAQZiNv7x8edEjCLxr1lRpsFKkjgrUDNBr1HihKjbC3m3PVrTNnY17yc tRuMz9AnuMnsJjcHPqvC4aN32htAth50/Ge1DRw6g9gjw8SSGqtgvAa2PMI86AJmCfDxrQ i1ck+i4J8OBrp5HjEgxZ2nrzRr5VZ2/441oDqEOTm12dD22iayOih9V6RRRbcQ== 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 B8E833D0B0 for ; Wed, 28 Feb 2024 21:56:04 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfQxk-0004ta-Rm; Wed, 28 Feb 2024 15:55:36 -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 1rfQxj-0004tD-GD for guix-patches@gnu.org; Wed, 28 Feb 2024 15:55:35 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rfQxj-0000mi-8H for guix-patches@gnu.org; Wed, 28 Feb 2024 15:55:35 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rfQy9-00030C-Vb for guix-patches@gnu.org; Wed, 28 Feb 2024 15:56:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68675] [PATCH v3 2/2] services: dhcp: Support the dhcpcd implementation. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 28 Feb 2024 20:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68675 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: soeren@soeren-tempel.net Cc: 68675@debbugs.gnu.org Received: via spool by 68675-submit@debbugs.gnu.org id=B68675.170915372711438 (code B ref 68675); Wed, 28 Feb 2024 20:56:01 +0000 Received: (at 68675) by debbugs.gnu.org; 28 Feb 2024 20:55:27 +0000 Received: from localhost ([127.0.0.1]:42756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rfQxa-0002yJ-8B for submit@debbugs.gnu.org; Wed, 28 Feb 2024 15:55:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rfQwd-0002v3-Iv for 68675@debbugs.gnu.org; Wed, 28 Feb 2024 15:54:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfQw6-0000Py-Jd; Wed, 28 Feb 2024 15:53:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=1bXGvrXtYU6T5ck/vbZQpLiNIxMGd3nNBLe7Q4o9rVg=; b=OIWxfZQRfl83D48G7Uc6 y6dGn5zuQUJeRKQ+QvzwPNMVSoVn/CyveOeMqP33hyGuaSQw1jSPTRl80IeuaATs79mCKqh05D+39 AIA5YaqRDJBvN3HY3RfHaZ56w3jdMeXioicU5dRVTqrJ2gWkfKs1al+aVO2v56hivtj58slmdFOmP 2jNs6h575k1Z1BwQXCiuSAPhgR73H1KAdaXFbhUNcfcTZCeS9Y9rcGh/vjtLfsTTx+CWPOYxGF2yd IPZoHhwVPplIDAvY+NTR25kbAgNv4uxBZGEPRJqlBCmNhuCox/W98KAsYrBaaNFJdOXYMrYt4pxFI 5SYspeqlc8m16Q==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (soeren@soeren-tempel.net's message of "Tue, 13 Feb 2024 13:50:43 +0100") References: <5c6f714f4802ec17bc247e701bcee82d54733005.1707828643.git.soeren@soeren-tempel.net> Date: Wed, 28 Feb 2024 21:53:51 +0100 Message-ID: <87plwgfgyo.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 X-Migadu-Spam-Score: -7.17 X-Spam-Score: -7.17 X-Migadu-Queue-Id: B8E833D0B0 X-Migadu-Scanner: mx11.migadu.com X-TUID: 9MkReHVayZKE Hello, soeren@soeren-tempel.net skribis: > * gnu/services/networking.scm (dhcp-client-shepherd-service): Add > support for the dhcpcd client implementation. > * gnu/services/networking.scm (dhcp-client-account-service): New > procedure. > * gnu/services/networking.scm (dhcp-client-service-type): Add optional > account-service-type extensions (needed for dhcpcd). > * gnu/system.scm (%base-packages-networking): Remove isc-dhcp from > %base-packages (will be pulled in by dhcp-client-shepherd-service). [...] > + ;; Returns the execution configuration for the = DHCP client > + ;; selected by the package field of dhcp-client= -configuration. > + ;; The configuration is a pair of pidfile and e= xecution command > + ;; where the latter is a list. > + (define exec-config > + (case (string->symbol #$client-name) > + ((isc-dhcp) > + (let ((pid-file "/var/run/dhclient.pid")) > + (cons > + (cons* (string-append #$package "/sbin= /dhclient") > + "-nw" "-I" "-pf" pid-file iface= s) > + pid-file))) > + ((dhcpcd) > + ;; For dhcpcd, the utilized pid-file depen= ds on the > + ;; command-line arguments. If multiple in= terfaces are > + ;; given, a different pid-file is returned= . Hence, we > + ;; consult dhcpcd itself to determine the = pid-file. > + (let* ((cmd (string-append #$package "/sbi= n/dhcpcd")) > + (arg (cons* cmd "-b" ifaces))) > + (cons arg > + (let* ((pipe (string-join (append arg = '("-P")) " ")) > + (port (open-input-pipe pipe)) > + (path (read-line port))) > + (close-pipe port) > + path)))) > + (else > + (display > + "unknown 'package' value in dhcp-client= -configuration" > + (current-error-port)) > + (newline (current-error-port)) > + #f))) > + I would very much like to avoid the =E2=80=98open-input-pipe=E2=80=99 dance= here. Maybe there=E2=80=99s a way to ask it to not fork, in which case we don=E2=80=99t= need to wait for a PID file? (I=E2=80=99ll give up if this really really can=E2=80=99t = be avoided. :-)) > + (and > + exec-config > + (let ((pid-file (cdr exec-config)) > + (exec-cmd (car exec-config))) > + (false-if-exception (delete-file pid-file)) > + (let ((pid (fork+exec-command exec-cmd))) > + (and (zero? (cdr (waitpid pid))) > + (read-pid-file pid-file))))))) Two notes: I would find it clearer to call =E2=80=98fork+exec-command=E2=80= =99 above instead of constructing =E2=80=98exec-config=E2=80=99. Ideally, we=E2=80=99d use: (start #~(if (file-exists? (string-append #$package "/bin/dhclient")) (make-forkexec-constructor =E2=80=A6) ;ISC version, with #= :pid-file (make-forkexec-constructor =E2=80=A6))) ;dhcpcd, maybe witho= ut #:pid-file Maybe that is too naive, but at least we should get as close as possible to that, for instance by avoiding direct calls to =E2=80=98fork+exec-comman= d=E2=80=99 + =E2=80=98waitpid=E2=80=99 + =E2=80=98read-pid-file=E2=80=99 as much as poss= ible. HTH! Ludo=E2=80=99.