fix keys-for-user
[monkeysphere.git] / src / share / ma / update_users
index 0086cd32f57dc8573d8f6d5df8a5585e00bd0fc4..91acd669d7c8679dd7c05d9c6f4e7e9e66fecf67 100644 (file)
@@ -129,17 +129,23 @@ for uname in $unames ; do
        # the same uid that sshd is launched as); change the group of
        # the file so that members of the user's group can read it.
 
-       # FIXME: is there a better way to do this?
-       chown $(whoami) "$AUTHORIZED_KEYS" && \
-           chgrp $(id -g "$uname") "$AUTHORIZED_KEYS" && \
-           chmod g+r "$AUTHORIZED_KEYS" && \
-           mv -f "$AUTHORIZED_KEYS" "${authorizedKeysDir}/${uname}" || \
-           { 
-           log error "Failed to install authorized_keys for '$uname'!"
-           rm -f "${authorizedKeysDir}/${uname}"
-           # indicate that there has been a failure:
-           returnCode=1
-       }
+       if [ "$OUTPUT_STDOUT" ] ; then
+           log debug "outputting keys to stdout..."
+           cat "$AUTHORIZED_KEYS"
+       else
+           log debug "moving new file to ${authorizedKeysDir}/${uname}..."
+           # FIXME: is there a better way to do this?
+           chown $(whoami) "$AUTHORIZED_KEYS" && \
+               chgrp $(id -g "$uname") "$AUTHORIZED_KEYS" && \
+               chmod g+r "$AUTHORIZED_KEYS" && \
+               mv -f "$AUTHORIZED_KEYS" "${authorizedKeysDir}/${uname}" || \
+               {
+               log error "Failed to install authorized_keys for '$uname'!"
+               rm -f "${authorizedKeysDir}/${uname}"
+               # indicate that there has been a failure:
+               returnCode=1
+           }
+       fi
     else
        rm -f "${authorizedKeysDir}/${uname}"
     fi