Running Dreamweaver MX4 ( 2004 ) with Wine 1.1 in Linux

This will be Quick Post as i just manged to fix the odbc32.dll error i been getting while trying to run the Dreamweaver from wine. this is what i did

1) Downloaded MAC 2.8 and installed it ( as Dreamweaver MX4 needs MDAC 2.6 or  higer )

2) Install Dreamweaver MX4 with wine

wine /path/to/setup/folder/dreamweaver2004.exe

3)next add odbc32.dll & odbcint.dll as native library in winecfg as follows

i) open winecfg

ii) Click on “Library” tab

iii) Add odbc32.dll & odbcint.dll

4) start Dreamweaver with wine

wine “C:\\Program Files\\Macromedia\\Dreamweaver MX 2004\\Dreamweaver.exe”

5) Make Menu Shortcut with Help of Menu Editor  so, you don’t have to all dirty codes in back ground and it launches nicely! :)

I haven’t tested it yet so not sure if it crashes while using or not, i will update that soon as well

03 Virtual Hosting With Tomcat

This third tutorial is going to very very short for this we are going to heavily relay on the second tutorial about configuring one web application. My advice is to keep 2nd tutorial handy.

I. First we will create application directory structure for aap1 & app2 (abbreviated for application1 & application2)

a. [root@linbox~]#mkdir -pv $tchome/webapps/{app1.com,app2.com}/{logs,ROOT/WEBINF/classes}

II. Change Directory permissions to 755

III. Copy/Modify your configuration files.

1. Add the following lines to our existing server.xml (you already know where to look for it)
<!– Virtual host for app1.com –>
<Host name=”app1.com”
appBase=”/$tchome /webapps/app1.com”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false”
xmlNamespaceAware=”false”>
</Host>
<!– Virtual host for app2.com –>
<Host name=”app2.com”
appBase=”/$tchome /webapps/app2.com”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false”
xmlNamespaceAware=”false”>
</Host>

Looks familiar? Yes, it should its same <Host/> tag that we used to configure our tctest.com with two differences.

  • appBase is point to new respective application base for aap1 & app2
  • name is changed from tctest.com different host , which is more correctly virtual host since its being hosted by same instance of tomcat on same IP address

2. No need to modify context.xml

3. Instead of creating new web.xml we can simply copy the web.xml from tctest.com to app1.com & app2.com

IV. No need to install servlet classes again.

V. For preparing test environment we may need to modify the CLASSPATH if you are planning to compile the java files. However if you are simply going to copy the compiled class. Simply skip this

VI. You can either copy existing test files from tctest.com or follow the same instruction as in 2nd tutorial for this step

VII. Test the app2.com & app2.com on port 8080

VIII. You can easily add named virtual hosts for app1.com & app2.com in apache.

Just follow the configuration file given in 2nd tutorial for this step There should be no problem, if you follow through these steps properly. However feel free t o contact me with your suggestions, doubts & difficulties

02 Configuring Single Custom Web Application in Tomcat

Last time we learned about how to install & integrate Tomcat with Apache. This time we will focus our full attention on the Tomcat and try to learn how to configure custom web application in it.

Why?
Why do we need to configure the custom web application? When, Tomcat comes along with preconfigured web application. Well here are the some of the answers for why

• We must not have web application inside Tomcat installation. This makes software upgrade easy
• We don’t accidently delete the application along with Tomcat
• We can set appropriate permissions for application without messing with Tomcat
• Most importantly, we make application maintainable

HOW?
Following are generic steps that one needs to follow to configure Tomcat Web Application.

I. Create the Web Application Directory Structure
II. Set appropriate permission on the Web Application Directory Structure
III. Modifying the configuration files
IV. Installing Javax Servlet Classes
V. Preparing Test Environment
VI. Preparing Test files
VII. Testing the Web Application
VIII. Accessing Application via Apache

I. Creating Web Application Directory Structure

I’m going to put my web application at $tchome which refers to the location /var/www/tctest throughout this document. We need following structure in order to deploy our web application

1. $tchome/webapp  This is works as the root for all the Tomcat web application. May be we can call it container

2. $tchome/webapp/$domain Replace $domain with the name of your domain for e.g. tctest.com

3. $tchome/webapp/$domain/logs This is where we can keep the logs. Note that this is not mandatory directory but logs are always
good to have especially in rainy day.

4. $tchome/webapp/$domain/ROOT ROOT is the root of your application for $domain

5. $tchome/webapp/$domain/ROOT/WEB-INF WEB-INF is the directory where we put the application specific configuration files

6. $tchome/webapp/$domain/ROOT/WEB-INF/classes This is where you can put the application related java classes

I’m quite sure that you can create the directory structure on your own, just to make it quick I have give you one command which build the structure in single stroke.

[root@linbox~]#mkdir –pv $tchome/webapp/$domain/{logs,ROOT/WEB-INF/classes}

II. Set appropriate permission on the Web Application Directory Structure

We have to make sure that web application is accessible
[root@linbox~]#chmod 775 $tchome/webapp/{$domain,$domain/ROOT}

III. Modifing the configuration files

1. Take back up of original server.xml in your tomcat installation directory (i.e. /usr/local/tomcat/conf in our case) and, create new server.xml with following contents

<Server port=”8005″ shutdown=”SHUTDOWN”>
<Service name=”Catalina”>
<Connector port=”8080″ protocol=”HTTP/1.1″ connectionTimeout=”20000″ redirectPort=”8443″ />
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
<Engine name=”Catalina” defaultHost=”localhost”>
<!– Define the default virtual hos –>
<Host name=”tctest.com”
appBase=”/var/www/tctest /webapps/tctest.com”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false”
xmlNamespaceAware=”false”>
</Host>
</Engine>
</Service>
</Server>

2. Take backup of original context.xml in your tomcat installation directory and, create new context.xml with following contents
<Context reloadable=”true” privileged=”true”/>

3. Now, final configuration file web.xml, there will be one default web.xml file inside your tomcat installation directory which you can modify for the global effect. However at this stage better not to play with default file. We will simply create another web.xml inside WEB-INF of our application (i.e. /var/www/tctest/webapps/tctest.com/ROOT/WEB-INF ) with following contents.

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web-app xmlns=”http://java.sun.com/xml/ns/javaee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” version=”2.5″>
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
</web-app>

I have not explained any DTDs & TAGS used in these xml files. If you are curious,you can check out Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/index.html

IV. Installing Javax Servlet Classes

Javax Servelt Classes are used very often in any web application. It contains several built in classes which can be used by servlet developers for building web application. Correct me if am wrong, as in my view, one can think of Javax Servlet classes as API or RAD tool

You can download javax servelt classes from here

Following are the steps to install these javax servlet classes

1. Unzip the classfile
[root@linbox~]#unzip servlet-2_3-fcs-classfiles.zip

2. Copy/Move it inside Tomcat library
[root@linbox~]cp -rv javax/ /usr/local/tomcat/lib

V. Preparing Test Environment

1. First thing we need to do is create one development directory where we will keep the source files for JSP and servlets. It could be anywhere but, outside tomcat installation directory.

For e.g. I have created directory src, at location /var/www/tctest/webapps/tctest.com/

although, practically one should have absolutely separate development directory

2. As, second step we have to set the environment variable CLASSPATH, since servlets and JSP are not part of the J2SE. Here Tomcat server already knows about the servlets but, compiler (i.e. javac ) have no idea about those servlet classes hence, it will throw an compilation error when we make use of those servlet classes.

Use these commands to set your CLASSPATH

[root@linbox~]#CLASSPATH=”.:/var/www/tctest/webapps/tctest.com/src:/usr/local/tomcat/lib”
[root@linbox~]#export CLASSPATH

As usual remember to put these command in /etc/profile to make your life easy
That’s it! We are done with configuration and everything is set to test out application only missing part is test files

VI. Preparing Test Files

Let’s create some HTML, JSP & Servlets, test files inside our development directory we created in previous step (i.e. src ) to verify our configuration Below are the some example codes that you can use for testing.

HTML Page <hello.html>
<html>
<title>Hello! Html from Tomcat</title>
<body>
Hello! Html From TomCat
</body>
</html>
JSP Page <hello.jsp>
<html>
<title>Hello! JSP from Tomcat</title>
<body>
<% out.println( “Hello! JSP From Tomcat” ); %>
</body>
</html>
Servlet <helloservlet.java>
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Simple servlet used to test server.
* <P>
* Taken from Core Servlets and JavaServer Pages 2nd Edition
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* &copy; 2003 Marty Hall; may be freely used or adapted.
*/
public class helloservlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
String docType =
“<!DOCTYPE HTML PUBLIC \”-//W3C//DTD HTML 4.0 ” +
“Transitional//EN\”>\n”;
out.println(docType +
“<HTML>\n” +
“<HEAD><TITLE>Hello Servelts</TITLE></HEAD>\n” +
“<BODY BGCOLOR=\”#FDF5E6\”>\n” +
“<H1>Hello Servlets! </H1>\n” +
“</BODY></HTML>”);
}
}

Before we can make use of this servlet we need to compile it and get the class file. Use the following command to do generate class file for our first servlet

[root@src]#javac helloservlet.java

To use this command your J2SE installations bin directory must be in your path. If you have followed the installation steps as per first tutorial then , javac will can be found in /usr/local/java/bin directory

Please don’t ask me to trouble shoot the compilation errors as am not servlet developer myself, if you can see, I have taken this example from http://www.coreservlets.com/ You can either visit that site or Google for some other example

We will be ready to see the result, once we put/copy/move these test files in appropriate directories as shown

move hello.html  to /var/www/tctest/webapps/tctest.com/ROOT/
move hello.jsp to /var/www/tctest/webapps/tctest.com/ROOT/
move helloservlet.class to /var/www/tctest/webapps/tctest.com/ROOT/WEB-INF/classes

VII. Testing Web Application

To test it, we will be accessing application directly with Tomcat port 8080 as follows

http://tctest.com:8080/hello.html  This should display Hello HTML Page
http://tctest.com:8080/hello.jsp  This should display Hello JSP Page
http://tctest.com:8080/servlet/helloservlet  This should display Hello Servlet Page

You may need to make entry of tctest.com in your /etc/hosts file to make it work

VIII. Accessing Application via Apache
Finally, let’s add the following lines in apache configuration file to access our tctest.com via apache.

<VirtualHost *:80>
ServerAdmin admin@tctest.com
DocumentRoot “/$tchome /webapps/tctest.com/ROOT”
<Directory “/$tchome /webapps/tctest.com/ROOT/”>
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#which pages to seek for by default in website
DirectoryIndex index.jsp hello.jsp index.html hello.html
JkMount / worker1
JkMount /* worker1
# Where to put jk logs
JkLogFile /$tchome /webapps/tctest.com/logs/tctest.com-mod_jk_log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “
# JkRequestLogFormat set the request format
JkRequestLogFormat “%w %V %T”
ServerName www.tctest.com
ServerAlias tctest.com
ErrorLog /$tchome /webapps/tctest.com/logs/tctest.com-error_log
CustomLog /$tchome/webapps/tctest.com/logs/tctest.com-access_log common
</VirtualHost>

To use the above configuration make sure you have uncommented NameVirtualHost *:80 directive in httpd.conf

Stop/start both Apache & Tomcat, and then try to access

http://tctest.com/hello.html  to test HTML file
http://tctest.com/hello.jsp  to test JSP file
http://tctest.com/servlet/helloservlet  to test Servelt

So, this time we coved how to configure & test custom web application. We have also covered Tomcat virtual hosting (Surprised?). Remember yet, security area is untouched hence, it’s pretty much unsafe way to deploy web application. For those, who are wondering where Tomcat Virtual hosting came in this tutorial. I will cover clear example with two custom web applications in next tutorial. There should be no problem, if you follow through these steps properly. However feel free t o contact me with your suggestions, doubts & difficulties

Posted in Tomcat. 2 Comments »

01 Very Basic, Tomcat & Apache Integration on Linux

Both, Apache and Tomcat can work independent of each other and Tomcat is used to serve the dynamic java servlet pages. Although there are many other competitors like PHP & ASP.NET, Java servlet still remains to be the most popular for building the web application. Just like others Tomcat also have some competitor, one that worth mentioning here is Web-sphere of IBM which is the most widely used Enterprise Server (So It is not free to use for commercial purpose, however one can obtain free copy for the non-commercial purpose).

Now, that you know Tomcat can serve the pages independently question is why to integrate it along with apache? Answer to this question becomes more vital considering fact that Tomcat is found to be faster in serving static pages then apache. So, what is the point?

Let’s see some of the advantages to gain by Integrating Tomcat with Apache

1. You can use Apache to buffer slow connections. Tomcat uses java.io, which uses a thread for each request, so Tomcat can run out of connections as the number of slow requests grows. This could be an issue if your application supports a large number of dial-up users.

2. You can use a connector such as mod_jk to load balance amongst several Tomcat instances.

3. You can take advantage of Apache features such as cgi and PHP.

4. You can take advantage of Apache modules such as mod_rewrite, mod_headers, and mod_expire.

5. You can isolate virtual hosts in their own Tomcat instances.

With this little background now, we are ready to get started with our objective
What we need? (Beside Fully Loaded working Linux OS ;) )

• Apache web-server available here, it’s available only as source from the site. Alternatively you
can download the rpm package for your favorite Linux distribution and install it.

• J2SE 5.0 or later available here, Download the binary or rpm binary file which ever you like

• Tomcat Application Server available here, download the binary file to save unnecessary pain of
compiling the tomcat from source.

• Tomcat-Connector available here, It’s available only as source from the site.

How do we get started?
Follow this step by step procedure to integrate the Apache & Tomcat. When I say step-by-step it means only new concepts will be explained in details and other things will be left on readers to implement it way they like

Part 1: Installing the Apache, J2SE & Tomcat

1. Install the Apache with rpm or compile it, if it’s not in place already. Yes I expect readers to know how to install and configure basic apache web-server

2. Start the Apache and test whether it works or not.

3. Stop the Apache

4. Install the J2SE with following command. In your current directory

[root@linbox~]#chmod 755 jdk-6u2-linux-i586.bin
[root@linbox~]#./ jdk-6u2-linux-i586.bin
[root@linbox~]#mv jdk1.6.0_02 /usr/local/

5. Extract the Tomcat in current directory ( you should know how to extract zip or tar.gz files ) and
move it to /usr/local/

6. Now let’s create some softlinks to make future upgrades somewhat easier

[root@linbox~]#ln -s /usr/local/ jdk1.6.0_02 /usr/local/java
[root@linbox~]#ln -s /usr/local/ apache-tomcat-6.0.13 /usr/local/tomcat

7. Set the JAVA_HOME environment variable for Tomcat.

[root@linbox ~]#JAVA_HOME=”/usr/local/java”
[root@linbox~]#export JAVA_HOME

Don’t forget to put this variable in /ect/profile. Otherwise it won’t be available to any
user after reboot.

8. Start the Tomcat Server with following command

[root@linbox~]#/usr/local/tomcat/bin/startup.sh
9.Now its time to  test the Tomcat
Open http://localhost:8080 in your browser you should see the Tomcat page there.

10. Finally stop the tomcat with following command

[root@linbox~]#/ usr/local/tomcat/bin/shutdown.sh
Part2: Installing Tomcat Connector

Brief Introduction: Tomcat connector (i.e mod_jk) is the communication link between Apache & Tomcat it listens on the defined port for request from apache and forwards those to tomcat.

Steps to Install
1. [root@linbox~]#tar -zxvf tomcat-connectors-1.2.24-src.tar.gz

2. [root@linbox~]#mv tomcat-connectors-1.2.24-src /usr/src

3. [root@linbox~]#cd /usr/src/ tomcat-connectors-1.2.24-src/native

4. [root@linbox native]#./configure –with-apxs=/usr/sbin/apxs or /usr/sbin/apxs2

You may not find the apax/apxs2 binary at above location if you have compiled apache from source. Probably you already know where to look for it ;)

5. [root@linbox native]#make

6. [root@linbox native]#make install

That’s it we are done with installing tomcat connector
Part3: Integrating Tomcat with Apache

1. First thing we need is to have workers.properties file.You can place it anywhere you like however usually it is in same directory as in which httpd.conf (i.e. /etc/httpd/ for rpm install).

This file contains details about how each process is linked to Tomcat. Each worker communicates with Tomcat via ajpv13 protocol.

workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/java
ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

If worker.default.host=localhost doesn’t work try to use the IP
for e.g. worker.default.host=192.168.0.10

2. Add the following lines at end of your httpd.conf

#location of mod_jk
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /etc/httpd /workers.properties
# Where to put jk logs
JkLogFile /etc/httpd/logs/tc_connector.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “
# JkRequestLogFormat set the request format
JkRequestLogFormat “%w %V %T”
# Send servlet for context /examples/jsp to worker named worker1
JkMount /examples/jsp worker1
# Send JSPs for context /examples/jsp/* to worker named worker1
JkMount /examples/jsp/* worker1

3. Start the tomcat, start the Apache and finally test it with your browser

http://localhost/  For testing Apache, You should see page saying “It! Works” if its newer version
http://localhost:8080/  For testing Tomcat, You should se Tomcat Page
http://localhost/examples/jsp/  For testing the Tomcat & Apache Integration, You should see the tomcat page with JSP examples
There should be no problems if you follow through these steps properly. Do let me know the problems you faced I will try to cover them in further topics. Once again let me remind you this is very basic level configuration and I have not consider any security or virtual hosting related concept here this is for just to get you started and show you it’s not as difficult to integrate Tomcat with Apache as it seems

Posted in Tomcat. 1 Comment »

02 Simple User Authentication with LDAP on Linux

This is a general step by step procedure which will focus on how to use the LDAP for user authentication.


What we need?

  • LDAP server running on Linux platform
  • One Linux Client Machine to test the LDAP authentication
  • Some Basic knowledge of the LDAP server and how ldif files are structured


What I have used?

LDAP Server:

  • Fedora core 8 – 64 bit running on Qemu Virtual machine with 256MB of ram
  • Openldap 2.4.7  compiled it from source

Client Machine:

  • Fedora core 8 – 64 bit running on Qemu Virtual machine with 256MB of ram

Why to do it?
Why to take pain of creating LDAP authentication server? My answer to that is, am too lazy to create users on several system  although, its easy but , creating users on 10 system means maintaining same user 10 times for every request even as simple as changing user password and, this is kinda very usual request admins get 100 times a day.

Now imagine all of sudden , I have to add another 100 system, Task will be error pron if i had to create users manually on each system.

So, why not to use LDAP which will make my life much more easy, All i have to do is add users in LDAP data base and ask clients to authenticate users from LDAP server.

How to do it?
Authenticating users with LDAP is much more easier then legend says, I will show you how to do it. In this section.

Server side Configuration

1.STOP SLAPD if, its alredy running

2.We need to configure our slapd.conf file to make it aware about the schema & class that deals with user authentication.

Following are four schema , that we have to add in order to make slapd aware about the Object classes that we will use in ldap database file ( ldif ) later on to add ldap data

1) core.schema
2) cosine.schema
3) inetorgperson.schema
4) nis.schema

Other thing i have used is, hierarchical  database (hdb) it’s relatively new type of data base and as name suggests it has support for hierarchical data base  , in other words , it supports tree type structure and, that is how actually ldap data can be visualized.

Below given is my slapd.conf file which works
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /openldap/install/etc/openldap/schema/core.schema
include         /openldap/install/etc/openldap/schema/cosine.schema
include         /openldap/install/etc/openldap/schema/inetorgperson.schema
include         /openldap/install/etc/openldap/schema/nis.schema
pidfile         /openldap/install/var/run/slapd/slapd.pid
argsfile        /openldap/install/var/run/slapd/slapd.args
loglevel none
################################################################
# rocky.com Data base definition
################################################################
database        hdb
suffix          “dc=rocky,dc=com”
rootdn          “cn=dhaval,dc=rocky,dc=com”
rootpw          secret
directory       /openldap/install/var/ldap-dbs/rocky.com
index objectClass eq

3.Now we need to create the User database for authentication, it can be done  manually, by editing the text file but, i will choose to use the migration tools which, can help me to migrate the users from system to LDAP database easily. These tools  are available at  padl.com

4.Following are the steps to migrate an existing user “test”  to LDAP database.

  • grep test /etc/passwd > test.passwd
  • grep test /etc/group > test.group
  • vi migrate_common.ph
  • search for $DEFAULT_BASE = “dc=example,dc=com” replace it by our domain components i.e. rocky & com
  • perl migrate_base > base.rocky.ldif
  • perl migrate_group.pl test.group group.rocky.ldif
  • perl migrate_passwd.pl test.passwd passwd.rocky.ldif
  • slapadd -f slapd.conf -l base.rocky.ldif
  • slapadd -f slapd.conf -l group.rocky.ldif
  • slapadd -f slapd.conf -l passwd.rocky.ldif

5.Now lets add one more user manually in ldap, a user that doesn’t exist on our Linux box. To achieve this we must do following

  • create a encrypted password for user , lets call it  “ldapuser”. Using following command

slappasswd -v -s ldap -h {crypt}

  • Next create the ldapuser.ldif file as follows

dn: uid=ldapuser,ou=People,dc=rocky,dc=com
uid: ldapuser
cn: ldapuser
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}$1$ScJYhgVJ$isZSQ/tPEVJqa0BmAF4nk/
shadowLastChange: 13939
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 700
gidNumber: 700
homeDirectory: /home/ldapuser

Note that the, ‘userPassword’ field contains out put of slappasswd command

  • We also need to create and entry for ldapuser group ( i.e. Users default group ). lets store it in the ldapuser-group.ldif file as shown below

dn: cn=ldapuser,ou=Group,dc=rocky,dc=com
objectClass: posixGroup
objectClass: top
cn: ldapuser
userPassword: {crypt}x
gidNumber: 700

  • Then add ldapuser to our, ldap data base using slapadd command  as showin step 4

6.Next, thing we have to do is , modify the /etc/hosts to resolve the rocky.com on Internal network like this

172.172.10.101          rocky.com

7.Type setup or authconf at CLI ( availabe only for fedora/redhat i think). Choose Use LDAP & Use  LDAP Authentication as shown in dialog below

8.Now provide it , ldap server location & base DN

9.Start LDAP server daemon

10.to  test if LDAP is really working, use following command

  • getent passwd | grep test
  • getent passwd | grep ldapuser
  • if LDAP was configured properly you should see two entry for test users & one for ldapuser in output

Client Side configuration

Repeat the steps 5 to 9 of server side configuration, in step 10 if you see one entry for each test & ldap user which doesn’t exists on client machine then, you have successfully configured LDAP authentication server

Qemu –Linux Guest on Windows Host

Yes! This amazing thing call Qemu does have its port which works really great on windows as well. You don’t have to have Linux to use Qemu

Why Linux on M$ Window$ Host?

Some of you might be disappointed to see this post cause its for Evil M$, Thing is iagree am my self not too happy doing things way this, but happens when I want to play some nice games , such as Prince Of Persia , Need For Speed, War craft , Counter strike, Assassin’s creed ………. And so on. I don’t want to get in to debit that whose fault it is for not having Linux compatible game but sad fact is we need M$ at such a time ( or Expensive Play stations )

In my case, Play station is still and expensive item for my budget so I have no choice to but install M$ but, at same time I want to keep perusing Linux so, this is what do, Use Qemu

What we need?

1. 1 Working M$ Window$ system

2. 2 Qemu Binaries

3. 3 OpenVPN

4. 4 Linux DVD-ISO /CDs /DVD

How to do it?

Here we go….

Installing Qemu

1. 1 Download the Qemu emulator for windows from http://www.h7.dion.ne.jp/~qemu-win/

2. 2 Extract the zip file at desire location , let’s say c:\qemu

3. 3 Now we should add path to Qemu in Environment variable to do that follow these steps

a. Click StartàMy Computer à Right click, Properties à click Advance Tab, Environment Variable à Select PATH in User Variables à click on Edit à Add following entries in variable separated by semicolon (;)

b. c:\qemu;c:\qemu\bin

c. Click OK à Click OK à Reboot to reflect the change

Installing OpenVPN

We need OpenVPN to have windows tap device which we will be using later on for Host & Guest Networking

1. 2 Download the openVPN from http://openvpn.net/index.php/downloads.html

2. 3 Simply double click the installation pack and follow the instruction on screen to install OpenVPN

3. 4 Go to Network connection and rename the newly installed Network connection to something small such as openvpn1 (this is not mandatory step, it just good to have small name) .

4. 5 Assign an IP address to it ( I assigned 10.20.30.1/255.255.255.0 )

Installing Guest OS

1. 1 Create the disk image of size 10GB , Using following command

qemu-img create -f qcow linux.disk 10G

2. 2 Install the linux guest os from DVD ISO imaage

qemu-system-x86_64 -m 512 -hda linux.disk -localtime -net nic –net tap,ifname=openvpn1 -cdrom “e:\\OSes\\Fedora-8-x86_64-DVD.iso” –boot d –L “c:\\qemu”

3. 3 You know how to Install Linux , so don’t ask me J tip from m yside is try to do it in text mode it will be much faster (which is already slow enough to test your patients )

4. 4 Once installation is done , we can start the os using below command

qemu-system-x86_64 -m 512 -hda linux.disk -localtime -net nic –net tap,ifname=openvpn1 –boot c –L “c:\\qemu”

For little more explanation on these commands you can check out my previous post here

Set up Network between guest & host OS

This is the most critical and important part, if there is no network between Host & Guest OS there is no need to have any guest of at all. Now, Let’s DO IT!

If you have installed OS using above step your network should alredy be up and running, however if that doesn’t work you can try following

1. 1 Load the proper module on guest OS

modprobe ne2k-pci

2. 2 Configure your network

ifconfig eth0 10.20.30.110

3. 3 Add the route to your guest os

route add default gw 10.20.30.1 eth0

01 Compiling & Installing Openldap 2.4.7 from source on 64 bit & 32 Bit system

Here i will show you how to Install, configure & use the openldap. There are two ways in which you can install the ldap

  • Easy way: download and install the rpm of stable release for your distro

  • Harder way : download the latest source , compile & install them on your system

For those who prefer easy way and want to jump start to configure the ldap , may skip this unit. There is nothing wrong in installing things from rpm and thats how it should be done if you are not going to use the cutting edge functionality available with latest release ( of course it got to be buggy hence, not suitable for production environment unless you want to risk your peace of mind ).

So, are you ready to stretch your brain muscles ? If Yes , lets start the warm up

When, we are compiling the source , we need all sort of development tools to make sure we can get things done right way. Usually this is what we must have

  • gcc >=4.0, to check your version simpy type gcc -v at CLI ( command line interface )

  • cc, In most of the modern *inx system its nothing for then symbolic link to gcc. You can verify that using these two commands

    • whereis cc , this should display where cc command is located, usually its /usr/bin/cc

    • ls -l /usr/bin/cc , and you should see its symbolic link to gcc

  • whereis, This is a shell utility to find out where particular command is located

  • db-4.6.21, This is one of the MUST HAVE item, if you don’t ave db in place , you will not be able to take advantage of openldap’s bdb & hdb database support.

On newer os, this version of db should be there already. If not you can update the rpm , which is better way as usual or install from source if you prefer.

Be sure to check , INSTALL & README files , as different versions of openldap are compatible with only certain versions of Brekeley db.

Make sure, you have all this tools with you (i will suggest you to install all development tool, although not everything is required ) before you begin your journey.

Also, let me tell you these steps, mentioned here may not be the exact and only way to compile openldap from source, of-course you can follow them as they are. However, i will strongly recommended you to look at them as the pointers toward your destination.

Steps to Compile & Install Openldap 2.4.X from source
1 Download the latest source from openldap.org ( it’s 2.4.7 in my case )

2 Extract the source

3 locate the ltdl.h , if its located in /usr/share/libtool/libltdl/ltdl.h, then you need to reinstall the libtools as follows

32 bit OS

  • cd /usr/share/libtool/libltdl
  • ./configure
  • make
  • make install

64 bit OS

  • cd /usr/share/libtool/libltdl
  • LDFLAGS=”-L/usr/lib64″ ./configure
  • make
  • make install

    Note: You need to follow this step, if and only if you are planning to install available features as module

4 cd openldap-2.4.7

5 Configure the openldap as follows

32 bit OS

./configure ” –enable-ipv6=no –enable-slapd –enable-bdb=yes –enable-hdb=yes –enable-monitor=yes –enable-relay=yes –enable-sql=no –enable-static=yes –enable-shared=yes –with-threads –with-tls

64 bit OS

LDFLAGS=”-L/usr/lib64/” ./configure ” –enable-ipv6=no –enable-slapd –enable-bdb=yes –enable-hdb=yes –enable-monitor=yes –enable-relay=yes –enable-sql=no –enable-static=yes –enable-shared=yes –with-threads –with-tls

6 Compile the dependent stuff for openldap with , `make depend` command

7 Compile the openldap with `make` command

8 We are pretty close now , but before installing openldap, its advisable to run `make test` command which will perform several tests on your “to be installed” package. However if you are in rush you may skip this step as ,it consumes lot of time ( may be even more then `make` )

9 Finally, install the openldap with `make install` command

Thats all!! We are done! :)

Script to Convert HighQuality ImagesTo E-mail size Images

What it does?

This is one little script, which can convert your High Quality & High Resolution (7M pix) to small Email size images with losses that wont be visible to human eyes.

Why to use it?

Well, simply  if you don’t have enough time and/or enough bandwidth to mail/upload the 7MP images which are atleast 2.5MB and, you want to share it with your friends/family then you have to use some or other method to reduce the size.

What i have used?

I have simply used the convert utility for building this script which is availae with all the Linux distro. However be fore you use the script make sure you have it with command

whereis convert

it should show

convert: <path of binary> < path for man page>

If you don;t have it , then just install ImageMagic package ;)

How to use it?

to use this script simply type

1 ./esizeimg.sh <path to your image folder>

for e.g. ./esizeimg “/my collection/gardens/rose garden”

2 once script is executed you will find the files in <path to your image folder>/Esize_Imgs

Note

1 This script currently works for *.JPG & *.jpg images

2 This is very much of first draft so its not much user friendly , it doesn’t show even usage

3 It worsk in BASH shell

How to get it?

simply, download emailsize.odt from Esize Image and, rename it to emailsize.sh

Enjoy :)

Firefox Flash-plugin for 64 bit linux OS

Well, Like it or not Adobe is not releasing 64 bit support for its Linux flash-plugin any sooner but, thanks to our open source community they always have some or other way to get things done.

Here is what i did to enable flash player on my 64 bit system

1 Install latest Firefox web browser using yum, idieally any version should do , its just good to have latest stable release

2 install flash-plugin rpm from adobe site http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash

3 install nspluginwarpper for x86_64 system using yum

4 open your browser and type about:plugins in the address bar , you should see something like this

Shockwave Flash
File name: nswrapper_32_64.libflashplayer.so
Shockwave Flash 9.0 r115
MIME Type Description Suffixes Enabled application/x-shockwave-flash Shockwave Flash swf Yes application/futuresplash FutureSplash Player spl Yes

its also advisable to install livna repository which is available here http://rpm.livna.org/rlowiki/

Qemu – Extremely Quick , Out Standing & Feature rich Emulator

In my last post, I did lot of “bla…bla” about nvidia’s XEN incompatible kernel module. It been couple of months since then. However even recent test proves situations are still same there ain’t any improvement.

On other hand I was not ready to wait any more for the XEN compatible nvidia module. We all know thats not the only solution for virtualization. So, wht not to play around a bit. While looking for alternates I came across QEMU, which stands for Quick Emulator. Trust me, It stands true to its name it’s real quick and have amazing ability to emulate not just software but, hardware as well (surprised!!).

However, am not going to deal with its feature list here, whati i gonna show is steps to compile qemu and additinal packages that we need to build fully networked guest OS ( i will take example of installing XP as guest OS here)

If you are interested in detailed documentation kindly checkout the reference site(s) given at the bottom of this page.

Get Set GO!!!!!!!

STEP 1: Before we cook guest OS, we need some raw material listed here

Must Have

Qemu - Quick Emulator package available at http://fabrice.bellard.free.fr/qemu/download.htm , download the latest source ( 0.9.1 when i used it)

uml-utilities - stands for “User Mode Linux Utilities”, these utilities enable linux to run as the user process and can be useful for kernel development, sand boxing , experimenting etc. It’s available at http://packages.debian.org/stable/otherosfs/uml-utilities , download the latest source or rpm based on your cpu architecture

VDE - VDE stands for Virtual Distributed Either, its one of many way to get connectivity between host OS and guest OS, although its strictly optional to use, I have it here as one of the Required package cause, I have configured my Virtual machine connection with VDE,It’s available at http://sourceforge.net/projects/vde/ download the latest source (2.2.0-pre1 when i used it)

Option packs

kqemu – kernel module for qemu availabe here http://fabrice.bellard.free.fr/qemu/download.htm

qemu-launcher - Gtk2-perl based Qemu GUI interface

qtemu - QT4 based Qemu GUI interface

dnsmasq – provides DHCP and DNS service for Qemu host

Note: I have not given the links for the GUI interface for one reason, I haven’t installed them :)

STEP 2: Set up cooking environment, Installing the raw material Instillation is quiet straight forward if you have all needed compiler packages installed such as gcc. I will show how to do it for qemu though, for others steps are same.

  1. login as root (yes root access is must)
  2. tar -zxvf qemu-0.9.1.tar.gz
  3. cd qemu-0.9.1
  4. ./configure
  5. make
  6. make install

by default, binaries will be installed in /usr/local

Note: If you are running newer system, chances are you have gcc verion 4.X. However, till now qemu can’t be compiled with gcc 4.x. Thus before you try to compile check if you have compat-gcc-3.X. If yes you will have no problem what so ever. other wise , just install compat-gcc-3.x rpm

similarly you can install VDE

STEP 3: Lets Work It, Start Cooking

I’ll assume all these commands are executed from /usr/local/bin ( default installation location) if you have modified it with –prefix while configuring please, refer to “your path/bin”

1] First thing we need to do is create one disk image , where we will install Guest OS ( XP in my case ).

qemu-img create -f qcow winxp.diskimage 4G

this will create file/disk image called wixp.diskimage with qcow formate ( i.e. copy on write ) . advantage of this formate is , it wont reserve the allotted space ( of 4G) at once and will keep on writing to file as it grow until it reach the limit of 4GB

2] Now, we will launch virtual machine and install XP on it with, one single command provided you have cd or iso image of xp ;)

vdeqemu -m 256 -localtime -hda winxp.diskimage -cdrom winxp.iso -boot d

vdeqemu - this is responcible for launching qemu

-m option to specify how much ram virtual machine have 256MB in our case

-localtime option to sync guest os time with local time of host os

-hda option to specify first disk image (often bootable drive)

-cdrom option to specify cdrom device or iso file

-boot boot the specific device. when it’s ‘d’ boot from cdrom, when ‘c’ boot from hda

for more information please see vdeqemu –help or qemu –help

3] Mean while, Installation is going on , lets get system ready for virtual LAN

  1. vde_switch -t tap0 -d #initialize tap device
  2. ifconfig tap0 192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0 #configure tap device
  3. chmod -R a+rwx /var/run/vde.ctl #change file permissions

    echo “1″ > /proc/sys/net/ipv4/ip_forward
    #enable IP forwarding
  4. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE #hide your new tap device behind firewall with natting

4] Once, installation of guest OS (XP) is over, shut down the Guest os and start it with the below command

vdeqemu -net vde,vlan=0 -net nic,vlan=0,macaddr=52:54:00:00:EE:02 -m 256 -localtime -hda winxp.diskimage -boot -c

to start os in back ground as demon

vdeqemu -net vde,vlan=0 -net nic,vlan=0,macaddr=52:54:00:00:EE:02 -m 256 -localtime -hda winxp.diskimage -boot c -vnc :1 -daemonize

Always keep VNC enable so that you can access the guest os via vnc client on port you choose ( which is 1 in above case )

STEP 5: Ready to taste what you baked?

Finally, disable Guest OS firewall and configure it’s network with ip 192.168.0.X ( for e.g. 192.168.0.10) and ping it from host and viz. you should be able to do it with no problem.

Note:

For emulating 64bit system you must use command like this to install

vdeq qemu-system-x86_64 -m 256 -localtime -hda winxp64.disk -cdrom win64.iso -boot d

and to start 64 bit guest OS

vdeq qemu-system-x86_64 -net vde,vlan=0 -net nic,vlan=0,macaddr=52:54:00:00:EE:02 -m 256 -localtime -hda winxp.diskimage -boot c -vnc :1 -daemonize

Ref URL:

Qemu Documentation: http://fabrice.bellard.free.fr/qemu/user-doc.html