aboutcode-org / aboutcode-org/scancode-toolkit

Crash on generation of cache license dir in R/O installation when run with user privileges

Đang mở
#2,780 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
2.6k
Fork
791
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
5

Mô tả

If ScanCode is installed as a superuser/root in *nix environment and no previous cache is generated, first run as non-privileged user will crash

Easily reproducible:
- Compile and install scancode as root in any directory
- run scancode --version as user ( non privoleged )

Version tested: 30.1.0
Method if instlalation:
```sh
SCANCODE_VERSION="30.1.0"
SCANCODE_URL "https://github.com/nexB/scancode-toolkit/archive/refs/tags/"
mkdir -p /opt/scancode
curl -ksSL ${SCANCODE_URL}/v${SCANCODE_VERSION}.tar.gz | tar -C /opt/scancode -xz --strip-components=1 \
cd /opt/scancode || exit 1
PYTHON_EXE=python3 ./configure
# Clean up unneeded installed binaries
rm -rf /opt/scancode/thirdparty
```

Log output:
```
ort@b172a93c5fa5:~$ scancode --help
Traceback (most recent call last):
File "/usr/bin/scancode", line 33, in
sys.exit(load_entry_point('scancode-toolkit', 'console_scripts', 'scancode')())
File "/usr/bin/scancode", line 25, in importlib_load_entry_point
return next(matches).load()
File "/opt/python/versions/3.9.9/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/opt/python/versions/3.9.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 972, in _find_and_load_unlocked
File "", line 228, in _call_with_frames_removed
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/opt/scancode/src/scancode/__init__.py", line 16, in
from commoncode import fileutils
File "/opt/scancode/lib/python3.9/site-packages/commoncode/fileutils.py", line 21, in
from scancode_config import scancode_temp_dir as _base_temp_dir
File "/opt/scancode/src/scancode_config.py", line 151, in
_create_dir(licensedcode_cache_dir)
File "/opt/scancode/src/scancode_config.py", line 52, in _create_dir
os.makedirs(location)
File "/opt/python/versions/3.9.9/lib/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/scancode/src/licensedcode/data/cache'
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.