From af9ff0feedd40dadc8df15bf9f5392a599e5279e Mon Sep 17 00:00:00 2001 From: Jameson Rollins Date: Fri, 22 Oct 2010 16:25:04 -0400 Subject: don't fail if authorized_keys file not present we create a new function here, touch_key_file_or_fail, which will touch a new key file if there isn't one already present. This is now used in the update_authorized_keys and update_known_hosts functions when looking for authorized_keys and known_hosts respectively. Closes Debian 600644 --- src/share/common | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/share/common') diff --git a/src/share/common b/src/share/common index d286145..0f760c3 100644 --- a/src/share/common +++ b/src/share/common @@ -383,6 +383,23 @@ test_gpg_expire() { echo "$1" | egrep -q "^[0-9]+[mwy]?$" } +# touch a key file if it doesn't exist, including creating needed +# directories with correct permissions +touch_key_file_or_fail() { + local keyFile="$1" + if [ ! -f "$keyFile" ]; then + # make sure to create files and directories with the + # appropriate write bits turned off: + newUmask=$(printf "%04o" $(( 0$(umask) | 0022 )) ) + [ -d $(dirname "$keyFile") ] \ + || (umask "$newUmask" && mkdir -p -m 0700 $(dirname "$keyFile") ) \ + || failure "Could not create path to $keyFile" + # make sure to create this file with the appropriate bits turned off: + (umask "$newUmask" && touch "$keyFile") \ + || failure "Unable to create $keyFile" + fi +} + # check that a file is properly owned, and that all it's parent # directories are not group/other writable check_key_file_permissions() { @@ -886,7 +903,7 @@ process_authorized_user_ids() { fi ;; (*) - ((nline++)) + ((++nline)) userIDs[${nline}]="$line" unset koptions[${nline}] || true ;; -- cgit v1.2.3