diff options
author | Jameson Rollins <jrollins@finestructure.net> | 2010-10-22 16:25:04 -0400 |
---|---|---|
committer | Jameson Rollins <jrollins@finestructure.net> | 2010-10-24 11:51:02 -0400 |
commit | af9ff0feedd40dadc8df15bf9f5392a599e5279e (patch) | |
tree | b97a3f94a107b045d29cd527515e697e477c0464 /src/share/common | |
parent | c7d807fb792096862a27fa0742f825d4792b7a01 (diff) |
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
Diffstat (limited to 'src/share/common')
-rw-r--r-- | src/share/common | 19 |
1 files changed, 18 insertions, 1 deletions
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 ;; |