From b0ba9a553e14e4a7c11c9e0574d3e47bdffd31fb Mon Sep 17 00:00:00 2001 From: Maarten de Waard <maarten@greenhost.nl> Date: Wed, 19 Jul 2017 11:43:33 +0200 Subject: [PATCH] add command to ssh key when using PUT --- src/api/ssh_keys_post.c | 5 ++--- src/api/ssh_keys_put.c | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/api/ssh_keys_post.c b/src/api/ssh_keys_post.c index 08fd28f..30633c1 100644 --- a/src/api/ssh_keys_post.c +++ b/src/api/ssh_keys_post.c @@ -41,13 +41,12 @@ int callback_ssh_keys_post(const struct _u_request * request, return send_simple_response(response, 400, "error", "missing ssh-key"); } + // add cryptops-client command to ssh-key char * ssh_key_with_command; - add_ssh_command(&ssh_key_with_command, ssh_key); - asprintf(&ssh_key_with_command, "%s\n", ssh_key_with_command); - // Write SSH key to file + asprintf(&ssh_key_with_command, "%s\n", ssh_key_with_command); fprintf(authorized_keys, ssh_key_with_command); fclose(authorized_keys); diff --git a/src/api/ssh_keys_put.c b/src/api/ssh_keys_put.c index 0af4782..8e9bec0 100644 --- a/src/api/ssh_keys_put.c +++ b/src/api/ssh_keys_put.c @@ -50,7 +50,12 @@ int callback_ssh_keys_put(const struct _u_request * request, return send_simple_response(response, 400, "error", "missing ssh-key"); } - r = replace_ssh_key(id, ssh_key); + // add cryptops-client command to ssh-key + char * ssh_key_with_command; + add_ssh_command(&ssh_key_with_command, ssh_key); + + r = replace_ssh_key(id, ssh_key_with_command); + if (r < 0) { if (r == -1) -- GitLab