Friday, August 22, 2014

Unpacking the last ext3 box

Finally converted my last "home" partition to ext4.  The time it takes to tar it all up  (350 GiB) has dropped from 3.5 hours to 70 minutes; a full fsck, from 2.5 minutes to 10 seconds.  Quite happy.

(I was a bit surprised, as these are mostly big files; I expected ext4 to have less of an impact here than with a partition full of little files, scattered all around.  Shows how little I know about this stuff.)

Thank you LVM

I still can't get over how cool it is to be able to move an entire mounted partition from one drive to another, live, without missing a beat.  (Okay, so it stutters a little bit, obviously.)

Thursday, August 14, 2014

T is for Title

(Finally noticed the quite obvious "Post title" input field, right there above.  After a mere several days.  I expect to have fully mastered this whole blogging thing by 2038.)

Linux capabilities are here

My thanks to Craig Small for making me aware of how simple Linux capabilities are.  I remember hearing about them from time to time, but they usually got mingled with SELinux in my mind, and I assumed they were just as complicated and troublesome.  Little did I know...
 $ ls -l /bin/ping
-rwxr-xr-x 1 root root 44104 Jun 18 17:37 /bin/ping
Look Ma, no SUID!  I've been using them all this time.  :)

One thing escaped me, though: are capabilities set up at boot time (like sysctl), or are they stored on the filesystem, like the old SUID?  Turns out they are indeed stored, as attributes:
$ lsattr /bin/ping
-------------e-- /bin/ping
Erm, I mean, extended attributes:
 $ getfattr /bin/ping
Oops, getfattr(1) only displays user attributes by default.  My bad:
$ getfattr -m '-' /bin/ping
# file: bin/ping
security.capability
Oops, getfattr only displays the list of attribute names by default.  My bad:
$ getfattr -d -m '-' /bin/ping
# file: bin/ping
security.capability=0sAQAAAgAgAAAAAAAAAAAAAAAAAAA=
Huh.  This kinda looks like base64, doesn't it?  Ah, the manpage doesn't really say which encoding is chosen by default.  Let's give this another try:
$ getfattr -d -e hex -m '-' /bin/ping
# file: bin/ping
security.capability=0x0100000200200000000000000000000000000000
There we go.

Wednesday, August 13, 2014

It's 1975 all over again

This one had me confused for a moment:
$ date
Wed Aug 13 14:34:53 EDT 2014
$ re.pl
$ # The join() is only for cosmetic reasons
$ join " " => localtime
6 36 14 13 7 114 3 224 1
$ # Let's grab only the HH:MM part (items 2 and 1)
$ my ($h, $m) = localtime[2,1]
$VAR1 = 56;
$VAR2 = 44;
Huh?

Oh, I see: I forgot my parentheses.
$ ($h, $m) = (localtime)[2,1]
$VAR1 = 14;
$VAR2 = 41;
Much better.  But where the hell did the first set of values come from?
$ join " " => localtime[2,1]
56 31 8 17 10 75 1 320 0
$  scalar localtime[2,1]
Mon Mar 10 02:35:04 1975
Dang, I forgot that localtime() can take an argument, a Unix time number (just like localtime(3) takes a time_t as argument).  This is all starting to make sense.
$ [2,1] . ''
ARRAY(0x9f9dd0c)
$ [2,1] + 0
164751992
$ scalar localtime 164751992
Sat Mar 22 15:26:32 1975
(I'm still a bit surprised that Perl didn't say a word about this.)

Tuesday, August 12, 2014

Dear Time::Piece,

Dear Time::Piece,
re.pl
$ use Time::Piece

$ my $now = Time::Piece->new->strftime("%F %T")
2014-08-12 17:36:04
$ Time::Piece->strptime($now, "%F %T")
Runtime error: Error parsing time at /usr/lib/perl/5.18/Time/Piece.pm line 469.
I hate you.

(more info)

Dear Postfix,

Dear Postfix,

If I enable debugging with these debug options:
debug_peer_list=smtp.relay.example
debug_peer_level=3
Am I crazy to assume that these debug messages will be sent to syslog with the debug priority?

Dear syslog,

Dear syslog,

If I SIGHUP you, telling you to reload your configuration, and you reply this:
Aug 12 17:18:15 hostname rsyslogd: [origin software="rsyslogd" swVersion="4.6.4" x-pid="30944" x-info="http://www.rsyslog.com"] rsyslogd was HUPed, type 'lightweight'.
Am I crazy to assume that you actually, for realz, reloaded your configuration?

Sunday, August 10, 2014

Lies I've repeatedly told myself these past few weeks:
  • "This should be easy."
  • "There's probably a feature that will do the trick."
  • "It will only take a few minutes to implement."
  • "This feature works exactly as documented."
  • "I should be just about done in a few more minutes."
  • "Surely, it can't be that difficult."
  • "This feature is documented."
  • "Only five more minutes and I'm off to bed."
 If only I could say that this was the last time...

Unable to locate package policy

  $ apt-cache show policy
  N: Unable to locate package policy
  E: No packages found


What do you mean, APT, you can't locate my package policy?  Did I screw up /etc/apt/preferences somehow?

How strange, I can't even find another occurrence of this error message on the interwebs...

(scratches head)

Oh, you can't find a package named "policy".  Erm, yeah, I don't know where I got the idea that this was a valid command either.  Sorry, that one's on me.

Saturday, August 9, 2014

Heard many good things about this new newfangled "blogging" thing that's all the rage among hipster kids these days.  I thought I'd try it out and see what the fuss is all about, before the media latch into this and it goes mainstream.