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

Location for downloading data is inflexible #12

Closed
liveforeverx opened this issue Oct 29, 2015 · 5 comments
Closed

Location for downloading data is inflexible #12

liveforeverx opened this issue Oct 29, 2015 · 5 comments

Comments

@liveforeverx
Copy link

Location, where data saved is hardcoded to priv.

Problem is, that: https://github.com/lau/tzdata/blob/master/lib/tzdata/data_loader.ex#L13 based on CWD it creates a priv. For example on releases, it seems, like: release_name/priv/... not in tzdata/priv, but somewhere starting from cwd. That means, on releases, where CWD is changed, it is not really known, where the priv folder should be created.

Possible solutions: explicitly define the download directory in configuration (download_dir: "/tmp/..." ), or use :code.priv_dir for it. I'm against to use priv dir so explicitly for mutable data. Problem is, that it makes impossible to install release on immutable location(at least for a application themself), and configure the whole application to have it mutable data on another storage.

@liveforeverx liveforeverx changed the title Location for downloading data is wrong Location for downloading data is inflexible Oct 29, 2015
@lau
Copy link
Owner

lau commented Oct 29, 2015

Yeah I actually have wanted a setting for that for a while. Basically something to use instead of priv.

Problem is, that it makes impossible to install release on immutable location(at least for a location themself), and configure the whole application to have it mutable data on another storage.

I'm not sure I understand what you mean by this. If data does not already exist, Tzdata will attempt to download it. Alternatively developers/admins can copy the existing .ets file to the defined dir before starting the app. Tzdata looks for the newest ets file and uses that.

@liveforeverx
Copy link
Author

Sorry, if it was not understandable, I'll try to explain it in more details, the whole problem and confusion.

I'll try to show it on example( https://github.com/liveforeverx/test_app ). Most elixir software, running in production is using exrm under hood (self phoenix guideline have an section, how to run phoenix with exrm).

We can try to create the test_app and add exrm and tzdata to dependencies of our app.

Now, starting shell iex -S mix, we get it manually (Tzdata.DataLoader.download_new()) and what we see is:

test_app % ls
README.md  _build/    config/    deps/      lib/       mix.exs    mix.lock   priv/      test/

We get new priv directory in our app, now, I show the most confusion, that other can get:

test_app % mix release
rel/test_app/bin/test_app console
iex(test_app@127.0.0.1)1> Tzdata.DataLoader.download_new()

And after, we download it, that is the structure

ls
bin/            erts-7.0/       lib/            log/            priv/           releases/       running-config/

test_app/rel/test_app % find . -name "priv"
./lib/asn1-4.0/priv
./lib/crypto-3.6/priv
./lib/hackney-1.3.2/priv
./lib/test_app-0.0.1/priv
./lib/tzdata-0.5.4/priv
./priv

Every production release structure will be damaged with an priv directory on place, which is not means to be used for. That is a problem, with priv on CWD, which will simply creating on very different locations the priv directory.

Next problem is questionable, but good to think about(as I do not have answer for it). If we try for security reasons to split executable data location(where apps, beams are located) with mutable data locations(where for example database files located), which is requirement on most enterprise servers, which I know (May be I know, not so much).

If release directory shouldn't be changable, for example, if we make the whole rel/test_app directory immutable(read only), than the application can't download the tmp data and overwrite the tzdata.

That means 2 consequences:

  1. priv shouldn't contain mutable data
  2. mutable data location should be configure, too (that means, that to accept requirement of splitting executable and data locations, we need to save ets and tmp on configured locations, instead of locations, where executable is placed ).

Can follow me?

@lau
Copy link
Owner

lau commented Oct 31, 2015

Let's say there is a custom location for mutable tzdata files. For instance config :tzdata, :data_dir, "/var/tzdata" In this example /var/tzdata is writable by the release. Tzdata will then use that instead of the default priv dir. It can write files there. That's what I meant by having an alternative dir instead of priv. That should solve the problems, right?

@liveforeverx
Copy link
Author

Yes

@lau lau closed this as completed Nov 2, 2015
@lau
Copy link
Owner

lau commented Nov 19, 2015

@liveforeverx I have released a new version (0.5.5) where the data directory can be specified in a config file.

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