Category Archives: howto

newznab and the elusive -INF

Some people running newznab can run into an issue if the connection to the news provider is lost during backfill, and the only thing which happen is that it will spit out:

Getting next article date... -INF
Error : Failed to write to socket! (connection lost!)

The only “standard” way to fix this is to stop the process and start again. This should not be necessary as the only thing the code needs to check for is “-INF”, and then just stop processing that group.

Adding the following to /www/lib/backfill.php at line 259

if(($pos !== false)) {
echo "Something went horrible wrong!!....\n";
return "";

just after

if($debug) echo "Getting next article date... $upperbound\n";

Will break the loop and make it process the next group.

iTunes scrollbar in Applications

I just wrote and entry about how to get nice scrollbars in Finder.

Well there is a way to do the same in other Applications which does not get the resources from OSX. In for example Firefox, copy the Extras2.rsrc to /Applications/, restart Firefox and the scrollbar looks like it does in iTunes.

Only thing is that I now need to find a Theme which makes it look nice, as, as it is not it does look a bit odd….

iTunes scrollbar in Finder

Even though [stag]Apple[/stag]have said that they have made the Leopard GUI unified, there are still a few things which are lacking. For example the scrollbars in [stag]Finder[/stag] are not as nice as in [stag]iTunes[/stag].

I stumbled over this Italian blog which describes how to change the look of the scrollbars in Finder.

It’s in Italian which I do not understand but the which is for download on the website, have a readme.rtf which also have the instructions in English.

But the easy way of doing it is;

1) download file
2) extract the file
3) copy Extras.rsrc (PowerPC) or Extras2.rsrc (MacIntel) to /System/Library/Frameworks/Carbon.framework/Versions/A/
4) make sure that root:wheels is the owner of the file (#sudo chown root:wheel Extras2.rsrc)
5) restart Finder (#sudo killall Finder)

And then the Finder windows will have a nice scrollbar.

Now, next step is to figure out how to do that for all Applications….

CarbonCopy and OSX 10.4.8 (Intel)

If you as I, have been trying to get CarbonCopy (CCC) to work on your IntelMac, and successfully failed, then what?

Well as it turnes out it looks like the problem is not CCC, but psync which is used to do the actual copy, so if you did click the ‘install psync’ in CCC, then it will install a psync which is compiled for Perl 5.8.1 – guess what 10.4.8 comes with Perl 5.8.6.

So what you need to do is

1) remove the ‘wrong’ version of psync;

# sudo rm /usr/bin/psync
# sudo rm -rf /Library/Perl/5.8.1

2) install the development tools
3) download MacOSX::File from CPAN (
4) compile and install it

# tar zxfv MacOSX-File-0.71.tar.gz
# cd MacOSX-File-0.71
# perl
# make
# make test
# sudo make install

And then CCC should work…. That is not so difficult, but slightly anoying.

Howto block scripts kiddie’s

So you probably have the same issue as I do – you see ‘[sshd] … Invalid user … ‘, a couple of hundred times a day. And would like to stop that, well you could write a script which scannes the /var/log/secure every couple of seconds, or you could do as I did.

First I figured out how to read from syslog in realtime. Next came the big one, how to make the whole thing work. Well I knew that my pipe was working, and the daemon thing – well it was running, but howto make it work. After some hours the result is actually working, and I only see one entry in my secure syslog per attempt to break in, and also only one entry in iptables (timing is the issue here).

If you’re interested in the code download it

It should be self explaining, otherwise use to find out what it does (there are some pretty good perl sites out there) – not the most pretty perl code ever produced, but hey it is working.

Howto process syslog log files

There are tools out there which will process (and do other things) the syslog log files. But if you just need to look for specfic things in the logfiles, then somehow installing Snort might be a bit drastic. So what other options are there.

Syslog can log to files (which is quite normal), or FIFO pipes. The syntax for pipes are:

facilty.priority |<path>/<pipe -file>

To create the pipe use mkfifo:

# mkfifo <path>

An example of how to set this up in syslog.conf:

authpriv.* |/tmp/syslog-secure.pipe
authpriv.* /var/log/secure

The above example will make sure that authpriv.* will be send to both a file and a pipe. Now the next thing which is needed is a program (preferable a daemon), which will continue to read the pipe, and do interesting stuff

For that I use perl… To be continued

Daemonize Perl – or howto create a daemon in Perl

Perl have never been something I’ve looked in to as it is not as easy (I think as) as what I’m used to, which is C/C++, PHP, Shell scripts, etc. But I’ve found out that there are a few things where nothing beats Perl, and one of them is to create small deamons (and also programs) which only exist because I got an "excelent" idea.

Having my own server, one of the most anoying things I see everyday is people who is trying to login to my server with SSH, so I get my log filled up with stuff like "Aug 17 01:54:22 blabla sshd[9821]: Invalid user blabla from ::ffff:123.456.789.123", and in some cases hundreds of them every day. So looking into how syslog works, it turned out that one can actually have multible log facilities pointing to diffrent targets. But more about that later, read another blog entry

The problem is that a daemon is require in an enviroment where one wants to monitor events which happens now. Writing deamon’s is possible in almost every programming language, but Perl *) is good at one thing, it have everything, and then a bit. Especially the way one can use regular expressions directly in the language helps.

*) Yes I could do it in C or C++ (which probably would make more sense), but I could not be bothered, and this was a good excercise in learning Perl.

So I set up trying to figure out how to do this, and found that it is not too difficult (I’m a great believer in cut ‘n paste), and a skeleton would look like this:

use strict;
use POSIX qw(setsid);
use LWP::Simple;

# flush the buffer
$| = 1;

# daemonize the program

while(1) {
# Do interesting stuff here…….

# here is where we make ourself a daemon
sub daemonize {
chdir ‘/’ or die “Can’t chdir to /: $!”;
open STDIN, ‘/dev/null’ or die “Can’t read /dev/null: $!”;
open STDOUT, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
open STDERR, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
defined(my $pid = fork) or die “Can’t fork: $!”;
exit if $pid;
setsid or die “Can’t start a new session: $!”;
umask 0;

See that is not to difficult, I will continue my saga about how to stop idiots trying to access my box.