Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load config issue #1144

Closed
JeyJeyGao opened this issue Jan 14, 2025 · 0 comments · Fixed by #1145
Closed

Load config issue #1144

JeyJeyGao opened this issue Jan 14, 2025 · 0 comments · Fixed by #1145
Assignees
Labels
bug Something isn't working

Comments

@JeyJeyGao
Copy link
Contributor

What is not working as expected?

➜ chmod 0000 ~/.config/notation 
➜ notation 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x850078]

goroutine 1 [running]:
github.com/notaryproject/notation/internal/cmd.init.func2(0xc0000e2900, 0xc0000d64c8)
        /home/jj/projects/junjie/notation/internal/cmd/flags.go:50 +0x38
github.com/notaryproject/notation/internal/cmd.(*SignerFlagOpts).ApplyFlagsToCommand(0xc0000d64b8, 0xc00021c008)
        /home/jj/projects/junjie/notation/internal/cmd/options.go:39 +0x5a
main.signCommand(0xc000076698?)
        /home/jj/projects/junjie/notation/cmd/notation/sign.go:144 +0x1d6
main.main()
        /home/jj/projects/junjie/notation/cmd/notation/main.go:56 +0x79

When the notation config directory lacks permission, it will trigger an error in LoadConfigOnce(). This issue was exposed after the blob signing command was added, which required calling LoadConfigOnce() twice (OCI signing + blob signing command). We need to fix it.

What did you expect to happen?

No error.

How can we reproduce it?

run chmod 0000 ~/.config/notation, then call notation command

Describe your environment

Linux x64

What is the version of your Notation CLI or Notation Library?

main branch

@JeyJeyGao JeyJeyGao added the bug Something isn't working label Jan 14, 2025
@JeyJeyGao JeyJeyGao self-assigned this Jan 14, 2025
JeyJeyGao added a commit that referenced this issue Jan 14, 2025
Fix:
- the `LoadConfigOnce` function forgets the error and return a nil
config and nil error next time. Updated to use `sync.OnceValues` to keep
the returned values.

Resolves #1144

---------

Signed-off-by: Junjie Gao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant