FreeBSD: HOWTO install vim from ports WITHOUT X-Windows.

I’m normally a manually-compile-from-source type of guy, but I thought I’d give FreeBSD’s ports system a try. Right away I ran into an annoyance, and something that underscores a constant battle: trading customizability for ease-of-use. Yes, ports makes installing things easier, but you lose a certain level of control and customizability.

Installing vim from ports seems easy enough, right? Sure, if you want tons of bloat included! A simple make; make install in /usr/ports/editors/vim started a flurry of downloads for things like X11toolkits, X11R6.8.2, etc, etc.. in other words, installing vim from ports was trying to also install X-Windows on my machine!! This is a server, I do NOT need the bloat of X-Windows simply to run a frickin’ text editor like vim.

So, after some research, I discovered that you can in fact control port installs with various arguments. Here’s how I installed vim:
cd /usr/ports/editors/vim
make WITHOUT_X11=yes
make WITHOUT_X11=yes install

PRESTO, a nice, clean, bloat-free, non-X-Windows install of vim. As a general tip, you can look inside the port’s Makefile to see various arguments that you can pass in.

A caveat though, if you ever upgrade all your ports with portupgrade, all of your ports will upgrade with the default arguments. So if I ran portupgrade and a new version of vim was available, it would install vim and all the X-Windows crap along with it.

Luckily, FreeBSD provides a way to automatically provide arguments to auto-upgrades via portupgrade: Simply open up /usr/local/etc/pkgtools.conf and fill in the MAKE_ARGS tag like so:
MAKE_ARGS = {
'editors/vim' => 'WITHOUT_X11=YES',
}

Now the next time you upgrade vim using portupgrade, the WITHOUT_X11 argument will be automatically included, so you won’t have to worry about all that extra X11 crap being included in your install.

RealTek RTL8100S LAN on FreeBSD 5.4: no carrier

I just installed FreeBSD 5.4 on my Abit AA8-DuraMax, but I’ve run into some troubles with my networking. It seems that the on-board NIC doesn’t properly detect when a cable is plugged in. ifconfig shows it as “status: no carrier

I know it’s not the router or the cable, because they both work fine on other machines. The 8100S chipset is listed as supported on the FreeBSD 5.4 Hardware compatibility list, as well as the man pages for the re driver.

Some other weirdness: If I plug the ethernet cable from the BSD machine to another machine’s NIC, it is properly detected. It only doesn’t detect when connected to my router. Also, if I manually set the card to 10baseT/UTP using ifconfig’s media parameter, it also works. It doesn’t work on autoselect, or any other media setting besides 10baseT/UTP.

Anyone have any ideas? Some info:
ifconfig:
--------------------------------------
re0: flags=8843<up ,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=18<vlan_mtu ,VLAN_HWTAAGGING>
inet 192.168.1.31 netmask 0xffffff00 broadcast 192.168.1.255
inet6 ...
ether 00:50:8d:eb:e5:be
media: Ethernet autoselect (none)
status: no carrier
lo0: flags=8049<up ,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4Relevant dmesg:
--------------------------------------
re0: <realtek 8169S Single-chip Gigabit Ethernet> port 0xee00-0xeeff mem 0xfbfff000-0xfbfff0ff irc 16 at device 1.0 on pci1
miibus0: <mii bus> on re0
rgephy0: <rtl8169s /8110S media interface> on miibus0
rgephy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 1000baseTX-FDX, auto
re0: Ethernet address: 00:50:8d:eb:e5:bepciconf -lv:
--------------------------------------
re0@pci1:1:0: class=0x020000 card=0x1039147b chip=0x816910ec rev=0x10 hdr=0x00
vendor = 'Realtek Semiconductor'
device = 'RTL8169 Gigabit Ethernet Adapter'
class = network
subclass = ethernet
 
pciconf -r pci1:1:0 0:0xff
--------------------------------------
816910ec 02b00007 02000010 00002008
0000ee01 fbfff000 00000000 00000000
00000000 00000000 00000000 1039147b
00000000 000000dc 00000000 40200110
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 f7c20001
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000

phplist/Sendmail/FreeBSD: X-Authentication-Warning

If you enable the $message_envelope variable in the config.php file of phplist for processing bounces, sendmail will probably complain with the following header in your email:
X-Authentication-Warning: your.domain.com: httpd set sender to account@domain.com using -f
This is because only “trusted users” are allowed to change the message envelope. By default, sendmail only considers root, daemon, and uucp as trusted users, so if you try changing the message envelope as the user Apache is running under (in my case httpd) sendmail will attach that nasty warning header to all your outgoing mails. Spam blockers don’t like this!

There are a couple of ways to fix this:

  1. Add httpd (or whatever user Apache is running under) to the daemon group:
    pw groupmod daemon -M httpd
  2. Add httpd (or whatever user Apache is running under) to Sendmail’s trusted-users file. Open up /etc/mail/your.domain.com.submit.mc in vi and insert the following line:
    FEATURE(`use_ct_file') dnl # Trusted users
    Save & Exit.
    Now you must create the trusted-users file in /etc/mail:
    touch /etc/mail/trusted-users
    Open /etc/mail/trusted-users with vi and on one line simply add the name of the user under which Apache is running:
    httpd
    Save & Exit. Run the following commands in /etc/mail to commit the changes to Sendmail and restart the server:
    make install
    make restart

That’s it, you should be good to go. Mail sent via PHP/Apache will no longer contain the X-Authentication-Warning header.

Note that there is a downside to this. Any user on your system can now use PHP to send email with “forged” headers. You basically just gave everyone on your system “Trusted User” status to Sendmail, so be sure that you trust your users before actually doing this!

UPDATE: How to do the same in Linux

phplist: Command not found / Bad interpreter

When using the script “phplist” to process queues or bounces on your phplist installation, you may receive the following error:
./phplist: Command not found.
This is caused by the file being in the wrong fileformat. You probably edited it on your Windows/Mac machine, uploaded it, and attempted to execute it. In order for this to work, the file must be in UNIX file format. To fix, open the file with vi (“vi phplist“) and type the following command:
: set ff=unix
Save, and exit, and your phplist should work as expected.

If you get the following error:
/bin/bash: bad interpreter: No such file or directory
That is because you either don’t have bash installed, or if you do, it’s in a different location. The first line of the phplist script (“#!/bin/bash“) must point to where your bash is installed. Find it with “whereis bash” or “find / -name bash“, edit the first line of the phplist script to match, and you should be good to go.