[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26099: [PATCH] services: Add inetd-service-type.
From: |
Ludovic Courtès |
Subject: |
bug#26099: [PATCH] services: Add inetd-service-type. |
Date: |
Wed, 15 Mar 2017 09:43:42 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Hi Thomas,
Thomas Danckaert <address@hidden> skribis:
> this patch adds an inetd-service. The service is configured using a list of
> <inetd-entry> records, which correspond to lines in the inetd.conf file
> (documented in the inetutils info manual). The following example will start
> inetd with the built-in “echo” service, and with an smtp service, which uses
> ssh to tunnel smtp traffic to a server “smtp-server” behind a gateway
> “hostname”:
>
> (service inetd-service-type
> (list
> (inetd-entry
> (name "echo")
> (socket-type 'stream)
> (protocol "tcp")
> (wait? #t)
> (user "root")) ; no program and arguments fields
> required for inetd's "internal" services such as echo
> (inetd-entry
> (node "127.0.0.1")
> (name "smtp")
> (socket-type 'stream)
> (protocol "tcp")
> (wait? #f)
> (user "root")
> (program (file-append openssh "/bin/ssh"))
> (arguments "-q -T -i /path/to/key -W
> smtp-server:25 address@hidden"))))
Very nice!
> The configuration doesn't include an “escape hatch” option where the user can
> specify an arbitrary inetd.conf, but I think the current configuration method
> captures all possibilities, and inetd's configuration format is unlikely to
> change radically? Or perhaps the (inetd-config-file) procedure can be
> exported, so users can either use the procedure with a list of
> <inetd-entry>'s, or directly pass a (mixed-text-file) or any other file-like.
As you write, I think an escape hatch isn’t needed in this case.
<inetd-entry> is expressive enough and inetd.conf isn’t going to change
overnight.
> Obviously documentation is still missing, but I wanted to wait for a first
> round of comments before writing the docs. Let me know if I should already
> include them anyway.
Sure. :-) Make sure to include an example like the one above (but wrap
lines to 80 chars).
Some very minor cosmetic comments:
> From 85b01d04d8b140ed3a1960b1678cc133367b916b Mon Sep 17 00:00:00 2001
> From: Thomas Danckaert <address@hidden>
> Date: Tue, 14 Mar 2017 18:12:34 +0100
> Subject: [PATCH] services: Add inetd-service-type.
>
> * gnu/services/networking.scm (<inetd-entry>): New record type.
> (inetd-config-file, inetd-shepherd-service): New procedures.
> (inetd-service-type): New variable.
[...]
> +(define-record-type* <inetd-entry> inetd-entry make-inetd-entry
> + inetd-entry?
> + (node inetd-entry-node (default #f)) ;string or #f
> + (name inetd-entry-name) ;string, from /etc/services
> + (socket-type inetd-entry-socket-type) ;stream | dgram | raw | rdm |
> seqpacket
> + (protocol inetd-entry-protocol) ;string, from /etc/protocols
> ("tcp", "udp", ...)
> + (wait? inetd-entry-wait? (default #t)) ;Boolean
> + (user inetd-entry-user) ;string
> + (program inetd-entry-program ;string or file-like
> + (default "internal"))
> + (arguments inetd-entry-arguments ;string
> + (default "internal")))
It would be nice to add a ‘package’ field that would default to
‘inetutils’, so that users can choose which package or variant inetd is
taken from.
> +(define (inetd-config-file service-list)
> + (apply mixed-text-file "inetd.conf"
> + (fold-right ; The order of address lines in inetd.conf matters.
> + (lambda (s prev)
Please avoid one-letter identifier. If it makes lines too long, you can
always move the ‘lambda’ to an internal ‘define’ above.
Also I have a slight preference for “services” rather than
“service-list”. :-)
> + (append
> + (list
> + (let* ((node (inetd-entry-node s))
> + (name (inetd-entry-name s))
> + (socket
> + (if node (string-append node ":" name) name))
> + (type
> + (match (inetd-entry-socket-type s)
> + ((or 'stream 'dgram 'raw 'rdm 'seqpacket)
> + (symbol->string (inetd-entry-socket-type s)))))
> + (protocol (inetd-entry-protocol s))
> + (wait (if (inetd-entry-wait? s) "wait" "nowait"))
> + (user (inetd-entry-user s))
> + (program (inetd-entry-program s))
> + (args (inetd-entry-arguments s)))
> + #~(string-join
> + (list #$@(list socket type protocol wait user program
> args))
> + " "))
> + "\n") prev)) '() service-list)))
I think you could just use (map entry->inetd.conf-line service-list),
where ‘entry->inetd.conf-line’ is the lambda above, no?
> +(define-public inetd-service-type
> + (service-type
> + (name 'inetd)
> + (extensions
> + (list (service-extension shepherd-root-service-type
> inetd-shepherd-service)))))
I think you also need to add ‘extend’ and ‘compose’ such that other
services (say, OpenSSH) can add inetd entries via service extensions.
Thank you!
Ludo’.