Skip to content

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

Open

Description

@zeripath

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?

Activity

  1. unknwon commented on Apr 12, 2019

    @unknwon
    Contributor

    Thanks for the feedback!

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

  2. zeripath commented on Apr 12, 2019

    @zeripath
    ContributorAuthor

    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.)

  3. unknwon commented on Apr 13, 2019

    @unknwon
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions