Archive for February, 2007

smtpd is done!!!

Monday, February 19th, 2007

after a lot of hours on smtp it is finally done. what a job. the patch came out to be 5160 lines long. the original smtpd.c file is 8944 lines long. i did a couple of simple grep and there were 2427 removed lines and 784 added lines. not too shabby. some of the patch is just whitespace or code formatting things, but a ton of it is the connio stuff. i’ve also rolled in a couple of patches that i submitted to hula-dev on the smtpd and various rfc compliance issues (one of which i critically needed here at my house for spam — the received line stuff). i ran through a bunch of test cases on that one and they all seemed to work great. let me list them out:

  • helo mail to a remote addr — denied relay
  • helo mail to local addr — worked
  • ehlo/auth mail to remote addr –worked
  • ehlo/auth mail to remote addr — worked
  • ehlo/tls mail to local addr– worked
  • ehlo/ssl/auth mail to remote addr — worked
  • ehlo/tls/auth mail to remote addr –worked

overall i’m pretty happy with how it turned out and really how long it took. i spent long hours (mostly late friday night) for 3 weekends (i think — the first one is a blur) and got it all going. mostly the coding went from about 10pm to 4am those nights with some work saturday and late night sunday as i could. this has turned out to be a very long and tedious process.

one major snag i hit just last night was remote delivery via tls. i had originally thought that it worked, but when i did a packet sniff to verify i found that the ConnNegotiate was just returning as if it had worked and the client went on its merry way. after a bit of digging and playing, i found that i had to make minor modifications to connio as the command sequence is different for gnutls servers and clients. i really should have caught that when i did the connio gnutls patches, but at the time i didn’t have any tls client apps to play with. this fix had the added benefit of fixing the mailproxy agent so that it should work (though i’ve not tested it). as i write this it seems to me now that ConnNegotiate() and ConnEncrypt are basically the same function now. perhaps we should merge them (i should look at this someday).

i’m not sure what i’ll hack on next, perhaps the nmap bug that i just submitted where there is still legacy ip code in nmap.c. i didn’t look into it wheni found it, but my gut feel is that that code is for nmap-to-nmap transfers of mail. we don’t really support this atm though, so i’m not sure if i’ll go there.

maybe i’ll just sit back, relax, and wait for the smtp bug reports to come in :)   or maybe i’ll try to figure out why wordpress is going so amazingly slow on my box.  i’m running plain wordpress 2.1 with no new plugins or anything. i’ve tried the cache stuff and it didn’t seem to help.  it can’t be mysql as the rest of my site works great.  i dunno what it is.  if any of you wordpress guru’s out there know what i’ve got misconfigured, let me know asap :)

the most i’ve written since my undergrad research paper

Monday, February 12th, 2007

time for the weekly blog :) i’ve spent another weekend heavilly devoted to smptd. i’ve chatted with a person who tried to do some hacking on the smtp server and gave up, and he told me of another who gave up and decided it’d be easier to rewrite it than to go where i’m going. do i agree? partly. for those of you who have not read the irc logs or were not around, at one point i commented on “looking at the same block of code for about an hour and a half, and finally come to the conclusion it is a complex piece of code”. it might be conceptually easier to think a rewrite would be better, but it would take a lot longer to try to get all the current functionality into the daemon. so what is the current status ?

i’ve gotten smtpd to accept mail for local delivery now for non-ssl connections. the ssl stuff won’t work quite yet as there is a small block of code i haven’t gotten to yet where the STARTTLS command is implemented. the code that goes in that block is already scattered through the system though so it should be fairly easy to get going.

remote delivery is close to being done, but there are two functions that i have yet to rework. one gets the answer from the remote system GetClientAnswer() and the other is one that i haven’t quite figure out yet SendServerEscaped(). i believe this one is supposed to escape data that could mess up the conversation (things like a period) in a certain spot. why this could happen i haven’t found yet, but the function is called in multiple places in code.

i’ve also been going to town on the variables. a bunch out of the ConnectionStruct struct are no longer needed so i’ve removed them. there were also a bunch of globals that i got rid of too. one in particular baffles me MaxFloodCount. it gets set in several places, but never used. i’m not sure what its intention was.

another area that needs a little bit of attention is the connection to the queue agent for queue processing. smtp is different from imap, pop, or dragonfly in that it registers with the queue on a specific queue number. when a message hits that queue number (6), the queue agent will call smtp to let it do processing. thus we have a thread system that listens for incoming connections from the queue server and processes those requests. the code is written but not tested yet (this is obvously tied closely with the outgoing mail tests).

there is also still a large number of things that i’d like to fix. there are blocks of code that are commented out via #if 0 statements, and abuses of variables clearly named for one purpose for something completely different. eventually (not for this release) it would be good to modularize the code more like imap making the code much easier to read. right now all the command processing is one big switch() statement. this could make for fast code (depending on your opinion of compiler optimizations — i’d like to see a study on speed comparisons), but it makes for code that is much harder to maintain and debug. another thing that kinda bugs is to have a variable on one line getting set with the result from another line. this makes gdb interesting as all you see is VariableName = (since my gdb doesn’t like to print multiline). other things like the non-standard (for bongo at least) matching of {} and other such things that don’t match.

on other fronts, alex and i have been doing lots of talking on lots of things. one thing he mentioned was address rewrites vs aliasing and how we are going to handle it. it would be nice to just have that code in smtp instead of a separate queue agent the way that it was before. this however would not work as then dragonfly would then have to be modified to use smtp instead of talking direct to the store. this would not be a cool thing for us as that would slow dragonfly down. it’ll probably end up in a library that is linked or used in some non-specific way like alex suggested of using the auth system in the store (which i think is an excellent idea. the only thing that worries me is non-global domain aliasing).

we chatted a little bit about bulid versioning just today. if you look at the agent code near the top is a define PRODUCT_VERSION which i believe used to be an expanded string in code (when i was on the team we used pvcs but i’m sure that’s long since been done away with). we were discussing a way to auto generate that constant. this needs a little more discussion.

we had a small discussion on dmc as well. dmc was a management tool to allow you to pass tuning parameters of almost any sort, and to get statistics from various agents. it is a great idea, but it is pretty complex code how it is currently implemented. the rules agent (which i’m not sure if it was ever completed) used a new system that is really pretty. we discussed the possibility of using this type of system as well. part of me thinks this would be really cool as then the snmp stuff i’d like to add eventually won’t have to be in every agent, but only in once place that speaks dmc-speak.

i think the other major discussion we had was the one concerning bongo-manager that alex mentioned where it provides configuration information. i think in the long run this is a good idea as bongo-mananger needs communication with the agents anyhow. it was pixelpapst on irc that proposed that idea after alex and i were chatting about mdb and configuration data.

one last thing i’d like to mention is an article i found on /. that i posted to the irc channel. it should be required reading in my opinion (InformationWeek). alex told me i should have blogged it and he’s right. i agree with a lot of what this guy says, some of it i don’t. i think that we have some of the things that he thinks makes an open source that will succeed. it’s a good read and if you want to discuss it, hop into irc :)

after having written this mostrosity, i’m seriously thinking about writing more often. this is just too much work for one sitting!

Finally! A blog!!

Tuesday, February 6th, 2007

i’ve finally gotten a blog going. this thing will mainly be about bongo stuff (since my life is pretty boring). as was mentioned by alex, i’m currently working on a patch to smtp to make it use connio. this has turned out to be quite a monster as there is a ton of code in smtpd that needs to be stripped and re-worked. this does have the good side affect of making smtp ssl work again since we stripped out linking with openssl due to license restrictions. as of right now the current patch is 1969 lines long and i’m still goin.

as for other stuff, alex and i have been having some long chats on mdb. the current thought is that we’ll add a new layer between mdb and the consumer that will for right now just map onto mdb. once all agents are *ported* to using it, we’ll strip out mdb and re-map the back end to be a direct access module. this will take some tough thinking since we want it to work right for the c agents and the python web uis (both hawkeye and dragonfly).

another task on the upcoming list is one that alex mentioned as well, the anti* stuff. currently the antispam stuff doesn’t work because the needed schema attributes did not get pulled over by the novell guys before they got re-tasked off the project. i had submitted a patch for it which worked great as long as you already had a configured system. for anyone who had a new system however it messed things up really bad. i ended up opening a huge can of worms that ties nicely into the mdb discussion.

i hope to be able to go to lunch tomorrow with a couple of old friends, micah and rodney. i’m sure they will both shudder at the stuff we are doing right now, but perhaps it won’t come up.

i’ll try to keep this thing up to date with my current bongo-ings.