blob: 0035290bc0aab2412ed79323a2c1f6f65e09a5cc [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start sshd to allow remote network login"
author "chromium-os-dev@chromium.org"
# This must start after the iptables job so that when we enable
# port 22 below, the change won't be overwritten.
start on stopped iptables and stopped ip6tables and starting failsafe
stop on stopping failsafe
respawn
# Allow boards to pass a few extra command line options. Like custom ports.
env SSHD_ARGS=
pre-start exec /usr/share/chromeos-ssh-config/sshd-pre
script
# sshd refuses to execute unless invoked with a full path. Go figure.
# For cros_embedded, sshd is in dev image so its in /usr/local/sbin.
path='/usr/sbin/sshd'
if [ ! -f "${path}" ]; then
path='/usr/local/sbin/sshd'
fi
# We pass -D to keep sshd in the foreground. Upstart already provides
# the same features for us:
# - It dropped a controlling tty (std{in,err,out} are /dev/null).
# - It calls setsid() for every job.
# - It forked for us.
# This is also required for newer versions of openssh which probes to see
# "am I already daemonized", and Upstart triggers that code.
exec "${path}" -D ${SSHD_ARGS}
end script
post-stop exec /usr/share/chromeos-ssh-config/sshd-post