..a dose of zero-day know-hows ..

11/26/2006

FOSS Act passed to the Philippine Congress

Cong. Teodoro A. CasiƱo passed an Act to the 13th Congress which will promote the use Free Open Source Software in the Philippines. The said Act will also ammend the current Philippine Republic Act 8923 also known as the "Intellectual Property Code of the Phillippines". The Act which will be called the "Free Open Source Software(FOSS) Act of 2006" will definetly encourage Open Source practices among Government bodies, which will be a great jumpstart to let the masses recognize the importance/gains brought about using FOSS. By enforcing policies such as limiting the use proprietary software on Government owned offices, operations such as Research and Development must utilize in 1st priority Open Source solutions over propriety ones. These will in turn benefit the state because the Government will take charge of the Source codes and be in full control of the over-all implementaion of IT-related processes. The following was quoted from the original house bill:

7.1. Use of Open StandardsThe Government shall use only ICT goods and services that comply with open standards as defined in section 4 of this Act;

7.2. Open Formatsall government communication and data intended for public consumption shall be encoded in open standard data formats;

7.3. Clarification on the Use of RAND License for Open Standards open standards licensed under “Reasonable and Non-Discriminatory” (RAND) terms and hence are not free but are available for a reasonable fee shall be used only under extraordinary circumstances as defined in section 7.5 of this Act.

7.4. Use of FOSS – The government shall apply only FOSS or FOSS solutions, as defined in section 5 of this Act, in all ICT projects and activities;



The FOSS Act of 2006 of the Philippines will fully support the Open Source standards and criteria set by the world-known FOSS Advocate Body. This means that current widely recognized FOSS license and standards will be legally acknowledged by the Government of the Republic of the Phillippines.

This FOSS Act will enforce the migration from propriety software to Open Source software used by the Government institions in all levels with certain exceptions as quoted from the original house bill as follows:

7.1. Extraordinary Circumstances – The following are extraordinary circumstances which may exempt government from using open standards and FOSS:

7.5.1.Where there is no reasonably available ICT good or services supporting open standards and/or FOSS in the field, area or activity that the Government intends to enter or participate; or,

7.5.2.Where a particular government agency or office has an existing, widely-used and widely implemented proprietary ICT system and there are no reasonably available technology using open standards and/or FOSS that can be used with the said proprietary system.

7.2. Determination of Extraordinary Circumstances The CICT, through the Office of FOSS Migration created under section 17 of this Act shall determine, through a public hearing, whether there exists extraordinary circumstances that will exempt a government agency or project from sections 7.1 to 7.4 of this Act.

I dearly hope that the above restrictions won't get abused by some government officials by resorting to propriety/commercial software and gain kickbacks (ok i'll shut my mouth, no politics.. :) ).

But being stated clearly, these exceptions on the enforcement of Open Source usage among IT-Related or IT-empowered Government instutions should not hinder the very goal of the Act itself. I am quite confident that the Philippine Commission on Information and Communication Technology(CICT) can handle this very well as even before the Commission has been promoting FOSS without direct intervention from the Philippine Congress. Once the bill is passed, the CICT will further have power promoting the application of Open Source in Government offices.

Basic: Preparing Solaris 10 to run Mambo CMS

Brief Backgrounder on Solaris 10:

Solaris 10 is the latest OS offered by Sun Microsystems. Unlike its predecessors – Solaris 9 and previous releases, this version of Solaris is free for use with no restriction of any kind. It also has a twin named OpenSolaris which is essentially an exact replica except that it is available in source and as the named implies, yes OpenSolaris is open source. More info here and here.

Preparing Solaris 10:

Preparing Solaris 10 environment to run Mambo is basically having to set up Apache, MySQL and PHP environment and nothing else, as you might know the system requirements of Mambo is any system that can run certain versions of Apache, MySQL and PHP – click here for details. Solaris 10 is bundled with Apache 2 and MySQL 5 already, its just a matter of configuring these which we will discuss in detail later. PHP 5 is a little different story though as we will need a source distribution to compile this ourselves. PHP 5 needs to be a module for Apache, it has to support MySQL so bear with as we dig deeper.

Configuring Apache:

The configuration file for Apache should be located in “/etc/apache2/”. From a fresh installation it is named as httpd.conf-example under the same directory. You have to rename it to httpd.conf so Apache will recognize it.

# mv /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf

Using your text editor (gedit or vi), edit httpd.conf to your liking, take note of the following directives as you may need to set this as neccessary:

ServerName – The IP address or hostname of your machine (ex. 127.0.0.1 or example.com)

Listen – the port where Apache will listen to (ex. 80)

Next, is invoke the terminal and enable the service using the following command:

# svcadm enable apache2

Test Apache by opening the browser and pointing it to http://localhost.

Note that depending with your Desktop GUI, invoking the Terminal is done differently. Under the Java Desktop System 3, you do this by right clicking the desktop and selecting Open Terminal. Under CDE, you do this by clicking the Tools menu (the arrow on top of Performance Meter) and clicking console.

Configuring MySQL:

The MySQL database tables need to be created 1st. It will be the physical representation of your would-be MySQL tables as you create them. Moreover, the physical storage for your MySQL databases. Invoke the terminal and do the following command:

# /usr/sfw/bin/mysql_install_db

You should see several messages. MySQL Daemon by default does not allow root to run it. In such case a user needs to be set up specifically to run the MySQL server. Proper permissions are also mandatory. Invoke the terminal and issue the following commands:

# groupadd mysql
# useradd –g mysql mysql
# chown root /var/mysql
# chgrp –R mysql /var/mysql
# chmod –R 770 /var/mysql

What the above commands do are:
  1. Creates a group called MySQL,

  2. Creates a User named MySQL and makes it a member for the MySQL Group,

  3. Sets the ownership of the MySQL data directory to root,

  4. Sets the group of the MySQL data directory to MySQL group and

  5. Sets Read write access for the Group and Owner designated to the MySQL data directory while leaving others with no access.

Next is to set the MySQL Configuration File: Using the terminal, create a copy of a sample MySQL configuration file to the /etc directory as follows:

# cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf

Now to start the MySQL Daemon, use the following command:

# cd /usr/sfw/sbin/
# ./mysqld_safe --user=mysql &

To set the MySQL Password, the following commands need to be executed:

# cd /usr/sfw/bin
#./mysqladmin –u root password new-password
#./mysqladmin –u root –h localhost password new-password

To start the MySQL Daemon automically when Solaris starts, you need to bootstrap the startup files to rcs.d, rc1.d, rc2.d and rc3.d under the /etc directory. Issue the following commands using the terminal:

# ln /etc/sfw/mysql/mysql.server /etc/rcS.d/k00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc0.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc2.d/K00mysql
# ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql

Compiling PHP 5

If you have gone this far without errors - congratulations, but we are still at the half. Since we will need to compile PHP from source, we will need to set Solaris for compiling environment and will install a bunch of applications.

Note that the variable $PATH which is an array of location where Solaris searches for applications is not set properly on a fresh installation. Consider setting up your path as follows
On TCSH:
# setenv PATH {$PATH}: /opt/csw/bin:/usr/sfw/bin:/usr/dt/bin:/usr/css/bin
On SH:
# set PATH=$PATH:/opt/csw/bin:/usr/sfw/bin:/usr/dt/bin:/usr/css/bin
# export PATH

A default install of PHP requires the following:

  • gcc
  • make
  • flex
  • m4
  • autoconf
  • automake
  • perl
  • gzip
  • GNU tar
  • GNU sed

However a standard install of Solaris is already bundled with most of the listed above, what you'll need is only autoconf, automake and GNU sed, you can download them directly by invoking the following commands from the terminal (you should be in a directory where you intend to store the packages). The full is at http://www.sunfreeware.com/programlistintel10.html

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/autoconf-2.60-sol-10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/8/automake-1.5-sol8-intel-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/sed-4.1.5-sol10-x86-local.gz

Note that the Automake version is for Solaris 8 but should also work, links to the Solaris 9 and 10 versions are dead on the time of this writing as reffered here.

Once you have downloaded the above packages, uncompress them using gunzip

# gunzip *.gz

Then install them using pkgadd -d

# pkgadd -d autoconf-2.60-sol-10-x86-local.gz
# pkgadd -d automake-1.5-sol8-intel-local.gz
# pkgadd -d sed-4.1.5-sol10-x86-local.gz

After successfully doing the steps above which have set up a compiling environment for PHP, there are still a few applications that needs to be installed similar to the procedure above. The following applications are needed for a fully functional and optimal Mambo installation later: Download the following files from http://www.sunfreeware.com/programlistintel10.html or use wget for direct download

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/zlib-1.2.3-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/xpm-3.4k-sol10-intel-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/freetype-2.2.1-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/freetype-2.2.1-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/fontconfig-2.2.98-sol10-intel-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/expat-1.95.5-sol10-intel-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libiconv-1.11-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libpng-1.2.12-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/jpeg-6b-sol10-intel-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/openssl-0.9.8d-sol10-x86-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/curl-7.15.4-sol10-x86-local.gz
#wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/ncurses-5.5-sol10-x86-local.gz

Install the above application in exact order as downloaded to stay safe. Certain dependencies might not be fullfilled if installed in random..

..TO BE CONTINUED

11/25/2006

Headaches compiling PHP with IMAP [and Solution]

Backgrounder on IMAP:

IMAP or Internet Message Access Protocol is a protocol for accessing email from an IMAP server for online/offline/disconnected operations. This protocol was developed 20 yrs ago at Stanford University. One of the current active implementation with rewritten c-library is maintained under the supervison of the University of Washington. The latest IMAP - although its name might not sound to imply - also support POP protocol. A few open source applications for email management like SquirrelMail and IMP rely on IMAP in conjunction with PHP.

Backgrounder on PHP:

PHP or (Phils Homepage Tools)PHP Hypertext Preprocessor is an Open Source scripting language mainly used for web applications (although it can be used for desktop applications through its CLI, an example of a GUI implementation of PHP is PHP-GTK. PHP is server side, which means the processing is loaded to the server. Over the years the PHP Platform has proven its effectiveness, although still under debate :) , even some Java-based servers attempts to fully implement PHP because of its proven robustness (ex. Resin). One of the popular applications that run PHP is Mambo. SugarCRM, IMP, SquirrelMail implements PHP in conjunction with IMAP

The Problem:

I have encountered some problems getting PHP to compile with IMAP. For some reason my Apache died on 1st compile attempt of PHP with IMAP which caused one of the livesites I administer to be down. I tried different combinations of PHP 4.4.1, PHP 5.1.6, PHP 5.2.0 on IMAP-2004g, IMAP-2006c, IMAP-DEVEL. It was one nightmare i had to venture on. In the hope of easing someone not to go the same route I did. The whole trial and error costed me straight 25 hrs.

I have installed the 3 different versions of IMAP in the same way as outlined:
  1. Uncompressed the gzipped source tarball
  2. Inititated make using "make gso" (was on a Solaris 9)
  3. Made 2 symlinks pointing to the c-client libraries directory as "lib" and "include"
The following Combinations failed on me with errors message: Error Compiling PHP: conflicting types for 'utf8_mime2text'
  • PHP 4.4.1 + imap-2006d.DEV.SNAP-0611062033
  • PHP 5.1.6 + imap-2006d.DEV.SNAP-0611062033
  • PHP 5.2.0 + imap-2006d.DEV.SNAP-0611062033
  • PHP 4.4.1 + imap-2006c1
  • PHP 5.1.6 + imap-2006c1
The following Combinations failed on me with errors message: php_imap.c:(.text+0x2260): undefined reference to `mail_expunge'
  • PHP 4.4.1 + imap-2004g
  • PHP 5.1.6 + imap-2004g
  • PHP 5.2.0 + imap-2004g
So with the above errors, i speculated that the c-client libraries arent compiled to be sharable so i did additional steps to make them shared:
  1. cd c-client - Changed directory to c-client inside the extracted IMAP
  2. edited MakeFile to include: BASECFLAGS="-fPIC -O3" specifically on the GSO line for Solaris
  3. mkdir shared - Made a temporary directory
  4. cd shared - Changed directory to the temporary directory
  5. ar xv ../c-client.a - Extracted the *.o files
  6. gcc -shared -o c-client.so *.o - Derive a shared c-client..so from the *.o files
  7. cp c-client.so /usr/local/imap/imap2006c1/c-client libclient.so -Thanks to Ben for the correction
  8. hide libc-client.a (by adding "." before the name")
  9. cd ..
  10. ln -sf c-client include
  11. ln -sf c-client lib
The above 11 steps helped but wasnt put into real action until i finally figured out the correct combination. It was PHP 5.2.0 and IMAP-2006c1. IMAP was installed normally with the c-client.so (libc-client.so) made shareable. PHP was compiled as follows:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --enable-mbstring --with-gd --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --with-zlib --with-curl --with-pgsql=/usr/local/pgsql --with-gettext --with-ncurses --with-imap=/usr/local/imap/imap-2006c1/ --with-imap-ssl=/usr/local/ssl/

Setting up Mambo on Fedora Core 6

Brief Backgrounder on Fedora Core:

Fedora Core is a Linux Distro for basic servers pretty much how its commercial father(Red Hat) is (although it could{It is!} be a really great desktop OS too) . It is sponsored by Red Hat and is run by a "Board of Directors" composed of folks from the community and Red Hat itself called Fedora Project Board. Its one of the multi-disc'd linux distros where you'll find a full-pack of open source programs for various applications, and is pretty sleek and secure. More about it here

Now on Mambo:

Mambo like Fedora Core is provided as an open source software. It is a Content Management System (CMS) which in brief - lets you set up a basic site in minutes. It is a PHP/MySQL CMS. Key features are great WYSIWYG editor letting you in-line edit content, Articles are saved using yet another open source database (MySQL), and general lay-out that is governed by templates and is easily customizable plus lots more for you to find out. There are also add-ons you could plug it in with to expand functionality. It could be used as a catalogue, portal, virtual department store etc., at our company, we're even using as a access-based knowledgebase.. the possibility is limitless.

Fedora Core 6 and Mambo 4.6:

..got a Server OS and a CMS? combine them and you'll have your own site running and it will be a matter of getting a name for your IP, or if not, a development environment. This article will discuss only in brief, but if you as a reader wants a detailed explanation on something all you have to do is to post a comment.

Preparing Fedora Core 6 run Mamb0 4.6.1

All the required software to run Mambo 4.6.1 is bundled already with Fedora Core 6, so probably if you decided to install a Full Fedora Core 6 package, you don't have to worry about installing these using the Packager Manager or Yum. Basically if you have PHP, MySQL, and Apache on the server, then all you have to do is configure these. Let me outline a list of all required packages to get Fedora Core 6 operate PHP5, MySQL5 and Apache2 properly:
  • MySQL
  • httpd
  • libdbi-dbd-mysql
  • mod_pearl
  • mysql-connector-odbc
  • mysql-server
  • perl-DBD-MySQL
  • php
  • php-mysql
  • php-pecl-apc
  • unixODBC
  • libdbi
  • libdbi-drivers
  • mx
  • perl-BSD-Resource
  • perl-DBI
  • php-cli
  • php-common
  • php-pdo
Its not that many actually, basically its just to set up an Apache, MySQL, PHP and Pearl for Mambo under Fedora. You wont even have to download these one by one as listed. All you have to do is use Download Manager and check the key applications to install and Fedora will figure out the dependencies for you.

Supposing you installed Fedora Core using a standard set up. Invoke the Package Manager (from GNOME desktop) by clicking Applications -> Add/Remove Software. Install the following the applications and their optional packages if they are not checked:
  • Servers
    • MySQL Database
      • php-mysql
    • Web Servers
      • mod_perl
      • php_mysql
      • php
      • php_pecl_apc
The 1st level list is the Application Category, the 2nd level is the Application itself, while the third are the Optional Packages. Upon selecting an application by checking the corresponding checkbox, there are a number of optional packages that are already checked by default, you could leave them as is but you have to make additional optional packages available as outlined above. Make sure these Optional packages are installed as well together with the default ones upon application selection. Hit apply and let Package Manager figure out the dependencies for you. A few prompts and you'll get a confirmation when its done. It might take a while though.

Once through, invoke the terminal by clicking Applications -> Accessories -> Terminal. Start the MySQL and Apache Services using the following commands on the Terminal:
Start MySQL Daemon

Start Apache HTTPD Server


You can now download the latest Mambo Stable version from here. Depending on the format of the Mambo installer, you have to uncompress it on the "/var/www/html" folder which is the directory where Apache publishes files also termed as DocumentRoot. For ex. if you unzipped a folder named Mambo-4.6.1 under the /var/www/html directory, its live address would be http://example.com/Mambo-4.6.1. Otherwise, if you uncompressed the Mambo files directly to /var/www/html folder with no other folders, the live address would be http://example.com/ or http://localhost for local viewing.

NOTE: The default configuration of Apache 2 for Fedora Core 6 is to run the HTTPD instance under the user Apache. This means you will have to chown and chgrp the folder and files under the "var/www/html" to user apache using the following command:
Change user to Apache

Change group to Apache


This is of course after you have uncompressed the Mambo files under the directory above. Also, all files needs to be owned by user apache so the HTTPD server can serve them as content.

Open your browser and point it to http://localhost and you should see the Mambo installation page. For further details on installation click here. We try our best to periodically add and update content so bear with us or join to help.. ;)

Startin' off anew

Its been a while since i last blogged, maybe 8 months ago i dont actually remember.. :) but for some reasons i had to do it again, although i dont have much time considering my 14 hour online work daily.. yes daily, no saturdays and sundays.. well just kicking things in and we'll see.. off to my 1st "worth-something" post and leaving this one as only a starter.. //out