Skip to content

Commit

Permalink
Remove NativeAOT changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Saksham Bhalla committed Jan 24, 2025
1 parent e780de5 commit 0c62a44
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 25 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ endif()
add_custom_command(
TARGET credentials-fetcherd
PRE_LINK
COMMAND bash -c "CURR_DIR=$PWD && echo $CURR_DIR && cd ${CMAKE_CURRENT_SOURCE_DIR}/auth/kerberos/src/utf16_decode && ./build-using-native-aot.sh && cp bin/Release/net8.0/linux-x64/publish/utf16_decode $CURR_DIR/credentials_fetcher_utf16_private"
COMMAND bash -c "CURR_DIR=$PWD && echo $CURR_DIR && cd ${CMAKE_CURRENT_SOURCE_DIR}/auth/kerberos/src/utf16_decode && ./build-using-csc.sh Program.cs && cp Program.exe $CURR_DIR/credentials_fetcher_utf16_private.exe && cp Program.runtimeconfig.json $CURR_DIR/credentials_fetcher_utf16_private.runtimeconfig.json"
VERBATIM)
target_include_directories(credentials-fetcherd PUBLIC common)

Expand Down Expand Up @@ -222,7 +222,11 @@ install(FILES ${CMAKE_BINARY_DIR}/credentials-fetcherd
install(FILES ${CMAKE_SOURCE_DIR}/scripts/systemd/credentials-fetcher.service
DESTINATION "/usr/lib/systemd/system/")

install(FILES ${CMAKE_BINARY_DIR}/credentials_fetcher_utf16_private
install(FILES ${CMAKE_BINARY_DIR}/credentials_fetcher_utf16_private.exe
DESTINATION "/usr/sbin/"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)

install(FILES ${CMAKE_BINARY_DIR}/credentials_fetcher_utf16_private.runtimeconfig.json
DESTINATION "/usr/sbin/"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)

Expand Down
4 changes: 2 additions & 2 deletions auth/kerberos/src/krb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const std::vector<char> invalid_characters = { '&', '|', ';', ':', '$', '*', '
'>', '!', ' ', '\\', '.', ']', '[', '+',
'\'', '`', '~', '}', '{', '"', ')', '(' };

const std::string install_path_for_decode_exe = "/usr/sbin/credentials_fetcher_utf16_private";
const std::string install_path_for_decode_exe = "/usr/sbin/credentials_fetcher_utf16_private.exe";

const std::string install_path_for_aws_cli = "/usr/bin/aws";

Expand Down Expand Up @@ -213,7 +213,7 @@ std::pair<int, std::string> fetch_gmsa_password_and_create_krb_ticket(
std::string default_principal = "'" + gmsa_account_name + "$'" + "@" + domain_name;

/* Pipe password to the utf16 decoder and kinit */
std::string kinit_cmd = std::string( install_path_for_decode_exe ) +
std::string kinit_cmd = std::string("dotnet ") + std::string( install_path_for_decode_exe ) +
std::string( " | kinit " ) + std::string( " -c " ) + krb_cc_name +
" -V " + default_principal;
std::cerr << Util::getCurrentTime() << '\t' << "INFO:" << kinit_cmd << std::endl;
Expand Down
8 changes: 8 additions & 0 deletions auth/kerberos/src/utf16_decode/Program.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"runtimeOptions": {
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
}
}
}
63 changes: 63 additions & 0 deletions auth/kerberos/src/utf16_decode/build-using-csc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

# Thanks to https://github.com/dotnet/sdk/issues/8742#issuecomment-890559867

DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_CLI_TELEMETRY_OPTOUT

sdkver=$(LC_ALL=C dotnet --version)
fwkver=$(LC_ALL=C dotnet --list-runtimes | \
LC_ALL=C sed --posix -n '/^Microsoft.NETCore.App \([^ ]*\) .*$/{s//\1/p;q;}')

dotnethome=/usr/lib/dotnet
if [ -d /usr/lib64/dotnet ]; then
dotnethome=/usr/lib64/dotnet
fi
echo "dotnethome=$dotnethome"

dotnetlib=$dotnethome/shared/Microsoft.NETCore.App/$fwkver
if [ -d /usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/$fwkver/ref/net8.0/ ]; then
dotnetlib=/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/$fwkver/ref/net8.0/
elif [ -d /usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/$fwkver/ref/net6.0/ ]; then
dotnetlib=/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/$fwkver/ref/net6.0/
fi
echo "dotnetlib=$dotnetlib"

dotnet_cscdll=$dotnethome/sdk/$sdkver/Roslyn/bincore/csc.dll
if [ -f /usr/share/dotnet/sdk/$sdkver/Roslyn/bincore/csc.dll ]; then
dotnet_cscdll=/usr/share/dotnet/sdk/$sdkver/Roslyn/bincore/csc.dll
fi
echo "dotnet_cscdll=$dotnet_cscdll"

dotnet_csclib='-r:netstandard.dll -r:Microsoft.CSharp.dll -r:System.dll'
for x in "$dotnetlib"/System.*.dll; do
dotnet_csclib="$dotnet_csclib -r:${x##*/}"
done
echo "dotnet_csclib=$dotnet_csclib"
# add if needed
#dotnet_csclib="$dotnet_csclib -r:Microsoft.Win32.Primitives.dll"

exec dotnet "$dotnet_cscdll" "-lib:$dotnetlib" $dotnet_csclib "$@"

#!/bin/sh

DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_CLI_TELEMETRY_OPTOUT

sdkver=$(LC_ALL=C dotnet --version)
fwkver=$(LC_ALL=C dotnet --list-runtimes | \
LC_ALL=C sed --posix -n '/^Microsoft.NETCore.App \([^ ]*\) .*$/{s//\1/p;q;}')

exename=$1
case $exename in
(*.exe|*.EXE) ;;
(*)
echo >&2 "E: $exename is not a .exe file"
exit 1
;;
esac

jsonname=${exename%.*}.runtimeconfig.json
printf '%s"%s"%s\n' \
'{"runtimeOptions":{"framework":{"name":"Microsoft.NETCore.App","version":' \
"$fwkver" '}}}' >"$jsonname"
19 changes: 0 additions & 19 deletions auth/kerberos/src/utf16_decode/build-using-native-aot.sh

This file was deleted.

1 change: 0 additions & 1 deletion auth/kerberos/src/utf16_decode/utf16_decode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
Expand Down
4 changes: 3 additions & 1 deletion package/credentials-fetcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BuildRequires: aws-sdk-cpp-devel aws-sdk-cpp aws-sdk-cpp-static
%endif

BuildRequires: dotnet-sdk-8.0
Requires: dotnet-runtime-8.0

Requires: bind-utils openldap openldap-clients awscli jsoncpp
# No one likes you i686
Expand Down Expand Up @@ -64,7 +65,8 @@ ctest3
%license LICENSE
# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/
%doc CONTRIBUTING.md NOTICE README.md
%attr(0700, -, -) %{_sbindir}/credentials_fetcher_utf16_private
%attr(0700, -, -) %{_sbindir}/credentials_fetcher_utf16_private.exe
%attr(0700, -, -) %{_sbindir}/credentials_fetcher_utf16_private.runtimeconfig.json
%attr(0755, -, -) %{_sbindir}/krb5.conf

%changelog
Expand Down

0 comments on commit 0c62a44

Please sign in to comment.