diff mbox series

[bug#49430] doc: Add auto login to tty guide to the cookbook.

Message ID 20210706080856.22614-1-jbranso@dismail.de
State Accepted
Headers show
Series [bug#49430] doc: Add auto login to tty guide to the cookbook. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Joshua Branson July 6, 2021, 8:08 a.m. UTC
From: Joshua Branson <jbranso@gnucode.me>

* doc/guix-cookbook.texi (System Configuration): Add a brief guide that
explains auto login to a TTY.  This is a follow up to bug 48974.
---
 doc/guix-cookbook.texi | 45 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

Comments

Leo Prikler July 6, 2021, 8:58 a.m. UTC | #1
Hi,

this looks a bit better, but a few things remain, that irk me.
Am Dienstag, den 06.07.2021, 04:08 -0400 schrieb Joshua Branson:
> From: Joshua Branson <jbranso@gnucode.me>
> 
> * doc/guix-cookbook.texi (System Configuration): Add a brief guide
> explaining mingetty auto-login.
I think the commit message is better written as above instead of what
you had.
> ---
>  doc/guix-cookbook.texi | 45
> +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
> index 1cddaa7faf..85489e1a93 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
I'm not a fan of this breaking the columns, but perhaps it's necessary.
>  * 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,47 @@ 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
> +
> +Guix System currently offers auto login to a tty via
> @code{mingetty},
> +but a newcomer to Guix System may be unfamiliar with setting up auto
Note, that mingetty is not the only service offering auto-login. 
Basically all terminals and DMs have one.
Also "a newcomer" → "newcomers" may be more appropriate in that it
doesn't single anyone out, though in my personal opinion "newcomer" has
some "only grade schoolers play on easy modo" vibes attached to it,
particularly within a manual/cookbook.

Perhaps to soften this, you should open up stating "While the Guix
manual explains how to login a user to *all* TTYs, some might prefer a
situation, in which one user is logged in to one TTY with the other
TTYs either configured to login different users or no one at all."
> +login.  First, 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 is a secure
> and
> +convenient option for you.
> +
> +Here is how one might go about setting up auto login to a tty:
> +
> +@lisp
> +(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"))))
I'd inline this definition below in services
> +(operating-system
> +    (host-name "antelope")
> +    ...
> +    (services
> +     (append
> +      (list (service dhcp-client-service-type))
Replace this by a comment ";; additional services you might want, e.g"
followed by the commented service list.
> +      %my-base-services)))
> +@end lisp
Follow up with how one can compose auto-login-to-tty to login multiple
users to multiple TTYs (no full system config needed here, just the
mention of compose).

Finally, though this is very personal, I'd put the note of caution from
before here at the end, because now the reader has a complete
understanding of what it is, that they are achieving.  Putting the
warning in the front might scare them away into not trying – which
would be a security win for sure – but it could also happen, that they
just skip over the warning and copypasta the code.  Having everything
together at the bottom is therefore preferable in my personal opinion,
though again, that's very personal and others might disagree here.

> +Note that the above code will automatically login the user
> @code{alice}
> +into @code{tty3}. You can auto-login your user to any TTY, though
> it's
> +usually advisable to avoid @code{tty1}, as by default it is used to
> log
> +warnings and errors.
The explanation that alice is logged into tty3 is probably apparent
from the procedure call, so putting the explanation of avoiding TTY1
among the caveats above has priority over when to explain, that alice
is logged in to tty3.  Still, you might want to split this up, so that
the former goes in front of the explanation on how to login multiple
users and the latter to the caveats.

Regards,
Leo
diff mbox series

Patch

diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index 1cddaa7faf..85489e1a93 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,47 @@  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
+
+Guix System currently offers auto login to a tty via @code{mingetty},
+but a newcomer to Guix System may be unfamiliar with setting up auto
+login.  First, 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 is a secure and
+convenient option for you.
+
+Here is how one might go about setting up auto login to a tty:
+
+@lisp
+(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 (service dhcp-client-service-type))
+      %my-base-services)))
+@end lisp
+
+Note that the above code will automatically login the user @code{alice}
+into @code{tty3}. You can auto-login your user to any TTY, though it's
+usually advisable to avoid @code{tty1}, as by default it is used to log
+warnings and errors.
+
+
 @node Customizing the Kernel
 @section Customizing the Kernel