Ramblings of Narc

When the issue isn't confused enough.

Archive for the ‘Around The House’ Category

Webmin, Oopsies, and the Fun of DNS

So, I must be the last person on the Internet to have heard of webmin — or, at least, the last person who administers a bunch of Linuxen to do so.

After installing it yesterday on Bast, I discovered, among other things, that webmin has a neat little interface to configure BIND. Since that was basically the one thing I hated having to manage on my own, I decided I’d give it a try — and boy, did it ever work nicely. I’ve managed to transfer the narc.ro zone from the shitty MS server to a nice, neat little BIND9-managed zone on bast.

On top of that, I’ve finally segregated *.narc.ro and *.internal.narc.ro, which makes the DNS a lot cleaner.

In other recent news, however, I did a stupid (this is where the “oopsies” part of the title comes in): I had to change Themis’s IP from 192.168.0.1 to .100 (well, I didn’t have to, I was just lazy), and… I forgot to change the port forward for the DNS. Which ended up breaking my e-mail deliveries, as well as most of everything else related to narc.ro, I’m sure. Luckily, since I also had a reason to change that forward, I caught it relatively quickly (yeah, it only took a couple of days, heh).

So if you were wondering why you couldn’t reach narc.ro, or why your RSS reader was having trouble getting updates, now you know. Aren’t ya glad?

…And we’re back up

The toughest parts proved to be:

  • Finding an optical drive that worked (I found one… from 1998 (!))
  • Getting everything (postfix, apache, mysql) migrated

Total downtime was about six hours or so. The final result is excellent.

Now if you’ll excuse me, I need to get some sleep :)

Update: Wait one goddamned minute, I just noticed my permalinks aren’t! Valid, that is — they 404. Bah, I have to fix this…

Update to the update: Yeah, that worked. mod_rewrite wasn’t enabled. Oops. Wonder what other modules I’m missing.

OK, Down We Go… [pre-planned downtime]

As announced, I’m starting the setup for some downtime, with intent to switch my mail/web server to Ubuntu Server edition. It will still take some time to get everything set up (backups in place, etc), so this post should reach RSS readers (including the Google Feedreader), but at some point there will be downtime. If all goes well, it shouldn’t take too long. Wish me luck! :)

That’s odd…

Now, here’s an odd one for you, courtesy of my friend, Cristian Chilipirea (Dark Hunterj):

#include <stdio.h>

int* holy_crap()
{
	/*static*/ int s;
	printf("%i\n", s);
	return &s;
}

main()
{
	int* x = holy_crap();
	*x = 2;
	holy_crap();
}

So, what are we looking at? Well, if you uncomment the “static”, you get the intended effect — holy_crap(), when called for the first time, (prints “0\n” and) returns the address of its static variable; the value in that address is changed to contain a 2, and then holy_crap() prints out “2\n”. This is as intended, and it is a very silly thing to do, but it works and is legal.

And then, you comment out the static as I’ve done, and… it still works? That’s odd… In theory, at least, the allocation of a non-static local variable can take place absolutely anywhere in memory, so the address read and returned by the first call to holy_crap() could be different from the address checked and returned by the second call. Yet, on my compiler (gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)) and on Dark’s, it actually does print “2\n” on the second call to holy_crap().

Granted, gcc does complain: “warning: function returns address of local variable”, but it still works, for whatever reason.

And it gets better! Check this out:

#include <stdio.h>

int * holy_crap()
{
	int s;
	printf("%i\n",s);
	return &s;
}

int huh_what()
{
	int test;
	test = 3;
}

main()
{
	int* x = holy_crap();
	*x = 2;
	huh_what();
	holy_crap();
}

This actually prints “3\n” on the second call to holy_crap()! We could probably reduce this further by removing the initial call to holy_crap() and the assignment of 2 to that pointer, but it doesn’t matter, because this is still some weird shit going on here.

Oh, and, I probably don’t need to tell you this but don’t ever rely on this happening for you! It’s very likely a combination of compiler, OS, and unoptimized compilation. I haven’t tried this in any conditions other than “gcc file.c -o file”, and I definitely do not recommend writing anything like this in any application beyond the most trivial/educational.

Still, any ideas to explain why this happens?

Recognizing Failures

(or, just how much can you chew?)

Way back in late 2005 (a lifetime ago, as far as I’m concerned), a friend of mine came for a visit one day. He was coming to me on behalf of a (non-mutual) friend who needed a programmer because he had an application in mind. He tried to explain the application to me, and on the face of it, I didn’t think it was a particularly difficult one. I still don’t, actually, but that’s a purely academic distinction at this point.

So because I didn’t think it was going to be that difficult, I went ahead and told him to have his friend contact me; he did, and he did, and we met, and I got to sketch out a reasonable idea for the program both in my mind, and hopefully in the client’s mind as well.

And then things got bad.

I strongly suspect I was right, that the project was not particularly difficult. I also suspect that, just as I couldn’t finish (or even start) it then, I would be completely unable to finish it now. It’s just beyond my capabilities.

The first hint of this “too big to chew” property of the project was when I tried to start writing some kind of database abstraction for it and kept coming up with flaws in that abstraction. I had gotten a number of details on what the final application would have to deal with, and even though I had decided (together with the client) that the initial version would be limited to some much simpler-to-model data, it became more and more clear that this initial iteration would have to be thrown away almost entirely after its implementation.

And here’s where I went wrong: I could have created the initial, very limited application. It would’ve had to have been (at least partially) thrown away after its launch, and the next iteration would probably have been more complex, but it would have been something tangible, more than just a concept in our heads, but something that could be interacted with, could be tested, could be considered for the recycle bin or for the improvements treadmill. Instead, I froze. Almost literally. I couldn’t write the code. I couldn’t make it happen. All I could think of was how complicated an architecture would be required, and how it was so completely beyond me because man, I’ve never written something like this before and I’m so fucked; I told this man I’d deliver something and now I can’t deliver, I can’t do it, and I’d rather die than see this man again and dash his hopes after I made it sound so good…

Now, if that sounds like I’m maybe hiding the fact that I couldn’t bear the shame of not being able to write something, and I’m lying to myself (hello, armchair psychologists out there on the Interwebs!), the fact is I’m not. Yes, I was ashamed, but not that I couldn’t do it — I was ashamed that I’d ended up lying to my client about being able to do it. And, to be honest, I don’t think I even ever said I would be able to do it, but I’d made it sound so good, like it was just a few steps away from being real… which, of course, it never had been — except in my head. Before I’d really thought about it, that is.

So, the lesson I took from this was: don’t promise you can do something you’ve never done before, and don’t make it sound like you can. Because if you end up biting off more than you can chew, you’ll make a liar out of yourself, and your client will not only not want to hire you again, but they will also tell their friends that you’re unreliable, that you make promises you can’t deliver on, and that will fuck you more than anything. Obviously, this is just after-the-fact reasoning, the real reason for me was that it made me feel like shit — but it also happens to be true, and my feeling made me look at that, analyze it, and see it for myself. And now I can share it with you, anonymous reader.


This is the first of hopefully many “personal experience” posts, where I will detail the things I’ve learned — some good, some not so good. Merry Xmas, Internet.

The next post in the series is One Is The Most Important Number, and refers to the age-old programming concept: “Don’t repeat yourself”.

WTB: Round Tuit*

I’m severely low on tuits these days, especially round ones (laugh, it’s supposed to be funny ;) ), but when I get one I need to:

  • set up my newly-acquired D-Link router as the common gateway to the Internet, in place of the old computer currently doing this (implies moving any and all port forwards there, too)
  • possibly set up a DNS server (BIND, probably) on one of the other computers (most likely bast)
  • set up mum’s computer so she doesn’t have to work on the current router anymore (thus clearing it up for the next step)
  • set up the current router as network-attached storage, running SAMBA and possibly NFS and probably SVNserve, too, on an Ubuntu Server Edition (plus transferring any of the data we want to keep off its current drives and onto different ones before formatting to ext3)
  • (added to the above) look into the possibility of consolidating the four drives on the current router into a single logical partition (or perhaps two) using some kind of software RAID. This may or may not be a good idea, considering the age of the drives and their possibility of failure

Aside from all this, I have a bunch of other running around to do, most specifically involving putting a bunch of documentation together and finally becoming a one-man company so I can be paid more. I’ve unfortunately been slacking off in that department.

ETA: And that’s my quota of 1 post for this month, and just in time, too, October’s about to start. Boy, does time fly, or what?

(*) – WTB == “want to buy”; “round tuit” == common joke/wordplay around the statement “I’ll do it when I get around to it”.

Mail Server (And Assorted Naughtiness)

In keeping with the previously mentioned tip about getting stuff done, I’m now starting to work on a problem I’ve been avoiding for several months — moving the mail server.

First part, setting up Postfix on bast to be authoritative for narc.ro, and do all the things my current mail server does. Will it end well? Watch this space, updates forthcoming as progress inevitably ensues (possibly with hilarity; most likely not). Current time: 2:34 am.

Update: 5:15 am and I have Postfix doing most of the important stuff. Counting them:

  • receiving mail on the catch-all
  • receiving forwarded mail from gmail
  • not being an open relay — from default config, so not taking credit for it
  • receiving mail on various blackhole accounts — and sending them straight to /dev/null

What isn’t there anymore:

  • SpamAssassin. No great loss for me, as the only thing it was doing was marking emails as spam. My main filter has always been the blackhole.
  • DNS Blacklists. Also no great loss, for the same reason as above. Further, I’ve heard it’s pretty easy to get on one of them, but very hard to get off them. So, no problem.
  • SSL/TLS — wasn’t in use, since SMTP is secured by the anti-relay setup, and POP3 isn’t even open to the Internets. If someone (like me) wants to get their mail remotely, they can tunnel through SSH. And I can, have done, and will continue to do so.
  • SPF/DomainKeys/etc. Same argument as above: not in use.
  • Antivirus. Never received a virus in email. Don’t have any clueless users. So, no need.
  • POP3 “forwards”. This might be a problem, as I did have a couple of email accounts I was fetching mail from using POP3. OTOH, the single important emails getting delivered to that account can be redirected through GMail, whose forwarding works fine. Come to think of it, I can have GMail fetch the emails remotely, and get those spiffy spam filters in on it, too! Not bad.

So, in conclusion, there’s not much I’m missing, and in exchange, I now have a much freer computer that I can power down at night and install Ubuntu on (when I can find some space for a complete backup). Very very good trade.

#1 Tip About Getting Stuff Done: Get Stuff Done!

Seriously, that’s all it takes.

No more putting things off because they’re “going to take too long”. Or because they’re unfamiliar. If something is going to be a net benefit to you, go for it. Right now.

I’m taking my own advice right now and setting up my mother’s computer, the first step in overhauling all the computers in the house. It’ll be a pain figuring out where to back stuff up temporarily (I’m switching most computers from Windows to Linux, so that will involve some hard-drives getting reformatted from NTFS to Ext3), but I’m going to do it. Starting now.

As a consequence, the mail server will be down starting now. I’ll update the post when everything’s back up and running. Excuse me, I’m about to Get Stuff Done™. :)

UPDATE: Partly done — I’ve decided to do some computer surgery and swapped cases with one of mine. Mail server is up and running again. More downtime tomorrow, around the same time.