From patchwork Fri May 22 16:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsOpbXkgUk9TRU4=?= X-Patchwork-Id: 1296392 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=edbKj8Nr; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49TCbg11Ymz9sPK for ; Sat, 23 May 2020 03:07:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2061D8885F; Fri, 22 May 2020 17:07:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p-dYXljQEBQM; Fri, 22 May 2020 17:07:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 346DF87587; Fri, 22 May 2020 17:07:38 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 203811BF3BC for ; Fri, 22 May 2020 17:07:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 194B887587 for ; Fri, 22 May 2020 17:07:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5lXTj6IH2y5l for ; Fri, 22 May 2020 17:07:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id A867F81C8D for ; Fri, 22 May 2020 17:07:35 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id w10so13568432ljo.0 for ; Fri, 22 May 2020 10:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V5r1lmbZBW9RU/sMF2yJydenhhG4stJ2jzwUHBaXwSQ=; b=edbKj8NrA5GWNUD+O/wOWlBpJV4p5KKP58RD8/9hD0FjLgxPV9cYc+Wgh5/lil9UwR FYX/VTaCveKlSSr0qnHNBRO72dUyb+wMV/tq72G7kegBjU7+gQafstZrm+Gm76Dth3Ep 4wQ2hQuCj5oPb+IkQu5xwqLnnSJ9Tipim6BBccfuNJKi/oj27MvkKf2/9EKGagq6lCr5 8q87/hM/mEqr027oPGy9VXUkc82uIpQ4UwNdflhWpe8Ner3g39I+ICSZqrhTbWnyhko7 /5uATa4Gm6Kaem3yNDkBheMGIpS0QYJRD0Wr4QvD9R4cjO3yXghdgcGHCSJOqceSAGno v2/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=V5r1lmbZBW9RU/sMF2yJydenhhG4stJ2jzwUHBaXwSQ=; b=n4B351XFWgCuTSEMO7JfSadd+gHKyN7kYtNBTUlvnJTgUNFkk7SLa+u5+ZMWryuCS0 NVwdyhVucFYuBEfvzWF2fQg/Xr3cyxc7wMjcMNkDdJ6ewK2S5GfHEr7yW4XHIyWcTnYW qalQuGsqqVwiE2HZsP30oDvtTVcgBXnZjFEON9iG/JkBnCe8z4qvQv60dRUVFsXD68x0 D0BD6tfi03UO27ZMesm4gtXw92Oo8ioppTLfCSbKuPeVtcCr8cQ+Wkn/WCiCK9AQxqQZ vEwTcmg6Vtc5wE2hihj4yYAsVMfI43bS4W8fyJE+KdBg9sgwAg49wCE3CyF++rcxIRaC f2Iw== X-Gm-Message-State: AOAM533WOLYDAESTZR3OgtMQVwmFIynAJG8cCiLi1c49pHJVOI/0NTFa o7HyMpQIt+cT3lA3UIsH2y0TSLCl5w== X-Google-Smtp-Source: ABdhPJw/c/H9CHDg+mArbDcU7I7ZrtqAKFZLJiVlXBRe1A18tZRRhUYJ1jePnrX+SA/M4WpKfB29fA== X-Received: by 2002:a17:906:2e4c:: with SMTP id r12mr9373361eji.546.1590166772149; Fri, 22 May 2020 09:59:32 -0700 (PDT) Received: from localhost.localdomain (221.86.207.77.rev.sfr.net. [77.207.86.221]) by smtp.googlemail.com with ESMTPSA id o21sm7798476edr.68.2020.05.22.09.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 09:59:31 -0700 (PDT) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@busybox.net Date: Fri, 22 May 2020 18:59:29 +0200 Message-Id: <20200522165929.682891-1-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] packages/systemd: fix double getty on console X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" When selecting "console" for the automatic getty, the buildroot logic would collide with systemd's internal console detection logic, resulting in two getty being started on the console. This commit fixes that by doing nothing when "console" is selected and letting systemd-getty-generator deal with starting the proper getty. Note that if something other than the console is selected * Things will work properly, even if the selected terminal is also the console * A getty will still be started on the console. This is what systemd has been doing on buildroot since the beginning. it could be disabled but I left it for backward compatibility Fixes: #12361 Signed-off-by: Jérémy Rosen --- package/systemd/systemd.mk | 46 ++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk index 50398e747e..92de540725 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -497,37 +497,42 @@ define SYSTEMD_USERS endef ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),) -# systemd needs getty.service for VTs and serial-getty.service for serial ttys -# note that console-getty.service should be used on /dev/console as it should not have dependencies -# also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that +# systemd provides multiple units to autospawn getty as neede +# * getty@.service to start a getty on normal TTY +# * sertial-getty@.service to start a getty on serial lines +# * console-getty.service for generic /dev/console +# * container-getty@.service for a getty on /dev/pts/* # -# systemd defaults to only have getty@tty.service enabled -# * DefaultInstance=tty1 in getty@service -# * no DefaultInstance in serial-getty@.service -# * WantedBy=getty.target in console-getty.service -# * console-getty is not enabled because of 90-systemd.preset -# We want "systemctl preset-all" to do the right thing, even when run on the target after boot -# * remove the default instance of getty@.service via a drop-in in /usr/lib -# * set a new DefaultInstance for getty@.service instead, if needed -# * set a new DefaultInstance for serial-getty@.service, if needed -# * override the systemd-provided preset for console-getty.service if needed +# the generator systemd-getty-generator will +# * read the console= kernel command line parameter +# * enable one of the above units depending on what it finds +# +# Systemd defaults to enablinb getty@tty1.service +# +# What we want to do +# * Enable a getty on $BR2_TARGET_GENERIC_TTY_PATH +# * Set the baudrate for all units according to BR2_TARGET_GENERIC_GETTY_BAUDRATE +# * Always enable a getty on the console using systemd-getty-generator +# (backward compatibility with previous releases of buildroot) +# +# What we do +# * disable getty@tty1 (enabled by upstream systemd) +# * enable getty@xxx if $BR2_TARGET_GENERIC_TTY_PATH is a tty +# * enable serial-getty@xxx for other $BR2_TARGET_GENERIC_TTY_PATH +# * rewrite baudrates if a baudrate is provided define SYSTEMD_INSTALL_SERVICE_TTY mkdir $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d; \ printf '[Install]\nDefaultInstance=\n' \ >$(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf; \ if [ $(BR2_TARGET_GENERIC_GETTY_PORT) = "console" ]; \ then \ - TARGET="console-getty.service"; \ - printf 'enable console-getty.service\n' \ - >$(TARGET_DIR)/usr/lib/systemd/system-preset/81-buildroot-tty.preset; \ + : ; \ elif echo $(BR2_TARGET_GENERIC_GETTY_PORT) | egrep -q 'tty[0-9]*$$'; \ then \ - TARGET="getty@.service"; \ printf '[Install]\nDefaultInstance=%s\n' \ $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)) \ >$(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf; \ else \ - TARGET="serial-getty@.service"; \ mkdir $(TARGET_DIR)/usr/lib/systemd/system/serial-getty@.service.d;\ printf '[Install]\nDefaultInstance=%s\n' \ $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)) \ @@ -535,7 +540,10 @@ define SYSTEMD_INSTALL_SERVICE_TTY fi; \ if [ $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE)) -gt 0 ] ; \ then \ - $(SED) 's,115200,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),' $(TARGET_DIR)/lib/systemd/system/$${TARGET}; \ + $(SED) 's/115200/$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),115200/' $(TARGET_DIR)/lib/systemd/system/getty@.service; \ + $(SED) 's/115200/$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),115200/' $(TARGET_DIR)/lib/systemd/system/serial-getty@.service; \ + $(SED) 's/115200/$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),115200/' $(TARGET_DIR)/lib/systemd/system/console-getty@.service; \ + $(SED) 's/115200/$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),115200/' $(TARGET_DIR)/lib/systemd/system/container-getty@.service; \ fi endef endif