summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2012-09-01 16:10:06 -0400
committerJakub Hrozek <jhrozek@redhat.com>2012-09-04 10:17:42 +0200
commit4a628b83d129463e7886c8cdaa31739512947e42 (patch)
tree7fa8c3db79ab065d0d95dad82abac15f43690b6e /src/util
parentef9f85751b26995093cc9782fe48ddeacc8e2d3f (diff)
downloadsssd-4a628b83d129463e7886c8cdaa31739512947e42.tar.gz
sssd-4a628b83d129463e7886c8cdaa31739512947e42.tar.bz2
sssd-4a628b83d129463e7886c8cdaa31739512947e42.zip
SSH: Simplify public key formatting function
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_ssh.c36
-rw-r--r--src/util/sss_ssh.h13
2 files changed, 9 insertions, 40 deletions
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_ */