2011-01-31

FreeBSD - How to reduce TIME_WAIT connections

Routinely, I did a "netstat -an" on a FreeBSD box, a DNS server. The screen then shower with hundreds of "TIME_WAIT" connections. Seems like some malware infected clients are querying the server and causes the terminated TCP socket waiting to be shutdown, but not fast enough, to be efficient. Fortunately, the numbers of TIME_WAIT sockets accumulated are insignificant.

In order to reduce the number of socket waiting, tune the system value :

2011-01-28

FreeBSD - How to make changes to sendmail, FreeBSD styled

Sendmail is the default MTA in FreeBSD. FreeBSD has its own way in managing sendmail's configuration files. Instead of making changes to sendmail.mc, changes should be made to $(hostname).mc. Similarly for submit.mc, changes should be $(hostname).submit.mc.

Here's how :

2011-01-24

FreeBSD - How to test newsyslog for systax error

Platform :
FreeBSD

Purpose :
Syntax checking after creating a new logrotate in "newsyslog"

Command :
newsyslog


Installation :
The "newsyslog" log rotation program comes with the base installation.

Useful switches :
-n == DO NOT actually do the logrotate. Instead, show what will be perform
-vv == verbose on what newsyslog is doing

Example :

2011-01-21

BIND - Error "loading from master file managed-keys.bind failed: file not found"

Platform :
FreeBSD

Error message :
Every time restarting the BIND DNS server, the log file will have this entry :
general: error: managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found
BIND DNS continue to work though.

Solution :
Create a empty file in /var/named/etc/namedb, name "managed-keys.bind":
touch /var/named/etc/namedb/managed-keys.bind

Why :
The file "managed-keys.bind" is used for managing keys in DNSSEC. By default, BIND is looking for it. Even though you might not be using this feature, creating the file in empty will make the error message go away.


Sayonara !!!

2011-01-17

2011-01-14

OSX - How to maximize window using keyboard shortcut

By default, OSX does not comes with a shortcut, though there's a function for it. To make use of it, we'll need to assign a keyboard shortcut key to maximize or un-maximize window.








Here's how to do it :
  1. Open the "System Preferences"
  2. Under the "Hardware" section, click on "Keyboard"
  3. Next, click on "Keyboard Shortcuts" then "Application Shortcuts" (on the left hand box)
  4. Add a shortcut key by clicking on "+" symbol, on the bottom of the right hand box
  5. At the next dialog box, choose "All Applications" for "Application:"
  6. In the "Menu Title :" column, type in "Zoom"
  7. Click on the next column, "Keyboard Shortcut:", then press your preferred keyboard shortcut.
    E.g. Control + Option + Command + m (you didn't read wrongly, is 4 keys there :p)

    *** Avoid popular shortcut key, e.g. Command + v

Now, open an application and try the new keyboard shortcut key. Press the first time for maximized and the second time to return the previous size.

Nemaste !!!

2011-01-10

FreeBSD - portupgrade php5 got hiccups with security/php5-filter

During the routing upgrading of ports, caught a hiccups while upgrading php5 related packages.

One of the port failed to upgrade after issuing "portupgrade -vr php5*".







The errors :
===>  Building for php5-filter-5.3.4
/bin/sh /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/libtool --mode=compile cc  -I. -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -DPHP_ATOM_INC -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/include -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/main -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -O2 -fno-strict-aliasing -pipe   -c /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c -o logical_filters.lo
 cc -I. -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -DPHP_ATOM_INC -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/include -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/main -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -O2 -fno-strict-aliasing -pipe -c /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c  -fPIC -DPIC -o .libs/logical_filters.o
In file included from /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:25:
/usr/local/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:25:
/usr/local/include/php/ext/pcre/php_pcre.h:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/local/include/php/ext/pcre/php_pcre.h:38: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/local/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before 'pcre'
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c: In function 'php_filter_validate_regexp':
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: 'pcre' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: (Each undeclared identifier is reported only once
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: for each function it appears in.)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: 're' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:412: error: 'pcre_extra' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c: In function 'php_filter_validate_email':
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:527: error: 'pcre' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:527: error: 're' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:528: error: 'pcre_extra' undeclared (first use in this function)
*** Error code 1
1 error
*** Error code 1

Stop in /usr/ports/security/php5-filter.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20101224-47314-9ktu04-0 env UPGRADE_TOOL=portupgrade UPGRADE_PORT=php5-filter-5.2.11_1 UPGRADE_PORT_VER=5.2.11_1 make
** Fix the problem and try again.
--->  Build of security/php5-filter ended at: Fri, 24 Dec 2010 09:36:27 +0800 (consumed 00:00:43)
--->  Upgrade of security/php5-filter ended at: Fri, 24 Dec 2010 09:36:27 +0800 (consumed 00:00:43)
--->  ** Upgrade tasks 1: 0 done, 0 ignored, 0

Checking out /usr/ports/UPDATING and /usr/ports/MOVED doesn't seems to give a hint. Next try on Forum.FreeBSD.org shed light on this :

2011-01-07

Bash - How to check the exit status of pipe command


Piping in bash commands are common.
Checking exit status of a command in bash scripting is essential.
How about checking exit status of the commands in a pipe?





Example:

2011-01-03

FreeBSD - Port p5-Encode-Detect error

While patching one of the FreeBSD box, a perl module port, converters/p5-Encode-Detect-1.01, failed to compile. This is the abstract of the error message :







===>  Extracting for p5-Encode-Detect-1.01
=> SHA256 Checksum OK for Encode-Detect-1.01.tar.gz.
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>  Patching for p5-Encode-Detect-1.01
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/lib/perl5/site_perl/5.8.9/ExtUtils/CBuilder.pm - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/lib/perl5/site_perl/5.8.9/Module/Build.pm - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>  Configuring for p5-Encode-Detect-1.01
Warning: ExtUtils::CBuilder not installed or no compiler detected
Proceeding with configuration, but compilation may fail during Build

Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'Encode-Detect' version '1.01'
===>  Building for p5-Encode-Detect-1.01
Building Encode-Detect
Error: no compiler detected to compile 'src/LangBulgarianModel.cpp'.  Aborting
*** Error code 2

Stop in /usr/ports/converters/p5-Encode-Detect.

It seems like the port devel/p5-ExtUtils-CBuilder didn't quite compile it's option and installed properly. Reinstalling devel/p5-ExtUtils-CBuilder didn't help. Re-compile all of the dependency of converters/p5-Encode-Detect & devel/p5-ExtUtils-CBuilder also didn't work as well.

The error message does strongly suggest that there's problem with devel/p5-ExtUtils-CBuilder. It's time to get my hands dirty, by manually compiling the port devel/p5-ExtUtils-CBuilder :