.net MIP SDK on Ubuntu 2204 fails to load libraries

286 Views Asked by At

Current setup:

  • Running on mcr.microsoft.com/dotnet/sdk:7.0-jammy container (Ubuntu 2204)
  • .net 7.0
  • Microsoft.InformationProtection.File.Ubuntu2204 Version "1.14.108"
  • Installed all dependencies mentioned in sample application
    sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev

I am attempting to run MIP sdk to read confidential files in my company in backend code. I tested it with Windows setup and it works, however, running MIP sdk code on Unix systems which we use in Azure doesn't work.

  1. Library is compiled for wrong operating system, because it's referencing libdl.so. As this post clearly states, libdl.so is no longer available in Ubuntu 2204 and application should reference libdl.so.2. Application fails with the following error:
System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
      /workspace/RestAPI/bin/Debug/net7.0/runtimes/linux/native/libdl.so.so: cannot open shared object file: No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/libdl.so.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/libdl.so.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/runtimes/linux/native/liblibdl.so.so: cannot open shared object file: No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/liblibdl.so.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/liblibdl.so.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/runtimes/linux/native/libdl.so: cannot open shared object file: No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/libdl.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/libdl.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/runtimes/linux/native/liblibdl.so: cannot open shared object file: No such file or directory
      /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/liblibdl.so: cannot open shared object file: No such file or directory
      /workspace/RestAPI/bin/Debug/net7.0/liblibdl.so: cannot open shared object file: No such file or directory

By adding the link sudo ln -s /usr/lib/aarch64-linux-gnu/libdl.so.2 /usr/lib/aarch64-linux-gnu/libdl.so, I was able to work around this issue temporarily, but it's not ideal by any stretch.

  1. After adding a link to previously missing library, I am greeted with a new error:
System.ComponentModel.Win32Exception (0x80004005): LoadLibrary failed for: [/workspace/RestAPI/bin/Debug/net7.0/libmip_dotnet.so]
         at Microsoft.InformationProtection.Utils.SafeNativeMethods.LoadLibrary(String dllToLoad)
         at Microsoft.InformationProtection.Utils.Loader.LoadDlls(String dllFolder, String dllName, String[] dllDependencies)
         at Microsoft.InformationProtection.MIP.Initialize(MipComponent mipComponent, String path)
         at Microsoft.InformationProtection.MIP.CreateMipContext(MipConfiguration mipConfiguration)

Here I am completely stuck. Even attempted at running a c snippet from this suggestion in github, but I got this error. I tried all kinds of paths, copying the files close and nothing worked here.

err = ./libmip_dotnet.so: cannot open shared object file: No such file or directory

All resources I found online failed me. Maybe someone has some bright ideas how to fix this or how to get in touch with the team to fix this library?

1

There are 1 best solutions below

3
On

I thought we fixed this issue, but it may not have been released. I’ll follow up with the engineering folks on Monday.

Edit: The libdl.so.2 issue has been fixed and will be released in January.

I can't repro the other issue you're seeing with a sample application unless I rename or delete libmip_dotnet.so. Is libmip_dotnet.so in the same directory as the executable?

Here's a link to my dockerfile with a modified version of the File SDK .NET sample.

https://gist.github.com/tommoser/ee3adaed016dc7086557c35b4e2548d9

You can get the modified sample from this branch: https://github.com/Azure-Samples/MipSDK-File-Dotnet/tree/major-update

I'll update docs later but thought this might be helpful to test. Update the appsettings.json with your clientId, tenantId, and app secret (just for testing). Then you can run ./mipsdk -l in the container or as part of the build to see what happens.

If the .so file is not in the app directory, you can try using the optional path param on MIP.Initialize.

MIP.Initialize(MipComponent.File, "/app/so_files");