Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of /etc/dropbear #119

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/etc/init.d/S50dropbear
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ start() {
umask 077
local dropbear_key_dir="/etc/dropbear"

# Handle symlinked directories
if [ -L "$dropbear_key_dir" ]; then
dropbear_key_dir=$(readlink -f "$dropbear_key_dir")
# If /etc/dropbear is not a directory, and
# - the filesystem is RO (i.e. we can not rm the symlink),
# create the directory pointed to by the symlink.
# - the filesystem is RW (i.e. we can rm the symlink),
# replace the symlink with an actual directory
if ! [ -d /etc/dropbear ]; then
if ! rm -f /etc/dropbear; then
dropbear_key_dir=$(readlink "$dropbear_key_dir")
fi
smoser marked this conversation as resolved.
Show resolved Hide resolved
fi

# Ensure host keys are changed when instance ID changes
Expand All @@ -26,7 +32,7 @@ start() {

# Regenerate invalid or missing keys
local ktype file
for ktype in rsa ecdsa; do
for ktype in rsa ecdsa ed25519; do
file="${dropbear_key_dir}/dropbear_${ktype}_host_key"
# -f = input file, -y = validate and print pubkey info
if ! dropbearkey -f "$file" -y &>/dev/null; then
Expand Down
Loading