Monday, August 28

FINAL Progress Report

FINAL Progress Report #12 28-08-2017

We've reached the end of the line!

This blog post is the final log entry to my development journal for GSoC 2017 and my project with Samba.

You can find a detailed Work Product Submission link at Samba Wiki.

A GitHub Gist has been created to host all the libcli/dns patches that were sent to Samba Team for reviewing, you may browse its contents here.

All GitHub repositories linked from the "Navigate" section, have been fully updated for the final GSoC evaluation.

I will post again on the blogspot, when Google Summer of Code 2017 is officially over.

Thanks to everyone who dropped by, I hope you found something in my logs that was worth your time and helped you in any way!

Cheers,
Dimitris

Notice: dimgrav/samba (fork) repository will continue to receive fixes during the final evaluation process. dimgrav/Samba-GSOC2017 repository will be updated after the end of GSoC.

Saturday, August 19

Progress Report #11

Progress Report #11 19-08-2017

As mentioned in my previous log entry, most work occurs in samba-fork at this point. In the following days, Samba-GSOC2017 repo will also be fully updated, for the final stage and evaluation of GSoC.

Documentation

Project documentation has been organized according to the repository structure, in the form of markdown README files, as follows:

  • libcli/dns/ : Project description, library index
  • libcli/dns/cli-fn/ : DNS client features
  • libcli/dns/cmocka-tests/ : Client tests information and instructions

This is intended to help developers, who wish to contribute to Samba, get a good grasp of the existing DNS client code and ease their way in Samba development. There is no formal, end-user documentation needed as far as I can tell, due to the intrinsic functionality of the project. The text will be updated constantly, to reflect changes in code, yet this format is to be kept.

Waf

Scripts for configuring and building the code for Samba integration are needed. the libcli/dns/wscript_build has been updated to use the new source code.

In libcli/dns/cmocka-tests/, a wscript file has been set up to handle test suite configuration and building, though it's not yet fully functional, there is troubleshooting to be done, to properly handle internal Samba build objects. I expect to sort it out shortly.

Other

Other changes include code formatting to match Samba conventions and guidelines, minor changes in libraries (mostly to make the code more readable and straightforward) and similar refinements.

Things are coming together at this stage!

Cheers,
Dimitris

Saturday, August 12

Progress Report #10

Progress Report #10 12-08-2017

Since the last update, all active work has been moved, restructured (and changed a bit where needed) so that it could be integrated to the samba-fork I use on GitHub.

The Samba-GSOC2017 repo will still be updated to match the samba-fork repo, but not always simultaneously.

Major changes in structure include:

cli_dns.c
This will be acting as the DNS UDP/TCP call handler with socketwrapper support and TSIG generation, which is the project goal. This is intended to replace libcli/dns/dns.c of the mainline Samba Git in the final builds, through libcli/dns/wscript_build.

client_crypto.c - libtsig.h
GSS-TSIG client-side handling for signed packets with the structures and utilities lib.

dns_tcp.c - libtcp.h
TCP client-side DNS call handling and structures lib.

dns_udp.c - libdns.h
The pre-existing async DNS library for Samba with socketwrapper support, as written by Kai Blin.

The above corresponding .h files are used in cli_dns.c. The .c files that handle calls and sig generation are incorporated in cli_dns.c and are currently used only to facilitate writing tests. They are not intended to be part of the builds (will be probably removed when cli_dns.c and tests are finalized).

wrap_cli.c - libwrap.h
Multiple wrapping for cli_dns.c and associated library.

cmocka-tests
  • cli_crypto_test.c
  • dns_tcp_test.c
  • dns_udp_test.c
The test suites that are currently under development, in accordance to client_crypto, dns_tcp, dns_udp. Integration of tests to a larger suite that would test cli_dns.c should be relatively simple, if these suites are individually succesful.

To-do list:
  1. TESTS - TESTS - TESTS! Writing tests is probably the hardest part yet, but that's a good thing!
  2. Complete preprocessor include/define statements in all .c and .h files as required for functionality and performance.
Should I be done with the above swiftly, I might be able to go through the dns handler code for improvements.

I went through the Samba Wiki in regard to adding documentation, I've started making some drafts, but I'll have to get some guidelines from my mentors and the team.

Cheers,
Dimitris


Saturday, August 5

Progress Report #9

Progress Report #9 05-08-2017

gss-tsig and tcp-cli:
  • minor syntax and parameter fixes, some corrections and additions to struct descriptions.

I'm currently in the process of making wrapper functions for the dns call and tsig, but I'm not quite there yet. I've had no previous experience with wrappers.

cmocka-tests:
  • many additions, a bit stuck in testing functions that return void type. Additional parameter checks must probably be added and properly running tests should be ready this week.

This last part is quite challenging, but I enjoy the process!

Cheers,
Dimitris

Saturday, July 29

Progress Report #8

Progress Report #8 29-07-2017

  • changed tsig record generation in dns_empty_tsig() of client_crypto.c (thanks for the tip Andreas!)
  • minor corrections and additions in libcli_crypto.h

  • changes in socket handling and registered associated callback in dns_tcp.c
  • some changes in pdu_blob_send/recv() loop that should be revisited and reviewed, in dns_tcp.c

  • initial test suite templates
  • added tests for dns_empty_tsig(), dns_find_tkey() and dns_cli_generate_tsig() in cli_crypto_test.c (incomplete)

I consider gss-tsig to be at a valid state at the moment, therefore I will focus in coding a correct cmocka test suite to assure it's ok, then look for potential improvements.

In tcp-cli, I must work on creating the wrapper functions to hide the process. Then I can proceed with writing the tests. Any books or references in declaring/defining/creating wrappers will be extremely appreciated.

In cmocka-tests I'm walking baby steps at this point, but I invest a lot of time on it and I should figure out my tests soon enough.

In the following days, I'll fork Samba to merge with my temp repo, making it easy to incorporate what I've got so far to Samba, as well as for everyone interested to take a look and provide tips and feedback.

Cheers,
Dimitris

Saturday, July 22

Progress Report #7

Progress Report #7 22-07-2017

  • memset() in dns_empty_tsig() to initialize empty rdata fields in client_crypto.c
  • full tsig generation and server mac validation in client_crypto.c
  • minor changes in libcli_crypto.h

client_crypto.c
I used WERROR in accordance to error handling in the server code. Is there an advantage in using NTSTATUS instead?

Use of memset() must be reviewed, as it uses pointers and I am not fully aware if all related fields in rdata are declared as such.

dns_find_tkey() is used as coded for its respective use in /source4/dns_server/dns_server.c. It has been suggested that I use a new linked-list to manipulate the cache, though I've come across this tutorial, which suggests that linked-lists may not be ideal for locating specific nodes in the cache.

  • added tcp connection handling in dns_tcp.c
  • tstream_read_pdu_blob_send/recv() loop implemented in dns_tcp.c
  • added missing callback assignments in dns_tcp.c
  • changes in libdns_tcp to accomodate changes

dns_tcp.c
The send/recv loop should probably be reviewed, since tstream_read_pdu_blob does not appear to be defined in tsocket, so I'm not sure I've got it right.

Additionally, dns_tcp_req_done() is probably wrong, but I'd need some verification on this.

I'm starting writing tests for gss-tsig tomorrow, as I'm quite confident that the code appears to be a solid foundation for fine-tuning.

The TCP call handler needs a bit of work, so that I can add signature generation.

As always, feedback would be greatly appreciated.

Temporary GitHub repo here.

Cheers,
Dimitris

Friday, July 14

Progress Report #6

Progress Report #6 14-07-2017

  • signature generation in gss-tsig/client_crypto.c.
  • removes inbound dns_tsig_record and rebuilds with MAC signature and tsig rdata (as stated in RFC 2845 2.3).
  • corresponding header with structures in gss-tsig/libcli_crypto.h.

  • client-side dns tcp query send/receive.
  • corresponding header with structures in tcp-cli/libdns-tcp.

gss-tsig needs fine tuning in general, some headers must be removed as well. I followed Samba APIs and existing code.

tcp-cli is not yet sorted out, as there don't seem to be definitions for tstream_read_pdu_blob_send()/recv(), I could use some help on passing the tstream vector to the callback as well. Also I'm not sure if I need to create a new connection from the client to the server, as UDP queries use existing sockets.

Once the above are done, I can wrap up all the features and work on creating tests, so any feedback at all would be greatly appreciated (and really needed!) to speed things up.

I think I'm quite comfortable with tsocket and tevent at this point.

Cheers,
Dimitris

Sunday, July 9

Progress Report #5

Progress Report #5 09-07-2017

libcli/dns:
  • tcp client-server communication
  • initial client-side call management
  • initial client-side tcp call library

I went through tons of documentation regarding DNS, TCP, UDP, TSIG, also invested all available time on comprehending Samba APIs. There's such a solid base behind Samba, but the learning curve is probably too steep, steeper than I initially thought it would be.

Moving on!
Dimitris