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

Jack.phillips/update embedded permissions #32119

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pkg/collector/python/init_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ package python

import (
"os"
"path/filepath"

pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/util/winutil"
)

// Any platform-specific initialization belongs here.
Expand All @@ -21,5 +23,25 @@ func initializePlatform() error {
os.Unsetenv("PYTHONPATH")
}

// get program data directory and set PYTHONPYCACHEPREFIX
pd, err := winutil.GetProgramDataDir()
if err != nil {
return err
}
pycache := filepath.Join(pd, "python-cache")

// check if path exists
if _, err := os.Stat(pycache); os.IsNotExist(err) {
// create the directory
if err := os.MkdirAll(pycache, 0755); err != nil {
return err
}
} else if err != nil {
return err
}
// TODO check if we have access to the directory ?

os.Setenv("PYTHONPYCACHEPREFIX", pycache)

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,6 @@ private List<string> PathsWithAgentAccess()
// agent needs to be able to write to run/
// agent needs to be able to create auth_token
_session.Property("APPLICATIONDATADIRECTORY"),
// allow agent to write __pycache__
Path.Combine(_session.Property("PROJECTLOCATION"), "embedded2"),
Path.Combine(_session.Property("PROJECTLOCATION"), "embedded3"),
};
}

Expand Down
Loading