Tag Archives: freebsd

Cron can’t start PAM on FreeBSD

I was having these error messages in /var/log/cron:

Feb 29 15:52:01 localhost /usr/sbin/cron[96178]: in openpam_load_module(): no pam_nologin.so found
Feb 29 15:52:01 localhost /usr/sbin/cron[96178]: (CRON) error (can't start PAM

Searched the net, couldn’t find anything relevant.

Eventually, though, figured out to /etc/rc.d/cron restart, and voila! Maybe something went hazy after upgrade.

PHP doesn’t execute scripts

Neither using CLI (with -f or a shebang) nor through Apache.

It was just dumping the script to stdout, and that means short PHP tags (<? ... ?>) are disabled. Nothing serious, fixed in php.ini.

But then it just did nothing. No output, no errors, no warnings. Turned out this particular version of PHP can’t read DOS-formatted text files. To change them to Unix, in vim:

:set ff-unix

This happened after I flipped from FreeBSD to Arch Linux.

csh: Cannot open /etc/termcap

Upon logging into my remote server with ssh, I started getting:

csh: Cannot open /etc/termcap.
csh: using dumb terminal settings.

There is no rxvt-unicode entry in /etc/termcap. You should specify one, but if you’re lazy, you can just

setenv TERM xterm

in your ~/.cshrc.

P.S. Nah, this doesn’t help. You have to put that line in /etc/csh.cshrc (via).

A move to Arch Linux

As if there wasn’t enough changes in my life lately, I’ve switched from FreeBSD to Arch Linux. I did this, since a lot of software is first developed on Linuxes, so that gets the bleeding edge. Such as wireless drivers, window managers, etc..

This wasn’t the only reason, though. I like the strict GPL licence a lot more than the corporate-capitalist-fuck-allowing BSD type. BSD’s not BDSM!..

Anyway, Arch is very much like BSD, the most BSD-like of Linuxes I’ve seen.

Before you start with Arch, get a hold of this: Arch Beginner’s guide.

Notes on enlarging my /usr, FreeBSD

First, introduce yourself to man fdisk, bsdlabel, growfs.

Quick link: this. Refer for good detailed instructions.


Those with extensive Windows experience might think of “resizing the FreeBSD partition”, but that’s not how it works in FreeBSD.

When you search the net, the first thing you’ll find is people saying you should use growfs to do that. Obviously, they’ve never did anything like it before and are just playing wise-ass.

Here’s the deal: for resizing partitions (in “classical” DOS terms; this is “slices” for FreeBSD), you use fdisk. You may both enlarge and shrink at this stage.

(NOTE 1: you’ll have to do this in single-user mode. When asked which shell you want, use the default /bin/sh. Using /bin/csh is bad, mkay? First, I’ve found the environment variables aren’t set in this case (you’ll have to write full path names). Then, there’s the quirk with utilities (vi, say) grabbing one line instead of the entire screen.)

Then you use bsdlabel (aka disklabel) to change the size of FreeBSD partitions in a chosen slice. You will actually have to use /usr/bin/vi at this stage (I think it’s hard-coded into the bsdlabel executable). You can change the sizes in any way – enlarge or shrink. After all, it’s just editing a text file.

(NOTE 2: vi is on /usr. It will want /tmp to store the file being edited. You’ll have to mount those. Don’t worry, it’s OK, as long as you don’t forget to unmount them after editing.)

Finally, you can use growfs to grow the file system, according to the info you’ve specified in the disk’s label. If there was shrinkfs, you could shrink it, too.

So, you see, growfs is the shortest and easiest part of growing a file system.

Stock FTP with chroot (FreeBSD 7.0)

I was having really weird problems trying to set up a user that would be properly chrooted. Here are some traps/pitfalls.

1) The stock ftpd is not native! It’s merged in from NetBSD (I think). If you look for /usr/share/examples/ftpd/ftpd.conf, you won’t find it.

2) Make sure /home can be executed by anyone. I had everything (“rwx”) disabled for “others”, so that users can’t see who else exists on the system. Well, I had to put the “x” permission back on (in my case, “r” suffices).

3) There might be confusion on what the /etc/ftpXXX files actually do. man ftpchroot says:

The ftpusers file provides user access control for ftpd(8) by defining which users may login.

But if you read further, the file actually defines which users may not login.

Funny thing is, it also says the ftpchroot has the same format; but putting

retard yes

in it caused user retard not to be able to be chrooted upon entering the password. Putting a simple


did the trick.

MLDonkey can’t compile: Tcl/Tk missing

Installing from packages:

ml_togl.c:12:17: error: tcl.h: No such file or directory
ml_togl.c:13:16: error: tk.h: No such file or directory

This happens because some dependencies aren’t in the requirements list:

portinstall tclX tcllib tk

The first two will handle the tcl.h dependency. The second will do tk.h. You should probably make sure tk is the same version as tcl.

A PHP script to resize all images in a directory

This is a crude hack to resize images in a directory. The script is invoked as:

shrink <new_x> <new_y> <file> <file> <file> ...

You’ll need PHP with the GD library. That’s php5-gd on FreeBSD.

# The output is JPEG, quality 88.


// Fuction to resize images, originally by D. Weimer.
// Code reformatting done, and '>' changed to '<'.
// http://www.dweimer.net/?page=help&subpage=imageresize
function resize($img,$nx,$ny)
    // $x and $y: original image's sizes.
    $x = imagesx($img);
    $y = imagesy($img);

    // Here, $nx and $ny are the minimal desired dimensions.
    if ( ($x/$nx) < ($y/$ny) )
        $ny = round( $y * ($nx/$x) );
        $nx = round( $x * ($ny/$y) );

    $nimg = imagecreatetruecolor($nx,$ny);

$arguments = $_SERVER['argv'];          // What the user wants to process.
array_shift($arguments);                // 1st element is the path to the script itself.
$newx = array_shift($arguments);        // 2nd is the new desired x dimension.
$newy = array_shift($arguments);        // 3rd is new y.
                                        // all the remaining args are images.

foreach ( $arguments as $arg )          // Go over user's shown items (single or "heaps").
    foreach (glob("$arg") as $filename) // Go over every file in a "heap".
        $image = file_get_contents($filename);
        $image = imagecreatefromstring($image);

        $image = resize($image, $newx, $newy);

        imagejpeg( $image, $filename, 88 ); // WARNING!!! Writes JPEG by default!


I was too lazy to go searching for something pre-made.

Octave – open-source alternative to MatLAB

There are some links on osalt.com, and Octave even boasts language compatibility.

Will try it out and see how it works. I wonder most whether it has something like MatLAB’s toolboxes.

EDIT: Ah, yes, there are:

…the toolboxes that exist are donated by those interested in them…

(From the FAQ.)

Simple SSH account blocking, FreeBSD

Read the man page! There you’ll find that it’s performed in /etc/ssh/sshd_config by a troup of four directives:


In that order.

Say you’ve got group users with users jack, off, and jill, and group assholes with jack and jill.

If you want only jill to be able to login, you could specify:

AllowUsers jill


AllowUsers jill
AllowGroups assholes

and both of these wouldn’t allow (sic!) jack in!

If you wanted all the users of group assholes to be authorized, you’d put:

AllowUsers *
AllowGroups assholes

in the file. With only the second line, you’d lock everybody out (like I just did with my remote machine… oops!).

After you’re done, restart the server with

sudo /etc/rc.d/sshd restart