On Wed, Oct 14, 2020 at 12:25:02AM +0400, marcandre.lur...@redhat.com wrote: > From: Marc-André Lureau <marcandre.lur...@redhat.com> > > Add new commands to add and remove SSH public keys from > ~/.ssh/authorized_keys. > > I took a different approach for testing, including the unit tests right > with the code. I wanted to overwrite the function to get the user > details, I couldn't easily do that over QMP. Furthermore, I prefer > having unit tests very close to the code, and unit files that are domain > specific (commands-posix is too crowded already). Fwiw, that > coding/testing style is Rust-style (where tests can or should even be > part of the documentation!). > > Fixes: > https://bugzilla.redhat.com/show_bug.cgi?id=1885332 > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > qga/commands-posix-ssh.c | 394 +++++++++++++++++++++++++++++++++++++++ > qga/commands-win32.c | 10 + > qga/meson.build | 17 +- > qga/qapi-schema.json | 32 ++++ > 4 files changed, 452 insertions(+), 1 deletion(-) > create mode 100644 qga/commands-posix-ssh.c
Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> > +## > +# @guest-ssh-add-authorized-keys: > +# > +# @username: the user account to add the authorized key > +# @keys: the public keys to add (in OpenSSH format) > +# > +# Append a public key to user $HOME/.ssh/authorized_keys on Unix systems (not > +# implemented for other systems). s/a public key/public keys/ > +# > +# Returns: Nothing on success. > +# > +# Since: 5.2 > +## > +{ 'command': 'guest-ssh-add-authorized-keys', > + 'data': { 'username': 'str', 'keys': ['str'] } } > + > +## > +# @guest-ssh-remove-authorized-keys: > +# > +# @username: the user account to add the authorized key > +# @keys: the public keys to remove (in OpenSSH format) > +# > +# Remove public keys from the user $HOME/.ssh/authorized_keys on Unix systems > +# (not implemented for other systems). Mention that if the requested key does not exist, it is not an error. > +# > +# Returns: Nothing on success. > +# > +# Since: 5.2 > +## > +{ 'command': 'guest-ssh-remove-authorized-keys', > + 'data': { 'username': 'str', 'keys': ['str'] } } Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|