[forwardport] fix(ooniprobe): ensure tunnelDir is correctly set (#694)

This commit forward ports 59c63ee0b2249c803c40f1eb19c0f6c062838bf1,
whose original log message follows:

- - -

While doing QA in https://github.com/ooni/probe/issues/1845, I
noticed we're not using the correct directory.

Results are written in the current directory inside of the OONI_HOME,
which is quite not what we want to happen.

This diff WILL require forward porting to master.
This commit is contained in:
Simone Basso 2022-02-11 12:57:54 +01:00 committed by GitHub
parent 00b5c73c3a
commit fbae9ddece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,6 +189,7 @@ func (p *Probe) Init(softwareName, softwareVersion string) error {
return errors.Wrap(err, "creating TempDir") return errors.Wrap(err, "creating TempDir")
} }
p.tempDir = tempDir p.tempDir = tempDir
p.tunnelDir = utils.TunnelDir(p.home)
p.softwareName = softwareName p.softwareName = softwareName
p.softwareVersion = softwareVersion p.softwareVersion = softwareVersion
@ -205,7 +206,7 @@ func (p *Probe) NewSession(ctx context.Context) (*engine.Session, error) {
if err != nil { if err != nil {
return nil, errors.Wrap(err, "creating engine's kvstore") return nil, errors.Wrap(err, "creating engine's kvstore")
} }
if err := os.MkdirAll(utils.TunnelDir(p.home), 0700); err != nil { if err := os.MkdirAll(p.tunnelDir, 0700); err != nil {
return nil, errors.Wrap(err, "creating tunnel dir") return nil, errors.Wrap(err, "creating tunnel dir")
} }
return engine.NewSession(ctx, engine.SessionConfig{ return engine.NewSession(ctx, engine.SessionConfig{