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

Unquoted argument in dotnet-install.sh leads to build failure if the working directory path contains spaces #2435

Closed
Mr-Tao opened this issue Sep 5, 2021 · 4 comments · Fixed by dotnet/arcade#14583 · May be fixed by Mr-Tao/source-build#1
Labels
area-infra Source-build infrastructure and reporting

Comments

@Mr-Tao
Copy link

Mr-Tao commented Sep 5, 2021

The $dotnetRoot argument being passed in line 78 should be quoted.

InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || {

If the absolute path of the script contains spaces, it is being passed as multiple arguments. The values of the remaining arguments are populated with bogus values as a result.

Consequently, invocation of the InstallDotNet function in line 203 fails, despite the $root argument being properly quoted there, as it already contains only the leading part of the path up to the first space and remaining arguments contain all sorts of nonsense.

local archArg=''
if [[ -n "${3:-}" ]] && [ "$3" != 'unset' ]; then
archArg="--architecture $3"
fi
local runtimeArg=''
if [[ -n "${4:-}" ]] && [ "$4" != 'sdk' ]; then
runtimeArg="--runtime $4"
fi
local skipNonVersionedFilesArg=""
if [[ "$#" -ge "5" ]] && [[ "$5" != 'false' ]]; then
skipNonVersionedFilesArg="--skip-non-versioned-files"
fi
bash "$install_script" --version $version --install-dir "$root" $archArg $runtimeArg $skipNonVersionedFilesArg || {

A snippet of an example output of bash -x dotnet-install.sh -runtime dotnet -version 3.1.1 executed in ~/dotnet script test/a/b/c/d

+ skipNonVersionedFilesArg=--skip-non-versioned-files
+ bash /home/mustermann/dotnet/dotnet-install.sh --version script --install-dir /home/mustermann/dotnet --architecture test/a/b/.dotnet --runtime 3.1.1 --skip-non-versioned-files
dotnet_install: Error: Unsupported value for --runtime: '3.1.1'. Valid values are 'dotnet' and 'aspnetcore'.
+ local exit_code=1
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

Mr-Tao added a commit to Mr-Tao/source-build that referenced this issue Sep 5, 2021
Failure to quote the argument leads to incorrect assignment of positional arguments if the working path contains spaces.

fixes dotnet#2435
@omajid
Copy link
Member

omajid commented Sep 8, 2021

The dotnet-install script, as well as all files under eng/common are maintained in https://github.com/dotnet/arcade. IMO, this bug should be migrated to that repository.

@dseefeld
Copy link
Contributor

dseefeld commented Sep 9, 2021

Triage: This should be reviewed in source-build to ensure that the version of this file is up to date with Arcade.

@dseefeld dseefeld added area-infra Source-build infrastructure and reporting and removed untriaged labels Sep 9, 2021
@MichaelSimons
Copy link
Member

[Triage] source-build is using the Arcade version of the script. If this is still an issue please follow @omajid's guideance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infra Source-build infrastructure and reporting
Projects
None yet
4 participants