Thursday, February 23, 2012 - 04:51
FeedBurner  RSS 2.0 Feed  Follow Me On Twitter  Save On Delicious

Installing Perl With Setuid

Guide on how to install Perl With Setuid Enabled on FreeBSD

A few applications may need Perl with setuid enabled. And it’s a must if you are going to run Qmail.

FreeBSD 7.x comes with Perl installed which is fine in most cases, unfortunately without setuid enabled. The easiest approach for fixing this is to simply reinstall perl. FreeBSD 8.x on the other hand comes without perl installed making it easier for you to install the version you like. This guide covers FreeBSD 8.x as well as FreeBSD 7.x and earlier.

For FreeBSD 8.x

Now we need to change the "make" environment in order to build with setuid=true. I know there is a check box during the installation that claims to build perl with setuid enabled. But I usually put it in the environment as well just to be safe.

As root
echo "ENABLE_SUIDPERL=true" >> /etc/make.conf

There are 3 versions of perl to choose from
/usr/ports/lang/perl5.8
/usr/ports/lang/perl5.10
/usr/ports/lang/perl5.12

Install whatever you prefer. Perl5.12 is the latest production release. In this example I’ll use perl5.10

As root
cd /usr/ports/lang/perl5.10
make install clean

When the options screen pop’s up [Screenshot] be sure “Build set-user-id setuidperl binary” is checked [x] and hit [OK]

When the installation is finished type the following to see if things turned out right.

As any user
perl -v

You should get the following output.

Output
This is perl, v5.10.1 (*) built for i386-freebsd-64int

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

For FreeBSD 7.x and earlier.

First you need to figure out what version of Perl you have installed on your system. Type in the following.

As any user
perl -v

You should get an output very similar to the one below.

Output
This is perl, v5.8.9 built for i386-freebsd-64int
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2008, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Whatever version you may have 5.8 or 5.10 the first step is to uninstall your current version of perl.

As root if you have perl 5.8
cd /usr/ports/lang/perl5.8
make deinstall

As root if you have perl 5.10
cd /usr/ports/lang/perl5.10
make deinstall

Now that perl is uninstalled we need to change the "make" environment in order to build with setuid=true regardless of what version of perl you decide to install. I know there is a check box during the installation that claims to build perl with setuid enabled. But I usually put it in the environment as well just to be safe.

As root
echo "ENABLE_SUIDPERL=true" >> /etc/make.conf

Right all thats left for you now is to decide what version of perl to install.

There are 3 versions of perl to choose from
/usr/ports/lang/perl5.8
/usr/ports/lang/perl5.10
/usr/ports/lang/perl5.12

As root reinstalling perl 5.8
cd /usr/ports/lang/perl5.8
make install clean

As root installing perl 5.10
cd /usr/ports/lang/perl5.10
make install clean

When the options screen pop’s up [Screenshot] be sure “Build set-user-id setuidperl binary” is checked [x] and hit [OK]

As root installing perl 5.12
cd /usr/ports/lang/perl5.12
make install clean

When the options screen pop’s up [Screenshot] be sure “Build set-user-id setuidperl binary” is checked [x] and hit [OK]

After the installation it’s probably a good idea to reboot.

As root
reboot now
Related Guides  Links  Requirements