M2: improve error messages with actionable suggestions
udisks2 connection and device listing errors now suggest checking the service. Device-not-found errors suggest 'arca status' or 'arca init'. Failed cryptsetup token unlock hints at missing FIDO2/TPM2 key. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ type Client struct {
|
|||||||
func NewClient() (*Client, error) {
|
func NewClient() (*Client, error) {
|
||||||
conn, err := dbus.SystemBus()
|
conn, err := dbus.SystemBus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("connecting to system bus: %w", err)
|
return nil, fmt.Errorf("cannot connect to udisks2 — is the udisks2 service running? (%w)", err)
|
||||||
}
|
}
|
||||||
return &Client{conn: conn}, nil
|
return &Client{conn: conn}, nil
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ func (c *Client) FindDevice(uuid, pathOrName string) (*BlockDevice, error) {
|
|||||||
return &devices[i], nil
|
return &devices[i], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no device with UUID %s", uuid)
|
return nil, fmt.Errorf("no device with UUID %s — run 'arca status' to list devices", uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range devices {
|
for i := range devices {
|
||||||
@@ -47,7 +47,7 @@ func (c *Client) FindDevice(uuid, pathOrName string) (*BlockDevice, error) {
|
|||||||
return &devices[i], nil
|
return &devices[i], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("device %s not found", pathOrName)
|
return nil, fmt.Errorf("device %s not found — run 'arca status' to list devices or 'arca init' to generate config", pathOrName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListEncryptedDevices returns all block devices with the Encrypted interface.
|
// ListEncryptedDevices returns all block devices with the Encrypted interface.
|
||||||
@@ -152,7 +152,7 @@ func (c *Client) listBlockDevices() ([]BlockDevice, error) {
|
|||||||
var managed map[dbus.ObjectPath]map[string]map[string]dbus.Variant
|
var managed map[dbus.ObjectPath]map[string]map[string]dbus.Variant
|
||||||
err := obj.Call(ifaceObjectManager+".GetManagedObjects", 0).Store(&managed)
|
err := obj.Call(ifaceObjectManager+".GetManagedObjects", 0).Store(&managed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("listing devices: %w", err)
|
return nil, fmt.Errorf("listing devices — is the udisks2 service running? (%w)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var devices []BlockDevice
|
var devices []BlockDevice
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (u *Unlocker) Unlock(dev *udisks.BlockDevice, methods []string) (*Result, e
|
|||||||
}
|
}
|
||||||
errs = append(errs, fmt.Errorf("%s: %w", method, err))
|
errs = append(errs, fmt.Errorf("%s: %w", method, err))
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("all unlock methods failed:\n%w", errors.Join(errs...))
|
return nil, fmt.Errorf("all unlock methods failed for %s:\n%w", dev.DevicePath, errors.Join(errs...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Unlocker) tryMethod(dev *udisks.BlockDevice, method string) (*Result, error) {
|
func (u *Unlocker) tryMethod(dev *udisks.BlockDevice, method string) (*Result, error) {
|
||||||
@@ -96,7 +96,7 @@ func (u *Unlocker) unlockKeyfile(dev *udisks.BlockDevice) (*udisks.BlockDevice,
|
|||||||
func (u *Unlocker) unlockCryptsetup(dev *udisks.BlockDevice) (*udisks.BlockDevice, error) {
|
func (u *Unlocker) unlockCryptsetup(dev *udisks.BlockDevice) (*udisks.BlockDevice, error) {
|
||||||
name := cryptsetup.MapperName(dev.DevicePath)
|
name := cryptsetup.MapperName(dev.DevicePath)
|
||||||
if err := cryptsetup.Open(dev.DevicePath, name); err != nil {
|
if err := cryptsetup.Open(dev.DevicePath, name); err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("%w (is the FIDO2/TPM2 key plugged in?)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for udisks2 to pick up the new dm device.
|
// Wait for udisks2 to pick up the new dm device.
|
||||||
|
|||||||
Reference in New Issue
Block a user