Abhishek Gupta

The Sun won’t set at NIT Durgapur !

Posts Tagged ‘driver’

Finally some success porting OpenVPN

Posted by abhiitechie on May 15, 2009

Today has been quite  eventfull and productive for me . I finally found some success with my project . I am trying to port a software called OpenVPN .OpenVPN is a full-featured open source SSL VPN solution that accommodates a wide range of configurations, including remote access, site-to-site VPNs, Wi-Fi security, and enterprise-scale remote access solutions with load balancing, failover, and fine-grained access-control.

When I tried to build it from source I faced some difficulties getting the configure run. After a bit of research I got that working with the –disable lzo option . So this was the first dependency resolved for me . Then on doing make there was error compiling a file called tun.c . Researched again and found that for a 64 bit platform like open solaris I need to have the tun kernel module to compile the file tun.c and that to I had to make some changes inside the Makefile.in of the tun source adding the option -m64 for the 64 bit open solaris

Then I faced the error gcc not found while building the package tun 1.1 . As we kno gcc is not present by default in a Solaris system and is taken care of by Sun Studio compilers but the package in hand was hellbent on a gcc . So what I did is I again edited the file Makefile.in and replaced the CC entry with cc instead of gcc . Then it showed -Wall is an illegal option with cc so without thinking much I just removed it and crossed my fingers while making it and finally the tunnel driver was successfully installed and with the tunnel driver in the environment the dependencies of OpenVPN was also resolved .

Now it was the time for me making the Spec file from scratch for the OpenVPN source package. The preamble section was done easily without much trouble . Then I wrote the %prep section and kept it simple . Then there was the tough task of writing the %build section and I included all the dependency option of configure and with the help of someone in the mailing list I was able to write the %build section

%install was straight forward without any complicacies .

%file was the best . After lots of asking , mailing , head-scratching and research even that was done .

I kept my fingers crossed and executed pkgtool on the spec I wrote and guess what it passed .

Submitted my passed to the Source juicer site for the final test . It is still waiting to get validated may be by tommorow I will be able to see the results .

One important thing to be noted is that before submitting the spec to the juicer the license , vendor and copyright directives must be included as it is checked for also the .copyright file need to be uploaded along with the .spec file to the juicer . So the syntax check was done and it said OK .

Here is the spec I wrote :#OpenVPN (TM) — An Open Source VPN daemon

#Copyright (C) 2002-2008 OpenVPN Technologies, Inc.

%include Solaris.inc

Name:                openvpn
Summary:             OpenVPN is a full-featured open source SSL VPN solution.
Version:             2.0.9
License:             GPL license version 2
Group:               SSL VPN
Vendor:             OpenVPN
URL:                 http://openvpn.net/
Source:              http://openvpn.net/release/openvpn-2.0.9.tar.gz

SUNW_BaseDir:        %{_basedir}
SUNW_Copyright:      %{name}.copyright
BuildRoot:           %{_tmppath}/%{name}-%{version}-build
%include default-depend.inc

%package root
Summary:                 %{summary} – / filesystem
SUNW_BaseDir:            /
%include default-depend.inc
Requires: tun

# OpenSolaris IPS Manifest Fields
Meta(info.porter):  Abhishek Gupta < A.Gupta@sun.com >

%description
OpenVPN is a full-featured open source SSL VPN solution that accommodates a wide range of configurations, including remote access, site-to-site VPNs, Wi-Fi security, and enterprise-scale remote access solutions with load balancing, failover, and fine-grained access-controls. Starting with the fundamental premise that complexity is the enemy of security, OpenVPN offers a cost-effective, lightweight alternative to other VPN technologies that is well-targeted for the SME and enterprise markets.

%prep
%setup -q -n openvpn-%version

%build

export CFLAGS=”%optflags”
export LDFLAGS=”%{_ldflags}”

./configure –prefix=%{_prefix} \
–disable-lzo  \
–disable-crypto \
–disable-ssl

make

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr (-, root, root)
/usr/man/man8/openvpn.8
/usr/sbin/openvpn

%changelog
* Friday 15 May , 2009 – A.Gupta@sun.com
– initial version

Advertisements

Posted in sun | Tagged: , , , , , , , , , , , , , , , , , | 2 Comments »

Developing MySQL Database Applications With PHP

Posted by abhiitechie on April 27, 2009

A four part tutorial that explains the PHP / MySQL extensions – mysql, mysqli, and pdo_mysql – with simple examples is now accessible from Sun Developer Network. While most of the information presented in the tutorial is available elsewhere in bits and pieces, the real value-add is in the introduction of the MySQL native driver for PHP, mysqlnd.

Application developers who are new to the development of MySQL database applications with PHP are the target audience of this tutorial.

Posted in mysql | Tagged: , , , , , , | 1 Comment »

Database connections using JDBC – MySQL and Netbeans

Posted by abhiitechie on April 27, 2009

I am fed up of people asking me how to make Database connections in Java . No one wants to go through the painfull part of studying themselves . All they want is the short-cut . So let me dedicate this particular posts to the topic of database connections in Java .

I have MySQL 5.0 installed on my Windows. In order to make a JDBC connection to MySQL database one needs to downlad the MySQL/J connector driver from here . I will also expect that you have Netbeans 6+ installed on your machine.

Extract the zip file to a folder, you’ll see file ‘mysql-connector-java-5.0.6-bin.jar’ which is the library file that we want. Just copy the file to the library folder, for example to “C:\Program Files\Java\jdk1.6.0_02\lib” also to the “C:\Program Files\Java\jdk1.6.0_02\jre\lib directory.

Next, create a new Java project on NetBeans named ‘TestMySQL’.

Now I’m going to write some code to connect to MySQL database. I have configured MySQL service on localhost.
I’m going to use Connection and DriverMapper Classes so I need to import libraries.
import java.sql.*;

Inorder to test my connections I build my project.

So everything seems to be fine till now.

To get some data, I need to execute query on the SQL Server and get the result back to me. First, I create stmt (Statement object) and execute query in SQL language. Then I store the result on ResultSet object and iterative show the result on the output window.

Insert some data to the created table using the code

Statement stmt = null;

stmt = con.createStatement();

String SQL = “INSERT INTO ZanduBaam (Name,Roll) VALUES (‘Abhishek’,40)”;

int rowsEffected = stmt.executeUpdate(SQL);

System.out.println(rowsEffected + ” rows effected”);

Inorder to retrieve data from database , I need to execute query on the SQL Server and get the result back to me. First, I created stmt (Statement object) and execute query in SQL language. Then I store the result on ResultSet object and iterative show the result on the output window.

ResultSet rs = null; // SQL query command String SQL = “SELECT * FROM ZanduBaam”; stmt = con.createStatement(); rs = stmt.executeQuery(SQL); while (rs.next()) {
System.out.println(rs.getString(“Name”) + ” : ” + rs.getString(“Roll”));
}

Similarly you can do the required for updation and deletion .

Lots of time and sweat devoted to this post considering the fact that I have a test on Monday I should stop here.
Bbye.

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , , , , , , , , | 3 Comments »