From df882c1e7e63fc658d0296dbd272499923fc4c69 Mon Sep 17 00:00:00 2001 From: Jameson Rollins Date: Mon, 18 Oct 2010 09:55:53 -0400 Subject: Simplification/refactoring of key/file processing This is a fairly major overhaul to greatly reduce the number of redundant code paths. We here created a new process_keys_for_file function that processes key from a userid for a given key file. All the main top elevel functions now call this one function. The main top level monkeysphere functions for updating the user's authorized_keys and known_hosts files are now moved to their own sourced files, which greatly reduces the amount of code sourced with common. monkeysphere now updates authorized_keys and known_hosts in temporary files that are then atomically moved into place upon completion. Finally, removed the confusing return codes in the key/file processing functions that were based on number of valid/invalid keys processed. It was confusing in the presence of actual errors that stopped processing. --- src/share/m/keys_for_userid | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/share/m/keys_for_userid (limited to 'src/share/m/keys_for_userid') diff --git a/src/share/m/keys_for_userid b/src/share/m/keys_for_userid new file mode 100644 index 0000000..a65356b --- /dev/null +++ b/src/share/m/keys_for_userid @@ -0,0 +1,26 @@ +# -*-shell-script-*- +# This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) + +# Monkeysphere keys-for-userid subcommand +# +# The monkeysphere scripts are written by: +# Jameson Rollins +# Jamie McClelland +# Daniel Kahn Gillmor +# +# They are Copyright 2010, and are all released under the GPL, version +# 3 or later. + +keys_for_userid() { + local tmpFile=$(msmktempfile) + + trap "rm -f $tmpFile" EXIT + + FILE_TYPE='raw' process_keys_for_file "$tmpFile" "$@" + + cat "$tmpFile" + + rm -f "$tmpFile" + + trap - EXIT +} -- cgit v1.2.3