/dev/null: Permission Denied

by mijit in tech

i was getting this error repeatedly on boxes in my home domain. i would set up a system and then, seemingly at random, i would try to ssh to it and it would spout several “/dev/null: Permission Denied” as i tried to fire up an ssh-agent. looking at /dev/null, it showed a file mode of (if i remember correctly,) 600 and owned by root. i had no idea what was even *accessing* /dev/null – i certainly didn’t have any cron jobs set up to alter it. googling the problem didn’t really enlighten me, but i did check my .bashrc scripts and noted that i had set MYSQL_HISTFILE to /dev/null. a-ha! some reports on the web showed that various apps like to set files’ permissions in a sneaky sort of way, so i theorized that perhaps mysql sets the perms on that file to something sensible for a history file (to the detriment of other apps, of course, but mysql isn’t really expecting to write to a file other people will need, anyway. and mysql isn’t suid root, so this is still just a guess.) removing this line seems to work, for now, so hopefully i will have solved this. and hopefully this will have helped you, too!

black is beautiful. and energy efficient!

by mijit in tech

check out Rising Phoenix Design and the Blackback Web Theory.

i promise i won’t say “i told you so”.

blackback

or, check out ecoIron, with their textual analysis of how a Black Google Would Save 750 Megawatt-hours a Year:

As noted, an all white web page uses about 74 watts to display, while an all black page uses only 59 watts. I thought I would do a little math and see what could be saved by moving a high volume site to the black format.

Take at look at Google, who gets about 200 million queries a day. Let’s assume each query is displayed for about 10 seconds; that means Google is running for about 550,000 hours every day on some desktop. Assuming that users run Google in full screen mode, the shift to a black background [on a CRT monitor! mjo] will save a total of 15 (74-59) watts. That turns into a global savings of 8.3 Megawatt-hours per day, or about 3000 Megawatt-hours a year. Now take into account that about 25 percent of the monitors in the world are CRTs, and at 10 cents a kilowatt-hour, that’s $75,000, a goodly amount of energy and dollars for changing a few color codes.

the occasional vim error

by mijit in tech

this is something that had been bothering me for ages. i am one of those who keeps virtually all my info in one notes.txt file – no fancy GTD system, just a bunch of text that i noodle with on an ad hoc basis. i use vim to manage it, and it stays open 24×7 on multiple machines (via screen – something i’ll go into another time.)

but, the problem with keeping the window open is that, at least on my fedora boxes, a system cron script comes along once a week and cleans out the /tmp directory — including the temp files that vim is using to keep state in my editing session. this makes me have to save/close/reopen vim, usually when i try to launch some external command like sort.

the solution i found was to touch vim’s temp file daily, making it look like a “new” file to the system cleanup script. vim makes temp file directories in a format like this:

    /tmp/v\d??????
    

so, in my personal crontabs, i use this to ferret these out and touch them up-to-date:

    find /tmp -follow -type d -name v?????? -exec touch {} \; 2>/dev/null
    

works like a charm.

mutt/zimbra spam macros

by mijit in tech

here are snippets from my .muttrc file which allow me to bounce messages to my zimbra server spam / ham mailboxes, for the purposes of training spamassassin. this was taken from Lucas Nussbaum, but his link appears to be down at the moment. i’m including these here in case anyone elses googles “mutt zimbra spam macro“, like i did for a few weeks to no avail.


    macro index S "<bounce-message>spambox@mijit.com\nyd" "Learn as spam"
    macro pager S "<bounce-message>spambox@mijit.com\nyd" "Learn as spam"
    macro index H "<bounce-message>hambox@mijit.com\nyj" "Learn as ham"
    macro pager H "<bounce-message>hambox@mijit.com\nyj" "Learn as ham"

these allow you to highlight a message in the index or pager, hit “S” for spam (or “H” for ham,) and the message bounces away to the appropriate zimbra mailbox for automated spamassassin learning. (additionally, the “S” for spam macro marks the message for deletion; the “H” for ham macro simply moves to the next message.) the tricky bit for me was understanding that mutt allows the “\n” newline character to simulate <return> at the end of the <bounce-message> command.

note that you must change “spambox” and “hambox” to the appropriately named mailboxes for your domain. to see what your current spam mailboxes are, issue the following command as the zimbra user:


    zmprov gacf | grep SpamAccount

to change these values to something more appropriate to your domain, use zmprov again:


    zmprov mcf zimbraSpamIsNotSpamAccount <your ham account>@example.com
    zmprov mcf zimbraSpamIsSpamAccount <your spam account>@example.com

A beginning Test::More suite, VIM discoveries, and FuseFS musings

by mijit in tech

A Perl Test::More suite for small networks

I’ve been wanting to implement some simple tests for my home network to make sure everything is running the way I expect it to on an ad-hoc basis. I’ve got a Nagios setup monitoring my Apache, MySQL, and Zimbra services, but I wanted a bit more granularity to my tests, a command-line interface, and the ability to separate out the “business logic” a la MVC.

Since I had documented my server installation routine in chronological order (eg, “first, unpack the box,”) I immediately noticed I had roughly determined a five-step overview of the process. Since most tests I’ve seen run numerically, I decided on:

  • 00prereqs.t – do I have everything I need to run the other tests?
  • 01dns.t – can I resolve host names, so I can find hosts and services?
  • 02time.t – is my clock correct (so later time dependencies would work?)
  • 03hosts.t – can I find all hosts I expect to find?
  • 04services.t – can I contact all services (SMTP, HTTP, etc) I expect to find?

UPDATE: I forgot that I moved the DNS test earlier in the sequence – my NTP test relies on DNS to find external time masters to get the current time.

Note: I discovered via 02time.t that Net::Time doesn’t work for me; Net::NTP does. I don’t know what the difference is, but “working” is always a plus in my book. Basically, using it, I test whether localtime is the same as NTP time (see Net::NTP time for details.)

I am not sure whether 04services.t will grow into multiple files for various services, but this works well enough for now. I won’t go into each individual test in each file for this post, but suffice it to say this is how I now test for sanity from my SVN tree:

    ~/src/mijit
    [204]meatbag$ prove -l t/
    t/00prereqs.....ok
    t/01time........ok
    t/02dns.........ok
    t/03hosts.......ok
    t/04services....ok
    All tests successful.
    Files=5, Tests=11,  2 wallclock secs ( 0.97 cusr +  0.26 csys =  1.23 CPU)
    

VIM discoveries

  • When using the gq command, the autoindent option can be your friend! This allows indented text to be left-aligned correctly (a necessity for my notes.txt file.)
  • some matchparen plugin that is installed on some of my machines and not others adds annoying cyan brace-matching highlighting. This drags my eye away completely away from the cursor – bad plugin! The quick fix: :NoMatchParen disables the plugin, and :DoMatchParen enables it again. Do as you like to your plugin/ directory.

FuseFS musings:

Much seems to have been made of FuseFS lately, which I think is a really neat (but not necessarily great,) idea – and I mean that in a it works in theory, but not reality. At least, that’s been my limited experience. Given the state of these tools and the tech know-how needed to deploy them, I find myself asking why not just set an expectation that WebDAV can do it for you (yes, I know it has its own problems with various clients requiring certain server headers. Maybe that means we should pressure people more to follow open standards.) That said, I have been finding the following quite useful to mount a remote directory to a local directory over SSH:

    sshfs -p $REMOTE_PORT $REMOTE_HOST:$REMOTE_DIR $LOCAL_DIR