rng-tools permite o esgotamento / dev / random

0

Estou tentando entender o que está acontecendo com rng-tools e systemd em um dev-board do Beaglebone Black que está causando depleção de entropia em /dev/random . Eu tenho cerca de 8 placas-dev em uma configuração similar e apenas o Beaglebone tem o problema.

O Beaglebone roda um derivado Debian e tem um hardware. O OMAP rng sustenta as leituras de /dev/hwrng . No entanto, após drenar /dev/random , o dispositivo nunca será recuperado. Por exemplo, leva 646 segundos para ler 10 bytes de /dev/random .

Quando olho para systemd , não vejo um serviço habilitado para o rng:

$ systemctl list-unit-files | grep -i -E 'rng|rand'
rng-tools.service                      generated
systemd-random-seed.service            static
urandom.service                        static

Eu tento ativá-lo e nenhum erro é retornado:

# systemctl enable rng-tools.service
rng-tools.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable rng-tools

Mas o serviço não habilita:

$ systemctl list-unit-files | grep -i -E 'rng|rand'
rng-tools.service                      generated
systemd-random-seed.service            static
urandom.service                        static

E:

$ systemctl status rng-tools
● rng-tools.service
   Loaded: loaded (/etc/init.d/rng-tools; generated; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-10-14 02:36:05 EDT; 17h ago
     Docs: man:systemd-sysv-generator(8)

Há um script em rng-tools chamado /etc/init.d/rng-tools que parece um arquivo de serviço, mas não é um arquivo systemd service. Não vejo onde está ativado ou onde é alimentado /dev/random . O Debian pode ter um relatório de erros relacionado em Problema 776597, rng-tools: nenhum arquivo systemd .service . Não acredito que o script 776597 seja o mesmo script mostrado abaixo.

Como faço para corrigir esse problema ou solucioná-lo ainda mais?

Aqui estão alguns Q & A semelhantes. Eu não consegui extrair informações úteis deles. Parte do problema é a complexidade que systemd introduziu. Eu não estou seguindo o que deveria acontecer, e os pontos mais finos dos objetos abaixo de /etc/systemd/system like multi-user.target.wants .

O pacote rng-tools :

$ apt-file list rng-tools
rng-tools: /etc/default/rng-tools
rng-tools: /etc/init.d/rng-tools
rng-tools: /etc/logcheck/ignore.d.server/rng-tools
rng-tools: /etc/logcheck/violations.ignore.d/rng-tools
rng-tools: /usr/bin/rngtest
rng-tools: /usr/sbin/rngd
rng-tools: /usr/share/doc/rng-tools/README.gz
rng-tools: /usr/share/doc/rng-tools/TODO.Debian
rng-tools: /usr/share/doc/rng-tools/changelog.Debian.gz
rng-tools: /usr/share/doc/rng-tools/changelog.gz
rng-tools: /usr/share/doc/rng-tools/copyright
rng-tools: /usr/share/lintian/overrides/rng-tools
rng-tools: /usr/share/man/man1/rngtest.1.gz
rng-tools: /usr/share/man/man8/rngd.8.gz

O script /etc/init.d/rng-tools .

$ cat /etc/init.d/rng-tools
#! /bin/sh
#
# rng-tools     initscript for the rng-tools package
#               Copr. 2003 by Henrique de Moraes Holschuh <[email protected]>
#               Copr. 2002 by Viral Shah <[email protected]>
#
### BEGIN INIT INFO
# Provides:             rng-tools
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
### END INIT INFO
#
#
# $Id: rng-tools.init,v 1.6.2.10 2008-06-10 19:51:37 hmh Exp $

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/rngd
NAME=rngd
DESC="Hardware RNG entropy gatherer daemon"
PIDFILE=/var/run/rngd.pid

DEVICELIST="hwrng hw_random hwrandom intel_rng i810_rng"

HRNGDEVICE=/dev/hwrng
RNGDOPTIONS=
[ -r /etc/default/rng-tools ] && . /etc/default/rng-tools

test -f ${DAEMON} || exit 0

set -e

finddevice () {
        [ -c "${HRNGDEVICE}" ] && return 0
        for i in ${DEVICELIST} ; do
                if [ -c "/dev/$i" ] ; then
                        HRNGDEVICE="/dev/$i"
                        return 0
                fi
                if [ -c "/dev/misc/$i" ] ; then
                        HRNGDEVICE="/dev/misc/$i"
                        return 0
                fi
        done

        echo "(Hardware RNG device inode not found)"
        echo "$0: Cannot find a hardware RNG device to use." >&2
        exit 1
}

START="--start --quiet --pidfile ${PIDFILE} --startas ${DAEMON} --name ${NAME}"
case "$1" in
  start)
        echo -n "Starting $DESC: "
        finddevice
        START="${START} -- -r ${HRNGDEVICE} ${RNGDOPTIONS}"
        if start-stop-daemon ${START} >/dev/null 2>&1 ; then
                echo "${NAME}."
        else
                if start-stop-daemon --test ${START} >/dev/null 2>&1; then
                        echo "(failed)."
                        exit 1
                else
                        echo "${DAEMON} already running."
                        exit 0
                fi
        fi
        ;;
  stop)
        echo -n "Stopping $DESC: "
        if start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
                --startas ${DAEMON} --retry 10 --name ${NAME} \
                >/dev/null 2>&1 ; then
                        echo "${NAME}."
        else
                if start-stop-daemon --test ${START} >/dev/null 2>&1; then
                        echo "(not running)."
                        exit 0
                else
                        echo "(failed)."
                        exit 1
                fi
        fi
        ;;
  restart|force-reload)
        $0 stop
        exec $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|force-reload}" 1>&2
        exit 1
        ;;
esac

exit 0

Dmesg está relacionado com o rng:

$ dmesg | grep -i -E 'rand|rng'
[    4.560639] random: systemd-udevd urandom read with 11 bits of entropy available
[   11.086922] systemd[1]: Starting Load/Save Random Seed...
[   15.022431] using random self ethernet address
[   15.022465] using random host ethernet address
[   15.027177] using random self ethernet address
[   15.027195] using random host ethernet address
[   21.308396] omap_rng 48310000.rng: OMAP Random Number Generator ver. 20
[   34.690558] random: nonblocking pool is initialized

E systemd dump para rng-tools:

-> Unit rng-tools.service:
    Description: rng-tools.service
    Instance: n/a
    Unit Load State: loaded
    Unit Active State: failed
    State Change Timestamp: Sun 2018-10-14 02:36:05 EDT
    Inactive Exit Timestamp: Sun 2018-10-14 02:36:04 EDT
    Active Enter Timestamp: n/a
    Active Exit Timestamp: n/a
    Inactive Enter Timestamp: Sun 2018-10-14 02:36:05 EDT
    GC Check Good: yes
    Need Daemon Reload: no
    Transient: no
    Slice: system.slice
    CGroup: n/a
    CGroup realized: no
    CGroup mask: 0x0
    CGroup members mask: 0x0
    Name: rng-tools.service
    Documentation: man:systemd-sysv-generator(8)
    Fragment Path: /run/systemd/generator.late/rng-tools.service
    Source Path: /etc/init.d/rng-tools
    Condition Timestamp: Sun 2018-10-14 02:36:04 EDT
    Condition Result: yes
    Assert Timestamp: Sun 2018-10-14 02:36:04 EDT
    Assert Result: yes
    Requires: system.slice
    Requires: sysinit.target
    WantedBy: multi-user.target
    WantedBy: graphical.target
    Conflicts: shutdown.target
    Before: shutdown.target
    Before: multi-user.target
    Before: graphical.target
    After: systemd-journald.socket
    After: system.slice
    After: remote-fs.target
    After: sysinit.target
    After: systemd-journald-dev-log.socket
    After: basic.target
    References: remote-fs.target
    References: graphical.target
    References: sysinit.target
    References: system.slice
    References: multi-user.target
    References: systemd-journald.socket
    References: systemd-journald-dev-log.socket
    References: basic.target
    References: shutdown.target
    ReferencedBy: multi-user.target
    ReferencedBy: graphical.target
    StopWhenUnneeded: no
    RefuseManualStart: no
    RefuseManualStop: no
    DefaultDependencies: yes
    OnFailureJobMode: replace
    IgnoreOnIsolate: no
    Service State: failed
    Result: exit-code
    Reload Result: success
    PermissionsStartOnly: no
    RootDirectoryStartOnly: no
    RemainAfterExit: yes
    GuessMainPID: no
    Type: forking
    Restart: no
    NotifyAccess: none
    NotifyState: unknown
    KillMode: process
    KillSignal: SIGTERM
    SendSIGKILL: yes
    SendSIGHUP:  no
    UMask: 0022
    WorkingDirectory: /
    RootDirectory: /
    NonBlocking: no
    PrivateTmp: no
    PrivateNetwork: no
    PrivateDevices: no
    ProtectHome: no
    ProtectSystem: no
    IgnoreSIGPIPE: no
    RuntimeDirectoryMode: 0755
    LimitNOFILE: 4096
    LimitNOFILESoft: 1024
    StandardInput: null
    StandardOutput: journal
    StandardError: inherit
    SyslogFacility: daemon
    SyslogLevel: info
    -> ExecStart:
            Command Line: /etc/init.d/rng-tools start
    -> ExecStop:
            Command Line: /etc/init.d/rng-tools stop

E systemd services:

$ find /etc/systemd -name '*\.service'
/etc/systemd/system/sshd.service
/etc/systemd/system/getty.target.wants/[email protected]
/etc/systemd/system/getty.target.wants/[email protected]
/etc/systemd/system/dbus-org.freedesktop.Avahi.service
/etc/systemd/system/network-online.target.wants/networking.service
/etc/systemd/system/syslog.service
/etc/systemd/system/multi-user.target.wants/cron.service
/etc/systemd/system/multi-user.target.wants/networking.service
/etc/systemd/system/multi-user.target.wants/avahi-daemon.service
/etc/systemd/system/multi-user.target.wants/capemgr.service
/etc/systemd/system/multi-user.target.wants/rsyslog.service
/etc/systemd/system/multi-user.target.wants/generic-board-startup.service
/etc/systemd/system/multi-user.target.wants/ssh.service
/etc/systemd/system/[email protected]
/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service
    
por jww 15.10.2018 / 02:14

1 resposta

0

A solução alternativa local para mim foi executada rng-tools diretamente de rc.local :

$ cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

if [ -e /usr/sbin/rngd ]; then
    /usr/sbin/rngd -r /dev/hwrng -f
fi

exit 0

Também foi apresentado um bug contra o Debian: A edição 911043, rng-tools não funciona como esperado no Beaglebone Black com OMAP hw rng .

Vou deixar a questão em aberto caso alguém saiba a correção real dos problemas systemd .

A afirmação na resposta da @MariusMatutiae em Como posso executar um comando após a inicialização? era muito verdadeira:

In [the systemd] case, you should learn how to start a service to be run by systemctl, but this may be more than you bargained for with your simple question.

Eu desperdicei mais de quatro horas tentando fazer isso funcionar usando métodos e controles systemd . E a distro não conseguiu que funcionasse.

    
por 15.10.2018 / 07:53