Skip to content
Open
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
2 changes: 2 additions & 0 deletions container.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG ARCH
ARG EXE_PATH=build/${ARCH}/gprofiler
# lets gProfiler know it is running in a container
ENV GPROFILER_IN_CONTAINER=1
# Install sudo and bash for PerfSpect to run with full functionality
RUN apk add --no-cache sudo bash
COPY ${EXE_PATH} /gprofiler
RUN chmod +x /gprofiler

Expand Down
15 changes: 13 additions & 2 deletions gprofiler/hw_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,21 @@ def start(self) -> None:
str(self._perfspect_duration),
"--output",
PERFSPECT_DATA_DIRECTORY,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfspect ran perfectly with --noroot. What new capabilities are enabled when running as root. Giving root access to run perfspect incurs security risk

"--noroot",
]

self._ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE)
# Clean environment to avoid PyInstaller LD_LIBRARY_PATH pollution
# that causes sudo to fail with library loading errors
env = os.environ.copy()
if 'LD_LIBRARY_PATH' in env:
ld_paths = env['LD_LIBRARY_PATH'].split(':')
# Filter out paths that contain _MEI (PyInstaller temp directories)
cleaned_paths = [p for p in ld_paths if '_MEI' not in p]
if cleaned_paths:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are we sure that this change in env['LD_LIBRARY_PATH'] wont cause the regression

env['LD_LIBRARY_PATH'] = ':'.join(cleaned_paths)
else:
del env['LD_LIBRARY_PATH']

self._ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE, env=env) # nosec B603

def stop(self) -> None:
if self._ps_process:
Expand Down
8 changes: 7 additions & 1 deletion pyinstaller.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ a = Analysis(scripts=['pyi_build.py'],
pathex=['/app'],
binaries=[],
datas=[('gprofiler/resources', 'gprofiler/resources')],
hiddenimports=[],
hiddenimports=[
'backports',
'backports.tarfile',
'jaraco.text',
'jaraco.context',
'jaraco.functools',
],
hookspath=[],
runtime_hooks=[],
excludes=['readline'],
Expand Down
Loading