admin

HOW TO : Pass environment variables when using sudo

Say you need to sudo as a particular user and run a command and at the same time you need to pass an environmental variable to the command, you can do it by passing the command in doublequotes.

For example, I want to start Oracle while I am logged in as another user (vinay), I can start the database using dbstart by issues

"sudo su - oracle -c "dbstart /$ORACLE_HOME"

$ORACLE_HOME is an environmental variable listed under user oracle’s environment.

Needless to say, you need to ensure that you have sudo configured to allow your userID to su to oracle.

HOW TO : Block outbound e-mails in Postfix

I ran into a challenge at work, where we had to allow e-mail delivery for certain domains, but block all other domains. But at the same time, we had to ensure that the clients sending e-mails did not get a delivery error. We were using Postfix as the MTA running on Redhat Linux. Here’s how I resolved it

  • Edit the main.cf file (the default location is in /etc/postfix) and add “transport_maps = hash:/etc/postfix/transport” (without the quotes) to the file.
  • Create a file named “transport” in /etc/postfix, if it doesn’t exist
  • Add the following at the end of the transport file

DOMAIN1 :
DOMAIN2 :
* discard:

  • Run “postmap /etc/transport” to create a hash of the transport file
  • Run “service postfix restart” to restart the postfix service

This configuraiton will ensure that all e-mails address to DOMAIN1 and DOMAIN2 are delivered normally, but the rest of the e-mails are silently discarded.

Note : Ensure that you follow the syntax for where to place the : verbatim.

Google knows that I am Indian..

I logged into Gmail today and noticed this small icon on the left hand side of the rich editing option, a small icon showing the letter “a” in my native tounge (Telugu).. Me being the curious kind, clicked on it and found out that I can now compose e-mails in multiple Indian languages (Hindi, Tamil, Kannada, Telugu & Malyalam) by typing in English. Something that Google calls “transliteration“. Here are some screenshots of me using the feature

 

Screenshot of Gmail showing multiple language options..

Screenshot of Gmail showing multiple language options..

 

Screenshot of Telugu in Gmail

Screenshot of Telugu in Gmail

Pretty cool.. but scary too 🙂 that Google guessed I am Indian.

HOW TO : Redirect default home page on Jboss

If you want to redirect the default home page on Jboss (which has links to the Jboss site and also the JMX Console), you can do it by editing the index.html file in

$JBOSS_HOME/server/$INSTANCE/deploy/jboss-web.deployer/ROOT.war.

The $INSTANCE is the mode you are running Jboss in (default, all, messaging etc).

HOW TO : Setup SOCKS proxy using SSH/Putty and configure Pidgin to use SOCKS proxy

I ran into a challenge  recently, when I tried to connect to my IM services (Yahoo, MSN, AOL, GTalk) using Pidgin in a secured network. For some reason, the network administrator thought that he/she should make life hell for people trying to log into IM. I will have a whole new rant about companies trying to lock down networks thinking they are making the employees productive..

Here’s what I did to connect to my IM services.

  1. Configure Putty/SSH to act as a SOCKS proxy.
    • Most people might not be aware, but a typical SSH client can act as a SOCKS proxy. So I decided to leverage this functionality.
    • You will need access to a SSH server and Putty (Opensource Windows SSH client)
    • Launch Putty
    • Setup a new server connection profile. I used FREE_MY_IP as the profile name in this screen shot, but you can name it anything you want

    • Expand the SSH option in the left column and click on Tunnels
    • Choose any port higher than 1024 as source port (unless you are running some kind of server software on your workstation, it is safe to use any port above 8000) and enter the SSH server in the Destination field. Then choose the “Dynamic” option and click on Add.. the screen shot below shows the options I used

    • The tunnel will show up as below

    • Click on Open and establish the SSH tunnel
  1. Configure Pidgin (open source IM client) to use the SOCKS proxy
    • Launch Pidgin
    • Click on Tools -> Preferences in the menu
    • Click on the network tab
    • Choose SOCKS4 as the proxy type and enter localhost in the host field. In the port field enter the port you selected when setting up the tunnel in Putty.

  1. Connect to your IM services.. chat away and be unproductive 🙂

First race of 2009..

It was cold (35 F), Windy (30 mph) and snowing (3 inches) for the Shamrock Shuffle 8K race yesterday…. But I was determined not to miss yet another race this year. Thx to Sri for pushing me during the race, I finished it in 51:28 minutes. Thats an average of 10:22/mile.

[Photo Credit : Kieffer]

This is how the course looked like. The road was so slushly that my feet were frozen and I couldn’t feel them till the 2nd mile.

[ I have to make fun of Sri’s new moustache 🙂 ]

HOW TO : Force expire sudo security permissions..

Ever run into a situation when you thought you had sudo rights on a machine and tried to issue the sudo command and upon finding that you don’t have them..get your name added to the sudoers list by begging the sysadmin.. and then frusrated when sudo keeps throwing an error that you are not part of the sudoers list? Hmm.. that is a long sentance :)..

To expire any cached security permissions, so that sudo is forced to check the sudoers files, issue the following command

sudo -k

Open Source Education

If you have time on your hand and want to learn something useful, head on over to Academic Earth (http://academicearth.org/) and view lectures from some of the best professors in the world..

I liked this one by Alan Blinder about the cause of the current economic crisis

 

Quote from his lecture.. NINJA (No Income, No Job [and] Asset] loans are bad 🙂