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

"No such file or directory" issue when trying to run C# program using Dotnet #146

Closed
subhtak opened this issue Feb 21, 2024 · 7 comments
Closed

Comments

@subhtak
Copy link

subhtak commented Feb 21, 2024

isolate --cg -p --chdir=CSHARP11_BASIC/src --open-files=1024 -E HOME=tmp --box-id=555 --run -- /usr/local/dotnet-sdk/dotnet run

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.IOException: No such file or directory

Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception: System.IO.IOException: No such file or directory
   at Interop.Sys.TryGetUserNameFromPasswd(UInt32 uid, Byte* buf, Int32 bufLen, String& username)
   at Interop.Sys.GetUserNameFromPasswd(UInt32 uid)
   at System.Environment.get_UserName()

Thank you in advance

@gollux
Copy link
Member

gollux commented Feb 21, 2024

dotnet is very peculiar in many senses and it is hard to get it running within a sandbox. I tried that a few months ago and the results is issue 1243 in CMS repository, which documents all the roadblocks I encountered.

In this case, you need to provide /etc/passwd with entries for the UIDs used by the sandbox.

@subhtak
Copy link
Author

subhtak commented Feb 22, 2024

@gollux thanks for the reply. Attached is the /etc/passwd. I don't have much idea how to add user account specific to this usecase. Pls suggest.
passwd.txt

@gollux
Copy link
Member

gollux commented Feb 28, 2024

Look at Isolate's configuration file and find the UID range used for sandboxes. Add corresponding entries to passwd.

@subhtak
Copy link
Author

subhtak commented Mar 4, 2024

Hey @gollux

I am not very clear with how to make the entry there in etc/passwd as the created user info is not known. Following fields are required separated by colon (:)

  1. Encrypted Password
  2. UID number
  3. Default GID number
  4. user information: full name, office, phone, …
  5. Home directory
  6. Login shell

I am not able to find out the process id nor the uid/gid when the isolate command is run.
This is the range I have in config:

Block of UIDs and GIDs reserved for sandboxes
first_uid = 60000
first_gid = 60000
num_boxes = 50000

Please help @gollux

@gollux
Copy link
Member

gollux commented Mar 4, 2024

You do not need a process ID, just the user ID. You can determine it by running /usr/bin/id -a in the sandbox, or compute it as a sum of first_uid from the configuration with the ID of the sandbox you are starting (if you do not specify an explicit ID, it defaults to 0).

@subhtak
Copy link
Author

subhtak commented Mar 5, 2024

Thanks @gollux. After making the required entry in the /etc/passwd, the issue is resolved and dotnet commands are working inside isolate. But everytime making an entry in the /etc/passwd for every code execution is not great idea. I hope we can find a more optimal solution for this.

@gollux
Copy link
Member

gollux commented Mar 5, 2024

Just add the required users to /etc/passwd in the host system.

@gollux gollux closed this as completed Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants