From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: Re: [V2 PATCH 1/1] services: Add agetty service. Date: Thu, 16 Feb 2017 02:06:50 -0500 Message-ID: <20170216070650.GA21674@jasmine> References: <8b9a83141665a7a86aa3d3c9ba6363c1ba2e93cd.1487117562.git.leo@famulari.name> <20170215002417.GA19546@jasmine> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kXdP64Ggrk/fb43R" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceG9a-0006oa-2p for guix-devel@gnu.org; Thu, 16 Feb 2017 02:06:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceG9W-0001I3-Ow for guix-devel@gnu.org; Thu, 16 Feb 2017 02:06:58 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52572) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ceG9W-0001Hz-Gd for guix-devel@gnu.org; Thu, 16 Feb 2017 02:06:54 -0500 Received: from localhost (c-73-188-17-148.hsd1.pa.comcast.net [73.188.17.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 3CF117E16E for ; Thu, 16 Feb 2017 02:06:53 -0500 (EST) Content-Disposition: inline In-Reply-To: <20170215002417.GA19546@jasmine> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --kXdP64Ggrk/fb43R Content-Type: multipart/mixed; boundary="u3/rZRmxL6MmkK24" Content-Disposition: inline --u3/rZRmxL6MmkK24 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 14, 2017 at 07:24:17PM -0500, Leo Famulari wrote: > This 'extra' is a time-saving kludge. I'll add fields for all of > agetty's configuration options once I'm satisfied that the service works > on GuixSD. Here's a patch that exposes (almost all) of agetty's command-line options. Is this the right way? Or would we rather wrap only the most commonly-used options, and leave an "escape hatch" as in the first version of the patch? If so, which options should we expose in Scheme? I'll wait for feedback before writing the documentation. --u3/rZRmxL6MmkK24 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename="0001-services-Add-agetty-service.patch" Content-Transfer-Encoding: quoted-printable =46rom 215ad705a933fda1170a5883277cd9a68db693e0 Mon Sep 17 00:00:00 2001 =46rom: Leo Famulari Date: Tue, 14 Feb 2017 11:28:04 -0500 Subject: [PATCH] services: Add agetty service. * gnu/services/base.scm (): New record type. (agetty-shepherd-service, agetty-service): New procedures. (agetty-service-type): New variable. --- gnu/services/base.scm | 214 ++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 213 insertions(+), 1 deletion(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 57601eab8..a06d44bb2 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -3,7 +3,7 @@ ;;; Copyright =A9 2015, 2016 Alex Kost ;;; Copyright =A9 2015, 2016 Mark H Weaver ;;; Copyright =A9 2015 Sou Bunnbu -;;; Copyright =A9 2016 Leo Famulari +;;; Copyright =A9 2016, 2017 Leo Famulari ;;; Copyright =A9 2016 David Craven ;;; Copyright =A9 2016 Ricardo Wurmus ;;; @@ -38,6 +38,7 @@ #:select (canonical-package glibc)) #:use-module (gnu packages bash) #:use-module (gnu packages package-management) + #:use-module (gnu packages linux) #:use-module (gnu packages lsof) #:use-module (gnu packages terminals) #:use-module ((gnu build file-systems) @@ -74,6 +75,11 @@ login-service-type login-service =20 + agetty-configuration + agetty-configuration? + agetty-service + agetty-service-type + mingetty-configuration mingetty-configuration? mingetty-service @@ -730,6 +736,212 @@ Return a service that sets up Unicode support in @var= {tty} and loads the message of the day, among other things." (service login-service-type config)) =20 +(define-record-type* + agetty-configuration make-agetty-configuration + agetty-configuration? + (agetty agetty-configuration-agetty ; + (default util-linux)) + (tty agetty-configuration-tty) ;string + (term agetty-term ;string + (default #f)) + (baud-rate agetty-baud-rate ;string + (default #f)) + (auto-login agetty-auto-login ;string + (default #f)) + (login-program agetty-login-program ;gexp + (default (file-append shadow "/bin/login"))) + (login-pause? agetty-login-pause? ;Boolean + (default #f)) + (eight-bits? agetty-eight-bits? ;Boolean + (default #f)) + (no-reset? agetty-no-reset? ;Boolean + (default #f)) + (remote? agetty-remote? ;Boolean + (default #f)) + (flow-control? agetty-flow-control? ;Boolean + (default #f)) + (host agetty-host ;string + (default #f)) + (no-issue? agetty-no-issue? ;Boolean + (default #f)) + (init-string agetty-init-string ;string + (default #f)) + (no-clear? agetty-no-clear? ;Boolean + (default #f)) + (local-line agetty-local-line ;always | never | auto + (default #f)) + (extract-baud? agetty-extract-baud? ;Boolean + (default #f)) + (skip-login? agetty-skip-login? ;Boolean + (default #f)) + (no-newline? agetty-no-newline? ;Boolean + (default #f)) + (login-options agetty-login-options ;string + (default #f)) + (chroot agetty-chroot ;string + (default #f)) + (hangup? agetty-hangup? ;Boolean + (default #f)) + (timeout agetty-timeout ;integer + (default #f)) + (detect-case? agetty-detect-case? ;Boolean + (default #f)) + (wait-cr? agetty-wait-cr? ;Boolean + (default #f)) + (no-hints? agetty-no-hints? ;Boolean + (default #f)) + (no-hostname? agetty-no hostname? ;Boolean + (default #f)) + (long-hostname? agetty-long-hostname? ;Boolean + (default #f)) + (erase-chars agetty-erase-chars ;string + (default #f)) + (kill-chars agetty-kill-chars ;string + (default #f)) + (chdir agetty-chdir ;string + (default #f)) + (delay agetty-delay ;integer + (default #f)) + (nice agetty-nice ;integer + (default #f)) +;;; XXX Unimplemented for now! +;;; (issue-file agetty-issue-file ;plain-file +;;; (default #f)) + ) + +(define agetty-shepherd-service + (match-lambda + (($ agetty tty term baud-rate auto-login + login-program login-pause? eight-bits? no-reset? remote? flow-cont= rol? + host no-issue? init-string no-clear? local-line extract-baud? + skip-login? no-newline? login-options chroot hangup? timeout + detect-case? wait-cr? no-hints? no-hostname? long-hostname? erase-= chars + kill-chars chdir delay nice) + (list + (shepherd-service + (documentation "Run agetty on a tty.") + (provision (list (symbol-append 'term- (string->symbol tty)))) + + ;; Same comment as for mingetty-shepherd-service. + (requirement '(user-processes host-name udev)) + + (start #~(make-forkexec-constructor + (list #$ (file-append util-linux "/sbin/agetty") + #$@(if eight-bits? + #~("--8bits") + #~()) + #$@(if no-reset? + #~("--noreset") + #~()) + #$@(if remote? + #~("--remote") + #~()) + #$@(if flow-control? + #~("--flow-control") + #~()) + #$@(if host + #~("--host" #$host) + #~()) + #$@(if no-issue? + #~("--noissue") + #~()) + #$@(if init-string + #~("--init-string" #$init-string) + #~()) + #$@(if no-clear? + #~("--noclear") + #~()) + ;; This doesn't work as expected. According to + ;; agetty(8), if this option is not passed, then= the + ;; default is 'auto'. However, in my tests, when= that + ;; option is selected, agetty never presents the= login + ;; prompt, and the term-ttyS0 service respawns e= very + ;; few seconds. + #$@(if local-line + #~(#$(match local-line + ('auto "--local-line=3Dauto") + ('always "--local-line=3Dalways") + ('never "-local-line=3Dnever"))) + #~()) + #$@(if extract-baud? + #~("--extract-baud") + #~()) + #$@(if skip-login? + #~("--skip-login") + #~()) + #$@(if no-newline? + #~("--nonewline") + #~()) + #$@(if login-options + #~("--login-options" #$login-options) + #~()) + #$@(if chroot + #~("--chroot" #$chroot) + #~()) + #$@(if hangup? + #~("--hangup") + #~()) + #$@(if timeout + #~("--timeout" #$(number->string timeout)) + #~()) + #$@(if detect-case? + #~("--detect-case") + #~()) + #$@(if wait-cr? + #~("--wait-cr") + #~()) + #$@(if no-hints? + #~("--nohints?") + #~()) + #$@(if no-hostname? + #~("--nohostname") + #~()) + #$@(if long-hostname? + #~("--long-hostname") + #~()) + #$@(if erase-chars + #~("--erase-chars" #$erase-chars) + #~()) + #$@(if kill-chars + #~("--kill-chars" #$kill-chars) + #~()) + #$@(if chdir + #~("--chdir" #$chdir) + #~()) + #$@(if delay + #~("--delay" #$(number->string delay)) + #~()) + #$@(if nice + #~("--nice" #$(number->string nice)) + #~()) + #$@(if auto-login + #~("--autologin" #$auto-login) + #~()) + #$@(if login-program + #~("--login-program" #$login-program) + #~()) + #$@(if login-pause? + #~("--login-pause") + #~()) + #$tty + #$@(if baud-rate + #~(#$baud-rate) + #~()) + #$@(if term + #~(#$term) + #~())))) + (stop #~(make-kill-destructor))))))) + +(define agetty-service-type + (service-type (name 'agetty) + (extensions (list (service-extension shepherd-root-service= -type + agetty-shepherd-servi= ce))))) + +(define* (agetty-service config) + "Return a service to run agetty according to @var{config}, which specifi= es +the tty to run, among other things." + (service agetty-service-type config)) + (define-record-type* mingetty-configuration make-mingetty-configuration mingetty-configuration? --=20 2.11.1 --u3/rZRmxL6MmkK24-- --kXdP64Ggrk/fb43R Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAlilT4UACgkQJkb6MLrK fwhA0xAAog98vq5j04nQJbdoxmc3r6OLY9KDfQborS93RKeBU5g5pcQwTMgmhoKR rs136MOdz4zUgcblux0JjXMRGgtqV85soRU+m/auumbnxBs8pGjANlWYTkLzYxpO jy89dCohvYMcreIAltjkuRX8nTRX8FWLqLI454TsWesihAsuNgZ28VeQFd/Yrn/D CbWv0px2skbNKHOQf4zBQ3XPVZAhHOxLGxFzftkGff0wdk1FB5ec1LKgmahd/jX8 g6JcQjdGhCWWfuThmaLbsRDtbDlP5zMq7fYV/axiJIPQT0C781T2JBKd6e97Z2Ic 3wB/+Qr0QKXdS02HciZNmUJNWBSoVO8l81aO3mLmc3lnz7AZV6wR/TKVh6BTfHvM 8QnYzUheN+V5Psdvvi1RXwF4f0UVWA2sz2hVzOfdGQyH/8TZNGyK7il04xNYzA4T pDw9WiBwrMTQt1GW4SBrus48ccXGK/mdtfuPCP9mWkumcG2dIp4+ROp6iflbY9KH wkm1EIlPgGco3yzzG3DjqMHKSEj0iCCLFO+0EHfRkfAM94gDsl7zbVwjB8Uaznpl +Lwdr1dWTTyJQgSUXRDOrofNIYJA98+ZUFfYwZi7TfUOendL1yMoYcHBiTDI+cC5 LkTOESbxoLuFHWzk6ppzt8pHfmRosEGxGau1bJoPv77pc1Nl+0M= =befR -----END PGP SIGNATURE----- --kXdP64Ggrk/fb43R--