Skip to content
New issue

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

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

Already on GitHub? # to your account

Macaron causes panic on starting gogs/gitea in an unwritable/unreadable directory #175

Open
zeripath opened this issue Apr 9, 2019 · 3 comments

Comments

@zeripath
Copy link
Contributor

zeripath commented Apr 9, 2019

Hi!

The init method for macaron causes a panic if the current working directory cannot be read.

Root, err = os.Getwd()

Because this runs on init even if macaron is not going to be started, if it is linked to a binary it will prevent the binary from starting if it is started in a non-readable working directory.

A workaround is possible but it's not ideal. Is there any way to avoid panicking here?

@unknwon
Copy link
Contributor

unknwon commented Apr 12, 2019

Thanks for the feedback!

If working directory is not readable, what's the point of starting the binary?

@zeripath
Copy link
Contributor Author

If any part of a binary imports macaron then macaron's init will run. So if you have subcommands in your binary, even if that subcommand doesn't need macaron the macaron init will run and will cause a panic.

It may be that we should be separating out our subcommands from the main binary, but in any case panicking in an init is a fairly harsh thing to do. You can't reasonably manage such a situation or provide appropriate logging to the user.

(I could imagine a situation whereby you might want to run in a non-readable working directory but have macaron have its own configuration. That way if there is a security exploit and people are able run a command from your application they will find it very difficult to run anything because their working directory will be unreadable.)

@unknwon
Copy link
Contributor

unknwon commented Apr 13, 2019

OK, it makes sense. It indeed kind of annoying.

# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

2 participants