2 * This work is licensed under the terms of the GNU GPL, version 2 or later.
3 * See the COPYING file in the top-level directory.
6 #include "qemu/osdep.h"
7 #include "qapi/error.h"
8 #include "commands-common-ssh.h"
10 GStrv
read_authkeys(const char *path
, Error
**errp
)
12 g_autoptr(GError
) err
= NULL
;
13 g_autofree
char *contents
= NULL
;
15 if (!g_file_get_contents(path
, &contents
, NULL
, &err
)) {
16 error_setg(errp
, "failed to read '%s': %s", path
, err
->message
);
20 return g_strsplit(contents
, "\n", -1);
23 bool check_openssh_pub_keys(strList
*keys
, size_t *nkeys
, Error
**errp
)
28 for (k
= keys
; k
!= NULL
; k
= k
->next
) {
29 if (!check_openssh_pub_key(k
->value
, errp
)) {
41 bool check_openssh_pub_key(const char *key
, Error
**errp
)
43 /* simple sanity-check, we may want more? */
44 if (!key
|| key
[0] == '#' || strchr(key
, '\n')) {
45 error_setg(errp
, "invalid OpenSSH public key: '%s'", key
);