]> xenbits.xensource.com Git - libvirt.git/commit
virauth: Report error on empty auth result
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 27 Mar 2023 08:51:44 +0000 (10:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 3 Apr 2023 06:34:53 +0000 (08:34 +0200)
commit58b7cafc28dc86c4afae485b139927630c58bdc4
tree3f1c2ed73049431fead86dcb1b798d39163577c0
parent3a947eed06499fa1411e37fd110ee4b844e1c656
virauth: Report error on empty auth result

When opening a connection, it may be necessary to provide user
credentials, or some additional info (e.g. whether to trust an
ssh key). We have a special API for that: virConnectOpenAuth()
where and additional callback can be passed. This callback is
then called with _virConnectCredential struct filled partially
and it's callback's responsibility to get desired data (e.g. by
prompting user) and store it into .result member of the struct.

But we document the callback behaviour as:

  When authentication requires one or more interactions, this callback
  is invoked. For each interaction supplied, data must be gathered
  from the user and filled in to the 'result' and 'resultlen' fields.
  If an interaction cannot be filled, fill in NULL and 0.

  Returns 0 if all interactions were filled, or -1 upon error

But there are some buggy callbacks out there, which set:

  .result = NULL;
  .resultlen = 0;

and return 0. Report an error when such buggy callback is met.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2181235
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virauth.c