(serviceName string, unitName string)
| 608 | } |
| 609 | |
| 610 | func getServiceSocket(serviceName string, unitName string) (string, error) { |
| 611 | logrus.Debugf("Resolving path to the %s socket", serviceName) |
| 612 | |
| 613 | connection, err := dbus.SystemBus() |
| 614 | if err != nil { |
| 615 | logrus.Debugf("Resolving path to the %s socket: failed to connect to the D-Bus system instance: %s", |
| 616 | serviceName, |
| 617 | err) |
| 618 | return "", errors.New("failed to connect to the D-Bus system instance") |
| 619 | } |
| 620 | |
| 621 | unitNameEscaped := systemdPathBusEscape(unitName) |
| 622 | unitPath := dbus.ObjectPath("/org/freedesktop/systemd1/unit/" + unitNameEscaped) |
| 623 | unit := connection.Object("org.freedesktop.systemd1", unitPath) |
| 624 | call := unit.Call("org.freedesktop.DBus.Properties.GetAll", 0, "") |
| 625 | |
| 626 | var result map[string]dbus.Variant |
| 627 | err = call.Store(&result) |
| 628 | if err != nil { |
| 629 | logrus.Debugf("Resolving path to the %s socket: failed to get the properties of %s: %s", |
| 630 | serviceName, |
| 631 | unitName, |
| 632 | err) |
| 633 | return "", fmt.Errorf("failed to get the properties of %s", unitName) |
| 634 | } |
| 635 | |
| 636 | listenVariant, listenFound := result["Listen"] |
| 637 | if !listenFound { |
| 638 | return "", fmt.Errorf("failed to find the Listen property of %s", unitName) |
| 639 | } |
| 640 | |
| 641 | listenVariantSignature := listenVariant.Signature().String() |
| 642 | if listenVariantSignature != "aav" { |
| 643 | return "", errors.New("unknown reply from org.freedesktop.DBus.Properties.GetAll") |
| 644 | } |
| 645 | |
| 646 | listenValue := listenVariant.Value() |
| 647 | sockets := listenValue.([][]interface{}) |
| 648 | for _, socket := range sockets { |
| 649 | if socket[0] == "Stream" { |
| 650 | path := socket[1].(string) |
| 651 | if !strings.HasPrefix(path, "/") { |
| 652 | continue |
| 653 | } |
| 654 | |
| 655 | pathEvaled, err := filepath.EvalSymlinks(path) |
| 656 | if err != nil { |
| 657 | continue |
| 658 | } |
| 659 | |
| 660 | return pathEvaled, nil |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | return "", fmt.Errorf("failed to find a SOCK_STREAM socket for %s", unitName) |
| 665 | } |
| 666 | |
| 667 | func pullImage(image, release, authFile string) (bool, error) { |
no test coverage detected
searching dependent graphs…