sec / dotnet-core-freebsd-source-build

Collection of script to build .NET Core under FreeBSD OS (with binary releases)
MIT License
53 stars 4 forks source link

Unclear from documentation whether init.sh and other scripts should be run as root #10

Closed ajensenwaud closed 9 months ago

ajensenwaud commented 2 years ago

Hello. Thanks for making this important patch set. It's unclear from the documentation whether init.sh, build_runtime.sh etc should be run as root or not. It clearly states in README.md that install_tools.sh should be run as root. If I proceed to run init.sh as a normal user, I get the following error from kldload, which requires root privileges to run:

aj@dotnet:~/dotnet-core-freebsd-source-build % sudo ./install_tools.sh
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The most recent versions of packages are already installed
aj@dotnet:~/dotnet-core-freebsd-source-build % ./init.sh
kldload: can't load linux: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module linux
kldload: can't load linux64: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module linux64
sysctl: unknown oid 'compat.linux.emul_path'
kldload: can't load pty: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module pty
kldload: can't load fdescfs: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module fdescfs
kldload: can't load linprocfs: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module linprocfs
kldload: can't load linsysfs: Operation not permitted
/etc/rc.d/linux: WARNING: Unable to load kernel module linsysfs
sysctl: kern.elf64.fallback_brand=3: Operation not permitted
sysctl: kern.elf32.fallback_brand=3: Operation not permitted
mount: linprocfs: Operation not permitted
mount: linsysfs: Operation not permitted
mount: fdescfs: Operation not permitted
mkdir: /dev/shm: Operation not supported
mount: /dev/shm: No such file or directory
Downloading SDK for FreeBSD

Running init.sh as root unsurprisingly solves the problem, but it means code is checked out as root, which is suboptimal for compiling the code itself (root shouldn't be required for this step). See below:

aj@dotnet:~/dotnet-core-freebsd-source-build % ./build_runtime.sh
__DistroRid: freebsd-x64
mkdir: /usr/home/aj/dotnet-core-freebsd-source-build/runtime/artifacts: Permission denied
aj@dotnet:~/dotnet-core-freebsd-source-build % ./build_installer.sh
mkdir: installer/artifacts: Permission denied
cp: directory installer/artifacts/obj/redist/Release/downloads does not exist
cp: directory installer/artifacts/obj/redist/Release/downloads does not exist
cp: directory installer/artifacts/obj/redist/Release/downloads does not exist
mkdir: /usr/home/aj/dotnet-core-freebsd-source-build/installer/artifacts: Permission denied
sec commented 2 years ago

Hi, Yes this needs some more refactor, but in general those are put in there so I don't forget them on clean system :) The commands like mount and kldload and service linux start are one-time-needed and can be run by hand as root user - I just keep them around when doing new build/releases