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

qrcp creates a config directory with permission 0000 on initial run #268

Closed
1 of 4 tasks
tagattie opened this issue Apr 9, 2023 · 2 comments
Closed
1 of 4 tasks

Comments

@tagattie
Copy link

tagattie commented Apr 9, 2023

I'm opening this issue because:

  • I have found a bug

  • I want to request a feature

  • I have a question

  • Other

  • My Go version is: go version go1.20.2 freebsd/amd64

  • My GOPATH is unset

Steps to reproduce:

  • rm -r ${HOME}/.config/qrcp
  • qrcp <some file>

The above steps produce the following error:

panic: open /home/<username>/.config/qrcp/config.yml: permission denied

goroutine 1 [running]:
github.com/claudiodangelis/qrcp/config.New({{0x0, 0x0, 0x0, 0x0, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...})
	github.com/claudiodangelis/qrcp/config/config.go:46 +0x625
github.com/claudiodangelis/qrcp/cmd.sendCmdFunc(0xd1eb40?, {0xc00029c690?, 0x1?, 0x1?})
	github.com/claudiodangelis/qrcp/cmd/send.go:22 +0x118
github.com/spf13/cobra.(*Command).execute(0xd1eb40, {0xc000024050, 0x1, 0x1})
	github.com/spf13/cobra/command.go:842 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xd1eb40)
	github.com/spf13/cobra/command.go:950 +0x39d
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra/command.go:887
github.com/claudiodangelis/qrcp/cmd.Execute()
	github.com/claudiodangelis/qrcp/cmd/qrcp.go:48 +0x25
main.main()
	github.com/claudiodangelis/qrcp/main.go:10 +0x19

This is because qrcp creates the config directory with permission 0000. The following change should solve the problem:

diff --git a/config/config.go b/config/config.go
index 0d7cb52..a4792f7 100644
--- a/config/config.go
+++ b/config/config.go
@@ -38,7 +38,7 @@ func New(app application.App) Config {
 
        _, err = os.Stat(v.ConfigFileUsed())
        if os.IsNotExist(err) {
-               if err := os.MkdirAll(filepath.Dir(v.ConfigFileUsed()), os.ModeDir); err != nil {
+               if err := os.MkdirAll(filepath.Dir(v.ConfigFileUsed()), os.ModeDir | os.ModePerm); err != nil {
                        panic(err)
                }
                file, err := os.Create(v.ConfigFileUsed())
@claudiodangelis
Copy link
Owner

Interesting, I will try to reproduce the issue and will let you know.

@claudiodangelis
Copy link
Owner

Thanks a lot for reporting! This has been fixed in #269 and released as of version 0.10.1.
Claudio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants