Skip to content

Commit

Permalink
Ensure libvirt client auth config file is always used
Browse files Browse the repository at this point in the history
If you call a plain libvirt.NewConnect, libvirt will never consult
its client side auth config file. So even if the username & password
we have are both "", we should still call NewConnectWithAuth to
enable this config file lookup. This lets the user create a auth.conf
containing something like

  [credentials-test]
  authname=test
  password=123456

  [auth-libvirt-localhost]
  credentials=test

and that'll be automatically used when virt-handler/virt-manager
connect to libvirtd, if auth is requested by libvirtd.

Signed-off-by: Daniel P. Berrange <[email protected]>
  • Loading branch information
berrange committed May 30, 2017
1 parent 5fd6b93 commit afd51f3
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pkg/virt-handler/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func NewConnection(uri string, user string, pass string, checkInterval time.Dura
}

// TODO: needs a functional test.
func authWithPassword(uri string, user string, pass string) (*libvirt.Connect, error) {
func newConnection(uri string, user string, pass string) (*libvirt.Connect, error) {
callback := func(creds []*libvirt.ConnectCredential) {
for _, cred := range creds {
if cred.Type == libvirt.CRED_AUTHNAME {
Expand All @@ -298,17 +298,6 @@ func authWithPassword(uri string, user string, pass string) (*libvirt.Connect, e
return virConn, err
}

func newConnection(uri string, user string, pass string) (*libvirt.Connect, error) {
var virConn *libvirt.Connect
var err error
if user == "" {
virConn, err = libvirt.NewConnect(uri)
} else {
virConn, err = authWithPassword(uri, user, pass)
}
return virConn, err
}

func NewLibvirtDomainManager(connection Connection, recorder record.EventRecorder) (DomainManager, error) {
manager := LibvirtDomainManager{virConn: connection, recorder: recorder}
return &manager, nil
Expand Down

0 comments on commit afd51f3

Please sign in to comment.