aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016-2020, 2022-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu tests)
  #:use-module (guix gexp)
  #:use-module (guix diagnostics)
  #:use-module (guix records)
  #:use-module ((guix ui) #:select (warn-about-load-error))
  #:use-module (gnu bootloader)
  #:use-module (gnu bootloader grub)
  #:use-module (gnu system)
  #:use-module (gnu system file-systems)
  #:use-module (gnu system shadow)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services shepherd)
  #:use-module (guix discovery)
  #:use-module (guix monads)
  #:use-module ((guix store) #:select (%store-monad))
  #:use-module ((guix utils)
                #:select (%current-system %current-target-system))
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-9 gnu)
  #:use-module (ice-9 match)
  #:export (marionette-configuration
            marionette-configuration?
            marionette-configuration-device
            marionette-configuration-imported-modules
            marionette-configuration-requirements

            marionette-service-type
            marionette-operating-system
            define-os-with-source

            %simple-os
            simple-operating-system

            system-test
            system-test?
            system-test-name
            system-test-value
            system-test-description
            system-test-location

            fold-system-tests
            all-system-tests))

;;; Commentary:
;;;
;;; This module provides the infrastructure to run operating system tests.
;;; The most important part of that is tools to instrument the OS under test,
;;; essentially allowing it to run in a virtual machine controlled by the host
;;; system--hence the name "marionette".
;;;
;;; Code:

(define-record-type* <marionette-configuration>
  marionette-configuration make-marionette-configuration
  marionette-configuration?
  (device           marionette-configuration-device ;string
                    (default "/dev/virtio-ports/org.gnu.guix.port.0"))
  (imported-modules marionette-configuration-imported-modules
                    (default '()))
  (extensions       marionette-configuration-extensions
                    (default '())) ; list of packages
  (requirements     marionette-configuration-requirements ;list of symbols
                    (default '())))

;; Hack: avoid indenting code beyond column 80 in marionette-shepherd-service.
(define-syntax-rule (with-imported-modules-and-extensions imported-modules
                                                          extensions
                                                          gexp)
  (with-imported-modules imported-modules
    (with-extensions extensions
      gexp)))

(define (marionette-program device imported-modules extensions)
  "Return the program that runs the marionette REPL on DEVICE.  Ensure
IMPORTED-MODULES and EXTENSIONS are accessible from the REPL."
  (define code
    (with-imported-modules-and-extensions
        `((guix build utils)
          (guix build syscalls)
          ,@imported-modules)
        extensions
      #~(begin
          (use-modules (ice-9 match)
                       (ice-9 binary-ports))

          (define (self-quoting? x)
            (letrec-syntax ((one-of (syntax-rules ()
                                      ((_) #f)
                                      ((_ pred rest ...)
                                       (or (pred x)
                                           (one-of rest ...))))))
              (one-of symbol? string? keyword? pair? null? array?
                      number? boolean? char?)))

          (let ((repl    (open-file #$device "r+0"))
                (console (open-file "/dev/console" "r+0")))
            ;; Redirect output to the console.
            (close-fdes 1)
            (close-fdes 2)
            (dup2 (fileno console) 1)
            (dup2 (fileno console) 2)
            (close-port console)

            (display 'ready repl)
            (let loop ()
              (newline repl)

              (match (read repl)
                ((? eof-object?)
                 (primitive-exit 0))
                (expr
                 (catch #t
                   (lambda ()
                     (let ((result (primitive-eval expr)))
                       (write (if (self-quoting? result)
                                  result
                                  (object->string result))
                              repl)))
                   (lambda (key . args)
                     (print-exception (current-error-port)
                                      (stack-ref (make-stack #t) 1)
                                      key args)
                     (write #f repl)))))
              (loop))))))

  (program-file "marionette-repl.scm" code))

(define (marionette-shepherd-service config)
  "Return the Shepherd service for the marionette REPL"
  (match config
    (($ <marionette-configuration> device imported-modules extensions
                                   requirement)
     (list (shepherd-service
            (provision '(marionette))

            ;; Always depend on UDEV so that DEVICE is available.
            (requirement `(udev ,@requirement))

            (modules '((ice-9 match)
                       (srfi srfi-9 gnu)))
            (start #~(make-forkexec-constructor
                      (list #$(marionette-program device
                                                  imported-modules
                                                  extensions))))
            (stop #~(make-kill-destructor)))))))

(define marionette-service-type
  ;; This is the type of the "marionette" service, allowing a guest system to
  ;; be manipulated from the host.  This marionette REPL is essentially a
  ;; universal backdoor.
  (service-type (name 'marionette-repl)
                (extensions
                 (list (service-extension shepherd-root-service-type
                                          marionette-shepherd-service)))
                (description "The @dfn{marionette} service allows a guest
system (virtual machine) to be manipulated by the host.  It is used for system
tests.")))

(define* (marionette-operating-system os
                                      #:key
                                      (imported-modules '())
                                      (extensions '())
                                      (requirements '()))
  "Return a marionetteed variant of OS such that OS can be used as a
marionette in a virtual machine--i.e., controlled from the host system.  The
marionette service in the guest is started after the Shepherd services listed
in REQUIREMENTS.  The packages in the list EXTENSIONS are made available from
the backdoor REPL."
  (operating-system
    (inherit os)
    ;; Make sure the guest dies on error.
    (kernel-arguments (cons "panic=1"
                            (operating-system-user-kernel-arguments os)))
    ;; Make sure the guest doesn't hang in the REPL on error.
    (initrd (lambda (fs . rest)
              (apply (operating-system-initrd os) fs
                     #:on-error 'backtrace
                     rest)))
    (services (cons (service marionette-service-type
                             (marionette-configuration
                              (requirements requirements)
                              (extensions extensions)
                              (imported-modules imported-modules)))
                    (operating-system-user-services os)))))

(define-syntax define-os-with-source
  (syntax-rules (use-modules operating-system)
    "Define two variables: OS containing the given operating system, and
SOURCE containing the source to define OS as an sexp.

This is convenient when we need both the <operating-system> object so we can
instantiate it, and the source to create it so we can store in in a file in
the system under test."
    ((_ (os source)
        (use-modules modules ...)
        (operating-system fields ...))
     (begin
       (define os
         (operating-system fields ...))
       (define source
         '(begin
            (use-modules modules ...)
            (operating-system fields ...)))))))


;;;
;;; Simple operating systems.
;;;

(define %simple-os
  (operating-system
    (host-name "komputilo")
    (timezone "Europe/Berlin")
    (locale "en_US.UTF-8")

    (bootloader (bootloader-configuration
                 (bootloader grub-bootloader)
                 (targets '("/dev/sdX"))))
    (file-systems (cons (file-system
                          (device (file-system-label "my-root"))
                          (mount-point "/")
                          (type "ext4"))
                        %base-file-systems))
    (firmware '())

    (users (cons (user-account
                  (name "alice")
                  (comment "Bob's sister")
                  (group "users")
                  (supplementary-groups '("wheel" "audio" "video")))
                 %base-user-accounts))))

(define-syntax-rule (simple-operating-system user-services ...)
  "Return an operating system that includes USER-SERVICES in addition to
%BASE-SERVICES."
  (operating-system (inherit %simple-os)
                    (services (cons* user-services ... %base-services))))



;;;
;;; Tests.
;;;

(define-record-type* <system-test> system-test make-system-test
  system-test?
  (name        system-test-name)                  ;string
  (value       system-test-value)                 ;%STORE-MONAD value
  (description system-test-description)           ;string
  (location    system-test-location (innate)      ;<location>
               (default (and=> (current-source-location)
                               source-properties->location))))

(define (write-system-test test port)
  (match test
    (($ <system-test> name _ _ ($ <location> file line))
     (format port "#<system-test ~a ~a:~a ~a>"
             name file line
             (number->string (object-address test) 16)))
    (($ <system-test> name)
     (format port "#<system-test ~a ~a>" name
             (number->string (object-address test) 16)))))

(set-record-type-printer! <system-test> write-system-test)

(define-gexp-compiler (compile-system-test (test <system-test>)
                                           system target)
  "Compile TEST to a derivation."
  (mparameterize %store-monad ((%current-system system)
                               (%current-target-system target))
    (system-test-value test)))

(define (test-modules)
  "Return the list of modules that define system tests."
  (scheme-modules (dirname (search-path %load-path "guix.scm"))
                  "gnu/tests"
                  #:warn warn-about-load-error))

(define (fold-system-tests proc seed)
  "Invoke PROC on each system test, passing it the test and the previous
result."
  (fold-module-public-variables (lambda (obj result)
                                  (if (system-test? obj)
                                      (cons obj result)
                                      result))
                                '()
                                (test-modules)))

(define (all-system-tests)
  "Return the list of system tests."
  (reverse (fold-system-tests cons '())))


;; Local Variables:
;; eval: (put 'with-imported-modules-and-extensions 'scheme-indent-function 2)
;; End:

;;; tests.scm ends here
s needed by the ;; system openssh-service-type. (apply invoke "make" "install-nosysconf" make-flags) (with-directory-excursion "contrib" (chmod "ssh-copy-id" #o555) (install-file "ssh-copy-id" (string-append #$output "/bin/")) (install-file "ssh-copy-id.1" (string-append #$output "/share/man/man1/")))))))) (native-inputs (list groff pkg-config)) (inputs (cons* libedit openssl mit-krb5 zlib xauth ; for 'ssh -X' and 'ssh -Y' (if (target-hurd?) '() (list linux-pam libfido2)))) ; fails to build on GNU/Hurd (synopsis "Client and server for the secure shell (ssh) protocol") (description "The SSH2 protocol implemented in OpenSSH is standardised by the IETF secsh working group and is specified in several RFCs and drafts. It is composed of three layered components: The transport layer provides algorithm negotiation and a key exchange. The key exchange includes server authentication and results in a cryptographically secured connection: it provides integrity, confidentiality and optional compression. The user authentication layer uses the established connection and relies on the services provided by the transport layer. It provides several mechanisms for user authentication. These include traditional password authentication as well as public-key or host-based authentication mechanisms. The connection layer multiplexes many different concurrent channels over the authenticated connection and allows tunneling of login sessions and TCP-forwarding. It provides a flow control service for these channels. Additionally, various channel-specific options can be negotiated.") (license (license:non-copyleft "file://LICENSE" "See LICENSE in the distribution.")) (properties '((release-monitoring-url . "https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/"))) (home-page "https://www.openssh.com/"))) ;; OpenSSH without X support. This allows using OpenSSH without dragging X ;; libraries to the closure. (define-public openssh-sans-x (package (inherit openssh) (name "openssh-sans-x") (inputs (modify-inputs (package-inputs openssh) (delete "xauth"))) (synopsis "OpenSSH client and server without X11 support"))) (define-public guile-ssh (package (name "guile-ssh") (version "0.18.0") (home-page "https://github.com/artyom-poptsov/guile-ssh") (source (origin (method git-fetch) (uri (git-reference (url home-page) (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0zh1spkjl5q778y4rd6ml68fvz1r62xmk03khi4kp74z2rxgzcxb")))) (build-system gnu-build-system) (outputs '("out" "debug")) (arguments `(;; It makes no sense to build libguile-ssh.a. #:configure-flags '("--disable-static") #:phases (modify-phases %standard-phases (add-before 'bootstrap 'support-cross-compilation (lambda _ ;; Support cross-compilation: ;; <https://github.com/artyom-poptsov/guile-ssh/issues/30>. (substitute* "libguile-ssh/Makefile.am" (("\\$\\(guile_snarf\\)") "CPP=\"$(CPP)\" $(guile_snarf)")))) (add-before 'build 'fix-libguile-ssh-file-name (lambda* (#:key outputs #:allow-other-keys) ;; Build and install libguile-ssh.so so that we can use ;; its absolute file name in .scm files, before we build ;; the .go files. (let* ((out (assoc-ref outputs "out")) (lib (string-append out "/lib"))) (invoke "make" "install" "-C" "libguile-ssh" "-j" (number->string (parallel-job-count))) (substitute* (find-files "." "\\.scm$") (("\"libguile-ssh\"") (string-append "\"" lib "/libguile-ssh\"")))))) ,@(if (%current-target-system) '() '((add-before 'check 'fix-guile-path (lambda* (#:key inputs #:allow-other-keys) (let ((guile (assoc-ref inputs "guile"))) (substitute* "tests/common.scm" (("/usr/bin/guile") (string-append guile "/bin/guile")))))))) (add-after 'install 'remove-bin-directory (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (examples (string-append out "/share/guile-ssh/examples"))) (mkdir-p examples) (rename-file (string-append bin "/ssshd.scm") (string-append examples "/ssshd.scm")) (rename-file (string-append bin "/sssh.scm") (string-append examples "/sssh.scm")) (delete-file-recursively bin))))))) (native-inputs (list autoconf automake libtool texinfo pkg-config which guile-3.0)) ;needed when cross-compiling. (inputs (list guile-3.0 libssh libgcrypt)) (synopsis "Guile bindings to libssh") (description "Guile-SSH is a library that provides access to the SSH protocol for programs written in GNU Guile interpreter. It is a wrapper to the underlying libssh library.") (license license:gpl3+))) (define-public guile2.2-ssh (package (inherit guile-ssh) (name "guile2.2-ssh") (native-inputs (modify-inputs (package-native-inputs guile-ssh) (delete "guile") (prepend guile-2.2 ;needed when cross-compiling. ))) (inputs (modify-inputs (package-inputs guile-ssh) (replace "guile" guile-2.2))))) (define-public corkscrew ;; The last 2.0 release hails from 2009. Use a fork (submitted upstream as ;; <https://github.com/patpadgett/corkscrew/pull/5>) that adds now-essential ;; IPv6 and TLS support. (let ((revision "0") (commit "268b71e88ee51fddceab96d665b327394f1feb12")) (package (name "corkscrew") (version (git-version "2.0" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/rtgill82/corkscrew") (commit commit))) (sha256 (base32 "1rylbimlfig3ii4bqr4r058lkc43pqkxnxqpqdpm31blh3xs0dcw")) (file-name (git-file-name name version)))) (build-system gnu-build-system) (arguments `(#:configure-flags (list "--enable-ssl") #:phases (modify-phases %standard-phases (add-after 'unpack 'update-metadata (lambda _ (substitute* "configure.ac" ;; Our version differs significantly. (("2.0") (string-append ,version " (Guix)"))) (substitute* "corkscrew.c" ;; This domain's since been squat. (("\\(agroman@agroman\\.net\\)") (format #f "<~a>" ,(package-home-page this-package)))))) (add-after 'install 'install-documentation (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (doc (string-append out "/share/doc/" ,name "-" ,version))) (install-file "README.md" doc) #t)))))) (native-inputs (list autoconf automake pkg-config)) (inputs (list openssl)) (home-page "https://github.com/patpadgett/corkscrew") (synopsis "SSH tunneling through HTTP(S) proxies") (description "Corkscrew tunnels SSH connections through most HTTP and HTTPS proxies. It supports proxy authentication through the HTTP basic authentication scheme with optional @acronym{TLS, Transport-Level Security} to protect credentials.") (license license:gpl2+)))) (define-public mosh (package (name "mosh") (version "1.4.0") (source (origin (method url-fetch) (uri (string-append "https://mosh.org/mosh-" version ".tar.gz")) (sha256 (base32 "1pax8sqlvcc7ammsxd9r53yx4m2hg1827wfz6f4rrwjx9q9lnbl7")))) (build-system gnu-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (add-after 'unpack 'patch-FHS-file-names (lambda* (#:key inputs #:allow-other-keys) (substitute* "scripts/mosh.pl" (("/bin/sh" shell) (search-input-file inputs shell))))) (add-after 'install 'wrap (lambda _ ;; Make sure 'mosh' can find 'mosh-client' and 'mosh-server'. (let ((bin (string-append #$output "/bin"))) (wrap-program (string-append bin "/mosh") `("PATH" ":" prefix (,bin))))))))) (native-inputs (list pkg-config)) (inputs (list bash-minimal boost ncurses openssl perl perl-io-tty protobuf zlib)) (home-page "https://mosh.org/") (synopsis "Remote shell tolerant to intermittent connectivity") (description "Mosh is a remote terminal application that allows client roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes. It's a replacement for SSH that's more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.") (license license:gpl3+))) (define-public dropbear (package (name "dropbear") (version "2024.86") (source (origin (method url-fetch) (uri (string-append "https://matt.ucc.asn.au/dropbear/releases/" "dropbear-" version ".tar.bz2")) (sha256 (base32 "0pha5s1a3l0dadfba4lpp5k0j6arwrmisclrn06jwprrzkgkd2g7")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "libtommath") (delete-file-recursively "libtomcrypt") (substitute* "configure" (("-ltomcrypt") "-ltomcrypt -ltommath")))))) (build-system gnu-build-system) (arguments (list #:configure-flags #~(list "--disable-bundled-libtom") ;; The test suite runs an instance of dropbear, which requires a ;; resolver ("Error resolving: Servname not supported for ai_socktype"). #:tests? #f #:phases #~(modify-phases %standard-phases (add-after 'unpack 'enable-x11-forwarding (lambda _ (substitute* "src/default_options.h" (("#define DROPBEAR_X11FWD 0") "#define DROPBEAR_X11FWD 1"))))))) (inputs (list libtomcrypt libtommath libxcrypt zlib)) (synopsis "Small SSH server and client") (description "Dropbear is a relatively small SSH server and client. It runs on a variety of POSIX-based platforms. Dropbear is particularly useful for embedded systems, such as wireless routers.") (home-page "https://matt.ucc.asn.au/dropbear/dropbear.html") (license (license:x11-style "" "See file LICENSE.")))) (define-public liboop (package (name "liboop") (version "1.0.1") (source (origin (method url-fetch) (uri (string-append "http://ftp.lysator.liu.se/pub/liboop/" name "-" version ".tar.gz")) (sha256 (base32 "1q0p1l72pq9k3bi7a366j2rishv7dzzkg3i6r2npsfg7cnnidbsn")))) (build-system gnu-build-system) (home-page "https://www.lysator.liu.se/liboop/") (synopsis "Event loop library") (description "Liboop is a low-level event loop management library for POSIX-based operating systems. It supports the development of modular, multiplexed applications which may respond to events from several sources. It replaces the \"select() loop\" and allows the registration of event handlers for file and network I/O, timers and signals. Since processes use these mechanisms for almost all external communication, liboop can be used as the basis for almost any application.") (license license:lgpl2.1+))) (define-public lsh (package (name "lsh") (version "2.1") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/lsh/lsh-" version ".tar.gz")) (sha256 (base32 "1qqjy9zfzgny0rkb27c8c7dfsylvb6n0ld8h3an2r83pmaqr9gwb")) (modules '((guix build utils))) (snippet '(begin (substitute* "src/testsuite/functions.sh" (("localhost") ;; Avoid host name lookups since they don't work in ;; chroot builds. "127.0.0.1") (("set -e") ;; Make tests more verbose. "set -e\nset -x")) (substitute* (find-files "src/testsuite" "-test$") (("localhost") "127.0.0.1")) (substitute* "src/testsuite/login-auth-test" (("/bin/cat") "cat")))) (patches (search-patches "lsh-fix-x11-forwarding.patch")))) (build-system gnu-build-system) (native-inputs (list autoconf automake m4 guile-2.0 gperf psmisc)) ; for `killall' (inputs (list nettle-2 linux-pam ;; 'rl.c' uses the 'CPPFunction' type, which is no longer in ;; Readline 6.3. readline-6.2 liboop zlib gmp ;; The server (lshd) invokes xauth when X11 forwarding is requested. ;; This adds 24 MiB (or 27%) to the closure of lsh. xauth libxau ;also required for x11-forwarding libxcrypt)) (arguments '(;; Skip the `configure' test that checks whether /dev/ptmx & ;; co. work as expected, because it relies on impurities (for ;; instance, /dev/pts may be unavailable in chroots.) #:configure-flags '("lsh_cv_sys_unix98_ptys=yes" ;; Use glibc's argp rather than the bundled one. "--with-system-argp" ;; 'lsh_argp.h' checks HAVE_ARGP_PARSE but nothing ;; defines it. "CPPFLAGS=-DHAVE_ARGP_PARSE" ;; Fix the build of lsh@2.1 with GCC 10. "CFLAGS=-O2 -g -fcommon") #:phases (modify-phases %standard-phases (add-after 'unpack 'disable-failing-tests (lambda _ ;; FIXME: Most tests won't run in a chroot, presumably because ;; /etc/profile is missing, and thus clients get an empty $PATH ;; and nothing works. Run only the subset that passes. (delete-file "configure") ;force rebootstrap (substitute* "src/testsuite/Makefile.am" (("seed-test \\\\") ;prevent trailing slash "seed-test") (("^\t(lsh|daemon|tcpip|socks|lshg|lcp|rapid7|lshd).*test.*") "")))) (add-before 'configure 'pre-configure (lambda* (#:key inputs #:allow-other-keys) (let* ((nettle (assoc-ref inputs "nettle")) (sexp-conv (string-append nettle "/bin/sexp-conv"))) ;; Remove argp from the list of sub-directories; we don't want ;; to build it, really. (substitute* "src/Makefile.in" (("^SUBDIRS = argp") "SUBDIRS =")) ;; Make sure 'lsh' and 'lshd' pick 'sexp-conv' in the right place ;; by default. (substitute* "src/environ.h.in" (("^#define PATH_SEXP_CONV.*") (string-append "#define PATH_SEXP_CONV \"" sexp-conv "\"\n"))) ;; Same for the 'lsh-authorize' script. (substitute* "src/lsh-authorize" (("=sexp-conv") (string-append "=" sexp-conv))) ;; Tell lshd where 'xauth' lives. Another option would be to ;; hardcode "/run/current-system/profile/bin/xauth", thereby ;; reducing the closure size, but that wouldn't work on foreign ;; distros. (with-fluids ((%default-port-encoding "ISO-8859-1")) (substitute* "src/server_x11.c" (("define XAUTH_PROGRAM.*") (string-append "define XAUTH_PROGRAM \"" (assoc-ref inputs "xauth") "/bin/xauth\"\n"))))) ;; Tests rely on $USER being set. (setenv "USER" "guix")))))) (home-page "https://www.lysator.liu.se/~nisse/lsh/") (synopsis "GNU implementation of the Secure Shell (ssh) protocols") (description "GNU lsh is a free implementation of the SSH version 2 protocol. It is used to create a secure line of communication between two computers, providing shell access to the server system from the client. It provides both the server daemon and the client application, as well as tools for manipulating key files.") (license license:gpl2+))) (define-public sshpass (package (name "sshpass") (version "1.10") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/sshpass/sshpass/" version "/sshpass-" version ".tar.gz")) (sha256 (base32 "1npfvxxqs77qg6l4s6cn8q3b98zwr9n8rb9vra2n3dfb0g10c4dd")))) (build-system gnu-build-system) (home-page "https://sourceforge.net/projects/sshpass/") (synopsis "Non-interactive password authentication with SSH") (description "sshpass is a tool for non-interactively performing password authentication with SSH's so-called @dfn{interactive keyboard password authentication}.") (license license:gpl2+))) (define-public autossh (package (name "autossh") (version "1.4g") (source (origin (method url-fetch) (uri (string-append "https://www.harding.motd.ca/autossh/autossh-" version ".tgz")) (sha256 (base32 "0xqjw8df68f4kzkns5gcah61s5wk0m44qdk2z1d6388w6viwxhsz")))) (build-system gnu-build-system) (arguments `(#:tests? #f)) ; There is no "make check" or anything similar (inputs (list openssh)) (synopsis "Automatically restart SSH sessions and tunnels") (description "autossh is a program to start a copy of @command{ssh} and monitor it, restarting it as necessary should it die or stop passing traffic.") (home-page "https://www.harding.motd.ca/autossh/") (license ;; Why point to a source file? Well, all the individual files have a ;; copy of this license in their headers, but there's no separate file ;; with that information. (license:non-copyleft "file://autossh.c")))) (define-public pdsh (package (name "pdsh") (version "2.34") (source (origin (method url-fetch) (uri (string-append "https://github.com/chaos/pdsh/" "releases/download/pdsh-" version "/pdsh-" version ".tar.gz")) (sha256 (base32 "1s91hmhrz7rfb6h3l5k97s393rcm1ww3svp8dx5z8vkkc933wyxl")))) (build-system gnu-build-system) (arguments `(#:configure-flags (list "--with-ssh") #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-/bin/sh (lambda _ (substitute* '("tests/t0006-pdcp.sh" "tests/t0004-module-loading.sh" "tests/t2001-ssh.sh" "tests/t1003-slurm.sh" "tests/t6036-long-output-lines.sh" "tests/aggregate-results.sh" "tests/t2000-exec.sh" "tests/t0002-internal.sh" "tests/t1002-dshgroup.sh" "tests/t5000-dshbak.sh" "tests/t0001-basic.sh" "tests/t0005-rcmd_type-and-user.sh" "tests/test-lib.sh" "tests/t2002-mrsh.sh" "tests/t0003-wcoll.sh" "tests/test-modules/pcptest.c") (("/bin/sh") (which "bash"))) #t)) (add-after 'unpack 'patch-tests (lambda _ (substitute* "tests/t6036-long-output-lines.sh" (("which") (which "which"))) #t))))) (inputs (list openssh mit-krb5 perl)) (native-inputs (list which)) (home-page "https://github.com/chaos/pdsh") (synopsis "Parallel distributed shell") (description "Pdsh is a an efficient, multithreaded remote shell client which executes commands on multiple remote hosts in parallel. Pdsh implements dynamically loadable modules for extended functionality such as new remote shell services and remote host selection.") (license license:gpl2+))) (define-public python-asyncssh (package (name "python-asyncssh") (version "2.18.0") (source (origin (method url-fetch) (uri (pypi-uri "asyncssh" version)) (sha256 (base32 "08viv0k32l6f40sbraq4bqzizrkivf09zwy8kmqvjq0zq1hj2chs")))) (build-system pyproject-build-system) (arguments (list #:test-flags #~(list "-k" (string-join (list ;; TODO Test fails for unknown reason "not test_confirm" #$@(if (target-aarch64?) (list ;; Tests fail with: asyncssh.misc.ConnectionLost: ;; Connection lost "test_connect_non_tcp_sock" "test_connect_reverse_proxy" "test_get_server_auth_methods_no_sockn" "test_get_server_auth_methods_no_sockname" "test_get_server_host_key_proxy") '())) " and not " )) #:phases #~(modify-phases %standard-phases (add-before 'check 'pre-check (lambda* _ (substitute* "tests/test_connection.py" ;; nc is always available. (("which nc") "true"))))))) (native-inputs (list netcat openssh openssl python-aiofiles python-fido2 python-pytest python-setuptools python-wheel)) (propagated-inputs (list python-cryptography python-pyopenssl python-gssapi python-bcrypt python-typing-extensions)) (home-page "https://asyncssh.readthedocs.io/") (synopsis "Asynchronous SSHv2 client and server library for Python") (description "AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python 3.6+ asyncio framework.") (license license:epl2.0))) (define-public clustershell (package (name "clustershell") (version "1.9.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/cea-hpc/clustershell") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1zk3syrdck2gi27b9njaq98fnnjf14831yvkma2n4ydsf2mxnkaw")))) (build-system pyproject-build-system) (arguments (list #:tests? #f ; tests require python-nose, and most of them fail #:phases #~(modify-phases %standard-phases (add-before 'build 'fix-pathes (lambda _ (let ((ssh #$(this-package-input "openssh"))) (substitute* (list "lib/ClusterShell/Worker/Ssh.py" "lib/ClusterShell/Worker/fastsubprocess.py") (("\"/bin/sh\"") (format #f "'~a'" (which "sh"))) (("\"ssh\"") (format #f "'~a/bin/ssh'" ssh)) (("\"scp\"") (format #f "'~a/bin/scp'" ssh))) (substitute* (find-files "./tests" "\\.py$") (("\"/bin/hostname\"") (format #f "'~a'" (which "hostname"))) (("/bin/sleep") "sleep") (("/bin/echo") "echo") (("/bin/uname") "uname") (("/bin/false") "false") (("/bin/true") "true") (("/usr/bin/printf") "printf")))))))) (native-inputs (list python-setuptools python-wheel)) (inputs (list openssh)) (propagated-inputs (list python-pyyaml)) (home-page "https://cea-hpc.github.io/clustershell/") (synopsis "Scalable event-driven Python framework for cluster administration") (description "ClusterShell is an event-driven Python framework, designed to run local or distant commands in parallel on server farms or on large GNU/Linux clusters. It will take care of common issues encountered on HPC clusters, such as operating on groups of nodes, running distributed commands using optimized execution algorithms, as well as gathering results and merging identical outputs, or retrieving return codes. ClusterShell takes advantage of existing remote shell facilities such as SSH.") (license license:lgpl2.1+))) (define-public endlessh (package (name "endlessh") (version "1.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/skeeto/endlessh") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0ziwr8j1frsp3dajr8h5glkm1dn5cci404kazz5w1jfrp0736x68")))) (build-system gnu-build-system) (arguments `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) ,(string-append "CC=" (cc-for-target))) #:tests? #f ; no test target #:phases (modify-phases %standard-phases (delete 'configure)))) ; no configure script (home-page "https://github.com/skeeto/endlessh") (synopsis "SSH tarpit that slowly sends an endless banner") (description "Endlessh is an SSH tarpit that very slowly sends an endless, random SSH banner. It keeps SSH clients locked up for hours or even days at a time. The purpose is to put your real SSH server on another port and then let the script kiddies get stuck in this tarpit instead of bothering a real server. Since the tarpit is in the banner before any cryptographic exchange occurs, this program doesn't depend on any cryptographic libraries. It's a simple, single-threaded, standalone C program. It uses @code{poll()} to trap multiple clients at a time.") (license license:unlicense))) (define-public webssh (package (name "webssh") (version "1.6.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/huashengdun/webssh") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0v0dxnqac9xdj06lhljv6bhi8hd16rn6h0qr7fkm640nvr55a8i1")))) (build-system pyproject-build-system) (native-inputs (list python-pytest python-setuptools python-wheel)) (propagated-inputs (list python-paramiko python-tornado)) (home-page "https://webssh.huashengdun.org/") (synopsis "Web application to be used as an SSH client") (description "This package provides a web application to be used as an SSH client. Features: @itemize @bullet @item SSH password authentication supported, including empty password. @item SSH public-key authentication supported, including DSA RSA ECDSA Ed25519 keys. @item Encrypted keys supported. @item Two-Factor Authentication (time-based one-time password) supported. @item Fullscreen terminal supported. @item Terminal window resizable. @item Auto detect the ssh server's default encoding. @item Modern browsers are supported. @end itemize") (license license:expat))) (define-public tmate-ssh-server (let ((ver "2.3.0") (rev "0") (commit-id "d7334ee4c3c8036c27fb35c7a24df3a88a15676b")) (package (name "tmate-ssh-server") (version (git-version ver rev commit-id)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/tmate-io/tmate-ssh-server") (commit commit-id))) (file-name (git-file-name name version)) (sha256 (base32 "1vf9b0hlsi7wj5zqnbqph6f467mpkasaaspp80ipdmrdm2yp8yjp")))) (build-system gnu-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (add-after 'unpack 'patch-msgpack-pkg-config-dependency (lambda _ (substitute* "configure.ac" (("msgpack >= ") "msgpack-c >= "))))))) (native-inputs (list autoconf automake pkg-config)) (inputs (list libevent libite libssh msgpack-c ncurses)) (home-page "https://tmate.io/") (synopsis "The server side part of tmate") (description "This package allows users to host their own tmate servers.") (license license:expat)))) (define-public x11-ssh-askpass (package (name "x11-ssh-askpass") (version "1.2.4.1") (source (origin (method url-fetch) ;; The project home page seams to be offline. (uri (string-append "https://pkgs.fedoraproject.org/repo/pkgs/openssh/" name "-" version ".tar.gz" "/8f2e41f3f7eaa8543a2440454637f3c3/" name "-" version ".tar.gz")) (sha256 (base32 "124c1frwvdmg4nv8xqv435ibjhj2y8xc1bmfr6i8a8g75b1y63b2")))) (build-system gnu-build-system) (arguments (list #:tests? #f ;no tests #:make-flags #~(list (string-append "BINDIR=" #$output "/libexec") (string-append "MANDIR=" #$output "/share/man")) #:configure-flags #~(list (string-append "--mandir=" "/usr/share/man/test") (string-append "--libexecdir=" "/usr/lib/ssh/test") (string-append "--with-app-defaults-dir=" "/usr/share/X11/app-defaults/test")) #:phases #~(modify-phases %standard-phases (add-after 'configure 'xmkmf (lambda* (#:key inputs #:allow-other-keys) (let ((imake #$(this-package-native-input "imake"))) (invoke "xmkmf") (substitute* "Makefile" ;; These imake variables somehow remain undefined (("DefaultGcc2[[:graph:]]*Opt") "-O2") ;; Reset a few variable defaults that are set in imake ;; templates. ((imake) #$output) (("(MANPATH = )[[:graph:]]*" _ front) (string-append front #$output "/share/man")))))) (add-after 'xmkmf 'make-includes (lambda _ (invoke "make" "includes"))) (add-after 'install 'install/doc (lambda _ (lambda _ (invoke "make" (string-append "MANDIR=" #$output "/share/man") "install.man"))))))) (native-inputs (list imake)) (inputs (list libxt)) (home-page "http://www.jmknoble.net/software/x11-ssh-askpass/") (synopsis "Lightweight passphrase dialog for SSH") (description "code{x11-ssh-askpass} is an X11-based pass-phrase dialog for use with OpenSSH.") (license license:gpl2+)))