Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/cmd/register/device_registration_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package register
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -92,7 +94,7 @@ func (s *FileRegistrationStore) Delete() error {
if err == nil {
return nil
}
if !os.IsPermission(err) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the implementation here, this requires that err is exactly the "ErrPermission" error in the os package (which it is not, as the above "DeleteFile" call performs the typical "WrapAndTrace".

From the doc on this function:

// This function predates [errors.Is]. It only supports errors returned by
// the os package. New code should use errors.Is(err, fs.ErrPermission).

Validated that deregister functions again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh

if !errors.Is(err, fs.ErrPermission) {
return breverrors.WrapAndTrace(err)
}
// Fall back to sudo for non-root users.
Expand Down
Loading