Sunday, August 11, 2013

Hurray ! I am one of the top 5% most viewed LinkedIn profiles for 2012!


200 Million

Hi Sagar,

Recently, LinkedIn reached a new milestone: 200 million members. But this isn't just our achievement to celebrate — it's also yours.

I want to personally thank you for being part of our community. Your journey is part of our journey, and we're delighted and humbled when we hear stories of how our members are using LinkedIn to connect, learn, and find opportunity.

All of us come to work each day focused on our shared mission of connecting the world's professionals to make them more productive and successful. We're excited to show you what's next.

With sincere thanks,

Deep Nishar

Senior Vice President, Products & User Experience

P.S. What does 200 million look like?

See the infographic





Ciphers problem: Request over ssl


Recently, I was trying to make an HTTP request to  openmrs
web-app. When I was trying to connect over HTTPS, I was getting following
exception. Basically my php-client was sending HTTP request to
https://localhost:8443/openmrs using HTTP/Request2.

"   : Unable to connect to ssl://localhost:8443. Error: stream_socket_client():
unable to connect to ssl://localhost:8443 (Unknown error) stream_socket_client():
Failed to enable crypto stream_socket_client(): SSL operation failed with code 1.
OpenSSL Error messages: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert
internal errorstring(339) "Unable to connect to ssl://localhost:8443. Error:
stream_socket_client(): unable to connect to ssl://localhost:8443 (Unknown error)
stream_socket_client(): Failed to enable crypto stream_socket_client(): SSL operation
failed with code 1. OpenSSL Error messages: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1
alert internal error "

After struggling alot for possible solution, I came to know about allowed ciphers in openjdk which
was being used by tomcat7. To allow tomcat7 to run on https, I used

$ ssh-keygen -t RSA -C 'user@example.com'
 which will generate an RSA SSH(2) key. I added allowed ciphers in tomcat7 server configuration
 located at /etc/tomcat7/server.xml

<Connector port="8443" protocol="HTTP/1.1"
               SSLEnabled="true" maxThreads="150"
               scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="/home/XXXX/.keystore"
               keystorePass="XXXX"
               ciphers="SSL_RSA_WITH_RC4_18_SHA"/>

Thats solved my problem. Hope that helps others too !

Tuesday, April 30, 2013

Kernel modules simplified !

View Sagar Gugwad's profile on LinkedIn

This blog gives idea to develop simple kernel module. Information contained
here, is based on   linux foundation tutorial. This tutorial introduces about
basic kernel module,  to write a simple kernel module, compiling the kernel
module and injecting the module in to the kernel. In this tutorial,
we will be dealing with the following  set of commands.

*) lsmod
   lsmod command is used to list all the kernel modules that are loaded.
*) insmod <modulename>
   insmod command will insert the module into kernel.
*) dmesg
   dmesg command is used to obtain the kernel logs.
*) modinfo <modulename>
   modinfo provides information about the module such as author, license,
   version and description.
*) rmmod <modulename>
   rmmod command removes the specified command from the kernel.

Now its time to write your simple kernel module which says

*) "Loaded test module into kernel successfully" upon loading
*) "Unloaded test module from kernel successfully"  upon unloading.

Open your favorite editor (vim is my ravorite)
and type in the following code:

/**
 * Simple kernel module program, which outputs some string when
 * loaded into kernel.
 * Copyright (C) 2013 Sagar Gugwad <saagar.gugwad@gmail.com>
 *
 *      This program is free software: you can redistribute it and/or modify it
 *      under the terms of the GNU General Public License as published by the
 *      Free Software Foundation; either version 2 of the License, or (at your
 *      opinion) any later version.
 *
 * Derived from usb_tutorial driver
 * Copyright (C)  2013  Greg Kroah-Hartman, Linux Foundation @ linux foundation.org
 *
 * V0.1 (mh) Initial version
 */

#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/module.h>
                                                                                                                                                                                 
static int __init gotemp_init(void)
{
        printk(KERN_INFO "Loaded test module into kernel successfully");
        return 0;
}
static void __exit gotemp_exit(void)
{
        printk(KERN_INFO "Unloaded test module from kernel successfully");
        return 0;
}
module_init(gotemp_init);
module_exit(gotemp_exit);

MODULE_AUTHOR("Saagar Gugwad");
MODULE_DESCRIPTION("Test device driver");
MODULE_LICENSE("GPL");


The function gotemp_init will be called whenever the module is loaded into
kernel. The corresponding message passed for printk method will be logged.
KERN_INFO is used to debug the moduke by  printing messages. We can use
other possible macros which are:

*) KERN_EMERG
*) KERN_ALERT
*) KERN_CRIT
*) KERN_ERR
*) KERN_WARNING
*) KERN_NOTICE
*) KERN_DEBUG

Similarly, gotemp-exit will be called, whenever the module is exited from the
kernel. All the logged messages can be obatained by dmesg command.
Save the file with <yourfile>.c.

Now it is time to compile our code. Kernel module compilation is done
using the make utility. The make command defines part of the kernel module to

be re-compiled. Open your editor type in the following code:

obj-m := <yourfile>.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

all:
        $(MAKE) -C $(KERNELDIR) M=$(PWD)

obj-m specifies the kernel module to be recompiled. We specify the make command
with kernel directory to be used to re-compile and current module directory as
arguments. Save the file as Makefile.


Now type in the make command  which run the instructions specified within the
Makefile. It will generate yourfile.ko kernel object  which can be loaded in
to the kernel. You can load your module into kernel using
$ sudo insmod yourfile.ko
To see the all the loaded modules you can type in
$ sudo lsmod
You should be able to see the your module name.
$ dmesg
will show the logs by kernel, upon successfully inserting the module, you should be
able to see "Loaded test module into kernel successfully".

Now to remove the module inserted, we can run
$ sudo rmmod yourfile.ko
which will unload the module, within the kernel module you should be able to see
the message "Unloaded test module from kernel successfully".

Thats it you just wrote your first kernel module !