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

DNS: Add POSIX DNS implementation #334

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

0x5ECF4ULT
Copy link

@0x5ECF4ULT 0x5ECF4ULT commented Feb 22, 2023

What's the problem?

Kerberos.NET doesn't include "autodiscovery" of the KDC on a Linux host. Therefore one must "rely completely on a krb5 configuration file to provide all the necessary records, but that's complicated and messy." (qouted from here)

What's the solution?

I've implemented a native approach using resolv.h and friends in libc. I basically ported code written by Gerald Carter. Sadly, I don't have the original link to the gist anymore.

What issue is this related to, if any?

#185

@dnfadmin
Copy link

dnfadmin commented Feb 22, 2023

CLA assistant check
All CLA requirements met.

@0x5ECF4ULT
Copy link
Author

0x5ECF4ULT commented Feb 22, 2023

I have bumped the language version manually. Not doing this caused all kinds of havoc in my build environment. I hope this is covered by the Contribution Guidelines.

var buffer = new char[NS_PACKETSZ];

short respLen = -1;
if ((respLen = ResQuery(query, NsClass.NsCIn, type, buffer, NS_PACKETSZ)) < 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: brackets

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong about them?

@0x5ECF4ULT
Copy link
Author

@dotnet-policy-service agree

@0x5ECF4ULT
Copy link
Author

I still have to refactor the tests to run on Linux (dependencies on WinForms). Is this something that is better suited for another PR? I didn't plan to make that big of a change to the codebase.

@SteveSyfuhs
Copy link
Collaborator

I still have to refactor the tests to run on Linux (dependencies on WinForms). Is this something that is better suited for another PR? I didn't plan to make that big of a change to the codebase.

There will be considerable other problems with getting the tests running on Linux, like Windows crypto dependencies for DH, etc.

That said, I don't have a strong preference either way. If it's just a matter of refactoring the unit test library then you can bundle those changes here. If it requires substantial changes to the main Kerberos library then that would probably be better suited for a separate PR.

@0x5ECF4ULT
Copy link
Author

There will be considerable other problems with getting the tests running on Linux, like Windows crypto dependencies for DH, etc.

This could be a matter excluding some tests per platform. I believe pragmas can be used for this. That doesn't affect the main lib.

I haven't looked into Bruce but at least the references related to KerbDumpCore will need to go somehow. Porting this as a whole will definitely take a considerable amount of time. Avalonia is definitely helpful here.

@SteveSyfuhs
Copy link
Collaborator

That seems reasonable then. There's no particular reason for everything to exist in the Bruce project, and by extension all linked to the single test project. It could probably be split into Bruce-host, Bruce-xplat, Bruce-Windows, and then a separate test project and a ignore-on-linux configuration (or whatever is the common method of separating things in other projects).

@SteveSyfuhs
Copy link
Collaborator

BTW, if you're looking at the builds and noticing it's failing, that's normal. If you look at the details for the latest build (https://github.com/dotnet/Kerberos.NET/pull/334/checks?check_run_id=11557826802) you'll see errors about pushing the package. That means the both the build and test run succeeded.

Microsoft.VisualStudio.Services.Common.VssServiceException: VS800075: The project with id 'vstfs:///Classification/TeamProject/bcf490cf-a965-4d26-999c-8de04067ee1e' does not exist, or you do not have permission to access it.

@0x5ECF4ULT
Copy link
Author

I'm working on getting the tests to work on Linux and there is definitely much to do. I may have found a serious bug but haven't verified it yet.

@0x5ECF4ULT
Copy link
Author

I'm still working on it but I'm at a roadblock. The calls to the native code are making things complicated. First of all: it isn't all libc but rather libresolv. Second: idk if it's the struct but about 90% of the time i get an utterly useless error saying "No mapping for the Unicode character exists in the target multi-byte code page.". The other 10% are access violations. I had a look at the memory with your HexDump extension method and rn I'm trying to figure out wth I'm looking at.

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

Successfully merging this pull request may close these issues.

3 participants