-
Notifications
You must be signed in to change notification settings - Fork 289
Open
Labels
Description
I have run into some cases where step cli tries to open a TTY to prompt for input on an error while being called by systemd. This results in an unhelpful error message such as in the journal:
May 02 08:55:28 sw-0608 step[702563]: error allocating terminal: open /dev/tty: no such device or address
Which doesn't give the user any clear information as to why the command failed when being called via systemd. For example this is the unit file that caused the above error:
[Unit]
Description=Issue a smallstep certificate for %i
After=network-online.target step-ca-bootstrap.service
Wants=network-online.target step-ca-bootstrap.service
Before=%i.service
[Service]
Type=oneshot
PassEnvironment=HOSTNAME
EnvironmentFile=/etc/step/env
ExecStartPre=step ca root /etc/%i/tls/%i-ca.crt --force
ExecStart=step ca certificate ${HOSTNAME} \
--ca-url ${STEP_CA_URL} \
--provisioner ${STEP_CA_PROVISIONER} \
/etc/%i/tls/%i.crt \
/etc/%i/tls/%i.key \
--san 127.0.0.1 \
--not-after 24h \
--force \
--provisioner-password-file=${STEP_PROVISIONER_PASSWORD_FILE}
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
The above systemd error was generated by systemd's EnvironmentFile directive removing the PassEnvironment=HOSTNAME and it caused ${HOSTNAME} to be blank. This caused step to try to open a TTY and prompt for input which then fails because one does not exist when running step via systemd.
jorti