From patchwork Wed Jul 7 01:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joshua Branson X-Patchwork-Id: 31212 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A235327BC78; Wed, 7 Jul 2021 02:40:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 868D127BC81 for ; Wed, 7 Jul 2021 02:40:16 +0100 (BST) Received: from localhost ([::1]:55072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0wXv-0007v5-Ib for patchwork@mira.cbaines.net; Tue, 06 Jul 2021 21:40:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0wXi-0007uh-Gd for guix-patches@gnu.org; Tue, 06 Jul 2021 21:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0wXi-0006TG-8B for guix-patches@gnu.org; Tue, 06 Jul 2021 21:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0wXi-0000xm-4G for guix-patches@gnu.org; Tue, 06 Jul 2021 21:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49430] [PATCH] doc: Add auto login a user to a specific tty guide to the cookbook. References: <20210706062004.24820-1-jbranso@dismail.de> In-Reply-To: <20210706062004.24820-1-jbranso@dismail.de> Resent-From: Joshua Branson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 07 Jul 2021 01:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49430 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49430@debbugs.gnu.org Cc: Joshua Branson , leo.prikler@student.tugraz.at Received: via spool by 49430-submit@debbugs.gnu.org id=B49430.16256219863676 (code B ref 49430); Wed, 07 Jul 2021 01:40:02 +0000 Received: (at 49430) by debbugs.gnu.org; 7 Jul 2021 01:39:46 +0000 Received: from localhost ([127.0.0.1]:50449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0wXR-0000xD-Hm for submit@debbugs.gnu.org; Tue, 06 Jul 2021 21:39:45 -0400 Received: from mx1.dismail.de ([78.46.223.134]:17196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0wXP-0000wz-7O for 49430@debbugs.gnu.org; Tue, 06 Jul 2021 21:39:44 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id aaf61276; Wed, 7 Jul 2021 03:39:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h=from:to:cc :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=20190914; bh=TC4CwFYIMF3vO2MCcKluP b7o8KCAYdlLvhQDokFMvxY=; b=hc0YIOhrFzJgz5yln3y0oSKNPMgvKEGtJson1 fvvp4tvhn282ZZU54U/2/t0hR0cVtNp0g0VPqWpwtJZuFpUbboMOKoYFXJlwCqEY tVubtUKV1m3zMMBXO136VldDbYaI2bo5iCfkpAvweXsVjUq5kE6INsCRNouaSAg3 tQGdcJRybgNf18s01a3YgiSenHs7IrV6KGf7bJyAGoQuE5oqnJN+tRh1pw6GFHhD 8HUZ/6KOwFcU5QYbWXPT0Hq/xfQVOc/H3qDE/kxu5dAR2vC59cQNzWOzyXjTaLnY NZXyjdsQRj1+zBwMkQwgNqnPgaweamiuRoNsa1/2ns50ppBkQ== Received: from smtp2.dismail.de ( [10.240.26.12]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 693ed2da; Wed, 7 Jul 2021 03:39:35 +0200 (CEST) Received: from smtp2.dismail.de (localhost [127.0.0.1]) by smtp2.dismail.de (OpenSMTPD) with ESMTP id 54502962; Wed, 7 Jul 2021 03:39:35 +0200 (CEST) Received: by dismail.de (OpenSMTPD) with ESMTPSA id b014bb00 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 7 Jul 2021 03:39:34 +0200 (CEST) Date: Tue, 6 Jul 2021 21:39:09 -0400 Message-Id: <20210707013909.13774-1-jbranso@dismail.de> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Joshua Branson X-ACL-Warn: , Joshua Branson via Guix-patches X-Patchwork-Original-From: Joshua Branson via Guix-patches via From: Joshua Branson X-getmail-retrieved-from-mailbox: Patches From: Joshua Branson * doc/guix-cookbook.texi (System Configuration): Add a brief guide that explains auto login a user to one TTY. This is a follow up to bug 48974. * doc/guix.texi (System Services): Add an texinfo anchor, so that the cookbook entry "Auto Login a User to a Specific TTY" can refer back to the precise point that the GNU Guix Reference manual. Also add a reference to the cookbook that shows how to auto login a specific user to one TTY. --- doc/guix-cookbook.texi | 58 +++++++++++++++++++++++++++++++++++++++++- doc/guix.texi | 13 ++++++---- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 1cddaa7faf..a9c3ef6407 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -17,6 +17,7 @@ Copyright @copyright{} 2020 Marcin Karpezo@* Copyright @copyright{} 2020 Brice Waegeneire@* Copyright @copyright{} 2020 André Batista@* Copyright @copyright{} 2020 Christopher Lemmer Webber +Copyright @copyright{} 2021 Joshua Branson@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -85,7 +86,7 @@ Packaging System Configuration -* Customizing the Kernel:: Creating and using a custom Linux kernel +* Auto Login a User to a Specific TTY:: Automatically Login a User to a Specific TTY @end detailmenu @@ -1353,6 +1354,7 @@ chapter is to demonstrate some advanced configuration concepts. reference. @menu +* Auto Login a User to a Specific TTY:: Automatically Login a User to a Specific TTY * Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System. * Guix System Image API:: Customizing images to target specific platforms. * Connecting to Wireguard VPN:: Connecting to a Wireguard VPN. @@ -1363,6 +1365,60 @@ reference. * Setting up NGINX with Lua:: Configuring NGINX web-server to load Lua modules. @end menu +@node Auto Login a User to a Specific TTY +@section Auto Login a User to a Specific TTY + +While the Guix manual explains auto-login one user to @emph{all} TTYs ( +@pxref{auto-login to TTY,,, guix, GNU Guix Reference Manual}), some +might prefer a situation, in which one user is logged into one TTY with +the other TTYs either configured to login different users or no one at +all. Note that one can auto-login one user to any TTY, but it is +usually advisable to avoid @code{tty1}, which, by default, is used to +log warnings and errors. + +Here is how one might set up auto login for one user to one tty: + +@lisp +(use-modules (gnu) (guix)) +(use-service-modules avahi networking xorg) + +(define (auto-login-to-tty config tty user) + (if (string=? tty (mingetty-configuration-tty config)) + (mingetty-configuration + (inherit config) + (auto-login user)) + config)) + +(define %my-base-services + (modify-services %base-services + (mingetty-service-type config => + (auto-login-to-tty + config "tty3" "alice")))) + +(operating-system + (host-name "antelope") + ... + (services + (append + (list + ;; additional services you might want, e.g + ;; (service avahi-service-type) + ;; (service gdm-service-type) + (service dhcp-client-service-type)) + %my-base-services))) +@end lisp + +One could also @code{compose} (@pxref{Higher-Order Functions,,, guile, +The Guile Reference Manual}) @code{auto-login-to-tty} to login multiple +users to multiple ttys. + +Finally, here is a note of caution. Setting up auto login to a TTY, +means that anyone can turn on your computer and run commands as your +regular user. If you have encrypted your @code{/} partition, and thus +need to enter in a passphrase at boot, then perhaps auto login to a TTY +is a secure and convenient option for you. + + @node Customizing the Kernel @section Customizing the Kernel diff --git a/doc/guix.texi b/doc/guix.texi index 1086d3220b..0410225196 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13542,10 +13542,11 @@ Occasionally, instead of using the base services as is, you will want to customize them. To do this, use @code{modify-services} (@pxref{Service Reference, @code{modify-services}}) to modify the list. -For example, suppose you want to modify @code{guix-daemon} and Mingetty -(the console log-in) in the @code{%base-services} list (@pxref{Base -Services, @code{%base-services}}). To do that, you can write the -following in your operating system declaration: +@anchor{auto-login to TTY} For example, suppose you want to modify +@code{guix-daemon} and Mingetty (the console log-in) in the +@code{%base-services} list (@pxref{Base Services, +@code{%base-services}}). To do that, you can write the following in +your operating system declaration: @lisp (define %my-services @@ -13571,7 +13572,9 @@ following in your operating system declaration: This changes the configuration---i.e., the service parameters---of the @code{guix-service-type} instance, and that of all the -@code{mingetty-service-type} instances in the @code{%base-services} list. +@code{mingetty-service-type} instances in the @code{%base-services} list +(@pxref{Auto Login a User to a Specific TTY, see the cookbook for how to +auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})). Observe how this is accomplished: first, we arrange for the original configuration to be bound to the identifier @code{config} in the @var{body}, and then we write the @var{body} so that it evaluates to the