diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/responder/ssh/sshsrv_cmd.c | 6 | ||||
-rw-r--r-- | src/sss_client/ssh/sss_ssh_authorizedkeys.c | 3 | ||||
-rw-r--r-- | src/util/sss_ssh.c | 36 | ||||
-rw-r--r-- | src/util/sss_ssh.h | 13 |
4 files changed, 12 insertions, 46 deletions
diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c index a689515a..2497eb49 100644 --- a/src/responder/ssh/sshsrv_cmd.c +++ b/src/responder/ssh/sshsrv_cmd.c @@ -448,8 +448,7 @@ ssh_host_pubkeys_format_known_host_plain(TALLOC_CTX *mem_ctx, } for (i = 0; i < ent->num_pubkeys; i++) { - ret = sss_ssh_format_pubkey(tmp_ctx, ent, &ent->pubkeys[i], - SSS_SSH_FORMAT_OPENSSH, "", &pubkey); + ret = sss_ssh_format_pubkey(tmp_ctx, &ent->pubkeys[i], &pubkey); if (ret != EOK) { result = NULL; goto done; @@ -492,8 +491,7 @@ ssh_host_pubkeys_format_known_host_hashed(TALLOC_CTX *mem_ctx, } for (i = 0; i < ent->num_pubkeys; i++) { - ret = sss_ssh_format_pubkey(tmp_ctx, ent, &ent->pubkeys[i], - SSS_SSH_FORMAT_OPENSSH, "", &pubkey); + ret = sss_ssh_format_pubkey(tmp_ctx, &ent->pubkeys[i], &pubkey); if (ret != EOK) { result = NULL; goto done; diff --git a/src/sss_client/ssh/sss_ssh_authorizedkeys.c b/src/sss_client/ssh/sss_ssh_authorizedkeys.c index 74b9693f..902b4a07 100644 --- a/src/sss_client/ssh/sss_ssh_authorizedkeys.c +++ b/src/sss_client/ssh/sss_ssh_authorizedkeys.c @@ -109,8 +109,7 @@ int main(int argc, const char **argv) /* print results */ for (i = 0; i < ent->num_pubkeys; i++) { - ret = sss_ssh_format_pubkey(mem_ctx, ent, &ent->pubkeys[i], - SSS_SSH_FORMAT_OPENSSH, NULL, &repr); + ret = sss_ssh_format_pubkey(mem_ctx, &ent->pubkeys[i], &repr); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sss_ssh_format_pubkey() failed (%d): %s\n", diff --git a/src/util/sss_ssh.c b/src/util/sss_ssh.c index a713eab0..d36e3c62 100644 --- a/src/util/sss_ssh.c +++ b/src/util/sss_ssh.c @@ -111,7 +111,7 @@ done: return ret; } -errno_t +static errno_t sss_ssh_get_pubkey_algorithm(TALLOC_CTX *mem_ctx, struct sss_ssh_pubkey *pubkey, char **result) @@ -144,10 +144,7 @@ sss_ssh_get_pubkey_algorithm(TALLOC_CTX *mem_ctx, errno_t sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, - struct sss_ssh_ent *ent, struct sss_ssh_pubkey *pubkey, - enum sss_ssh_pubkey_format format, - const char *comment, char **result) { TALLOC_CTX *tmp_ctx; @@ -156,10 +153,6 @@ sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, char *algo; char *out = NULL; - if (!comment) { - comment = ent->name; - } - tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { return ENOMEM; @@ -171,26 +164,15 @@ sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, goto done; } - switch (format) { - case SSS_SSH_FORMAT_RAW: - /* base64-encoded key blob */ - out = talloc_steal(mem_ctx, blob); - break; - - case SSS_SSH_FORMAT_OPENSSH: - /* OpenSSH authorized_keys/known_hosts format */ - ret = sss_ssh_get_pubkey_algorithm(tmp_ctx, pubkey, &algo); - if (ret != EOK) { - goto done; - } - - out = talloc_asprintf(mem_ctx, "%s %s %s", algo, blob, comment); - if (!out) { - ret = ENOMEM; - goto done; - } + ret = sss_ssh_get_pubkey_algorithm(tmp_ctx, pubkey, &algo); + if (ret != EOK) { + goto done; + } - break; + out = talloc_asprintf(mem_ctx, "%s %s", algo, blob); + if (!out) { + ret = ENOMEM; + goto done; } *result = out; diff --git a/src/util/sss_ssh.h b/src/util/sss_ssh.h index ef663d9a..fec7c732 100644 --- a/src/util/sss_ssh.h +++ b/src/util/sss_ssh.h @@ -42,21 +42,8 @@ sss_ssh_make_ent(TALLOC_CTX *mem_ctx, struct sss_ssh_ent **result); errno_t -sss_ssh_get_pubkey_algorithm(TALLOC_CTX *mem_ctx, - struct sss_ssh_pubkey *pubkey, - char **result); - -enum sss_ssh_pubkey_format { - SSS_SSH_FORMAT_RAW, - SSS_SSH_FORMAT_OPENSSH -}; - -errno_t sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, - struct sss_ssh_ent *ent, struct sss_ssh_pubkey *pubkey, - enum sss_ssh_pubkey_format format, - const char *comment, char **result); #endif /* _SSS_SSH_H_ */ |